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.
This commit is contained in:
Ulf Lilleengen 2022-06-24 19:56:15 +02:00
parent 84628d36cf
commit 776be79f7b
87 changed files with 358 additions and 259 deletions

View file

@ -0,0 +1,18 @@
[package]
edition = "2021"
name = "embassy-boot-nrf-examples"
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", "nrf52840"] }
embassy-boot-nrf = { version = "0.1.0", path = "../../../../embassy-boot/nrf" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"

View file

@ -17,10 +17,10 @@ application.
```
# Use bare metal linker script
cp memory-bl.x ../../../embassy-boot/nrf/memory.x
cp memory-bl.x ../../bootloader/nrf/memory.x
# Flash bootloader
cargo flash --manifest-path ../../../embassy-boot/nrf/Cargo.toml --features embassy-nrf/nrf52840 --release --chip nRF52840_xxAA
cargo flash --manifest-path ../../bootloader/nrf/Cargo.toml --features embassy-nrf/nrf52840 --release --chip nRF52840_xxAA
# Build 'b'
cargo build --release --bin b
# Generate binary for 'b'

View file

@ -0,0 +1,25 @@
[package]
edition = "2021"
name = "embassy-boot-stm32f3-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] }
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -15,7 +15,7 @@ application.
```
# Flash bootloader
cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32f303re --chip STM32F303RETx
cargo flash --manifest-path ../../bootloader/stm32/Cargo.toml --release --features embassy-stm32/stm32f303re --chip STM32F303RETx
# Build 'b'
cargo build --release --bin b
# Generate binary for 'b'

View file

@ -0,0 +1,25 @@
[package]
edition = "2021"
name = "embassy-boot-stm32f7-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] }
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -0,0 +1,8 @@
#!/bin/bash
mv ../../bootloader/stm32/memory.x ../../bootloader/stm32/memory-old.x
cp memory-bl.x ../../bootloader/stm32/memory.x
cargo flash --manifest-path ../../bootloader/stm32/Cargo.toml --release --features embassy-stm32/stm32f767zi --chip STM32F767ZITx --target thumbv7em-none-eabihf
rm ../../bootloader/stm32/memory.x
mv ../../bootloader/stm32/memory-old.x ../../bootloader/stm32/memory.x

View file

@ -0,0 +1,25 @@
[package]
edition = "2021"
name = "embassy-boot-stm32f7-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] }
embassy-boot-stm32 = { version = "0.1.0", path = "../../../../embassy-boot/stm32" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -0,0 +1,8 @@
#!/bin/bash
mv ../../bootloader/stm32/memory.x ../../bootloader/stm32/memory-old.x
cp memory-bl.x ../../bootloader/stm32/memory.x
cargo flash --manifest-path ../../bootloader/stm32/Cargo.toml --release --features embassy-stm32/stm32f767zi --chip STM32F767ZITx --target thumbv7em-none-eabihf
rm ../../bootloader/stm32/memory.x
mv ../../bootloader/stm32/memory-old.x ../../bootloader/stm32/memory.x

View file

@ -0,0 +1,25 @@
[package]
edition = "2021"
name = "embassy-boot-stm32l0-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] }
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" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -15,7 +15,7 @@ application.
```
# Flash bootloader
cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l072cz --chip STM32L072CZTx
cargo flash --manifest-path ../../bootloader/stm32/Cargo.toml --release --features embassy-stm32/stm32l072cz --chip STM32L072CZTx
# Build 'b'
cargo build --release --bin b
# Generate binary for 'b'

View file

@ -0,0 +1,25 @@
[package]
edition = "2021"
name = "embassy-boot-stm32l1-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] }
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" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -15,7 +15,7 @@ application.
```
# Flash bootloader
cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l151cb-a --chip STM32L151CBxxA
cargo flash --manifest-path ../../bootloader/stm32/Cargo.toml --release --features embassy-stm32/stm32l151cb-a --chip STM32L151CBxxA
# Build 'b'
cargo build --release --bin b
# Generate binary for 'b'

View file

@ -0,0 +1,25 @@
[package]
edition = "2021"
name = "embassy-boot-stm32l4-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] }
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" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -15,7 +15,7 @@ application.
```
# Flash bootloader
cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32l475vg --chip STM32L475VG
cargo flash --manifest-path ../../bootloader/stm32/Cargo.toml --release --features embassy-stm32/stm32l475vg --chip STM32L475VG
# Build 'b'
cargo build --release --bin b
# Generate binary for 'b'

View file

@ -0,0 +1,25 @@
[package]
edition = "2021"
name = "embassy-boot-stm32wl-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../../embassy", features = ["nightly", "time-tick-32768hz"] }
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" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -15,7 +15,7 @@ application.
```
# Flash bootloader
cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32wl55jc-cm4 --chip STM32WLE5JCIx
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'

View file

@ -0,0 +1,20 @@
[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"

View file

@ -0,0 +1,58 @@
[package]
edition = "2021"
name = "nrf-bootloader-example"
version = "0.1.0"
description = "Bootloader for nRF chips"
[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"] }
embassy-boot-nrf = { path = "../../../../embassy-boot/nrf", default-features = false }
cortex-m = { version = "0.7" }
cortex-m-rt = { version = "0.7" }
cfg-if = "1.0.0"
[features]
defmt = [
"dep:defmt",
"embassy-boot-nrf/defmt",
"embassy-nrf/defmt",
]
softdevice = [
"embassy-boot-nrf/softdevice",
]
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

View file

@ -0,0 +1,11 @@
# 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
```

View file

@ -0,0 +1,37 @@
//! 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");
}
}

View file

@ -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);

View file

@ -0,0 +1,31 @@
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
}

View file

@ -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);

View file

@ -0,0 +1,48 @@
#![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();
}

View file

@ -0,0 +1,57 @@
[package]
edition = "2021"
name = "stm32-bootloader-example"
version = "0.1.0"
description = "Example bootloader for STM32 chips"
[dependencies]
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
embassy = { path = "../../../../embassy", default-features = false }
embassy-stm32 = { path = "../../../../embassy-stm32", default-features = false, features = ["nightly"] }
embassy-boot-stm32 = { path = "../../../../embassy-boot/stm32", default-features = false }
cortex-m = { version = "0.7" }
cortex-m-rt = { version = "0.7" }
embedded-storage = "0.3.0"
embedded-storage-async = "0.3.0"
cfg-if = "1.0.0"
[features]
defmt = [
"dep:defmt",
"embassy-boot-stm32/defmt",
"embassy-stm32/defmt",
]
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

View file

@ -0,0 +1,11 @@
# Bootloader for STM32
The bootloader uses `embassy-boot` to interact with the flash.
# Usage
Flash the bootloader
```
cargo flash --features embassy-stm32/stm32wl55jc-cm4 --release --chip STM32WLE5JCIx
```

View file

@ -0,0 +1,32 @@
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");
}
}

View file

@ -0,0 +1,18 @@
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);

View file

@ -0,0 +1,46 @@
#![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();
}

View file

@ -1,18 +0,0 @@
[package]
edition = "2021"
name = "embassy-boot-nrf-examples"
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", "nrf52840"] }
embassy-boot-nrf = { version = "0.1.0", path = "../../../embassy-boot/nrf" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"

View file

@ -1,25 +0,0 @@
[package]
edition = "2021"
name = "embassy-boot-stm32f3-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly", "time-tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f303re", "time-driver-any", "exti"] }
embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -1,25 +0,0 @@
[package]
edition = "2021"
name = "embassy-boot-stm32f7-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly", "time-tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32f767zi", "time-driver-any", "exti"] }
embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -1,8 +0,0 @@
#!/bin/bash
mv ../../../embassy-boot/stm32/memory.x ../../../embassy-boot/stm32/memory-old.x
cp memory-bl.x ../../../embassy-boot/stm32/memory.x
cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32f767zi --chip STM32F767ZITx --target thumbv7em-none-eabihf
rm ../../../embassy-boot/stm32/memory.x
mv ../../../embassy-boot/stm32/memory-old.x ../../../embassy-boot/stm32/memory.x

View file

@ -1,25 +0,0 @@
[package]
edition = "2021"
name = "embassy-boot-stm32f7-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly", "time-tick-32768hz"] }
embassy-stm32 = { version = "0.1.0", path = "../../../embassy-stm32", features = ["unstable-traits", "nightly", "stm32h743zi", "time-driver-any", "exti"] }
embassy-boot-stm32 = { version = "0.1.0", path = "../../../embassy-boot/stm32" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -1,8 +0,0 @@
#!/bin/bash
mv ../../../embassy-boot/stm32/memory.x ../../../embassy-boot/stm32/memory-old.x
cp memory-bl.x ../../../embassy-boot/stm32/memory.x
cargo flash --manifest-path ../../../embassy-boot/stm32/Cargo.toml --release --features embassy-stm32/stm32f767zi --chip STM32H743ZITx --target thumbv7em-none-eabihf
rm ../../../embassy-boot/stm32/memory.x
mv ../../../embassy-boot/stm32/memory-old.x ../../../embassy-boot/stm32/memory.x

View file

@ -1,25 +0,0 @@
[package]
edition = "2021"
name = "embassy-boot-stm32l0-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly", "time-tick-32768hz"] }
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" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -1,25 +0,0 @@
[package]
edition = "2021"
name = "embassy-boot-stm32l1-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly", "time-tick-32768hz"] }
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" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -1,25 +0,0 @@
[package]
edition = "2021"
name = "embassy-boot-stm32l4-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly", "time-tick-32768hz"] }
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" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]

View file

@ -1,25 +0,0 @@
[package]
edition = "2021"
name = "embassy-boot-stm32wl-examples"
version = "0.1.0"
[dependencies]
embassy = { version = "0.1.0", path = "../../../embassy", features = ["nightly", "time-tick-32768hz"] }
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" }
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal" }
defmt = { version = "0.3", optional = true }
defmt-rtt = { version = "0.3", optional = true }
panic-reset = { version = "0.1.1" }
embedded-hal = { version = "0.2.6" }
cortex-m = "0.7.3"
cortex-m-rt = "0.7.0"
[features]
defmt = [
"dep:defmt",
"embassy-stm32/defmt",
"embassy-boot-stm32/defmt",
]