Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Cyclone II support #448

Open
uint69-t opened this issue Mar 25, 2024 · 8 comments
Open

Adding Cyclone II support #448

uint69-t opened this issue Mar 25, 2024 · 8 comments

Comments

@uint69-t
Copy link
Contributor

Hey, im trying to add support for the classic Cyclone II (its a very very common entry board to FPGA field)
This is the board that im trying to support: https://www.ebay.com/itm/355257902298?mkcid=16&mkevt=1&mkrid=711-127632-2357-0&ssspo=kebs3p_ksj2&sssrc=2047675&ssuid=&widget_ver=artemis&media=COPY

I added the line:

/* Altera Cyclone II/III/IV/10 LP */
        {0x020b10dd, {"altera", "cyclone II", "EP2C5", 10}},

But running:
sudo ./openFPGALoader -c usb-blaster --write-flash blink.bit

Yields:

empty
write to flash
Can't program SPI flash: missing device-package information

But if i run:
sudo ./openFPGALoader -c usb-blaster --detect
I get:

empty
index 0:
	idcode 0x20b10dd
	manufacturer altera
	family cyclone II
	model  EP2C5
	irlength 10

I readed in another issue and i tried:
sudo ./openFPGALoader -b qmtechCycloneV -c usb-blaster --write-flash /shared/mass_blink.bit
(I know that this is not a Cyclone V but idk, i was just trying)
And it loaded but i got:

empty
write to flash
use: /usr/local/share/openFPGALoader/spiOverJtag_5ce223.rbf.gz
Load SRAM: [==================================================] 100.00%
Done
Detail: 
Jedec ID          : ff
memory type       : ff
memory capacity   : ff
flash chip unknown: use basic protection detection
unlock blocks
Error: block protection is set
       can't unlock without --unprotect-flash
Error: Failed to program FPGA: Fail to write data

If anyone can give me a hint about where to look, i will test it and make the PR, i think this is a very very cheap board, you can find the basic schematics of the base board that i shared and Quartus II is free and does not require a license that i think its pretty cool.

Thanks for the time.

@uint69-t
Copy link
Contributor Author

UPDATE:

I was looking at #129, using a RBF file without compression kind of works, the light in the board make a blink and the console does not report any errors but the FPGA still does nothing. (The code is known to work since i've loaded it from Quartus II and it works, openFPGALoader seems to be very close, but for some reason it does not work yet)

I also tried loading a .cdf file like quartus_pgm does but openFPGALoader yields:

empty
write to ram
file has an unknown type:
	please use rbf or svf file
	or use --write-flash with: -b board_name or --fpga_part xxxx
Error: Failed to claim FPGA device: Error: wrong file

@uint69-t
Copy link
Contributor Author

IT WORKS!!

Reading around the repo, i saw a mention of a intel.md in doc/, so i went to the first commit, found the file and noticed that SVF files are supported, it took me a while to find how to generate them (since in the old Quartus II 13.0sp1 that is the last to support the Cyclone II family, it is hidden under some settings of the device), but once i generated it, i ran:
sudo ./openFPGALoader -c usb-blaster -m /shared/blink.svf
And the console replied:

empty
write to ram
USB-BlasterI has a 24MHz fixed frequency
end of SVF file

And the board is alive and the code is working perfectly, im not sure why SVF files work and RBF dont, but it doesn't matter.
I can confirm that just adding the line:
{0x020b10dd, {"altera", "cyclone II", "EP2C5", 10}},

Will correctly add support for the Cyclone II family but i would suggest adding a little more documentation to how to generate the .svf file since its not easy.

This resource helped me:
https://stackoverflow.com/a/42827113/15924727

@trabucayre
Copy link
Owner

Hi and thanks to report this family is working using svf.
In your first tries you have tried to flash bitstream into SPI, but this operation requires to have a specific bitstream as a bridge JTAG<->SPI: no spiOverJtag bitsreams are availables for this family and the one for cyclone V isn't compatible.
Have you try :

sudo ./openFPGALoader -c usb-blaster -m /shared/mass_blink.rbf

ie without --write-flash: to load into memory instead of flash?

@uint69-t
Copy link
Contributor Author

I tried both, if you check the link to the board, it has two JTAG headers, one writes to a FLASH and the other writes to the FPGA (so when power its interrupted, the FPGA is blank again)
I did not managed to write to the flash, and only one JTAG header (the direct FPGA one) seems responsive, the other just reports a TDO stuck at 0 error.

As you can see in the diagram of the board PDF
It uses the EPCS4SI8, it would be interesting to find a way to write the flash, but already just having the SRAM its awesome.

And abut the RBF, maybe Quartus changed something abut the standard in some version, or im not sure, both RBF and SVF load without any error, but the SVF works and RBF does not.

@uint69-t uint69-t reopened this Mar 26, 2024
@uint69-t
Copy link
Contributor Author

PR #449 created

@trabucayre
Copy link
Owner

I'm mitigate to order this board. I have no real use for an old/obsolete device, but in other hand the behaviour is strange.
In fact there is no to jtag header but only one dedicated to the FPGA, second header is to have a direct access to the flash chip.
Maybe this FPGA has a different set of instructions and not understand instructions for cyclone III/IV/V ?

@uint69-t
Copy link
Contributor Author

It might be that the Cyclone II family managed FLASH in a different way or that its a lot cheaper just plug another JTAG header just for the flash, if you connect the USB-Blaster to the FLASH JTAG, you write to the FLASH and after a reboot the FPGA will read from FLASH, but if you plug it to RAM, you work directly in the FPGA (after a reboot everything is gone). But its truly weird that a FLASH chip its connected directly to a JTAG interface since the programming process from Quartus II its exactly the same.

And i know there is not a lot of use for this old FPGAs/CPLDs, but since they are so cheap (I picked up 20 MAX II CPLDs from aliexpress for 10 USD the other day) they are interesting to build distributed systems.

@Tpj-root
Copy link
Contributor

Tpj-root commented Oct 3, 2024

hii folks, any updates?
How do I store permanently in Cyclone II?

To create a .svf file for Cyclone II

a32863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants