I'm running into quite a complicated problem. When I flash my RISC-V chip with 
two consoles - one for OpenOCD and another for GDB - the flash succeeds. When I 
try to flash it from a single console - a procedure I've successfully applied 
on countless ARM-based chips - it fails. I'll give more details below. 








FLASHING FROM TWO CONSOLES 


====================== 


To flash my GD32VF103CBT6 chip (GD32VF103C-START board from GigaDevice) I spawn 
two consoles: one for OpenOCD and another for GDB. It kind of works - I have to 
increase the remote timeout before instructing the microcontroller to reset and 
run: 




# after loading the firmware to the chip: 

(gdb) set remotetimeout 3000 
(gdb) monitor reset run 




But aside from this issue with, the firmware flashes successfully. However, I 
might miss some anomalies in the output that some of you can better detect. 
Therefore, I've added the OpenOCD and GDB output to this mail: 

- openocd_output.txt 


- gdb_output.txt 


And also the OpenOCD config files: 


- openocd_chip.cfg 


- openocd_probe.cfg 


The OpenOCD version is compiled by GigaDevice themselves. They followed the 
xPack build procedure from Liviu Ionescu. The result can be found here, 

for Linux: 


[ 
https://new.embeetle.com/downloads/beetle_tools/linux/openocd_giga_0.10.0_dev_64b.7z
 | 
https://new.embeetle.com/downloads/beetle_tools/linux/openocd_giga_0.10.0_dev_64b.7z
 ] 


for Windows: 


[ 
https://new.embeetle.com/downloads/beetle_tools/linux/openocd_giga_0.10.0_dev_64b.7z
 | 
https://new.embeetle.com/downloads/beetle_tools/windows/openocd_giga_0.10.0_dev_64b.7z
 ] 








FLASHING FROM A SINGLE CONSOLE 


======================== 

In Embeetle IDE we aim to do the flashing procedure in a single console. That's 
why we give the following .gdbinit file to GDB at startup: 




define flash-remote 
echo \n 
echo 
\n--------------------------------------------------------------------------------
 
echo \n Run flash-remote function: 
echo \n ========================== 
echo \n flash-remote( 
echo \n elf_file = $arg0 , 
echo \n openocd_path = $arg1 , 
echo \n probe_file = $arg2 , 
echo \n chip_file = $arg3 , 
echo \n ) 
echo 
\n--------------------------------------------------------------------------------
 
echo \n 
file $arg0 
target extended-remote | $arg1 -f $arg2 -f $arg3 -c "gdb_port pipe; log_output 
openocd.log" 
load 
monitor reset run 
monitor shutdown 
quit 
end 




As you can see, this .gdbinit file instructs GDB to launch OpenOCD and hook 
into its GDB server. When launching GDB, we not only pass this .gdbinit file, 
but also give it a couple of flags on the commandline. This is our flash target 
in the makefile, so you can see the flags for yourself: 




GDB_FLASHFLAGS = \ 
-n \ 
-batch \ 
-x ../config/.gdbinit \ 
-ex "flash-remote $(ELF_FILE) openocd ../config/openocd_probe.cfg 
../config/openocd_chip.cfg" \ 



.PHONY : flash 
flash : $(ELF_FILE) 
$(GDB) $(GDB_FLASHFLAGS) 





In short, GDB starts in batch mode, is given a .gdbinit file with a 
user-defined-function and that same function is then called with the proper 
arguments. We've applied this technique to countless other chips (ARM-based 
ones) and it always worked. 








However, when running this flash target, I get the following output: 




--------------------------------------------------------------------------------
 

Run flash-remote function: 

========================== 

flash-remote( 

elf_file = application.elf , 

openocd_path = openocd , 

probe_file = ../config/openocd_probe.cfg , 

chip_file = ../config/openocd_chip.cfg , 

) 

--------------------------------------------------------------------------------
 

xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-dirty (2020-10-26-06:00) 

Licensed under GNU GPL v2 

For bug reports, read 

http://openocd.org/doc/doxygen/bugs.html 

jtag 

Info : CMSIS-DAP: SWD Supported 

Info : CMSIS-DAP: JTAG Supported 

Info : CMSIS-DAP: FW Version = 2.0.0 

Info : CMSIS-DAP: Interface Initialised (JTAG) 

Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1 

Info : CMSIS-DAP: Interface ready 

Info : clock speed 1000 kHz 

Info : cmsis-dap JTAG TLR_RESET 

Info : cmsis-dap JTAG TLR_RESET 

Info : 




Then it hangs. Nothing happens - I have to kill the process. There is no 
openocd.log file to be found. 

