lnls-dig / fpga-programming

Repository containing scripts for automating FPGA programming
GNU General Public License v3.0
5 stars 2 forks source link

Script openocd-prog-flash.sh doesn't work on AFCv3 #1

Open guilhermerc opened 1 year ago

guilhermerc commented 1 year ago

These are the logs: afcv3.log

guilhermerc commented 1 year ago

I increased openocd logs' level and executed openocd-prog-flash.sh both on AFCv3 and AFCv3. These are the logs, again: afcs-logs.zip

guilhermerc commented 1 year ago

AFCv4 [1] uses Micron's MT25QL256ABA8ESF-0AAT [2] as FPGA's FLASH memory, whereas AFCv3 [3] uses Micron's N25Q256A13EF840E [4]. These devices share the same Manufacturer and Device IDs (0x19BA20) and openocd handles both the same [5]. However, the 4-BYTE PAGE PROGRAM (0x12) and 4-BYTE SECTOR ERASE (0xDC) commands aren't supported by N25Q256A13EF840E [4, pp. 29-31, note 14].

[1] AFCv4.0.2_LNLS_FOFB.PDF [2] mt25q_qljs_l_256_aba_0.pdf [3] AMC_FMC_Carrier_v3.1_LNLS_201709BPM.pdf [4] n25q_256mb_3v.pdf [5] https://github.com/openocd-org/openocd/blob/2e60e2eca9d06dcb99a4adb81ebe435a72ab0c7f/src/flash/nor/spi.c#L110

guilhermerc commented 1 year ago

A work-in-progress fix can be found at https://github.com/lnls-dig/openocd/compare/master...fix-afcv3-flashing.

guilhermerc commented 1 year ago

https://github.com/openocd-org/openocd/commit/5d6bf8704ce7ed9a7e471e601ab91061c39f88c6 adds support for n25q256 flash. At that point, PAGE PROGRAM (0x02) and SECTOR ERASE (0xD8) commands were used, which are supported by N25Q256A13EF840E.

TODO: finish this comment