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 astm32f40x
crate from the officialstm32f401.svd
- I used the
cortex-m-quickstart
and basically thehello.rs
example - configuringmemory.x
and adding the dependency tostm32f40x
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.
if debugger attached then break
Also this may be relevant - specifically the part about changing the start-on-startup symbol frommain
tohelloworld::main
– Cliffordcortex-m-quickstart
uses#![no_main]
andentry!(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