What could the problem be? 





Kind regards, 


Kristof Mulier 















Attachment: openocd_chip.cfg
Description: Binary data

Attachment: openocd_probe.cfg
Description: Binary data

C:\Users\Gebruiker\beetle_projects\gd32vf103c_start_baremetal\build>riscv-none-embed-gdb.exe
riscv-none-embed-gdb.exe: warning: Couldn't determine a path for the index 
cache directory.
GNU gdb (xPack GNU RISC-V Embedded GCC, 64-bit) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-w64-mingw32 
--target=riscv-none-embed".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://github.com/sifive/freedom-tools/issues>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word".
(gdb) file application.elf
Reading symbols from application.elf...
(gdb) target extended-remote localhost:3333
Remote debugging using localhost:3333
0x08001564 in __floatunsidf ()
(gdb) load
Loading section .init, size 0x236 lma 0x8000000
Loading section .text, size 0x17e0 lma 0x8000240
Loading section .sdata2._global_impure_ptr, size 0x4 lma 0x8001a20
Loading section .init_array, size 0x4 lma 0x8001a24
Loading section .data, size 0x68 lma 0x8001a28
Start address 0x800015c, load size 6790
Transfer rate: 769 bytes/sec, 1358 bytes/write.
(gdb) set remotetimeout 3000
(gdb) monitor reset run
cmsis-dap JTAG TLR_RESET
cmsis-dap JTAG TLR_RESET
cmsis-dap JTAG TLR_RESET
JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology 
Corporation), part: 0x0005, ver: 0x1)
JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice 
Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Hart 0 didn't run coming out of reset in 1s; dmstatus=0x4f03a2; Increase the 
timeout with riscv set_reset_timeout_sec.
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not 
sent! (1813 ms). Workaround: increase "set remotetimeout" in GDB

Hart 0 unexpectedly reset!
(gdb) set remotetimeout 3000
(gdb) monitor reset run
cmsis-dap JTAG TLR_RESET
cmsis-dap JTAG TLR_RESET
cmsis-dap JTAG TLR_RESET
JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes Technology 
Corporation), part: 0x0005, ver: 0x1)
JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice 
Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
(gdb) monitor shutdown
shutdown command invoked
(gdb) quit
A debugging session is active.

        Inferior 1 [Remote target] will be detached.

Quit anyway? (y or n) y
Detaching from program: 
C:\Users\Gebruiker\beetle_projects\gd32vf103c_start_baremetal\build\application.elf,
 Remote target
Remote communication error.  Target disconnected.: Success.
C:\Users\Gebruiker\beetle_projects\gd32vf103c_start_baremetal\build>openocd -f 
../config/openocd_probe.cfg -f ../config/openocd_chip.cfg -c "init; reset halt"
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-dirty (2020-10-26-06:00)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
jtag
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: JTAG Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (JTAG)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 1 TDO = 1 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : clock speed 1000 kHz
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes 
Technology Corporation), part: 0x0005, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice 
Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Warn : AUTO auto0.tap - use "jtag newtap auto0 tap -irlen 5 -expected-id 
0x790007a3"
Info : datacount=4 progbufsize=2
Info : Examined RISC-V core; found 1 harts
Info :  hart 0: XLEN=32, misa=0x40901105
Info : starting gdb server for riscv.cpu on 3333
Info : Listening on port 3333 for gdb connections
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes 
Technology Corporation), part: 0x0005, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice 
Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x19060410
Info : flash_size_in_kb = 0x00000080
Info : flash size = 128kbytes
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes 
Technology Corporation), part: 0x0005, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice 
Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Info : Padding image section 0 at 0x08000236 with 10 bytes
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes 
Technology Corporation), part: 0x0005, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice 
Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes 
Technology Corporation), part: 0x0005, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice 
Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
Error: Hart 0 didn't run coming out of reset in 1s; dmstatus=0x4f03a2; Increase 
the timeout with riscv set_reset_timeout_sec.
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet 
not sent! (1813 ms). Workaround: increase "set remotetimeout" in GDB

Info : Hart 0 unexpectedly reset!
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : cmsis-dap JTAG TLR_RESET
Info : JTAG tap: riscv.cpu tap/device found: 0x1000563d (mfg: 0x31e (Andes 
Technology Corporation), part: 0x0005, ver: 0x1)
Info : JTAG tap: auto0.tap tap/device found: 0x790007a3 (mfg: 0x3d1 (GigaDevice 
Semiconductor (Beijing)), part: 0x9000, ver: 0x7)
shutdown command invoked
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to