From: Martin S. <mar...@we...> - 2020-09-08 12:14:41
|
Hello, i have a JTAG chain with two Xilinx 7-series FPGAs of type XC7k160t, which i call 'upper' and 'lower'. Each of them has an individual SPI flash memory attached. To use openocd with scripts (e.g. 'openocd -f custom.cfg program_Flash upper custom.bit') i added some helper functions in my custom.cfg file. These functions directly call the functions of the openocd scripts or are a copy of them with slight changes to parameters. The main changes are the calling via upper/lower and letting the functions add .tap, .spi or .proxy to it. 'scan_chain' shows both FPGAs and flash banks lists two devices. Writing a bitstream to the FPGA itself with my 'program_FPGA' is working (using cpld/xilinx-xc7.cfg), as well as reading the temperature (using fpga/xilinx-xadc.cfg) and DNA (using fpga/xilinx-dna.cfg). Writing to the flash memory of 'lower' using cpld/jtagspi.cfg works, but the verification call following it throws an error (see below). When i run the verify_Flash procedure right after this, there is no error. It only occurs inside my program_Flash function. Writing to the flash memory of 'upper' throws errors right at the beginning and there seems to be nothing written to the flash. The flash memory of 'lower' can be dumped with my 'dump_Flash' function and is correct. It doesn't work for 'upper', the result is a nearly the correct bitstream, but has lots of ones at the beginning and end. As 'upper' still boots correctly after a failed flash attempt, i guess that the result of the dump function is not a valid representation of the its flash memory contents. It may also be a mangled version of 'lower''s memory. As the proxy bitstream i'm using 'bscan_spi_xc7k160t.bit' downloaded from https://github.com/quartiq/bscan_spi_bitstreams. I think i have a wrong setting somewhere in my script, the jtagspi uses chain indices instead of tap names, which is why i'm using a function to translate the strings upper/lower to 0/1. It might also have sth to do with the order of the devices in the chain? Or am i missing a command to 'reset' the FPGA from the proxy bitstream to the correct one and this is then interfering? To make things worse, my tcl is also very weak and maybe the jimtcl implementation doesn't like it. To verify the FPGA bitstream, i'm using the "verify" function in Vivado. To check the flash i powercycle the board and then again use verify on the bitstream then found in the FPGA. Below is my custom.cfg file and the telnet outputs. You might notice that my adapter is not the standard variant, it's a modified version of xlnx_pcie_xvc. As the required modification was really minor, not affecting program logic and all other jtag transactions are working, this should not be the source of my problems. ----- custom.cfg -------------------------------------- debug_level 2 #[find scripts/interface/xlnx_pcie_xvc] adapter driver xlnx_pcie_xvc transport select jtag xlnx_pcie_xvc_config /dev/uio1 is_mmap_device 1 set board_flashsize 6692692 set flash_bitstream "/home/ubuntu/bscan_spi_xc7k160t.bit" set tap_postfix .tap set flash_postfix .spi set flashproxy_postfix .proxy set CHIPNAME upper source [find cpld/xilinx-xc7.cfg] source [find cpld/jtagspi.cfg] set CHIPNAME lower source [find cpld/xilinx-xc7.cfg] source [find cpld/jtagspi.cfg] source [find fpga/xilinx-dna.cfg] source [find fpga/xilinx-xadc.cfg] proc tapID_to_index {tap_name} { if [string equal $tap_name "upper"] { return 0 } else { return 1 } } init proc program_Flash {tap_name bitstream} { init global _FLASHNAME set _FLASHNAME $tap_name$::flash_postfix jtagspi_init [tapID_to_index $tap_name] $::flash_bitstream echo "init done" echo "_FLASHNAME = $_FLASHNAME" jtagspi_program $bitstream 0 echo "program done" xc7_program $tap_name } proc program_FPGA {tap_name bitstream} { global _CHIPNAME set _CHIPNAME $tap_name xc7_program $tap_name$::tap_postfix pld load [tapID_to_index $tap_name] $bitstream } proc verify_Flash {tap_name bitstream} { init global _FLASHNAME set _FLASHNAME $tap_name$::flash_postfix jtagspi_init [tapID_to_index $tap_name] $::flash_bitstream echo [flash verify_bank $tap_name$::flash_postfix $bitstream] xc7_program $tap_name$::tap_postfix } proc dump_Flash {tap_name bitstream} { init global _FLASHNAME set _FLASHNAME $tap_name$::flash_postfix jtagspi_init [tapID_to_index $tap_name] $::flash_bitstream echo [flash read_bank $tap_name$::flash_postfix $bitstream 0 $::board_flashsize] xc7_program $tap_name$::tap_postfix } proc get_DNA {tap_name} { xilinx_print_dna [xc7_get_dna $tap_name$::tap_postfix] } proc get_STATreg {tap_name} { xc7_program $tap_name$::tap_postfix virtex2 read_stat [tapID_to_index $tap_name] xc7_program $tap_name$::tap_postfix } proc get_Voltages {tap_name} { xadc_report $tap_name$::tap_postfix } proc get_Temp {tap_name} { xadc_select $tap_name$::tap_postfix echo "[format %.2f [xadc_temp [xadc_single $tap_name$::tap_postfix TEMP]]]" } ---------------------------------------------------------- As an aid during debugging, I added some printfs to the openocd scripts that are called. Here are the outputs > flash banks #0 : upper.spi (jtagspi) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0 #1 : lower.spi (jtagspi) at 0x00000000, size 0x00000000, buswidth 0, chipwidth 0 > program_Flash upper /home/ubuntu/current.bit pld load 0 /home/ubuntu/bscan_spi_xc7k160t.bit reset halt JTAG tap: upper.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) JTAG tap: lower.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) flash probe upper.spi Found flash device 'sp s25fl128s' (ID 0x00182001) init done _FLASHNAME = upper.spi flash write_image erase /home/ubuntu/current.bit 0 Unknown flash device (ID 0x003f0000) auto_probe failed auto erase enabled > program_Flash lower /home/ubuntu/current.bit pld load 1 /home/ubuntu/bscan_spi_xc7k160t.bit reset halt JTAG tap: upper.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) JTAG tap: lower.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) flash probe lower.spi Found flash device 'sp s25fl128s' (ID 0x00182001) init done _FLASHNAME = lower.spi flash write_image erase /home/ubuntu/current.bit 0 Found flash device 'sp s25fl128s' (ID 0x00182001) Found flash device 'sp s25fl128s' (ID 0x00182001) Found flash device 'sp s25fl128s' (ID 0x00182001) sector 0 took 391 ms sector 1 took 450 ms sector 2 took 452 ms sector 3 took 439 ms ... (removed to shorten log) sector 102 took 459 ms flash verify_bank lower.spi /home/ubuntu/current.bit 0 Found flash device 'sp s25fl128s' (ID 0x00182001) program done Invalid command argument Tap: lower unknown >verify_Flash lower /home/ubuntu/current.bit pld load 1 /home/ubuntu/bscan_spi_xc7k160t.bit reset halt JTAG tap: upper.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) JTAG tap: lower.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) flash probe lower.spi Found flash device 'sp s25fl128s' (ID 0x00182001) Found flash device 'sp s25fl128s' (ID 0x00182001) read 6692692 bytes from file /home/ubuntu/current.bit and flash bank 1 at offset 0x00000000 in 12.192206s (536.066 KiB/s) contents match > verify_Flash upper /home/ubuntu/current.bit pld load 0 /home/ubuntu/bscan_spi_xc7k160t.bit reset halt JTAG tap: upper.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) JTAG tap: lower.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) flash probe upper.spi Found flash device 'sp s25fl128s' (ID 0x00182001) Found flash device 'sp s25fl128s' (ID 0x00182001) read 6692692 bytes from file /home/ubuntu/current.bit and flash bank 0 at offset 0x00000000 in 12.189343s (536.192 KiB/s) contents differ diff 0 address 0x00000000. Was 0xff instead of 0x00 diff 1 address 0x00000001. Was 0xff instead of 0x09 ….. diff 127 address 0x00000084. Was 0x06 instead of 0xff More than 128 errors, the rest are not printed. > dump_Flash upper /home/ubuntu/test_200907_1.bit pld load 0 /home/ubuntu/bscan_spi_xc7k160t.bit reset halt JTAG tap: upper.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) JTAG tap: lower.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) flash probe upper.spi Found flash device 'sp s25fl128s' (ID 0x00182001) Found flash device 'sp s25fl128s' (ID 0x00182001) wrote 6692692 bytes to file /home/ubuntu/test_200907_1.bit from flash bank 0 at offset 0x00000000 in 12.218133s (534.929 KiB/s) > dump_Flash lower /home/ubuntu/test_200907_lower.bit pld load 1 /home/ubuntu/bscan_spi_xc7k160t.bit reset halt JTAG tap: upper.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) JTAG tap: lower.tap tap/device found: 0x0364c093 (mfg: 0x049 (Xilinx), part: 0x364c, ver: 0x0) flash probe lower.spi Found flash device 'sp s25fl128s' (ID 0x00182001) Found flash device 'sp s25fl128s' (ID 0x00182001) wrote 6692692 bytes to file /home/ubuntu/test_200907_lower.bit from flash bank 1 at offset 0x00000000 in 12.237569s (534.079 KiB/s) Maybe i'm overcomplicating this, i tried to reuse the existing scripts as they should be working and also adhere to the approach of setting global variables instead of passing parameters. Any help would be greatly appreciated. |