@cdickinson66 it will work fine. Iāve seen this response many times, it usually means wiring is wrong, device is missing, or a completely different and non-existent device has been selected.
First, make sure your olimax and tag-connect wiring is correct. You only need six wires, including power and ground. Below are some handy pinout diagrams. If your wires are longer than about 6in, a series RC filter (~50 Ohm, 1000 pF) on the TCK line to GND is necessary to eliminate stray pulses and signal reflections and, thus, erratic JTAG state machine behavior and even more strange and cryptic error messages from OpenOCD.
Second, for best results on MS Windows use the Zadig tool and install the libusbK
driver to at least the ā0ā instance of the Olimex device. You can leave theā1ā instance for FTDIās VCP (Virtual COM Port) driver if you wish to hook up a UART terminal). Zadig is open source, freely available, and a very good device driver management tool for Windows systems.
Third, here is the most brief script youād need:
ftdi vid_pid 0x15ba 0x002a ;# olimex arm-usb-tiny-h`
ftdi layout_init 0x0b08 0x0b1b ;# handle olimex glitch problem
adapter speed 500 ;# start slow, for now
reset_config none ;# IMPORTANT: dont use nSRST or nTRST
transport select jtag
jtag newtap riscv cpu -irlen 5 -ircapture 0x1 -irmask 0xf
target create riscv.cpu.0 riscv -chain-position riscv.cpu -coreid 0
riscv set_reset_timeout_sec 120 ;# IMPORTANT: time for hart to come out of reset -- 1.5 min, min
riscv set_command_timeout_sec 2 ;# num secs for hart to process command -- 2 sec, typ
riscv reset_delays 5 ;# num run-test-idle cycles between scans
riscv.cpu.0 configure -work-area-phys 0x80000000 -work-area-size 0x400 -work-area-backup 0
flash bank onboard_spi_flash fespi 0x20000000 0 0 0 riscv.cpu.0 0x10014000
init
halt
At this point youāre all set, target should be stopped, and you can either load/run program from RAM ā¦
load_image <my-ram-pgm.bin> 0x80000000 bin
verify_image <my-ram-pgm.bin> 0x80000000 bin
resume 0x80000000
⦠or you can load/run program from Flash/ROM (āNā is number of flash blocks your program occupies, rounded upāin case of your board, the ISSI flash block size is 0x1000
) ā¦
flash protect 0 0 N off
flash erase_sector 0 0 N
flash write_bank 0 <my-rom-pgm.bin>
flash verify_bank 0 <my-rom-pgm.bin>
flash protect 0 0 N on
resume 0x20000000
⦠or you can simply quit gracefully
shutdown
exit
Of course, make sure the RAM or ROM program you load has been linked to the appropriate address ā 0x80000000
or 0x20000000
, respectively.
To determine the number āNā of Flash/ROM blocks dynamically you can do so from within your OpenOCD tcl configuration file like
set secsz [expr 0x1000] ;# 4K sectors issi is25lp128d, typ. most NOR flash
set len [file size my-rom-pgm.bin]
set endsec [expr (${len}/${secsz})+((${len}-(${len}/${secsz})*${secsz})>0)-1]
In /bin/bash script, for use in makefiles on Linux or Mac machines:
$(eval SECSZ=$(shell echo "ibase=16; 1000" | bc))
$(eval LEN=$(shell <my-rom-pgm.bin wc -c))
$(eval ENDSEC=$(shell echo "(${LEN}/${SECSZ})+((${LEN}-(${LEN}/${SECSZ})*${SECSZ})>0)-1" | bc))
In msdos script, for use in makefiles on an MS Windows machine:
$(eval SECSZ=$(shell for /f "tokens=*" %%A in ('set /a "(0x1000)"') do echo %%A ))
$(eval LEN=$(shell forfiles /m my-rom-pgm.bin /c "cmd /c echo @fsize"))
$(eval ENDSEC=$(shell for /f "tokens=*" %%A in ('set /a "(${LEN}/${SECSZ})"') do echo %%A ))
#$(eval REM=$(shell for /f "tokens=*" %%A in ('set /a "(${LEN} %% ${SECSZ})"') do echo %%A ))
$(eval REM=$(shell for /f "tokens=*" %%A in ('set /a "(${LEN}-(${LEN}/${SECSZ})*${SECSZ})"') do echo %%A ))
$(eval ENDSEC=$(shell for /f "tokens=*" %%A in ('if ${REM} gtr 0 set /a "(${ENDSEC} + 1)"') do echo %%A ))
$(eval ENDSEC=$(shell for /f "tokens=*" %%A in ('set /a "(${ENDSEC} - 1)"') do echo %%A ))
Then you can simply replace the āNā with ${endsec}
in the protect and erase steps of the flash
commands above.