cancel
Showing results for 
Search instead for 
Did you mean: 

Debug broken after loading CubeMX code

Christian Harris
Associate
Posted on May 09, 2018 at 04:18

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?

#cubemx #stlink-openocd
1 ACCEPTED SOLUTION

Accepted Solutions
Nawres GHARBI
ST Employee
Posted on May 16, 2018 at 17:49

Hi

Harris.Christian

‌,

The Debug of STM32F1 is different from the other products as it is disabled by default.

Please enable the debug from SYS in the peripheral tree and all should be OK

View solution in original post

3 REPLIES 3
AvaTar
Lead
Posted on May 09, 2018 at 07:26

To return debugger access, I have to load another application via the mbed OS node drive.

This 'mbed OS node drive' is a second-stage bootloader application, posing as mass storage device, where you can drop applications in.

Then I am able to connect again via openocd/gdb.

I am not sure how the interaction with the debugger works.

And I usually don't care, because the first thing I do with such board is to remove those opaque loaders.

Perhaps some one else here has experience with it, or try the mbed website/forum.

Amel NASRI
ST Employee
Posted on May 15, 2018 at 12:45

Hi

Harris.Christian

‌,

Are you using the last MX version (4.x)?

-Amel

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Nawres GHARBI
ST Employee
Posted on May 16, 2018 at 17:49

Hi

Harris.Christian

‌,

The Debug of STM32F1 is different from the other products as it is disabled by default.

Please enable the debug from SYS in the peripheral tree and all should be OK