cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to debug CubeMX generated project for STM32F4103T6U7A if the binary size is bigger than 10160 bytes

martonmiklos
Senior
Posted on May 30, 2017 at 09:42

Hello all,

I am trying to use an STM32F4103T6U7A in an application where an USB CDC stack would be used.

I am using the STM32 Workbench, an original STLink V2.

If I generate my project with Disabled USB class:

0690X000006078pQAA.png

I can debug it fine with STM32 Workbench and openocd:

Open On-Chip Debugger 0.0-dev-00278-ga53935e-dirty (2017-05-09-09:16)
Licensed under GNU GPL v2
For bug reports, read
 http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_open_drain connect_assert_srst
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : clock speed 1000 kHz
Info : STLINK v2 JTAG v28 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.201569
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : STM32F103T6Ux.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080022fc msp: 0x20001800
Info : device id = 0x10006412
Info : flash size = 32kbytes
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080022fc msp: 0x20001800
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080022fc msp: 0x20001800
STM32F103T6Ux.cpu: target state: halted
target halted due to breakpoint, current mode: Thread 
xPSR: 0x61000000 pc: 0x2000003a msp: 0x20001800
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080022fc msp: 0x20001800�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

If I select the CDC stack, regenerate and recompile the code:

0690X000006079EQAQ.png

The openocd debug session fails with the following output (with -d2 loglevel):

Open On-Chip Debugger 0.0-dev-00278-ga53935e-dirty (2017-05-09-09:16)
Licensed under GNU GPL v2
For bug reports, read
 http://openocd.org/doc/doxygen/bugs.html
debug_level: 2
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 1000 kHz
adapter_nsrst_delay: 100
srst_only separate srst_nogate srst_open_drain connect_assert_srst
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : clock speed 1000 kHz
Info : STLINK v2 JTAG v28 API v2 SWIM v7 VID 0x0483 PID 0x3748
Info : using stlink api v2
Info : Target voltage: 3.201569
Info : Unable to match requested speed 1000 kHz, using 950 kHz
Info : STM32F103T6Ux.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08003884 msp: 0x20001800
Info : device id = 0x10006412
Info : flash size = 32kbytes
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08003884 msp: 0x20001800
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x08003884 msp: 0x20001800
Error: timed out while waiting for target halted
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Handler HardFault
xPSR: 0x81000003 pc: 0x08002278 msp: 0x200017d0
Error: error waiting for target flash write algorithm
Error: error writing to flash at address 0x08000000 at offset 0x00000000
STM32F103T6Ux.cpu: target state: halted
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x080022fc msp: 0x20001800
Error: address + size wrapped(0xffffffff, 0x00000004)
Error: address + size wrapped(0xffffffff, 0x00000002)
Error: address + size wrapped(0xffffffff, 0x00000004)
Error: address + size wrapped(0xffffffff, 0x00000002)
Info : dropped 'gdb' connection�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

Update:

I have figured out that the problem is not USB Stack dependent, but depends on the generated binary size.

I could debug a project with 10160 byte binary size, but I cannot with 10164 bytes.

#stlink-openocd #openocd
0 REPLIES 0