summaryrefslogtreecommitdiff
path: root/embassy-boot
diff options
context:
space:
mode:
authorUlf Lilleengen <ulf.lilleengen@gmail.com>2022-06-24 19:56:15 +0200
committerUlf Lilleengen <ulf.lilleengen@gmail.com>2022-06-24 19:56:15 +0200
commit776be79f7bb10b09e795e2ea93bb795a653c9b4c (patch)
tree269046d330ee503c84049bb8fc47baf0297ecb80 /embassy-boot
parent84628d36cf743193cbf0e7d47ef1cfa9fb590890 (diff)
downloadembassy-776be79f7bb10b09e795e2ea93bb795a653c9b4c.zip
Move bootloader main to examples
This should remove some confusion around embassy-boot-* being a library vs. a binary. The binary is now an example bootloader instead.
Diffstat (limited to 'embassy-boot')
-rw-r--r--embassy-boot/nrf/.cargo/config.toml20
-rw-r--r--embassy-boot/nrf/Cargo.toml37
-rw-r--r--embassy-boot/nrf/README.md11
-rw-r--r--embassy-boot/nrf/build.rs37
-rw-r--r--embassy-boot/nrf/memory-bm.x18
-rw-r--r--embassy-boot/nrf/memory-s140.x31
-rw-r--r--embassy-boot/nrf/memory.x18
-rw-r--r--embassy-boot/nrf/src/main.rs48
-rw-r--r--embassy-boot/stm32/Cargo.toml4
-rw-r--r--embassy-boot/stm32/build.rs32
-rw-r--r--embassy-boot/stm32/memory.x18
-rw-r--r--embassy-boot/stm32/src/main.rs46
12 files changed, 6 insertions, 314 deletions
diff --git a/embassy-boot/nrf/.cargo/config.toml b/embassy-boot/nrf/.cargo/config.toml
deleted file mode 100644
index 1060800a..00000000
--- a/embassy-boot/nrf/.cargo/config.toml
+++ /dev/null
@@ -1,20 +0,0 @@
-[unstable]
-build-std = ["core"]
-build-std-features = ["panic_immediate_abort"]
-
-[target.'cfg(all(target_arch = "arm", target_os = "none"))']
-#runner = "./fruitrunner"
-runner = "probe-run --chip nrf52840_xxAA"
-
-rustflags = [
- # Code-size optimizations.
- "-Z", "trap-unreachable=no",
- #"-C", "no-vectorize-loops",
- "-C", "force-frame-pointers=yes",
-]
-
-[build]
-target = "thumbv7em-none-eabi"
-
-[env]
-DEFMT_LOG = "trace"
diff --git a/embassy-boot/nrf/Cargo.toml b/embassy-boot/nrf/Cargo.toml
index b5cc9c4f..ea579483 100644
--- a/embassy-boot/nrf/Cargo.toml
+++ b/embassy-boot/nrf/Cargo.toml
@@ -2,11 +2,12 @@
edition = "2021"
name = "embassy-boot-nrf"
version = "0.1.0"
-description = "Bootloader for nRF chips"
+description = "Bootloader lib for nRF chips"
+
+[lib]
[dependencies]
defmt = { version = "0.3", optional = true }
-defmt-rtt = { version = "0.3", optional = true }
embassy = { path = "../../embassy", default-features = false }
embassy-nrf = { path = "../../embassy-nrf", default-features = false, features = ["nightly"] }
@@ -28,35 +29,3 @@ defmt = [
softdevice = [
"nrf-softdevice-mbr",
]
-debug = ["defmt-rtt"]
-
-[profile.dev]
-debug = 2
-debug-assertions = true
-incremental = false
-opt-level = 'z'
-overflow-checks = true
-
-[profile.release]
-codegen-units = 1
-debug = 2
-debug-assertions = false
-incremental = false
-lto = 'fat'
-opt-level = 'z'
-overflow-checks = false
-
-# do not optimize proc-macro crates = faster builds from scratch
-[profile.dev.build-override]
-codegen-units = 8
-debug = false
-debug-assertions = false
-opt-level = 0
-overflow-checks = false
-
-[profile.release.build-override]
-codegen-units = 8
-debug = false
-debug-assertions = false
-opt-level = 0
-overflow-checks = false
diff --git a/embassy-boot/nrf/README.md b/embassy-boot/nrf/README.md
deleted file mode 100644
index 23497a03..00000000
--- a/embassy-boot/nrf/README.md
+++ /dev/null
@@ -1,11 +0,0 @@
-# Bootloader for nRF
-
-The bootloader uses `embassy-boot` to interact with the flash.
-
-# Usage
-
-Flash the bootloader
-
-```
-cargo flash --features embassy-nrf/nrf52832 --release --chip nRF52832_xxAA
-```
diff --git a/embassy-boot/nrf/build.rs b/embassy-boot/nrf/build.rs
deleted file mode 100644
index e1da6932..00000000
--- a/embassy-boot/nrf/build.rs
+++ /dev/null
@@ -1,37 +0,0 @@
-//! This build script copies the `memory.x` file from the crate root into
-//! a directory where the linker can always find it at build time.
-//! For many projects this is optional, as the linker always searches the
-//! project root directory -- wherever `Cargo.toml` is. However, if you
-//! are using a workspace or have a more complicated build setup, this
-//! build script becomes required. Additionally, by requesting that
-//! Cargo re-run the build script whenever `memory.x` is changed,
-//! updating `memory.x` ensures a rebuild of the application with the
-//! new memory settings.
-
-use std::env;
-use std::fs::File;
-use std::io::Write;
-use std::path::PathBuf;
-
-fn main() {
- // Put `memory.x` in our output directory and ensure it's
- // on the linker search path.
- let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
- File::create(out.join("memory.x"))
- .unwrap()
- .write_all(include_bytes!("memory.x"))
- .unwrap();
- println!("cargo:rustc-link-search={}", out.display());
-
- // By default, Cargo will re-run a build script whenever
- // any file in the project changes. By specifying `memory.x`
- // here, we ensure the build script is only re-run when
- // `memory.x` is changed.
- println!("cargo:rerun-if-changed=memory.x");
-
- println!("cargo:rustc-link-arg-bins=--nmagic");
- println!("cargo:rustc-link-arg-bins=-Tlink.x");
- if env::var("CARGO_FEATURE_DEFMT").is_ok() {
- println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
- }
-}
diff --git a/embassy-boot/nrf/memory-bm.x b/embassy-boot/nrf/memory-bm.x
deleted file mode 100644
index 8a32b905..00000000
--- a/embassy-boot/nrf/memory-bm.x
+++ /dev/null
@@ -1,18 +0,0 @@
-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/embassy-boot/nrf/memory-s140.x b/embassy-boot/nrf/memory-s140.x
deleted file mode 100644
index 105db997..00000000
--- a/embassy-boot/nrf/memory-s140.x
+++ /dev/null
@@ -1,31 +0,0 @@
-MEMORY
-{
- /* NOTE 1 K = 1 KiBi = 1024 bytes */
- MBR : ORIGIN = 0x00000000, LENGTH = 4K
- SOFTDEVICE : ORIGIN = 0x00001000, LENGTH = 155648
- ACTIVE : ORIGIN = 0x00027000, LENGTH = 425984
- DFU : ORIGIN = 0x0008F000, LENGTH = 430080
- FLASH : ORIGIN = 0x000f9000, LENGTH = 24K
- BOOTLOADER_STATE : ORIGIN = 0x000ff000, LENGTH = 4K
- RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 0x2fff8
- uicr_bootloader_start_address (r) : ORIGIN = 0x10001014, LENGTH = 0x4
-}
-
-__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);
-
-__bootloader_start = ORIGIN(FLASH);
-
-SECTIONS
-{
- .uicr_bootloader_start_address :
- {
- LONG(__bootloader_start)
- } > uicr_bootloader_start_address
-}
diff --git a/embassy-boot/nrf/memory.x b/embassy-boot/nrf/memory.x
deleted file mode 100644
index 8a32b905..00000000
--- a/embassy-boot/nrf/memory.x
+++ /dev/null
@@ -1,18 +0,0 @@
-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/embassy-boot/nrf/src/main.rs b/embassy-boot/nrf/src/main.rs
deleted file mode 100644
index bc7e0755..00000000
--- a/embassy-boot/nrf/src/main.rs
+++ /dev/null
@@ -1,48 +0,0 @@
-#![no_std]
-#![no_main]
-
-use cortex_m_rt::{entry, exception};
-#[cfg(feature = "defmt")]
-use defmt_rtt as _;
-use embassy_boot_nrf::*;
-use embassy_nrf::nvmc::Nvmc;
-
-#[entry]
-fn main() -> ! {
- let p = embassy_nrf::init(Default::default());
-
- // Uncomment this if you are debugging the bootloader with debugger/RTT attached,
- // as it prevents a hard fault when accessing flash 'too early' after boot.
- /*
- for i in 0..10000000 {
- cortex_m::asm::nop();
- }
- */
-
- let mut bl = BootLoader::default();
- let start = bl.prepare(&mut SingleFlashProvider::new(&mut WatchdogFlash::start(
- Nvmc::new(p.NVMC),
- p.WDT,
- 5,
- )));
- unsafe { bl.load(start) }
-}
-
-#[no_mangle]
-#[cfg_attr(target_os = "none", link_section = ".HardFault.user")]
-unsafe extern "C" fn HardFault() {
- cortex_m::peripheral::SCB::sys_reset();
-}
-
-#[exception]
-unsafe fn DefaultHandler(_: i16) -> ! {
- const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
- let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16;
-
- panic!("DefaultHandler #{:?}", irqn);
-}
-
-#[panic_handler]
-fn panic(_info: &core::panic::PanicInfo) -> ! {
- cortex_m::asm::udf();
-}
diff --git a/embassy-boot/stm32/Cargo.toml b/embassy-boot/stm32/Cargo.toml
index 3f198c11..1b6eeef9 100644
--- a/embassy-boot/stm32/Cargo.toml
+++ b/embassy-boot/stm32/Cargo.toml
@@ -2,7 +2,9 @@
edition = "2021"
name = "embassy-boot-stm32"
version = "0.1.0"
-description = "Bootloader for STM32 chips"
+description = "Bootloader lib for STM32 chips"
+
+[lib]
[dependencies]
defmt = { version = "0.3", optional = true }
diff --git a/embassy-boot/stm32/build.rs b/embassy-boot/stm32/build.rs
deleted file mode 100644
index 3997702f..00000000
--- a/embassy-boot/stm32/build.rs
+++ /dev/null
@@ -1,32 +0,0 @@
-use std::env;
-use std::fs::File;
-use std::io::Write;
-use std::path::PathBuf;
-
-fn main() {
- // Put `memory.x` in our output directory and ensure it's
- // on the linker search path.
- let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
- File::create(out.join("memory.x"))
- .unwrap()
- .write_all(include_bytes!("memory.x"))
- .unwrap();
- println!("cargo:rustc-link-search={}", out.display());
-
- // By default, Cargo will re-run a build script whenever
- // any file in the project changes. By specifying `memory.x`
- // here, we ensure the build script is only re-run when
- // `memory.x` is changed.
- println!("cargo:rerun-if-changed=memory.x");
-
- println!("cargo:rustc-link-arg-bins=--nmagic");
- println!("cargo:rustc-link-arg-bins=-Tlink.x");
- if env::var("CARGO_FEATURE_DEFMT").is_ok() {
- println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
- }
-
- let target = env::var("TARGET").unwrap();
- if target.starts_with("thumbv6m-") {
- println!("cargo:rustc-cfg=armv6m");
- }
-}
diff --git a/embassy-boot/stm32/memory.x b/embassy-boot/stm32/memory.x
deleted file mode 100644
index 110c2325..00000000
--- a/embassy-boot/stm32/memory.x
+++ /dev/null
@@ -1,18 +0,0 @@
-MEMORY
-{
- /* NOTE 1 K = 1 KiBi = 1024 bytes */
- FLASH : ORIGIN = 0x08000000, LENGTH = 24K
- BOOTLOADER_STATE : ORIGIN = 0x08006000, LENGTH = 4K
- ACTIVE : ORIGIN = 0x08008000, LENGTH = 32K
- DFU : ORIGIN = 0x08010000, LENGTH = 36K
- RAM (rwx) : ORIGIN = 0x20000008, LENGTH = 16K
-}
-
-__bootloader_state_start = ORIGIN(BOOTLOADER_STATE) - ORIGIN(FLASH);
-__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE) - ORIGIN(FLASH);
-
-__bootloader_active_start = ORIGIN(ACTIVE) - ORIGIN(FLASH);
-__bootloader_active_end = ORIGIN(ACTIVE) + LENGTH(ACTIVE) - ORIGIN(FLASH);
-
-__bootloader_dfu_start = ORIGIN(DFU) - ORIGIN(FLASH);
-__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU) - ORIGIN(FLASH);
diff --git a/embassy-boot/stm32/src/main.rs b/embassy-boot/stm32/src/main.rs
deleted file mode 100644
index 45c511ce..00000000
--- a/embassy-boot/stm32/src/main.rs
+++ /dev/null
@@ -1,46 +0,0 @@
-#![no_std]
-#![no_main]
-
-use cortex_m_rt::{entry, exception};
-#[cfg(feature = "defmt")]
-use defmt_rtt as _;
-use embassy_boot_stm32::*;
-use embassy_stm32::flash::{Flash, ERASE_SIZE};
-
-#[entry]
-fn main() -> ! {
- let p = embassy_stm32::init(Default::default());
-
- // Uncomment this if you are debugging the bootloader with debugger/RTT attached,
- // as it prevents a hard fault when accessing flash 'too early' after boot.
- /*
- for i in 0..10000000 {
- cortex_m::asm::nop();
- }
- */
-
- let mut bl: BootLoader<ERASE_SIZE> = BootLoader::default();
- let mut flash = Flash::unlock(p.FLASH);
- let start = bl.prepare(&mut SingleFlashProvider::new(&mut flash));
- core::mem::drop(flash);
- unsafe { bl.load(start) }
-}
-
-#[no_mangle]
-#[cfg_attr(target_os = "none", link_section = ".HardFault.user")]
-unsafe extern "C" fn HardFault() {
- cortex_m::peripheral::SCB::sys_reset();
-}
-
-#[exception]
-unsafe fn DefaultHandler(_: i16) -> ! {
- const SCB_ICSR: *const u32 = 0xE000_ED04 as *const u32;
- let irqn = core::ptr::read_volatile(SCB_ICSR) as u8 as i16 - 16;
-
- panic!("DefaultHandler #{:?}", irqn);
-}
-
-#[panic_handler]
-fn panic(_info: &core::panic::PanicInfo) -> ! {
- cortex_m::asm::udf();
-}