snpashot
This commit is contained in:
parent
2a437d31c4
commit
9010bfe79b
@ -1,17 +1,6 @@
|
||||
[unstable]
|
||||
build-std = ["core"]
|
||||
build-std-features = ["panic_immediate_abort"]
|
||||
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
#runner = "./fruitrunner"
|
||||
runner = "probe-rs run --chip nrf52840_xxAA"
|
||||
|
||||
rustflags = [
|
||||
# Code-size optimizations.
|
||||
"-Z", "trap-unreachable=no",
|
||||
#"-C", "no-vectorize-loops",
|
||||
"-C", "force-frame-pointers=yes",
|
||||
]
|
||||
runner = "teleprobe local run --chip nRF52832_xxAA --elf"
|
||||
|
||||
[build]
|
||||
target = "thumbv7em-none-eabi"
|
||||
|
@ -6,8 +6,8 @@ description = "Bootloader for nRF chips"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
defmt = { version = "0.3", optional = true }
|
||||
defmt-rtt = { version = "0.4", optional = true }
|
||||
defmt = { version = "0.3" }
|
||||
defmt-rtt = { version = "0.4" }
|
||||
|
||||
embassy-nrf = { path = "../../../../embassy-nrf", features = ["nightly"] }
|
||||
embassy-boot-nrf = { path = "../../../../embassy-boot/nrf" }
|
||||
@ -17,15 +17,9 @@ 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", "defmt"]
|
||||
|
||||
[profile.dev]
|
||||
debug = 2
|
||||
|
@ -4,7 +4,6 @@
|
||||
use core::cell::RefCell;
|
||||
|
||||
use cortex_m_rt::{entry, exception};
|
||||
#[cfg(feature = "defmt")]
|
||||
use defmt_rtt as _;
|
||||
use embassy_boot_nrf::*;
|
||||
use embassy_nrf::nvmc::Nvmc;
|
||||
|
@ -1,6 +1,6 @@
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
#runner = "teleprobe local run --chip nRF52840_xxAA --elf"
|
||||
runner = "teleprobe client run"
|
||||
runner = "teleprobe local run --chip nRF52832_xxAA --elf"
|
||||
#runner = "teleprobe client run"
|
||||
|
||||
[build]
|
||||
target = "thumbv7em-none-eabi"
|
||||
|
@ -1,29 +0,0 @@
|
||||
[package]
|
||||
edition = "2021"
|
||||
name = "embassy-nrf-boot-tests"
|
||||
version = "0.1.0"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
||||
[dependencies]
|
||||
teleprobe-meta = "1"
|
||||
|
||||
embassy-futures = { version = "0.1.0", path = "../../../embassy-futures" }
|
||||
embassy-sync = { version = "0.2.0", path = "../../../embassy-sync", features = ["defmt", "nightly"] }
|
||||
embassy-executor = { version = "0.3.0", path = "../../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "nightly", "integrated-timers"] }
|
||||
embassy-time = { version = "0.1.3", path = "../../../embassy-time", features = ["defmt", "nightly", "unstable-traits", "defmt-timestamp-uptime"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
|
||||
embassy-embedded-hal = { version = "0.1.0", path = "../../../embassy-embedded-hal", features = ["nightly"] }
|
||||
embassy-boot-nrf = { version = "0.1.0", path = "../../../embassy-boot/nrf" }
|
||||
embedded-io-async = { version = "0.5.0" }
|
||||
embedded-hal-async = { version = "1.0.0-rc.1" }
|
||||
embedded-hal-bus = { version = "0.1.0-rc.1", features = ["async"] }
|
||||
embedded-storage = "0.3.0"
|
||||
embedded-storage-async = { version = "0.4.0" }
|
||||
static_cell = { version = "1.1", features = [ "nightly" ] }
|
||||
|
||||
defmt = "0.3"
|
||||
defmt-rtt = "0.4"
|
||||
|
||||
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
|
||||
cortex-m-rt = "0.7.0"
|
||||
panic-probe = { version = "0.3", features = ["print-defmt"] }
|
@ -1,17 +0,0 @@
|
||||
use std::error::Error;
|
||||
use std::path::PathBuf;
|
||||
use std::{env, fs};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
fs::write(out.join("memory.x"), include_bytes!("memory.x")).unwrap();
|
||||
println!("cargo:rustc-link-search={}", out.display());
|
||||
println!("cargo:rerun-if-changed=memory.x");
|
||||
|
||||
println!("cargo:rustc-link-arg-bins=--nmagic");
|
||||
println!("cargo:rustc-link-arg-bins=-Tmemory.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
|
||||
|
||||
Ok(())
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
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
|
||||
TEST_STATE : ORIGIN = 0x00028000, LENGTH = 4K
|
||||
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
||||
__bootloader_state_start = ORIGIN(BOOTLOADER_STATE);
|
||||
__bootloader_state_end = ORIGIN(BOOTLOADER_STATE) + LENGTH(BOOTLOADER_STATE);
|
||||
|
||||
__bootloader_dfu_start = ORIGIN(DFU);
|
||||
__bootloader_dfu_end = ORIGIN(DFU) + LENGTH(DFU);
|
||||
|
||||
__test_state_start = ORIGIN(TEST_STATE);
|
||||
__test-state_end = ORIGIN(TEST_STATE) + LENGTH(TEST_STATE);
|
@ -1,68 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
teleprobe_meta::target!(b"nrf52840-dk");
|
||||
|
||||
#[path = "../common.rs"]
|
||||
mod common;
|
||||
use common::*;
|
||||
|
||||
use embassy_boot_nrf::{BlockingFirmwareUpdater, FirmwareUpdaterConfig};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_nrf::nvmc::Nvmc;
|
||||
use embassy_time::{Timer, Duration};
|
||||
use embassy_sync::blocking_mutex::Mutex;
|
||||
use core::cell::RefCell;
|
||||
use embedded_storage::nor_flash::NorFlash;
|
||||
|
||||
static APP_SUCCESS: &[u8] = include_bytes!("../../update_success.bin");
|
||||
static APP_FAILURE: &[u8] = include_bytes!("../../update_failure.bin");
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(s: Spawner) {
|
||||
let p = embassy_nrf::init(Default::default());
|
||||
|
||||
s.spawn(watchdog_task()).unwrap();
|
||||
|
||||
let nvmc = Nvmc::new(p.NVMC);
|
||||
let nvmc = Mutex::new(RefCell::new(nvmc));
|
||||
|
||||
let state = TestState::init(&nvmc);
|
||||
|
||||
// First time we boot the bad firmare
|
||||
let app = if state.num_boots == 0 {
|
||||
APP_FAILURE
|
||||
// Second time we boot the good firmware
|
||||
} else if state.num_boots == 1 {
|
||||
APP_SUCCESS
|
||||
} else {
|
||||
defmt::panic!("Unexpected number of boots");
|
||||
};
|
||||
|
||||
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&nvmc);
|
||||
let mut magic = [0; 4];
|
||||
let mut updater = BlockingFirmwareUpdater::new(config, &mut magic);
|
||||
|
||||
// Check state if we've attempted update yet
|
||||
let dfu = updater.prepare_update().unwrap();
|
||||
|
||||
let mut offset = 0;
|
||||
for chunk in app.chunks(4096) {
|
||||
let mut buf: [u8; 4096] = [0; 4096];
|
||||
buf[..chunk.len()].copy_from_slice(chunk);
|
||||
dfu.write(offset, &buf).unwrap();
|
||||
offset += chunk.len() as u32;
|
||||
}
|
||||
updater.mark_updated().unwrap();
|
||||
cortex_m::peripheral::SCB::sys_reset();
|
||||
}
|
||||
|
||||
// Keeps our system alive
|
||||
#[embassy_executor::task]
|
||||
async fn watchdog_task() {
|
||||
let mut handle = unsafe { embassy_nrf::wdt::WatchdogHandle::steal(0) };
|
||||
loop {
|
||||
handle.pet();
|
||||
Timer::after(Duration::from_secs(2)).await;
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
teleprobe_meta::target!(b"nrf52840-dk");
|
||||
|
||||
#[path = "../common.rs"]
|
||||
mod common;
|
||||
use common::*;
|
||||
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::{Timer, Duration};
|
||||
use embassy_nrf::nvmc::Nvmc;
|
||||
use embassy_sync::blocking_mutex::Mutex;
|
||||
use core::cell::RefCell;
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(s: Spawner) {
|
||||
let p = embassy_nrf::init(Default::default());
|
||||
|
||||
s.spawn(watchdog_task()).unwrap();
|
||||
|
||||
let nvmc = Nvmc::new(p.NVMC);
|
||||
let nvmc = Mutex::new(RefCell::new(nvmc));
|
||||
|
||||
let mut state = TestState::init(&nvmc);
|
||||
state.inc(&nvmc);
|
||||
|
||||
// Simulate hang
|
||||
loop {}
|
||||
}
|
||||
|
||||
// Keeps our system alive
|
||||
#[embassy_executor::task]
|
||||
async fn watchdog_task() {
|
||||
let mut handle = unsafe { embassy_nrf::wdt::WatchdogHandle::steal(0) };
|
||||
loop {
|
||||
handle.pet();
|
||||
Timer::after(Duration::from_secs(2)).await;
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
teleprobe_meta::target!(b"nrf52840-dk");
|
||||
|
||||
#[path = "../common.rs"]
|
||||
mod common;
|
||||
use common::*;
|
||||
|
||||
use embassy_boot_nrf::{BlockingFirmwareUpdater, FirmwareUpdaterConfig};
|
||||
use embassy_executor::Spawner;
|
||||
use embassy_time::{Timer, Duration};
|
||||
use embassy_nrf::nvmc::Nvmc;
|
||||
use embassy_sync::blocking_mutex::Mutex;
|
||||
use core::cell::RefCell;
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(s: Spawner) {
|
||||
let p = embassy_nrf::init(Default::default());
|
||||
|
||||
s.spawn(watchdog_task()).unwrap();
|
||||
|
||||
let nvmc = Nvmc::new(p.NVMC);
|
||||
let nvmc = Mutex::new(RefCell::new(nvmc));
|
||||
|
||||
let mut state = TestState::init(&nvmc);
|
||||
if state.num_boots == 1 {
|
||||
let config = FirmwareUpdaterConfig::from_linkerfile_blocking(&nvmc);
|
||||
|
||||
let mut magic = [0; 4];
|
||||
let mut updater = BlockingFirmwareUpdater::new(config, &mut magic);
|
||||
|
||||
updater.mark_booted().unwrap();
|
||||
state.inc(&nvmc);
|
||||
cortex_m::peripheral::SCB::sys_reset();
|
||||
} else if state.num_boots == 2 {
|
||||
// Test success!
|
||||
cortex_m::asm::bkpt();
|
||||
} else {
|
||||
defmt::panic!("Unexpected number of boots");
|
||||
}
|
||||
}
|
||||
|
||||
// Keeps our system alive
|
||||
#[embassy_executor::task]
|
||||
async fn watchdog_task() {
|
||||
let mut handle = unsafe { embassy_nrf::wdt::WatchdogHandle::steal(0) };
|
||||
loop {
|
||||
handle.pet();
|
||||
Timer::after(Duration::from_secs(2)).await;
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
#![macro_use]
|
||||
|
||||
use core::cell::RefCell;
|
||||
|
||||
#[allow(unused)]
|
||||
pub use defmt::*;
|
||||
use embassy_embedded_hal::flash::partition::BlockingPartition;
|
||||
use embassy_nrf::nvmc::Nvmc;
|
||||
use embassy_sync::blocking_mutex::raw::NoopRawMutex;
|
||||
use embassy_sync::blocking_mutex::Mutex;
|
||||
use embedded_storage::nor_flash::{NorFlash, ReadNorFlash};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
pub struct TestState {
|
||||
pub num_boots: u32,
|
||||
}
|
||||
|
||||
impl TestState {
|
||||
pub fn init(flash: &Mutex<NoopRawMutex, RefCell<Nvmc<'_>>>) -> Self {
|
||||
extern "C" {
|
||||
static __test_state_start: u32;
|
||||
static __test_state_end: u32;
|
||||
}
|
||||
|
||||
let mut flash = unsafe {
|
||||
let start = &__test_state_start as *const u32 as u32;
|
||||
let end = &__test_state_end as *const u32 as u32;
|
||||
BlockingPartition::new(flash, start, end - start)
|
||||
};
|
||||
|
||||
let mut buf = [0; 4];
|
||||
let _ = flash.read(0, &mut buf).unwrap();
|
||||
if &buf[..] == &[0xff, 0xff, 0xff, 0xff] {
|
||||
TestState { num_boots: 0 }
|
||||
} else {
|
||||
TestState {
|
||||
num_boots: u32::from_be_bytes([buf[0], buf[1], buf[2], buf[3]]),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn inc(&mut self, flash: &Mutex<NoopRawMutex, RefCell<Nvmc<'_>>>) {
|
||||
extern "C" {
|
||||
static __test_state_start: u32;
|
||||
static __test_state_end: u32;
|
||||
}
|
||||
|
||||
let mut flash = unsafe {
|
||||
let start = &__test_state_start as *const u32 as u32;
|
||||
let end = &__test_state_end as *const u32 as u32;
|
||||
BlockingPartition::new(flash, start, end - start)
|
||||
};
|
||||
self.num_boots += 1;
|
||||
|
||||
flash.erase(0, 4096).unwrap();
|
||||
flash.write(0, &self.num_boots.to_be_bytes()).unwrap();
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
#runner = "teleprobe local run --chip nRF52840_xxAA --elf"
|
||||
runner = "teleprobe client run"
|
||||
runner = "teleprobe local run --chip nRF52832_xxAA --elf"
|
||||
#runner = "teleprobe client run"
|
||||
|
||||
[build]
|
||||
target = "thumbv7em-none-eabi"
|
||||
|
@ -11,7 +11,7 @@ embassy-futures = { version = "0.1.0", path = "../../embassy-futures" }
|
||||
embassy-sync = { version = "0.2.0", path = "../../embassy-sync", features = ["defmt", "nightly"] }
|
||||
embassy-executor = { version = "0.3.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "defmt", "nightly", "integrated-timers"] }
|
||||
embassy-time = { version = "0.1.3", path = "../../embassy-time", features = ["defmt", "nightly", "unstable-traits", "defmt-timestamp-uptime"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52840", "time-driver-rtc1", "gpiote", "unstable-pac"] }
|
||||
embassy-nrf = { version = "0.1.0", path = "../../embassy-nrf", features = ["defmt", "nightly", "unstable-traits", "nrf52832", "time-driver-rtc1", "gpiote", "unstable-pac"] }
|
||||
embedded-io-async = { version = "0.5.0" }
|
||||
embassy-net = { version = "0.1.0", path = "../../embassy-net", features = ["defmt", "tcp", "dhcpv4", "medium-ethernet", "nightly"] }
|
||||
embassy-net-esp-hosted = { version = "0.1.0", path = "../../embassy-net-esp-hosted", features = ["defmt"] }
|
||||
|
@ -1,17 +1,35 @@
|
||||
use std::error::Error;
|
||||
use std::path::PathBuf;
|
||||
use std::{env, fs};
|
||||
//! 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.
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let out = PathBuf::from(env::var("OUT_DIR").unwrap());
|
||||
fs::write(out.join("link_ram.x"), include_bytes!("link_ram.x")).unwrap();
|
||||
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());
|
||||
println!("cargo:rerun-if-changed=link_ram.x");
|
||||
|
||||
// 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_ram.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tlink.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tdefmt.x");
|
||||
println!("cargo:rustc-link-arg-bins=-Tteleprobe.x");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,254 +0,0 @@
|
||||
/* ##### EMBASSY NOTE
|
||||
Originally from https://github.com/rust-embedded/cortex-m-rt/blob/master/link.x.in
|
||||
Adjusted to put everything in RAM
|
||||
*/
|
||||
|
||||
/* # Developer notes
|
||||
|
||||
- Symbols that start with a double underscore (__) are considered "private"
|
||||
|
||||
- Symbols that start with a single underscore (_) are considered "semi-public"; they can be
|
||||
overridden in a user linker script, but should not be referred from user code (e.g. `extern "C" {
|
||||
static mut __sbss }`).
|
||||
|
||||
- `EXTERN` forces the linker to keep a symbol in the final binary. We use this to make sure a
|
||||
symbol if not dropped if it appears in or near the front of the linker arguments and "it's not
|
||||
needed" by any of the preceding objects (linker arguments)
|
||||
|
||||
- `PROVIDE` is used to provide default values that can be overridden by a user linker script
|
||||
|
||||
- On alignment: it's important for correctness that the VMA boundaries of both .bss and .data *and*
|
||||
the LMA of .data are all 4-byte aligned. These alignments are assumed by the RAM initialization
|
||||
routine. There's also a second benefit: 4-byte aligned boundaries means that you won't see
|
||||
"Address (..) is out of bounds" in the disassembly produced by `objdump`.
|
||||
*/
|
||||
|
||||
/* Provides information about the memory layout of the device */
|
||||
/* This will be provided by the user (see `memory.x`) or by a Board Support Crate */
|
||||
INCLUDE memory.x
|
||||
|
||||
/* # Entry point = reset vector */
|
||||
EXTERN(__RESET_VECTOR);
|
||||
EXTERN(Reset);
|
||||
ENTRY(Reset);
|
||||
|
||||
/* # Exception vectors */
|
||||
/* This is effectively weak aliasing at the linker level */
|
||||
/* The user can override any of these aliases by defining the corresponding symbol themselves (cf.
|
||||
the `exception!` macro) */
|
||||
EXTERN(__EXCEPTIONS); /* depends on all the these PROVIDED symbols */
|
||||
|
||||
EXTERN(DefaultHandler);
|
||||
|
||||
PROVIDE(NonMaskableInt = DefaultHandler);
|
||||
EXTERN(HardFaultTrampoline);
|
||||
PROVIDE(MemoryManagement = DefaultHandler);
|
||||
PROVIDE(BusFault = DefaultHandler);
|
||||
PROVIDE(UsageFault = DefaultHandler);
|
||||
PROVIDE(SecureFault = DefaultHandler);
|
||||
PROVIDE(SVCall = DefaultHandler);
|
||||
PROVIDE(DebugMonitor = DefaultHandler);
|
||||
PROVIDE(PendSV = DefaultHandler);
|
||||
PROVIDE(SysTick = DefaultHandler);
|
||||
|
||||
PROVIDE(DefaultHandler = DefaultHandler_);
|
||||
PROVIDE(HardFault = HardFault_);
|
||||
|
||||
/* # Interrupt vectors */
|
||||
EXTERN(__INTERRUPTS); /* `static` variable similar to `__EXCEPTIONS` */
|
||||
|
||||
/* # Pre-initialization function */
|
||||
/* If the user overrides this using the `pre_init!` macro or by creating a `__pre_init` function,
|
||||
then the function this points to will be called before the RAM is initialized. */
|
||||
PROVIDE(__pre_init = DefaultPreInit);
|
||||
|
||||
/* # Sections */
|
||||
SECTIONS
|
||||
{
|
||||
PROVIDE(_stack_start = ORIGIN(RAM) + LENGTH(RAM));
|
||||
|
||||
/* ## Sections in RAM */
|
||||
/* ### Vector table */
|
||||
.vector_table ORIGIN(RAM) :
|
||||
{
|
||||
/* Initial Stack Pointer (SP) value */
|
||||
LONG(_stack_start);
|
||||
|
||||
/* Reset vector */
|
||||
KEEP(*(.vector_table.reset_vector)); /* this is the `__RESET_VECTOR` symbol */
|
||||
__reset_vector = .;
|
||||
|
||||
/* Exceptions */
|
||||
KEEP(*(.vector_table.exceptions)); /* this is the `__EXCEPTIONS` symbol */
|
||||
__eexceptions = .;
|
||||
|
||||
/* Device specific interrupts */
|
||||
KEEP(*(.vector_table.interrupts)); /* this is the `__INTERRUPTS` symbol */
|
||||
} > RAM
|
||||
|
||||
PROVIDE(_stext = ADDR(.vector_table) + SIZEOF(.vector_table));
|
||||
|
||||
/* ### .text */
|
||||
.text _stext :
|
||||
{
|
||||
__stext = .;
|
||||
*(.Reset);
|
||||
|
||||
*(.text .text.*);
|
||||
|
||||
/* The HardFaultTrampoline uses the `b` instruction to enter `HardFault`,
|
||||
so must be placed close to it. */
|
||||
*(.HardFaultTrampoline);
|
||||
*(.HardFault.*);
|
||||
|
||||
. = ALIGN(4); /* Pad .text to the alignment to workaround overlapping load section bug in old lld */
|
||||
__etext = .;
|
||||
} > RAM
|
||||
|
||||
/* ### .rodata */
|
||||
.rodata : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__srodata = .;
|
||||
*(.rodata .rodata.*);
|
||||
|
||||
/* 4-byte align the end (VMA) of this section.
|
||||
This is required by LLD to ensure the LMA of the following .data
|
||||
section will have the correct alignment. */
|
||||
. = ALIGN(4);
|
||||
__erodata = .;
|
||||
} > RAM
|
||||
|
||||
/* ## Sections in RAM */
|
||||
/* ### .data */
|
||||
.data : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__sdata = .;
|
||||
__edata = .;
|
||||
*(.data .data.*);
|
||||
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
|
||||
} > RAM
|
||||
/* Allow sections from user `memory.x` injected using `INSERT AFTER .data` to
|
||||
* use the .data loading mechanism by pushing __edata. Note: do not change
|
||||
* output region or load region in those user sections! */
|
||||
. = ALIGN(4);
|
||||
|
||||
/* LMA of .data */
|
||||
__sidata = LOADADDR(.data);
|
||||
|
||||
/* ### .gnu.sgstubs
|
||||
This section contains the TrustZone-M veneers put there by the Arm GNU linker. */
|
||||
/* Security Attribution Unit blocks must be 32 bytes aligned. */
|
||||
/* Note that this pads the RAM usage to 32 byte alignment. */
|
||||
.gnu.sgstubs : ALIGN(32)
|
||||
{
|
||||
. = ALIGN(32);
|
||||
__veneer_base = .;
|
||||
*(.gnu.sgstubs*)
|
||||
. = ALIGN(32);
|
||||
__veneer_limit = .;
|
||||
} > RAM
|
||||
|
||||
/* ### .bss */
|
||||
.bss (NOLOAD) : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__sbss = .;
|
||||
*(.bss .bss.*);
|
||||
*(COMMON); /* Uninitialized C statics */
|
||||
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
|
||||
} > RAM
|
||||
/* Allow sections from user `memory.x` injected using `INSERT AFTER .bss` to
|
||||
* use the .bss zeroing mechanism by pushing __ebss. Note: do not change
|
||||
* output region or load region in those user sections! */
|
||||
. = ALIGN(4);
|
||||
__ebss = .;
|
||||
|
||||
/* ### .uninit */
|
||||
.uninit (NOLOAD) : ALIGN(4)
|
||||
{
|
||||
. = ALIGN(4);
|
||||
__suninit = .;
|
||||
*(.uninit .uninit.*);
|
||||
. = ALIGN(4);
|
||||
__euninit = .;
|
||||
} > RAM
|
||||
|
||||
/* Place the heap right after `.uninit` in RAM */
|
||||
PROVIDE(__sheap = __euninit);
|
||||
|
||||
/* ## .got */
|
||||
/* Dynamic relocations are unsupported. This section is only used to detect relocatable code in
|
||||
the input files and raise an error if relocatable code is found */
|
||||
.got (NOLOAD) :
|
||||
{
|
||||
KEEP(*(.got .got.*));
|
||||
}
|
||||
|
||||
/* ## Discarded sections */
|
||||
/DISCARD/ :
|
||||
{
|
||||
/* Unused exception related info that only wastes space */
|
||||
*(.ARM.exidx);
|
||||
*(.ARM.exidx.*);
|
||||
*(.ARM.extab.*);
|
||||
}
|
||||
}
|
||||
|
||||
/* Do not exceed this mark in the error messages below | */
|
||||
/* # Alignment checks */
|
||||
ASSERT(ORIGIN(RAM) % 4 == 0, "
|
||||
ERROR(cortex-m-rt): the start of the RAM region must be 4-byte aligned");
|
||||
|
||||
ASSERT(__sdata % 4 == 0 && __edata % 4 == 0, "
|
||||
BUG(cortex-m-rt): .data is not 4-byte aligned");
|
||||
|
||||
ASSERT(__sidata % 4 == 0, "
|
||||
BUG(cortex-m-rt): the LMA of .data is not 4-byte aligned");
|
||||
|
||||
ASSERT(__sbss % 4 == 0 && __ebss % 4 == 0, "
|
||||
BUG(cortex-m-rt): .bss is not 4-byte aligned");
|
||||
|
||||
ASSERT(__sheap % 4 == 0, "
|
||||
BUG(cortex-m-rt): start of .heap is not 4-byte aligned");
|
||||
|
||||
/* # Position checks */
|
||||
|
||||
/* ## .vector_table */
|
||||
ASSERT(__reset_vector == ADDR(.vector_table) + 0x8, "
|
||||
BUG(cortex-m-rt): the reset vector is missing");
|
||||
|
||||
ASSERT(__eexceptions == ADDR(.vector_table) + 0x40, "
|
||||
BUG(cortex-m-rt): the exception vectors are missing");
|
||||
|
||||
ASSERT(SIZEOF(.vector_table) > 0x40, "
|
||||
ERROR(cortex-m-rt): The interrupt vectors are missing.
|
||||
Possible solutions, from most likely to less likely:
|
||||
- Link to a svd2rust generated device crate
|
||||
- Check that you actually use the device/hal/bsp crate in your code
|
||||
- Disable the 'device' feature of cortex-m-rt to build a generic application (a dependency
|
||||
may be enabling it)
|
||||
- Supply the interrupt handlers yourself. Check the documentation for details.");
|
||||
|
||||
/* ## .text */
|
||||
ASSERT(ADDR(.vector_table) + SIZEOF(.vector_table) <= _stext, "
|
||||
ERROR(cortex-m-rt): The .text section can't be placed inside the .vector_table section
|
||||
Set _stext to an address greater than the end of .vector_table (See output of `nm`)");
|
||||
|
||||
ASSERT(_stext + SIZEOF(.text) < ORIGIN(RAM) + LENGTH(RAM), "
|
||||
ERROR(cortex-m-rt): The .text section must be placed inside the RAM memory.
|
||||
Set _stext to an address smaller than 'ORIGIN(RAM) + LENGTH(RAM)'");
|
||||
|
||||
/* # Other checks */
|
||||
ASSERT(SIZEOF(.got) == 0, "
|
||||
ERROR(cortex-m-rt): .got section detected in the input object files
|
||||
Dynamic relocations are not supported. If you are linking to C code compiled using
|
||||
the 'cc' crate then modify your build script to compile the C code _without_
|
||||
the -fPIC flag. See the documentation of the `cc::Build.pic` method for details.");
|
||||
/* Do not exceed this mark in the error messages above | */
|
||||
|
||||
|
||||
/* Provides weak aliases (cf. PROVIDED) for device specific interrupt handlers */
|
||||
/* This will usually be provided by a device crate generated using svd2rust (see `device.x`) */
|
||||
INCLUDE device.x
|
@ -1,5 +1,7 @@
|
||||
MEMORY
|
||||
{
|
||||
FLASH : ORIGIN = 0x00000000, LENGTH = 1024K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 256K
|
||||
/* NOTE 1 K = 1 KiBi = 1024 bytes */
|
||||
/* These values correspond to the NRF52840 with Softdevices S140 7.0.1 */
|
||||
FLASH : ORIGIN = 0x00000000, LENGTH = 256K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
teleprobe_meta::target!(b"nrf52840-dk");
|
||||
teleprobe_meta::target!(b"nrf52-dk");
|
||||
|
||||
use defmt::{assert, info};
|
||||
use embassy_executor::Spawner;
|
||||
|
Loading…
Reference in New Issue
Block a user