trabucayre / openFPGALoader

Universal utility for programming FPGA
https://trabucayre.github.io/openFPGALoader/
Apache License 2.0
1.16k stars 249 forks source link

3- vs. 4-Byte-Adressing: Flashing a MT25QL256 attached to Cyclone 10CL025 fails #467

Open kawk opened 2 months ago

kawk commented 2 months ago

Hi,

I tried to program a QSPI Flash (MT25QL256) attached to a Intel 10LP (10CL025YU256I7G) using openFPGALoader (branch master as of today, 1b00940). The output indicates a successful upload of the spiOverJtag config (spiOverJtag_10cl025256.rbf) and writing to flash (identified as Micron N25Q256).

However, the content of the flash is only "touched", but not correctly copied from the input RPD: Mostly 0xFF, with contiguous blocks of 256 zero bytes at 0 and then repeated every 64 kByte. Only the last byte of these blocks sometimes is neither 0 or 0xff...

Command: openFPGALoader -v -c usb-blaster -B spiOverJtag_10cl025256.rbf --external-flash top_auto.rpd

I normally program the device using Quartus Programmer with "Factory default enhanced SFL image" for "10CL025Y" and device "MT25QL256". Does specific information about this flash have to be added somewhere?

Kolja

kawk commented 2 months ago

I learned that Quartus Programmer changes the flash NVCFG from 0xFFFF to 0x8FEE when programming it for the first time. That changes initial addressing mode, for example, and is also needed for further operation (a NIOS2 running from this flash). I suspect that the addressing mode might cause such issues.

kawk commented 2 months ago

Indeed: After the nonvolatile config register (NVCFG) was forced back to 0xFFFF, programming with openFPGALoader succeeded. Now however my NIOS can't run. Even if it's possible to change the logic and firmware to run with NVCFG 0xFFFF, that would make it incompatible with boards programmed with Quartus Programmer.. Maybe the flash programming code should be enhanced to observe the addressing mode currently active?

kawk commented 2 months ago

I validated two possible approaches for the case that flash is configured with default 4-byte adressing in NVCFG:

Either way, I additionally have to implement some method to change the NVCFG register, because I need to have it changed from the factory default for normal operation, when flashing brand new chips for the first time. What would be be an appropriate way to provide such functionality? An extra command line argument?

kawk commented 2 months ago

Nb - the NVCFG may put the flash into much more exotic operational modes that prevent programming, such as automatic address wraparound after so many bytes (e.g. 32). I presume it might be a good idea to check for these and disable them at least volatile. However, I don't have an overview what flash chips provide what modes...