Skip to content

Unable to Debug GD32F30x When FreeRTOS is Integrated in PlatformIO #1

@nickrunning

Description

@nickrunning

This issue arose because the OpenOCD version used by this repository was outdated. When debugging the GD32F30x with an integrated FreeRTOS system, OpenOCD would automatically detect FreeRTOS upon startup, but subsequent operations (e.g., accessing registers or memory) would result in exceptions, making debugging impossible.

This problem persisted until I upgraded OpenOCD from version 0.11.0+dev-00557-g9acceee94 to 0.12.0-01004-g9ea7f3d64-dirty. This was achieved by executing the following command:

cp ~/.platformio/packages/tool-openocd/bin/openocd ~/.platformio/packages/tool-openocd-gd32/bin/openocd

Despite this upgrade, I still encountered some memory read failure errors. We hope you will update the OpenOCD version in your platform to resolve this issue.

Debug info before openocd replaced

PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = cmsis-dap
PlatformIO: Initializing remote target...
Open On-Chip Debugger 0.11.0+dev-00557-g9acceee94 (2022-06-23-13:10)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
swd
0x2ba01477
none separate

Info : DEPRECATED target event trace-config; use TPIU events {pre,post}-{enable,disable}
Info : tcl server disabled
Info : telnet server disabled
Info : CMSIS-DAP: SWD  supported
Info : CMSIS-DAP: JTAG supported
Info : CMSIS-DAP: Atomic commands supported
Info : CMSIS-DAP: FW Version = 0254
Info : CMSIS-DAP: Serial# = 07000001002200453200000d4e574335a5a5a5a597969908
Info : CMSIS-DAP: Interface Initialised (SWD)
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 : SWD DPIDR 0x2ba01477
Info : stm32f1x.cpu: Cortex-M4 r0p1 processor detected
Info : stm32f1x.cpu: target has 6 breakpoints, 4 watchpoints
Info : starting gdb server for stm32f1x.cpu on pipe
Info : accepting 'gdb' connection from pipe
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x08002082 psp: 0x20000bc0
Info : device id = 0x21040414
Warn : STM32 flash size failed, probe inaccurate - assuming 512k flash
Info : flash size = 512kbytes
vApplicationIdleHook () at src/freertos_callbacks.c:63
63	}
Info : Auto-detected RTOS: FreeRTOS
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000210 msp: 0x2000c000
Loading section .isr_vector, size 0x130 lma 0x8000000
Loading section .text, size 0x3818 lma 0x8000130
Loading section .rodata, size 0x1c8 lma 0x8003948
Loading section .init_array, size 0x4 lma 0x8003b10
Loading section .fini_array, size 0x4 lma 0x8003b14
Loading section .data, size 0x70 lma 0x8003b18
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000210 msp: 0x2000c000
Start address 0x8000210, load size 15240
Transfer rate: 11 KB/sec, 2540 bytes/write.
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000210 msp: 0x2000c000
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000210 msp: 0x2000c000
Temporary breakpoint 1 at 0x8002244: file src/main.c, line 99.
PlatformIO: Initialization completed
[New Thread 536872184]
[New Thread 536873320]
[New Thread 536875216]
[Switching to thread 1 (Thread 536873944)]
[New Thread 536873944]
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0xf4436814
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> https://bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
[New Remote target]
[Switching to Thread 1]

Debug info after openocd replaced

Reading symbols from /home/nick/workspace/gd32-platform/.pio/build/DHLR_debug/firmware.elf...
PlatformIO Unified Debugger -> https://bit.ly/pio-debug
PlatformIO: debug_tool = cmsis-dap
PlatformIO: Initializing remote target...
xPack Open On-Chip Debugger 0.12.0-01004-g9ea7f3d64-dirty (2023-01-30-15:03)
Licensed under GNU GPL v2
For bug reports, read
	http://openocd.org/doc/doxygen/bugs.html
swd
0x2ba01477
Info : DEPRECATED target event trace-config; use TPIU events {pre,post}-{enable,disable}
Info : tcl server disabled
Info : telnet server disabled
Info : CMSIS-DAP: SWD supported
Info : CMSIS-DAP: JTAG supported
Info : CMSIS-DAP: Atomic commands supported
Info : CMSIS-DAP: FW Version = 0254
Info : CMSIS-DAP: Serial# = 07000001002200453200000d4e574335a5a5a5a597969908
Info : CMSIS-DAP: Interface Initialised (SWD)
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 : SWD DPIDR 0x2ba01477
Info : [stm32f1x.cpu] Cortex-M4 r0p1 processor detected
Info : [stm32f1x.cpu] target has 6 breakpoints, 4 watchpoints
DEPRECATED! use 'read_memory' not 'mem2array'
Info : starting gdb server for stm32f1x.cpu on pipe
Info : accepting 'gdb' connection from pipe
[stm32f1x.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x0800121c psp: 0x20000bc0
Info : device id = 0x21040414
Warn : STM32 flash size failed, probe inaccurate - assuming 512k flash
Info : flash size = 512 KiB
prvIdleTask (pvParameters=<optimized out>) at lib/FreeRTOS/src/tasks.c:3492
3492	                vApplicationIdleHook();
Info : Auto-detected RTOS: FreeRTOS
DEPRECATED! use 'read_memory' not 'mem2array'
[stm32f1x.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000210 msp: 0x2000c000
Loading section .isr_vector, size 0x130 lma 0x8000000
Loading section .text, size 0x3818 lma 0x8000130
Loading section .rodata, size 0x1c8 lma 0x8003948
Loading section .init_array, size 0x4 lma 0x8003b10
Loading section .fini_array, size 0x4 lma 0x8003b14
Loading section .data, size 0x70 lma 0x8003b18
DEPRECATED! use 'read_memory' not 'mem2array'
[stm32f1x.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000210 msp: 0x2000c000
Start address 0x8000210, load size 15240
Transfer rate: 11 KB/sec, 2540 bytes/write.
DEPRECATED! use 'read_memory' not 'mem2array'
DEPRECATED! use 'read_memory' not 'mem2array'
[stm32f1x.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000210 msp: 0x2000c000
[stm32f1x.cpu] halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08000210 msp: 0x2000c000
Temporary breakpoint 1 at 0x8002244: file src/main.c, line 99.
PlatformIO: Initialization completed
[New Thread 536873320]
[New Thread 536872184]
[New Thread 536875216]
[Switching to thread 1 (Thread 536873944)]
[New Thread 536873944]
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x23006014
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
Info : SWD DPIDR 0x2ba01477
Error: Failed to read memory at 0x430b68c4
Error: Error reading stack frame from thread
Error: RTOS: failed to get register list
PlatformIO: Resume the execution to `debug_init_break = tbreak main`
PlatformIO: More configuration options -> https://bit.ly/pio-debug
Note: automatically using hardware breakpoints for read-only addresses.
[New Thread 1]
[Switching to Thread 1]

Thread 6 "Current Execution" hit Temporary breakpoint 1, main () at src/main.c:99
99	{

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions