-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Damaging an update firmware makes rustboot hang at boot #80
Comments
When rust boot hangs, execution seems to hit the following rustBoot/rustBoot/src/image/image.rs Line 572 in 8437fd2
|
@imrank03 - would you be able to look into this? |
Hi @nihalpasham, since the issue seems to be functioning as expected, I didn't look into it further. |
@lionelains - I believe we are unable to recreate the above scenario. Can you help in recreating this bug? |
Closing. feel free re-open if needed |
I am going to give it a try again on my board. I'll keep you posted. |
I did reproduce on 8437fd2 and also on d4394d3 Same thing after a
which leads to:
I use the nightly toolchain to compile rustBoot ( In all these configurations, my board boots the green firmware, but never upgrades to the red (manually corrupted) firmware (as expected). |
@imrank03, on which board did you try to run the test? on a NUCLEO-H723ZG? |
|
@lionelains, I was able to reproduce the issue, and it seems the problem is related to the boot-loader panicking. Here's the output from my command: ❯ probe-rs run --chip STM32H723ZGTx ./boards/target/thumbv7em-none-eabihf/release/stm32h723
Erasing ✔ [00:00:01] [##############################################] 128.00 KiB/128.00 KiB @ 67.63 KiB/s (eta 0s)
Programming ✔ [00:00:01] [###############################################] 52.00 KiB/52.00 KiB @ 51.06 KiB/s (eta 0s)
Finished in 2.922s
Frame 0: __bkpt @ 0x0800c3b2 inline
./asm/lib.rs:48:1
Frame 1: __bkpt @ 0x000000000800c3b2
./asm/lib.rs:51:17
Frame 2: bkpt @ 0x0800c38e inline
/Users/IKL2KOR/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cortex-m-0.7.7/src/call_asm.rs:19:21
Frame 3: panic @ 0x000000000800c38a
/Users/IKL2KOR/Imran_Bosch/rust_dev/rustBoot/boards/bootloaders/stm32h723/src/main.rs:21:9
Frame 4: panic_bounds_check @ 0x08000a82
/rustc/798fb83f7d24e31b16acca113496f39ff168c143/library/core/src/panicking.rs:271:1 The CPU halts due to a panic in the bootloader code at |
Hi @imrank03 , yes, the panic implementation is indeed in main.rs. rustBoot/rustBoot/src/image/image.rs Line 572 in 8437fd2
Changing it from a panic() into a returned Result<> would allow the caller to handle the case (in this specific scenario, that would probably mean ignore and continue booting from the other slot).
I will see if I can propose a refactor of the code following the strategy described above, but I am not going to be able to work on this during at least the coming two weeks. |
Hi @lionelains , thanks for the update and for pointing out the root cause in I understand you won’t be available for the next two weeks, so I’ll look into it and see if I can start implementing the changes in the meantime. Once you’re back, feel free to jump in as well. Let me know if there's anything else I should consider while working on this! |
Hello @imrank03, did you make any progress on this? |
Hi @lionelains , I haven’t had the chance to look into this yet, unfortunately. If it’s not too much trouble, it would be great if you could take a look and create a PR. |
I am preparing a PR here. |
Sounds great! I’ll clone the PR, test it, and share my feedback. I have a tech summit this week, so I’ll aim to work on it over the weekend. |
When manually changing the firmware payload of a signed firmware, rustboot seems to upgrade flash to it but subsequent boots never process correctly.
Found in 8437fd2
Scenario
Build the sample boot demo binaries from rustboot project:
Before programming these 3 firmwares, we modify at least one byte in the 3rd binary (the upgrade firmware), and program the 3 firmwares on the board.
Expected
green blinking firmware boots and refuses to program the red firmware
at all subsequent boots, only the green firmware boots
Observed
green blinking firmware boots
the board reboots
rustboot does not launch neither the red nor the green firmware and remains stuck in the boot phase
resetting the board does not revert to the green firmware either, possibly resulting in a bricked device
Steps to reproduce on NUCLEO-H723ZG
Run the normal demo:
Watch the green firmware blink, then red firmware
Alter the red firmware (overwrite 4 bytes at offset 1024) :
Program again the two application firmwares:
Program rustboot and run the demo.
Observe the board first running the green firmware, then reboot and hang while in rustboot.
The text was updated successfully, but these errors were encountered: