From b7e7211a204d40afaf98e0c1ed405a898f8fc689 Mon Sep 17 00:00:00 2001 From: Ulf Lilleengen Date: Thu, 28 Apr 2022 14:08:33 +0200 Subject: [PATCH] Fix linker script for nrf bootloader example --- embassy-boot/nrf/memory-bm.x | 2 +- embassy-boot/nrf/memory.x | 2 +- examples/boot/nrf/README.md | 3 +++ examples/boot/nrf/memory-bl.x | 18 ++++++++++++++++++ examples/boot/nrf/memory.x | 3 ++- examples/boot/nrf/src/bin/a.rs | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) create mode 100644 examples/boot/nrf/memory-bl.x diff --git a/embassy-boot/nrf/memory-bm.x b/embassy-boot/nrf/memory-bm.x index 257d6564..8a32b905 100644 --- a/embassy-boot/nrf/memory-bm.x +++ b/embassy-boot/nrf/memory-bm.x @@ -5,7 +5,7 @@ MEMORY BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K DFU : ORIGIN = 0x00017000, LENGTH = 68K - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K + RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K } __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); diff --git a/embassy-boot/nrf/memory.x b/embassy-boot/nrf/memory.x index 257d6564..8a32b905 100644 --- a/embassy-boot/nrf/memory.x +++ b/embassy-boot/nrf/memory.x @@ -5,7 +5,7 @@ MEMORY BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K DFU : ORIGIN = 0x00017000, LENGTH = 68K - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K + RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K } __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); diff --git a/examples/boot/nrf/README.md b/examples/boot/nrf/README.md index 453df7f3..1f25ffc0 100644 --- a/examples/boot/nrf/README.md +++ b/examples/boot/nrf/README.md @@ -16,6 +16,9 @@ application. ``` +# Use bare metal linker script +cp memory-bl.x ../../../embassy-boot/nrf/memory.x + # Flash bootloader cargo flash --manifest-path ../../../embassy-boot/nrf/Cargo.toml --features embassy-nrf/nrf52840 --release --chip nRF52840_xxAA # Build 'b' diff --git a/examples/boot/nrf/memory-bl.x b/examples/boot/nrf/memory-bl.x new file mode 100644 index 00000000..8a32b905 --- /dev/null +++ b/examples/boot/nrf/memory-bl.x @@ -0,0 +1,18 @@ +MEMORY +{ + /* NOTE 1 K = 1 KiBi = 1024 bytes */ + FLASH : ORIGIN = 0x00000000, LENGTH = 24K + BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K + ACTIVE : ORIGIN = 0x00007000, LENGTH = 64K + DFU : ORIGIN = 0x00017000, LENGTH = 68K + RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K +} + +__bootloader_state_start = ORIGIN(BOOTLOADER_STATE); +__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE); + +__bootloader_active_start = ORIGIN(ACTIVE); +__bootloader_active_end = ORIGIN(ACTIVE) + LENGTH(ACTIVE); + +__bootloader_dfu_start = ORIGIN(DFU); +__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU); diff --git a/examples/boot/nrf/memory.x b/examples/boot/nrf/memory.x index dfb72103..3a54ca46 100644 --- a/examples/boot/nrf/memory.x +++ b/examples/boot/nrf/memory.x @@ -1,10 +1,11 @@ MEMORY { /* NOTE 1 K = 1 KiBi = 1024 bytes */ + BOOTLOADER : ORIGIN = 0x00000000, LENGTH = 24K BOOTLOADER_STATE : ORIGIN = 0x00006000, LENGTH = 4K FLASH : ORIGIN = 0x00007000, LENGTH = 64K DFU : ORIGIN = 0x00017000, LENGTH = 68K - RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K + RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 32K } __bootloader_state_start = ORIGIN(BOOTLOADER_STATE); diff --git a/examples/boot/nrf/src/bin/a.rs b/examples/boot/nrf/src/bin/a.rs index 2f05c817..7368e36c 100644 --- a/examples/boot/nrf/src/bin/a.rs +++ b/examples/boot/nrf/src/bin/a.rs @@ -28,6 +28,7 @@ async fn main(_s: embassy::executor::Spawner, p: Peripherals) { let mut updater = FirmwareUpdater::default(); loop { + led.set_low(); button.wait_for_any_edge().await; if button.is_low() { let mut offset = 0;