fix(boot): update examples

This commit is contained in:
Badr Bouslikhin 2024-02-07 12:50:48 +01:00
parent 4a72f946e4
commit cfc3e96633
No known key found for this signature in database
GPG Key ID: 3B081233DD4DE99B
18 changed files with 24 additions and 44 deletions

View File

@ -50,7 +50,7 @@ async fn main(_spawner: Spawner) {
let nvmc = Nvmc::new(p.NVMC); let nvmc = Nvmc::new(p.NVMC);
let nvmc = Mutex::new(BlockingAsync::new(nvmc)); let nvmc = Mutex::new(BlockingAsync::new(nvmc));
let config = FirmwareUpdaterConfig::from_linkerfile(&nvmc); let config = FirmwareUpdaterConfig::from_linkerfile(&nvmc, &nvmc);
let mut magic = [0; 4]; let mut magic = [0; 4];
let mut updater = FirmwareUpdater::new(config, &mut magic); let mut updater = FirmwareUpdater::new(config, &mut magic);
loop { loop {

View File

@ -36,7 +36,7 @@ async fn main(_s: Spawner) {
let flash = Flash::<_, _, FLASH_SIZE>::new_blocking(p.FLASH); let flash = Flash::<_, _, FLASH_SIZE>::new_blocking(p.FLASH);
let flash = Mutex::new(RefCell::new(flash)); let flash = Mutex::new(RefCell::new(flash));
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash, &flash);
let mut aligned = AlignedBuffer([0; 1]); let mut aligned = AlignedBuffer([0; 1]);
let mut updater = BlockingFirmwareUpdater::new(config, &mut aligned.0); let mut updater = BlockingFirmwareUpdater::new(config, &mut aligned.0);

View File

@ -3,8 +3,8 @@ MEMORY
/* NOTE 1 K = 1 KiBi = 1024 bytes */ /* NOTE 1 K = 1 KiBi = 1024 bytes */
BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K
BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
FLASH : ORIGIN = 0x08008000, LENGTH = 32K FLASH : ORIGIN = 0x08008000, LENGTH = 64K
DFU : ORIGIN = 0x08010000, LENGTH = 36K DFU : ORIGIN = 0x08018000, LENGTH = 66K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
} }

View File

@ -28,7 +28,7 @@ async fn main(_spawner: Spawner) {
let mut led = Output::new(p.PA5, Level::Low, Speed::Low); let mut led = Output::new(p.PA5, Level::Low, Speed::Low);
led.set_high(); led.set_high();
let config = FirmwareUpdaterConfig::from_linkerfile(&flash); let config = FirmwareUpdaterConfig::from_linkerfile(&flash, &flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]); let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = FirmwareUpdater::new(config, &mut magic.0); let mut updater = FirmwareUpdater::new(config, &mut magic.0);
button.wait_for_falling_edge().await; button.wait_for_falling_edge().await;

View File

@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) {
let mut led = Output::new(p.PB7, Level::Low, Speed::Low); let mut led = Output::new(p.PB7, Level::Low, Speed::Low);
led.set_high(); led.set_high();
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash, &flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]); let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = BlockingFirmwareUpdater::new(config, &mut magic.0); let mut updater = BlockingFirmwareUpdater::new(config, &mut magic.0);
let writer = updater.prepare_update().unwrap(); let writer = updater.prepare_update().unwrap();

View File

@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) {
let mut led = Output::new(p.PB14, Level::Low, Speed::Low); let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
led.set_high(); led.set_high();
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash, &flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]); let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = BlockingFirmwareUpdater::new(config, &mut magic.0); let mut updater = BlockingFirmwareUpdater::new(config, &mut magic.0);
let writer = updater.prepare_update().unwrap(); let writer = updater.prepare_update().unwrap();

View File

@ -3,8 +3,8 @@ MEMORY
/* NOTE 1 K = 1 KiBi = 1024 bytes */ /* NOTE 1 K = 1 KiBi = 1024 bytes */
BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K
BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
FLASH : ORIGIN = 0x08008000, LENGTH = 32K FLASH : ORIGIN = 0x08008000, LENGTH = 64K
DFU : ORIGIN = 0x08010000, LENGTH = 36K DFU : ORIGIN = 0x08018000, LENGTH = 66K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K
} }

View File

@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) {
led.set_high(); led.set_high();
let config = FirmwareUpdaterConfig::from_linkerfile(&flash); let config = FirmwareUpdaterConfig::from_linkerfile(&flash, &flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]); let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = FirmwareUpdater::new(config, &mut magic.0); let mut updater = FirmwareUpdater::new(config, &mut magic.0);
button.wait_for_falling_edge().await; button.wait_for_falling_edge().await;

View File

@ -3,8 +3,8 @@ MEMORY
/* NOTE 1 K = 1 KiBi = 1024 bytes */ /* NOTE 1 K = 1 KiBi = 1024 bytes */
BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K
BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
FLASH : ORIGIN = 0x08008000, LENGTH = 32K FLASH : ORIGIN = 0x08008000, LENGTH = 46K
DFU : ORIGIN = 0x08010000, LENGTH = 36K DFU : ORIGIN = 0x08013800, LENGTH = 54K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 16K
} }

View File

@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) {
led.set_high(); led.set_high();
let config = FirmwareUpdaterConfig::from_linkerfile(&flash); let config = FirmwareUpdaterConfig::from_linkerfile(&flash, &flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]); let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = FirmwareUpdater::new(config, &mut magic.0); let mut updater = FirmwareUpdater::new(config, &mut magic.0);
button.wait_for_falling_edge().await; button.wait_for_falling_edge().await;

