6 years, 11 months ago.

Cannot debug the mbed application with using System workbench for STM32

I'm trying to debug mbed simple application using "System workbench for STM32" and STM32F446RE.

The simple application code is below.

#include "mbed.h"

DigitalOut myled(LED1);

int main() {
    while(1) {
        myled = 1; // LED is ON
        wait(0.2); // 200 ms
        myled = 0; // LED is OFF
        wait(1.0); // 1 sec
    }
}

When I complile above code with using mbed web site, the application works fine.(LD2 blinking).

However, when I complile above code with using "System workbench for STM32" and run "Debug As" on "System workbench for STM32" menu, the application does NOT work(LD1 blinking infinitely), the debugger stacks in WWDG_IRQHandler(), and it does NOT break in above main() function.

I've already installed the ST-Link/V2 driver during installing "System workbench for STM32" into my PC. But the above trouble occurs.

Could you please give some advise in order to solve my trouble ?

Thanks. Tomohiro

Question relating to:

Affordable and flexible platform to ease prototyping using a STM32F446RET6 microcontroller.

1 Answer

6 years, 11 months ago.

When you say you compile it on system workbench, it requires a lot of steps to make this happen. Did you export from the online compiler or build a project using mbed-cli? Are you using a devboard? The specific board matters and affects some settings like the openocd configuration. The real STLink standalone debugger is V2, while the one on the Nucleo boards is v2.1.

Did you get a Debug build to successfully compile? Check the Debug build settings and make sure optimization is -0g and debug level probably to max -g3. If it is really misbehaving sometimes closing the project and reopening helps or cleaning and refreshing.

WWDG is obviously the windowed watchdog. That you stop in the handler sort of implies it's on? Entirely possible for it to tick before you get to main if it's on. But also it is off by default. So that's weird. Also WWDG is usually disabled in debug mode - there is a setting. There are no other modules in the project that could be doing this? Maybe find the startup assembly file (.s file) and put a breakpoint in there. This is the first bit of code that runs. Then step through all the startup code.

In case this might help, I made keep notes for myself on setting up a new sw4stm32 mbed-os project.

https://gitlab.com/GrahamS/mbed-os-5.4-export-sw4stm32/

You could give Embitz a try as well. Exporter works much better. I ran into a roadblock with the debugger though - something about my usb port driver was not compatible.

Thanks for your answer.

I've exported the project from online compiler, and imported it to system workbench.

I've checked the debug build settings(optimization level is -Og, and debug level is -g3), and debug build was successfully finished.

I've tried again, but the same result appeared(debugger stacks in WWDG_IRQHandler).

As you commented there is a setting to disable WWDG in debug mode, can you please give a procedure ?

posted by Tomohiro Shirane 17 May 2017

I spent some time tracking this down. It is an issue with the default FPU settings from the project export. If the FPU is selected and ABI is soft, there is extra stuff inserted between _start and main(). One of these is a bad instruction causing the CPU to halt. It's not actually a watchdog issue.

Under Properties->C/C++ Build->Settings->MCU Settings Keep the FPU selected but change ABI to softfp. That worked for me. Setting FPU to none and using ABI soft also worked.

posted by Graham S. 17 May 2017