Openocd flash command for RISC-V

hi what is the openocd command to flash using CMSIS-DAPv2? on the terminal?
i did:
openocd -c “source [find interface/CMSIS-DAPv2.cfg]”
Open On-Chip Debugger 0.11.0+dev-02228-gbdce7319b (2022-02-15-02:17)
Licensed under GNU GPL v2
For bug reports, readsd
OpenOCD: Bug Reporting
Can’t find interface/CMSIS-DAPv2.cfg

Does the regular cmsis-dap.cfg not work?

openocd -f interface/cmsis-dap.cfg 

(follow by -f <config file for your board/target MCU>)

See openocd/tcl at master · openocd-org/openocd · GitHub.

okay i ditched the dongle and instead using the openocd’s ftdi232 method. it’s connecting now:

openocd -f ~/openocd-cfg/my_ft232r.cfg -f tgt_602.cfg
Open On-Chip Debugger 0.11.0+dev-02230-g347395372 (2022-02-16-03:05)
Licensed under GNU GPL v2
For bug reports, read
Info : only one transport option; autoselect 'jtag'
DEPRECATED! use 'ft232r restore_serial' not 'ft232r_restore_serial'
FT232R restore serial: 0x0015 (enabled)

Ready for Remote Connections
Warn : `riscv set_prefer_sba` is deprecated. Please use `riscv set_mem_access` instead.
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : clock speed 3000 kHz
Info : JTAG tap: riscv.cpu tap/device found: 0x20000c05 (mfg: 0x602 (Open HW Group), part: 0x0000, ver: 0x2)
Info : [riscv.cpu.0] datacount=1 progbufsize=2
Info : Disabling abstract command reads from CSRs.
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40801125
[riscv.cpu.0] Target successfully examined.
Info : starting gdb server for riscv.cpu.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333

i can also attach from risc-v gdb:

Reading symbols from /home/ajit/doiting/bl_iot_sdk/customer_app/sdk_app_helloworld/build_out/sdk_app_helloworld.elf...
(gdb) sourcd ~/.gdbinit
Undefined command: "sourcd".  Try "help".
(gdb) source ~/.gdbinit 
The target architecture is assumed to be riscv:rv32
overlapping memory region
overlapping memory region
overlapping memory region
overlapping memory region
overlapping memory region
overlapping memory region
overlapping memory region
overlapping memory region
overlapping memory region
(gdb) target remote :3333
Remote debugging using :3333
0x21003ec0 in ?? ()
(gdb) load
Loading section .init, size 0xe0 lma 0x23000000
Load failed

but what is the correct way to flash the program?


I’ve seen the load command work in other environments, funny that it works not here.

Usually though, flashing is done via OpenoOCD’s program command, as illustrated e.g. here. With the, you should be able to e.g. do

openocd -f ~/openocd-cfg/my_ft232r.cfg -f tgt_602.cfg -c "program {firmware.elf} verify reset; shutdown;"

(assuming the file firmware.elf exists in the folder where the command is executed.)

thanks for the confirmation, i think the chip cfg has flashing disabled:
gdb_memory_map enable
gdb_flash_program disable

i read somewhere too that the chip only loads into ram for debugging…

I don’t know, maybe OpenOCD does not have support for writing to the flash memory of this device yet. Ask the devs there via a ticket. For our PlatformIO+BL602 projects (Community-BL-IOT · GitHub), we’re using the serial bootloader for uploading the firmware (this flasher), The firmware can still be debugged via SWD.

according to the document:

If it is XIP code, you need to burn it first and then debug
• Currently OpenOCD + GDB cannot achieve 602 SPI/XIP flash programming

as it seems, the flash is external to the mcu…

my biggest nag is that need to press the bootloader buttons all the time (i make a lot of bugs repeatedly :blush: ) is there a way you know to auto trigger the bootloader in these XIP chips? perhaps a ftdi232rl hack?

found one!
but it requires a linux sbc instead of a miniature ftdi chip…

just found out that there’s a bounty set for this task at upwork: