diff --git a/Cargo.toml b/Cargo.toml index 95c8119..d307c25 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,9 +3,6 @@ name = "rp" version = "0.1.0" edition = "2021" -[workspace] -members = ["bootloader"] - [dependencies] cortex-m = { version = "0.7", features = ["inline-asm"] } cortex-m-rt = "0.7" diff --git a/bootloader/Cargo.toml b/bootloader/Cargo.toml deleted file mode 100644 index 3332d96..0000000 --- a/bootloader/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "bootloader" -version = "0.1.0" -edition = "2021" - -[dependencies] -defmt = { version = "0.3", optional = true } -defmt-rtt = { version = "0.4", optional = true } - -embassy-rp = { version = "0.1", features = ["nightly"] } -embassy-boot-rp = { version = "0.1" } -embassy-sync = { version = "0.2" } -embassy-time = { version = "0.1", features = ["nightly"] } - -cortex-m = { version = "0.7", features = [ - "inline-asm", - "critical-section-single-core", -] } -cortex-m-rt = { version = "0.7" } -embedded-storage = "0.3.0" - -[features] -defmt = ["dep:defmt", "embassy-boot-rp/defmt", "embassy-rp/defmt"] -debug = ["defmt-rtt", "defmt"] diff --git a/bootloader/build.rs b/bootloader/build.rs deleted file mode 100644 index 07d2655..0000000 --- a/bootloader/build.rs +++ /dev/null @@ -1,36 +0,0 @@ -use std::env; -use std::fs::File; -use std::io::Write; -use std::path::PathBuf; - -fn main() { - let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); - - // By default cortex-m-rt expects memory.x, however this causes issues with workspaces as it - // will pick the first file that is found. - // In order to get around this we make a dummy memory.x file - File::create(out.join("memory.x")).unwrap(); - - // Use memory.x.in as a template for the actual memory.x - let memory = include_str!("../memory.x.in") - .replace("{BOOTLOADER}", "FLASH") - .replace("{ACTIVE}", "ACTIVE"); - - // And then include it with a unique name - File::create(out.join("memory_boot.x")) - .unwrap() - .write_all(memory.as_bytes()) - .unwrap(); - println!("cargo:rustc-link-search={}", out.display()); - println!("cargo:rerun-if-changed=../memory.x.in"); - - // And link with that one - println!("cargo:rustc-link-arg-bins=-Tmemory_boot.x"); - - println!("cargo:rustc-link-arg-bins=--nmagic"); - println!("cargo:rustc-link-arg-bins=-Tlink.x"); - println!("cargo:rustc-link-arg-bins=-Tlink-rp.x"); - if env::var("CARGO_FEATURE_DEFMT").is_ok() { - println!("cargo:rustc-link-arg-bins=-Tdefmt.x"); - } -} diff --git a/bootloader/src/main.rs b/bootloader/src/main.rs deleted file mode 100644 index b14e444..0000000 --- a/bootloader/src/main.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![no_std] -#![no_main] - -use core::cell::RefCell; - -use cortex_m_rt::{entry, exception}; -#[cfg(feature = "defmt")] -use defmt_rtt as _; -use embassy_boot_rp::*; -use embassy_rp::flash::{Blocking, Flash}; -use embassy_sync::blocking_mutex::Mutex; - -const FLASH_SIZE: usize = 2 * 1024 * 1024; - -#[entry] -fn main() -> ! { - let p = embassy_rp::init(Default::default()); - - let flash = Flash::<_, Blocking, FLASH_SIZE>::new_blocking(p.FLASH); - let flash = Mutex::new(RefCell::new(flash)); - - let config = BootLoaderConfig::from_linkerfile_blocking(&flash); - let active_offset = config.active.offset(); - let bl: BootLoader = BootLoader::prepare(config); - - unsafe { bl.load(embassy_rp::flash::FLASH_BASE as u32 + active_offset) } -} - -#[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(); -}