View File

@ -3,8 +3,8 @@ MEMORY
/* NOTE 1 K = 1 KiBi = 1024 bytes */ /* NOTE 1 K = 1 KiBi = 1024 bytes */
BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K
BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
FLASH : ORIGIN = 0x08008000, LENGTH = 32K FLASH : ORIGIN = 0x08008000, LENGTH = 64K
DFU : ORIGIN = 0x08010000, LENGTH = 36K DFU : ORIGIN = 0x08018000, LENGTH = 68K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
} }

View File

@ -28,7 +28,7 @@ async fn main(_spawner: Spawner) {
let mut led = Output::new(p.PB14, Level::Low, Speed::Low); let mut led = Output::new(p.PB14, Level::Low, Speed::Low);
led.set_high(); led.set_high();
let config = FirmwareUpdaterConfig::from_linkerfile(&flash); let config = FirmwareUpdaterConfig::from_linkerfile(&flash, &flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]); let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = FirmwareUpdater::new(config, &mut magic.0); let mut updater = FirmwareUpdater::new(config, &mut magic.0);
button.wait_for_falling_edge().await; button.wait_for_falling_edge().await;

View File

@ -1,29 +1,9 @@
# Examples using bootloader # Examples using bootloader
Example for STM32WL demonstrating the bootloader. The example consists of application binaries, 'a' Example for STM32WB demonstrating the USB DFU application.
which allows you to press a button to start the DFU process, and 'b' which is the updated
application.
## Prerequisites
* `cargo-binutils`
* `cargo-flash`
* `embassy-boot-stm32`
## Usage ## Usage
``` ```
# Flash bootloader cargo flash --release --chip STM32WB55RGVx
cargo flash --manifest-path ../../bootloader/stm32/Cargo.toml --release --features embassy-stm32/stm32wl55jc-cm4 --chip STM32WLE5JCIx
# Build 'b'
cargo build --release --bin b
# Generate binary for 'b'
cargo objcopy --release --bin b -- -O binary b.bin
```
# Flash `a` (which includes b.bin)
```
cargo flash --release --bin a --chip STM32WLE5JCIx
``` ```

View File

@ -30,7 +30,7 @@ async fn main(_spawner: Spawner) {
let flash = Flash::new_blocking(p.FLASH); let flash = Flash::new_blocking(p.FLASH);
let flash = Mutex::new(RefCell::new(flash)); let flash = Mutex::new(RefCell::new(flash));
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash); let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&flash, &flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]); let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut firmware_state = BlockingFirmwareState::from_config(config, &mut magic.0); let mut firmware_state = BlockingFirmwareState::from_config(config, &mut magic.0);
firmware_state.mark_booted().expect("Failed to mark booted"); firmware_state.mark_booted().expect("Failed to mark booted");

View File

@ -3,8 +3,8 @@ MEMORY
/* NOTE 1 K = 1 KiBi = 1024 bytes */ /* NOTE 1 K = 1 KiBi = 1024 bytes */
BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K BOOTLOADER : ORIGIN = 0x08000000, LENGTH = 24K
BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
FLASH : ORIGIN = 0x08008000, LENGTH = 32K FLASH : ORIGIN = 0x08008000, LENGTH = 64K
DFU : ORIGIN = 0x08010000, LENGTH = 36K DFU : ORIGIN = 0x08018000, LENGTH = 68K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
} }

View File

@ -28,7 +28,7 @@ async fn main(_spawner: Spawner) {
let mut led = Output::new(p.PB9, Level::Low, Speed::Low); let mut led = Output::new(p.PB9, Level::Low, Speed::Low);
led.set_high(); led.set_high();
let config = FirmwareUpdaterConfig::from_linkerfile(&flash); let config = FirmwareUpdaterConfig::from_linkerfile(&flash, &flash);
let mut magic = AlignedBuffer([0; WRITE_SIZE]); let mut magic = AlignedBuffer([0; WRITE_SIZE]);
let mut updater = FirmwareUpdater::new(config, &mut magic.0); let mut updater = FirmwareUpdater::new(config, &mut magic.0);
button.wait_for_falling_edge().await; button.wait_for_falling_edge().await;

View File

@ -31,7 +31,7 @@ fn main() -> ! {
let flash = WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config); let flash = WatchdogFlash::start(Nvmc::new(p.NVMC), p.WDT, wdt_config);
let flash = Mutex::new(RefCell::new(flash)); let flash = Mutex::new(RefCell::new(flash));
let config = BootLoaderConfig::from_linkerfile_blocking(&flash); let config = BootLoaderConfig::from_linkerfile_blocking(&flash, &flash, &flash);
let active_offset = config.active.offset(); let active_offset = config.active.offset();
let bl: BootLoader = BootLoader::prepare(config); let bl: BootLoader = BootLoader::prepare(config);

View File

@ -27,7 +27,7 @@ fn main() -> ! {
let flash = WatchdogFlash::<FLASH_SIZE>::start(p.FLASH, p.WATCHDOG, Duration::from_secs(8)); let flash = WatchdogFlash::<FLASH_SIZE>::start(p.FLASH, p.WATCHDOG, Duration::from_secs(8));
let flash = Mutex::new(RefCell::new(flash)); let flash = Mutex::new(RefCell::new(flash));
let config = BootLoaderConfig::from_linkerfile_blocking(&flash); let config = BootLoaderConfig::from_linkerfile_blocking(&flash, &flash, &flash);
let active_offset = config.active.offset(); let active_offset = config.active.offset();
let bl: BootLoader = BootLoader::prepare(config); let bl: BootLoader = BootLoader::prepare(config);