AnsweredAssumed Answered

Debug broken after loading CubeMX code

Question asked by Christian Harris on May 9, 2018
Latest reply on May 16, 2018 by Nawres GHARBI

I created a very basic LED toggle project for my nucleo-103rb board using CubeMX that targeted Makefile. I opened the software, selected the chip, set PA5 as GPIO Output and clicked generate code. I did not change any options. [well I did choose to only inlcude used libraries]. After generating the code, I edited the makefile to remove the well known, duplicate source files. I also added the path to my tool chain (gcc-arm-none-eabi-7-2017-q4-major from GNU Arm Embedded). I added 3 lines in the while(1) loop:

 

int i;
for (i = 1; i <= 262143; i++){};
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);

 

Overall, these are very minimal changes to the project generated from CubeMX. I connected to my nucleo-103rb board with openocd/gdb and loaded the elf file. The led indeed starts blinking, but then my debug session goes dead! Disconnecting the power and reconnecting to my PC does not restore my ability to connect to the debugger. To return debugger access, I have to load another application via the mbed OS node drive. Then I am able to connect again via openocd/gdb.

 

Attached are both the CubeMX project along with my own, hacked together project. I am able to load and debug my own project with openocd/gdb, but the project generated by CubeMX seemingly disables debug access.

 

openocd.exe -f interface/stlink.cfg -f target/stm32f1x_stlink.cfg

arm-none-eabi-gdb main.elf

   target remote 127.0.0.1:3333

   monitor reset halt

   load

 

What do I need to do to be able to connect to my board and debug an app generated by CubeMX?

Outcomes