From 77ba056e8e624dbc109f5a61fad977f5d61feafe Mon Sep 17 00:00:00 2001 From: cos Date: Thu, 20 Oct 2022 10:35:10 +0200 Subject: Failing attempt to add softdevice to DFU package Ideally launching run.sh should results in the RGB LED to blink blue. Sections "12.3 Master boot record and SoftDevice reset procedure" and "14.1 Memory resource map and usage" of [S140_SDS_v2.1][] seems to suggest that once the SoftDevice is initialized, application execution should happen from APP_CODE_BASE According to the description of [SD_FLASH_SIZE][], the APP_CODE_BASE address should be set to 0x27000 for version 7.3.0 of s140. Yet this gives no blue blinking LED. :( [S140_SDS_v2.1]: https://infocenter.nordicsemi.com/pdf/S140_SDS_v2.1.pdf [SD_FLASH_SIZE]: https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_nrf52%2Fstruct%2Fs140.html --- examples/nrf/memory.x | 4 ++-- examples/nrf/run.sh | 11 +++++++---- examples/nrf/src/bin/blinky.rs | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/examples/nrf/memory.x b/examples/nrf/memory.x index faf1a439..ecb323e1 100644 --- a/examples/nrf/memory.x +++ b/examples/nrf/memory.x @@ -2,6 +2,6 @@ MEMORY { /* NOTE 1 K = 1 KiBi = 1024 bytes */ /* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */ - FLASH : ORIGIN = 0x00001000, LENGTH = 1020K - RAM : ORIGIN = 0x20000008, LENGTH = 255K + FLASH : ORIGIN = 0x00027000, LENGTH = 868K + RAM : ORIGIN = 0x20003840, LENGTH = 242K } diff --git a/examples/nrf/run.sh b/examples/nrf/run.sh index 20b4bc17..01c4463e 100755 --- a/examples/nrf/run.sh +++ b/examples/nrf/run.sh @@ -2,6 +2,8 @@ SUFFIX=$( ( sed -n 's/.*\(0x[0-9A-F]*\).*/\1/p' < memory.x; sed -n 's/.*.*\(P[0-9_]*\).*/\1/p' src/bin/blinky.rs) | tr '\n' - ) SD_REQ=0x00 +SD_ID=$( nrfutil pkg generate --help | + sed -n 's/.*s140_nrf52_7.3.0|\([0-9A-Fx]*\).*/\1/p' ) cargo build --bin blinky cp ./target/thumbv7em-none-eabi/debug/blinky \ ./blinky-${SUFFIX%-} @@ -9,11 +11,12 @@ llvm-objcopy --output-target ihex \ ./target/thumbv7em-none-eabi/debug/blinky \ blinky-${SUFFIX%-}.hex nrfutil pkg generate --hw-version 52 \ - --debug-mode --sd-req ${SD_REQ} \ + --debug-mode --sd-req ${SD_REQ} --sd-id ${SD_ID} \ + --softdevice s140_nrf52_7.3.0_softdevice.hex \ --application blinky-${SUFFIX%-}.hex \ - only_app-${SUFFIX%-}.zip + sd_plus_app-${SUFFIX%-}.zip nrfutil pkg display \ - only_app-${SUFFIX%-}.zip + sd_plus_app-${SUFFIX%-}.zip nrfutil dfu usb-serial \ -p /dev/ttyACM0 -b 115200 \ - -pkg only_app-${SUFFIX%-}.zip + -pkg sd_plus_app-${SUFFIX%-}.zip diff --git a/examples/nrf/src/bin/blinky.rs b/examples/nrf/src/bin/blinky.rs index eb548f16..60a267e9 100644 --- a/examples/nrf/src/bin/blinky.rs +++ b/examples/nrf/src/bin/blinky.rs @@ -10,7 +10,7 @@ use {defmt_rtt as _, panic_probe as _}; #[embassy_executor::main] async fn main(_spawner: Spawner) { let p = embassy_nrf::init(Default::default()); - let mut led = Output::new(p.P1_09, Level::Low, OutputDrive::Standard); + let mut led = Output::new(p.P0_12, Level::Low, OutputDrive::Standard); loop { led.set_high(); -- cgit v1.2.3