最近在调试时经常遇到启动调试时失败,无法联调,使用SWDTool经过擦除写入、掉电等一系列薛定谔般的操作后又有机会恢复调试连接。主要提示错误信息如下:
Error: error writing to flash at address 0x00000000 at offset 0x00030000
CH32V303RC芯片Flash容量480K,前192K为高速区。
不太清楚是什么原因引起,请问如何解决?
调试输出:
Open On-Chip Debugger 0.11.0+dev-02415-gfad123a16-dirty (2023-07-03-15:11)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
Info : only one transport option; autoselect 'sdi'
Warn : Transport "sdi" was already selected
Ready for Remote Connections
Started by GNU MCU Eclipse
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections
Info : WCH-LinkE mode:RV version 2.10
Info : wlink_init ok
Info : clock speed 6000 kHz
Info : [wch_riscv.cpu.0] datacount=2 progbufsize=8
Info : [wch_riscv.cpu.0] Examined RISC-V core; found 1 harts
Info : [wch_riscv.cpu.0] XLEN=32, misa=0x40901125
[wch_riscv.cpu.0] Target successfully examined.
Info : starting gdb server for wch_riscv.cpu.0 on 3333
Info : Listening on port 3333 for gdb connections
Info : accepting 'gdb' connection on tcp/3333
Info : device id = 0x6b59abcd
Info : flash size = 21037344kbytes
Info : ROM 192 kbytes RAM 128 kbytes
Warn : Prefer GDB command "target extended-remote :3333" instead of "target remote :3333"
Info : Flash write discontinued at 0x0002b100, next section at 0x00030000
Info : Flash write discontinued at 0x00034000, next section at 0x00038000
Error: error writing to flash at address 0x00000000 at offset 0x00030000
Warn : keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (14870 ms). Workaround: increase "set remotetimeout" in GDB
Info : dropped 'gdb' connection
根据实际情况,项目使用的ld文件内存区域定义如下:
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 192K
ROM_DATA1(rx) : ORIGIN = 0x00030000, LENGTH = 16K
ROM_DATA2(rx) : ORIGIN = 0x00034000, LENGTH = 32K
RAM (xrw) : ORIGIN = 0x20000000, LENGTH = 128K
}