Missing semihosting printouts after upgrade from v0.3.3 to v0.5.0
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- rust
- Domain
- embedded-iot
Research direction
Start with examples/binds.rs and the cortex-m-semihosting v0.5.0 upgrade described in PR#680. Reproduce the release build with cargo run for the thumbv7m-none-eabi target under QEMU, then compare objdumps using the command in the report. Done means the expected second printout is received before QEMU exits without relying on moving debug::exit into the loop.
Written by the indexing model from the issue text.
Description
In cortex-m-rtic CI cortex-m-semihosting is used for printouts and QEMU control.
As part of this PR#680 semihosting got bumped to latest v0.5.0, and after adopting code to match the removed error handling, CI still failed with the following:
👟 cargo run --example binds --target thumbv7m-none-eabi --features test-critical-section --release
Compiling cortex-m-rtic v1.1.3 (/home/henrik/dev/rust/rtic/cortex-m-rtic)
Finished release [optimized] target(s) in 0.17s
Running `qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic -semihosting-config enable=on,target=native -kernel target/thumbv7m-none-eabi/release/examples/binds`
Timer with period zero, disabling
init
foo called 1 time
idle
Error: Differing output in files.
Expected:
init
foo called 1 time
idle
foo called 2 times
Got:
init
foo called 1 time
idle
which given that the idle task in examples/binds.rs consists of:
#[idle]
fn idle(_: idle::Context) -> ! {
hprintln!("idle");
rtic::pend(Interrupt::UART0);
debug::exit(debug::EXIT_SUCCESS); // Exit QEMU simulator
loop {
cortex_m::asm::nop();
}
}
suggests that the rtic::pend(...) in the idle task did not get to run.
Modifying the code by placing the debug::exit(...) after the NOP inside the loop,
then all expected printouts gets received by the host.
Which modifies the hypothesis to "printout did not reach host before QEMU exited"
See this commit for the "fix" to the CI failures: 9764121c
Focusing on the binds example, this is an objdump diff together with the diff, however, not built with --release:

Another more complete picture, all built with release, the splits starting from the left:
- cortex-m-semihosting v0.3.3 idle task
- v0.5 without the "fix" idle task
- v0.5 with the "fix" idle task

Generating the objdumps with
cargo objdump --example binds --target thumbv7m-none-eabi --release -- -d --no-show-raw-insn --print-imm-hex
Curious to hear if this is something seen before, or if a possible fix would be to always throw in a NOP as part of the syscall when debug::exit-iting.
All tests were run with latest stable rustc 1.66.1 (90743e729 2023-01-10)
I have not tried different versions of QEMU, but it could be something on that end too...
- Dominant language
- Rust
- Stars
- 1k
- Forks
- 201
- Avg merge
- 1h 8m
- Merged PRs (30d)
- 2
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from rust-embedded/cortex-m
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
rust-embedded/cortex-m#651 · 5 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
rust-embedded/cortex-m#637 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rust-embedded/cortex-m#511 · 2 comments ·
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
rust-embedded/cortex-m#695 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 52/100
rust-embedded/cortex-m#694 · 1 comment ·
All issues in rust-embedded/cortex-m
Similar issues
-
bug user-priority/P2
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rescript-lang/rescript#8765 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
nautechsystems/nautilus_trader#5287 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
farion1231/cc-switch#8072 ·
Maintainers usually reply within 1 day
-
Python 3.15 supportPossibly taken @amnesiaof claimed this today. OpenL: python L: python:uv
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
dependabot/dependabot-core#16524 · 1 comment ·
Maintainers usually reply within 1 day