trabucayre / openFPGALoader

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

Tang Primer 25K SRAM loading fails when flash is erased #426

Closed jgroman closed 9 months ago

jgroman commented 9 months ago

openFPGALoader fails to load Tang Primer 25K SRAM when its flash has been erased and the board was powercycled.

Gowin programmer works fine in this case. Monitoring USB packets reveals that Gowin programmer sends extra commands before SRAM erase + load process if flash was erased beforehands. The commands in the marked part below are not sent when flash contains valid data. This part is probably injected after inspecting Status Register bits signalling invalid flash contents. The most interesting would probably be the command 0x3F which I was not able to locate any reference for in Arora V datasheet.

TAP reset
CMD 3A        // Config Disable
RD 1 byte     // execution result
CMD 00        // ???
RD 1 byte     // execution result
TAP reset
CMD 41        // Read Status Register
RD 1 byte     // execution result
R/W 7 bytes   // > FFFF FFFF 0000 00 (last byte 3 bits only are actually clocked out)
RD 7 bytes    // < 3862 0276 FFFF 80

==== ERASED FLASH ONLY START ====
CMD 3F        // ??? Undocumented command
RD 1 byte     // execution result
--- wait 100 ms
CMD 02        // NOOP
RD 1 byte     // execution result
CMD 11        // Supposedly Read ID code, but the code is never actually read
RD 1 byte     // execution result
CMD 02        // NOOP
RD 1 byte     // execution result
Clock out [19] 126x 00 byte   // ~ 100 us delay
--- wait 100 ms
CMD 11        // Supposedly Read ID code, but the code is never actually read
RD 1 byte     // execution result
==== ERASED FLASH ONLY END ====

CMD 15        // Config Enable
...