From da61611f8f57410a87106961efd24d80e6a8f63e Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Tue, 26 Apr 2022 18:33:09 +0200 Subject: Add bootloader to CI --- examples/boot/nrf/.cargo/config.toml | 6 ++++++ examples/boot/nrf/Cargo.toml | 2 +- examples/boot/nrf/README.md | 8 ++++---- examples/boot/stm32l0/Cargo.toml | 2 +- examples/boot/stm32l0/README.md | 2 +- examples/boot/stm32l0/memory.x | 8 ++++---- examples/boot/stm32l1/Cargo.toml | 2 +- examples/boot/stm32l1/README.md | 2 +- examples/boot/stm32l1/memory.x | 8 ++++---- examples/boot/stm32l4/Cargo.toml | 2 +- examples/boot/stm32l4/README.md | 2 +- examples/boot/stm32l4/memory.x | 10 +++++----- examples/boot/stm32wl/Cargo.toml | 2 +- examples/boot/stm32wl/README.md | 2 +- examples/boot/stm32wl/memory.x | 8 ++++---- examples/boot/stm32wl/src/bin/a.rs | 8 +++++--- 16 files changed, 41 insertions(+), 33 deletions(-) create mode 100644 examples/boot/nrf/.cargo/config.toml (limited to 'examples/boot') diff --git a/examples/boot/nrf/.cargo/config.toml b/examples/boot/nrf/.cargo/config.toml new file mode 100644 index 000000000..c75b5c539 --- /dev/null +++ b/examples/boot/nrf/.cargo/config.toml @@ -0,0 +1,6 @@ +[target.'cfg(all(target_arch = "arm", target_os = "none"))'] +# replace nRF82840_xxAA with your chip as listed in `probe-run --list-chips` +runner = "probe-run --chip nRF52840_xxAA" + +[build] +target = "thumbv7em-none-eabi" diff --git a/examples/boot/nrf/Cargo.toml b/examples/boot/nrf/Cargo.toml index 0a5bb8f9d..da8333b7c 100644 --- a/examples/boot/nrf/Cargo.toml +++ b/examples/boot/nrf/Cargo.toml @@ -6,7 +6,7 @@ version = "0.1.0" [dependencies] embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } -embassy-nrf = { version = "0.1.0", path = "../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly"] } +embassy-nrf = { version = "0.1.0", path = "../../../embassy-nrf", features = ["time-driver-rtc1", "gpiote", "nightly", "nrf52840"] } embassy-boot-nrf = { version = "0.1.0", path = "../../../embassy-boot/nrf" } embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } diff --git a/examples/boot/nrf/README.md b/examples/boot/nrf/README.md index b97513a9d..453df7f31 100644 --- a/examples/boot/nrf/README.md +++ b/examples/boot/nrf/README.md @@ -17,15 +17,15 @@ application. ``` # Flash bootloader -cargo flash --manifest-path ../../embassy-boot/nrf/Cargo.toml --release --features embassy-nrf/nrf52840 --chip nRF52840_xxAA +cargo flash --manifest-path ../../../embassy-boot/nrf/Cargo.toml --features embassy-nrf/nrf52840 --release --chip nRF52840_xxAA # Build 'b' -cargo build --release --features embassy-nrf/nrf52840 --bin b +cargo build --release --bin b # Generate binary for 'b' -cargo objcopy --release --features embassy-nrf/nrf52840 --bin b -- -O binary b.bin +cargo objcopy --release --bin b -- -O binary b.bin ``` # Flash `a` (which includes b.bin) ``` -cargo flash --release --features embassy-nrf/nrf52840 --bin a --chip nRF52840_xxAA +cargo flash --release --bin a --chip nRF52840_xxAA ``` diff --git a/examples/boot/stm32l0/Cargo.toml b/examples/boot/stm32l0/Cargo.toml index 2e093d771..5cb1add5b 100644 --- a/examples/boot/stm32l0/Cargo.toml +++ b/examples/boot/stm32l0/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" [dependencies] embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l072cz", "time-driver-any", "exti", "memory-x"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32", features = ["flash-128", "invert-erase", "thumbv6"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32", features = ["thumbv6"] } embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/stm32l0/README.md b/examples/boot/stm32l0/README.md index 9c8660821..b498fdc2d 100644 --- a/examples/boot/stm32l0/README.md +++ b/examples/boot/stm32l0/README.md @@ -15,7 +15,7 @@ application. ``` # Flash bootloader -cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l072cz,flash-128,invert-erase,thumbv6 --chip STM32L072CZTx +cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l072cz,thumbv6 --chip STM32L072CZTx # Build 'b' cargo build --release --bin b # Generate binary for 'b' diff --git a/examples/boot/stm32l0/memory.x b/examples/boot/stm32l0/memory.x index fd5bf1a5d..d0d2bd7bb 100644 --- a/examples/boot/stm32l0/memory.x +++ b/examples/boot/stm32l0/memory.x @@ -8,8 +8,8 @@ MEMORY RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 16K } -__bootloader_state_start = ORIGIN(BOOTLOADER_STATE); -__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE); +__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); +__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); -__bootloader_dfu_start = ORIGIN(DFU); -__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU); +__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER); +__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER); diff --git a/examples/boot/stm32l1/Cargo.toml b/examples/boot/stm32l1/Cargo.toml index ec396bef2..9f97462f6 100644 --- a/examples/boot/stm32l1/Cargo.toml +++ b/examples/boot/stm32l1/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" [dependencies] embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l151cb-a", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32", features = ["flash-256", "invert-erase"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/stm32l1/README.md b/examples/boot/stm32l1/README.md index 1a9e85a75..0d4accbff 100644 --- a/examples/boot/stm32l1/README.md +++ b/examples/boot/stm32l1/README.md @@ -15,7 +15,7 @@ application. ``` # Flash bootloader -cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l151cb-a,flash-256,invert-erase --chip STM32L151CBxxA +cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l151cb-a --chip STM32L151CBxxA # Build 'b' cargo build --release --bin b # Generate binary for 'b' diff --git a/examples/boot/stm32l1/memory.x b/examples/boot/stm32l1/memory.x index fd5bf1a5d..d0d2bd7bb 100644 --- a/examples/boot/stm32l1/memory.x +++ b/examples/boot/stm32l1/memory.x @@ -8,8 +8,8 @@ MEMORY RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 16K } -__bootloader_state_start = ORIGIN(BOOTLOADER_STATE); -__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE); +__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); +__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); -__bootloader_dfu_start = ORIGIN(DFU); -__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU); +__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER); +__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER); diff --git a/examples/boot/stm32l4/Cargo.toml b/examples/boot/stm32l4/Cargo.toml index 394f26a12..53424a666 100644 --- a/examples/boot/stm32l4/Cargo.toml +++ b/examples/boot/stm32l4/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" [dependencies] embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32l475vg", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32", features = ["flash-2k"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/stm32l4/README.md b/examples/boot/stm32l4/README.md index 09e09d6ef..8966c2fb5 100644 --- a/examples/boot/stm32l4/README.md +++ b/examples/boot/stm32l4/README.md @@ -15,7 +15,7 @@ application. ``` # Flash bootloader -cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l475vg,flash-2k --chip STM32L475VG +cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l475vg --chip STM32L475VG # Build 'b' cargo build --release --bin b # Generate binary for 'b' diff --git a/examples/boot/stm32l4/memory.x b/examples/boot/stm32l4/memory.x index fd5bf1a5d..14b2a2c9f 100644 --- a/examples/boot/stm32l4/memory.x +++ b/examples/boot/stm32l4/memory.x @@ -5,11 +5,11 @@ MEMORY BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K FLASH : ORIGIN = 0x08008000, LENGTH = 32K DFU : ORIGIN = 0x08010000, LENGTH = 36K - RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 16K + RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K } -__bootloader_state_start = ORIGIN(BOOTLOADER_STATE); -__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE); +__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); +__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); -__bootloader_dfu_start = ORIGIN(DFU); -__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU); +__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER); +__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER); diff --git a/examples/boot/stm32wl/Cargo.toml b/examples/boot/stm32wl/Cargo.toml index 9c69f4a65..fb64886e6 100644 --- a/examples/boot/stm32wl/Cargo.toml +++ b/examples/boot/stm32wl/Cargo.toml @@ -7,7 +7,7 @@ version = "0.1.0" [dependencies] embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly"] } embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32wl55jc-cm4", "time-driver-any", "exti"] } -embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32", features = ["flash-2k"] } +embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" } embassy-traits = { version = "0.1.0", path = "../../../embassy-traits" } defmt = { version = "0.3", optional = true } diff --git a/examples/boot/stm32wl/README.md b/examples/boot/stm32wl/README.md index a26a23852..edcdacf91 100644 --- a/examples/boot/stm32wl/README.md +++ b/examples/boot/stm32wl/README.md @@ -15,7 +15,7 @@ application. ``` # Flash bootloader -cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32wl55jc-cm4,flash-2k --chip STM32WLE5JCIx +cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32wl55jc-cm4 --chip STM32WLE5JCIx # Build 'b' cargo build --release --bin b # Generate binary for 'b' diff --git a/examples/boot/stm32wl/memory.x b/examples/boot/stm32wl/memory.x index 78dd69c35..14b2a2c9f 100644 --- a/examples/boot/stm32wl/memory.x +++ b/examples/boot/stm32wl/memory.x @@ -8,8 +8,8 @@ MEMORY RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K } -__bootloader_state_start = ORIGIN(BOOTLOADER_STATE); -__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE); +__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); +__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(BOOTLOADER); -__bootloader_dfu_start = ORIGIN(DFU); -__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU); +__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(BOOTLOADER); +__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(BOOTLOADER); diff --git a/examples/boot/stm32wl/src/bin/a.rs b/examples/boot/stm32wl/src/bin/a.rs index b1f4a4a03..d01a72f2d 100644 --- a/examples/boot/stm32wl/src/bin/a.rs +++ b/examples/boot/stm32wl/src/bin/a.rs @@ -17,16 +17,18 @@ static APP_B: &[u8] = include_bytes!("../../b.bin"); #[embassy::main] async fn main(_s: embassy::executor::Spawner, p: Peripherals) { - let flash = Flash::new(p.FLASH); + let flash = Flash::unlock(p.FLASH); let mut flash = BlockingAsync::new(flash); let button = Input::new(p.PA0, Pull::Up); let mut button = ExtiInput::new(button, p.EXTI0); let mut led = Output::new(p.PB9, Level::Low, Speed::Low); + led.set_high(); let mut updater = FirmwareUpdater::default(); button.wait_for_falling_edge().await; + //defmt::info!("Starting update"); let mut offset = 0; for chunk in APP_B.chunks(2048) { let mut buf: [u8; 2048] = [0; 2048]; @@ -39,7 +41,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { offset += chunk.len(); } updater.mark_update(&mut flash).await.unwrap(); - // defmt::info!("Marked as updated"); - led.set_high(); + //defmt::info!("Marked as updated"); + led.set_low(); cortex_m::peripheral::SCB::sys_reset(); } -- cgit