Skip to content

Commit

Permalink
docs: add an faq on bootloader failures
Browse files Browse the repository at this point in the history
  • Loading branch information
badrbouslikhin committed Dec 5, 2024
1 parent a5ab192 commit 75a21e5
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions docs/pages/faq.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -385,3 +385,49 @@ async fn idle() {
loop { embassy_futures::yield_now().await; }
}
----

== Why is my bootloader restarting in loop?

== Troubleshooting Bootloader Restart Loops

If your bootloader restarts in a loop, there could be multiple reasons. Here are some things to check:

=== Validate the `memory.x` File
The bootloader performs critical checks when creating partitions using the addresses defined in `memory.x`. Ensure the following assertions hold true:

[source,rust]
----
const {
core::assert!(Self::PAGE_SIZE % ACTIVE::WRITE_SIZE as u32 == 0);
core::assert!(Self::PAGE_SIZE % ACTIVE::ERASE_SIZE as u32 == 0);
core::assert!(Self::PAGE_SIZE % DFU::WRITE_SIZE as u32 == 0);
core::assert!(Self::PAGE_SIZE % DFU::ERASE_SIZE as u32 == 0);
}
// Ensure enough progress pages to store copy progress
assert_eq!(0, Self::PAGE_SIZE % aligned_buf.len() as u32);
assert!(aligned_buf.len() >= STATE::WRITE_SIZE);
assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE);
assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE);
----

If any of these assertions fail, the bootloader will likely restart in a loop. This failure might not log any messages (e.g., when using `defmt`). Confirm that your `memory.x` file and flash memory align with these requirements.

=== Handling Panic Logging
Some panic errors might log messages, but certain microcontrollers reset before the message is fully printed. To ensure panic messages are logged, add a delay using no-operation (NOP) instructions before the reset:

[source,rust]
----
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
for _ in 0..10_000_000 {
cortex_m::asm::nop();
}
cortex_m::asm::udf();
}
----

=== Feed the watchdog


Some `embassy-boot` implementations (like `embassy-boot-nrf` and `embassy-boot-rp`) rely on a watchdog timer to detect application failure. The bootloader will restart if your application code does not properly feed the watchdog timer. Make sure to feed it correctly.

0 comments on commit 75a21e5

Please sign in to comment.