0
votes

I'm trying to run a Rust Hello World on my STM32F401xB. I have a working C program for comparison (different functionality, but it verifies the flashing toolchain) and use the same openocd commands to flash both programs onto the controller.

When I flash the C program, I get:

...
** Verified OK **
adapter speed: 2002 kHz

When I flash the Rust program, I get the following:

...
** Verified OK **
adapter speed: 2002 kHz
target halted due to breakpoint, current mode: Thread
xPSR: 0x21000000 pc: 0x08002f42 msp: 0x2000ffa0

note the two extra lines. When I connect using gdb and continue, I get the Hello, World! printout through semihosting, so the program does in principle execute fine - it just pauses before main even though I have not set a breakpoint. My procedure for both binaries is the same. What could be going on? Why are the two binaries behaving differently?


  • I used svd2rust to create a stm32f40x crate from the official stm32f401.svd
  • I used the cortex-m-quickstart and basically the hello.rs example - configuring memory.x and adding the dependency to stm32f40x of course
  • there are no special configurations (that I would have identified) in my project, and the same behavior happens for debug and release builds.
1
Show the disassembly of the code at the breakpoint. It is possible that the code contains a direct beakpoint instruction in a conditional of the form if debugger attached then break Also this may be relevant - specifically the part about changing the start-on-startup symbol from main to helloworld::mainClifford
The cortex-m-quickstart uses #![no_main] and entry!(func); to define the entry function into the binary, so I don't think the problem is with a symbol name. But I'm sure you're right that I'll see a breakpoint in the disassembly; probably from semihosting as Turbo J wrote. Thanks!Silly Freak

1 Answers

2
votes

I get the Hello, World! printout through semihosting

Check the semihosting documentation. Last time I checked, semihosting works using breakpoints on several ARM targets.

Your C program probably does not use semihosting at all, so no breakpoints are used.