Skip to content

Commit a2f9599

Browse files
authored
Merge pull request #6 from rust-embedded/semihosting-faq
Explain hanging problems with semihosting
2 parents b7c71eb + 6eaaa41 commit a2f9599

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

faq.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,33 @@ wrote 0 bytes from file target/thumbv7em-none-eabihf/debug/examples/hello in 0.0
297297
If you see such a message you will need to check your linker configuration, usually in
298298
`memory.x` for the correct addresses (and ideally also sizes). Please also note that
299299
after a change you will need to `cargo clean` and rebuild to use the changed addresses.
300+
301+
# My program just halts without connected debugger. What am I doing wrong?
302+
303+
## Short answer
304+
305+
If you're using `semihosting`, switch to a different input / output mechanism.
306+
307+
## Long answer
308+
309+
An embedded MCU will typically stop working if exceptions (which is the MCUs way
310+
of signalling special or abnormal events) occur which are not handled and cleared,
311+
either by an exception handler or a connected debugger. The latter case is especially
312+
interesting because there's a method of interacting with a connected computer
313+
dubbed `semihosting` which will work iff a debugger is properly connected
314+
and debugging software running and correctly set up. This method uses special
315+
processor instructions (e.g. a service or breakpoint call) to alert the connected
316+
system about input and/or output requests from the device. If no debugger is
317+
available to handle such a situation, the system either wait indefinitely or
318+
generate an even stronger exception which can only be cleared by a reset.
319+
320+
There're two common scenarios which cause such a lockup unintentionally:
321+
- The use of semihosting as input / output channel, e.g. via `cortex-m-semihosting` crate
322+
- A `panic` in the program with the `panic-semihosting` crate in use, however the
323+
occurence of a `panic` means that the program is defunct anyway
324+
325+
Please note that examples may make use of the `semihosting` concept but this
326+
should not be used in production setups due to the lack of connected debugger and
327+
a host running appropriate debugging software. The use of a serial interface is
328+
often a better choice. However if you just would like to see your example running
329+
please make sure your setup is ready to deal with the `semihosting` requirements.

0 commit comments

Comments
 (0)