Unable to run/debug on Nucleo STMF401RE with embedded-nucleo_f401re runtime

I am trying to run and debug a simple program on the Nucleo-F401RE. The toolchain is GNAT ARM elf 15.2.1. The runtime is embedded-nucleo_f401re. For flash and debug, I’m using GNAT Studio 26.0 and the following is the Ide configuration in the project file:

package Ide is
  for Program_Host use “localhost:4242”;
  for Communication_Protocol use “remote”;
  for Connection_Tool use “st-util”;
end Ide;

The build and flash on MCU process works, while the execution and debugging not.
When I start the debugger, the program is waiting in _start_rom (), which is correct.

When I run the program, the program execution stops on its own after about ten seconds in the same function.

If I put the following breakpoint, it is never hit.

image

You can see the full alire project here: GitHub - BottCode/porting_blink_f401re.

Is there a problem with the embedded-nucleo_f401re runtime implementation? If I switch to another MCU (light-stm32f429disco), everithing works.

1 Like

You can try to execute program at CPU instructions level and look what happened. Giving the “empty” application main it should be doable.

You can check CPU/MPU registers to find why and probably where application fails.

You can set catch point on exceptions.

PS. Did you enable semihosting in GDB?

You can try to execute program at CPU instructions level and look what happened. Giving the “empty” application main it should be doable.

I have the same problem when I try to execute the assembly instructions.

You can check CPU/MPU registers to find why and probably where application fails.

There’s no any useful information. It looks like the execution never begins.

You can set catch point on exceptions.

Done, but no excpetions detected.

PS. Did you enable semihosting in GDB?

Yes, moreover if I switch to light-stm32f429disco runtime and I flash the related MCU with the same application source code, the debugging works as expected.

In addition, I’m trying to switching to embedded-stm32f4 runtime using the nucleo-f401re board. The execution is stucked is setup_pll function.

If I remember correctly, RCC is not compatible between F401 and F407 (as well as some peripherals). Thus, startup code is not compatible too.

I suggest to try to use light runtime to check setup. Or try following example, it known to work on F401/F411 on boards with HSE crystall.

Another way is to run

monitor reset halt
si
info register

and check stack pointer/command pointer registers

When I run the program, the program execution stops on its own after about ten seconds in the same function.

10s could be the timeout of a watchdog.

If I put the following breakpoint, it is never hit.

You try to put a breakpoint on a line which does nothing. It is more than likely this line has been optimized out by the compiler, so the breakpoint is not set.

1 Like