aboutsummaryrefslogtreecommitdiff
path: root/embassy-boot
diff options
context:
space:
mode:
authorKaitlyn Kenwell <[email protected]>2023-12-13 14:42:14 -0500
committerKaitlyn Kenwell <[email protected]>2023-12-13 14:42:14 -0500
commit2afec225e3eddb5738bbc995baf04e13dd1df9e7 (patch)
tree7a4490c42f63480ab7485227ac72e44b15152451 /embassy-boot
parent976a7ae22aa222213861c12d515115aac87bd2e0 (diff)
parent1279a1b7f6bc9c965f8d8da3a9c7449195b6a663 (diff)
Merge branch 'main' into feature/embassy-usb-dfu
Diffstat (limited to 'embassy-boot')
-rw-r--r--embassy-boot/boot/README.md19
-rw-r--r--embassy-boot/boot/src/boot_loader.rs2
2 files changed, 21 insertions, 0 deletions
diff --git a/embassy-boot/boot/README.md b/embassy-boot/boot/README.md
index 07755bc6c..3fc81f24b 100644
--- a/embassy-boot/boot/README.md
+++ b/embassy-boot/boot/README.md
@@ -8,6 +8,24 @@ The bootloader can be used either as a library or be flashed directly with the d
8 8
9By design, the bootloader does not provide any network capabilities. Networking capabilities for fetching new firmware can be provided by the user application, using the bootloader as a library for updating the firmware, or by using the bootloader as a library and adding this capability yourself. 9By design, the bootloader does not provide any network capabilities. Networking capabilities for fetching new firmware can be provided by the user application, using the bootloader as a library for updating the firmware, or by using the bootloader as a library and adding this capability yourself.
10 10
11## Overview
12
13The bootloader divides the storage into 4 main partitions, configurable when creating the bootloader instance or via linker scripts:
14
15* BOOTLOADER - Where the bootloader is placed. The bootloader itself consumes about 8kB of flash, but if you need to debug it and have space available, increasing this to 24kB will allow you to run the bootloader with probe-rs.
16* ACTIVE - Where the main application is placed. The bootloader will attempt to load the application at the start of this partition. The minimum size required for this partition is the size of your application.
17* DFU - Where the application-to-be-swapped is placed. This partition is written to by the application. This partition must be at least 1 page bigger than the ACTIVE partition.
18* BOOTLOADER STATE - Where the bootloader stores the current state describing if the active and dfu partitions need to be swapped.
19
20For any partition, the following preconditions are required:
21
22* Partitions must be aligned on the page size.
23* Partitions must be a multiple of the page size.
24
25The linker scripts for the application and bootloader look similar, but the FLASH region must point to the BOOTLOADER partition for the bootloader, and the ACTIVE partition for the application.
26
27For more details on the bootloader, see [the documentation](https://embassy.dev/book/dev/bootloader.html).
28
11## Hardware support 29## Hardware support
12 30
13The bootloader supports different hardware in separate crates: 31The bootloader supports different hardware in separate crates:
@@ -16,6 +34,7 @@ The bootloader supports different hardware in separate crates:
16* `embassy-boot-rp` - for the RP2040 microcontrollers. 34* `embassy-boot-rp` - for the RP2040 microcontrollers.
17* `embassy-boot-stm32` - for the STM32 microcontrollers. 35* `embassy-boot-stm32` - for the STM32 microcontrollers.
18 36
37
19## Minimum supported Rust version (MSRV) 38## Minimum supported Rust version (MSRV)
20 39
21`embassy-boot` is guaranteed to compile on the latest stable Rust version at the time of release. It might compile with older versions but that may change in any new patch release. 40`embassy-boot` is guaranteed to compile on the latest stable Rust version at the time of release. It might compile with older versions but that may change in any new patch release.
diff --git a/embassy-boot/boot/src/boot_loader.rs b/embassy-boot/boot/src/boot_loader.rs
index c0deca22b..340962a7a 100644
--- a/embassy-boot/boot/src/boot_loader.rs
+++ b/embassy-boot/boot/src/boot_loader.rs
@@ -224,6 +224,7 @@ impl<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash> BootLoader<ACTIVE, DFU, S
224 assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE); 224 assert_eq!(0, aligned_buf.len() % ACTIVE::WRITE_SIZE);
225 assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE); 225 assert_eq!(0, aligned_buf.len() % DFU::WRITE_SIZE);
226 226
227 // Ensure our partitions are able to handle boot operations
227 assert_partitions(&self.active, &self.dfu, &self.state, Self::PAGE_SIZE); 228 assert_partitions(&self.active, &self.dfu, &self.state, Self::PAGE_SIZE);
228 229
229 // Copy contents from partition N to active 230 // Copy contents from partition N to active
@@ -400,6 +401,7 @@ fn assert_partitions<ACTIVE: NorFlash, DFU: NorFlash, STATE: NorFlash>(
400) { 401) {
401 assert_eq!(active.capacity() as u32 % page_size, 0); 402 assert_eq!(active.capacity() as u32 % page_size, 0);
402 assert_eq!(dfu.capacity() as u32 % page_size, 0); 403 assert_eq!(dfu.capacity() as u32 % page_size, 0);
404 // DFU partition has to be bigger than ACTIVE partition to handle swap algorithm
403 assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size); 405 assert!(dfu.capacity() as u32 - active.capacity() as u32 >= page_size);
404 assert!(2 + 2 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32); 406 assert!(2 + 2 * (active.capacity() as u32 / page_size) <= state.capacity() as u32 / STATE::WRITE_SIZE as u32);
405} 407}