From 0e3cd87a323c464842ea66eeaf7b6da00d70d300 Mon Sep 17 00:00:00 2001 From: pennae Date: Tue, 9 May 2023 18:36:17 +0200 Subject: [PATCH] rp: use rp2040-boot2 to provide the boot2 blob we're currently shipping an old boot2 that runs the flash at half speed. use the more recent version instead, and allow user to choose between the different supported boot2 versions for different flash chips if they need that. --- embassy-rp/Cargo.toml | 10 ++++++++++ embassy-rp/src/boot2.bin | Bin 256 -> 0 bytes embassy-rp/src/lib.rs | 29 ++++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) delete mode 100644 embassy-rp/src/boot2.bin diff --git a/embassy-rp/Cargo.toml b/embassy-rp/Cargo.toml index 59d0bf33..28a35a1b 100644 --- a/embassy-rp/Cargo.toml +++ b/embassy-rp/Cargo.toml @@ -30,6 +30,15 @@ rom-func-cache = [] intrinsics = [] rom-v2-intrinsics = [] +# boot2 flash chip support. if none of these is enabled we'll default to w25q080 (used on the pico) +boot2-at25sf128a = [] +boot2-gd25q64cs = [] +boot2-generic-03h = [] +boot2-is25lp080 = [] +boot2-ram-memcpy = [] +boot2-w25q080 = [] +boot2-w25x10cl = [] + # Enable nightly-only features nightly = ["embassy-executor/nightly", "embedded-hal-1", "embedded-hal-async", "embassy-embedded-hal/nightly", "dep:embassy-usb-driver", "dep:embedded-io"] @@ -71,3 +80,4 @@ embedded-hal-nb = { version = "=1.0.0-alpha.2", optional = true} paste = "1.0" pio-proc = {version= "0.2" } pio = {version= "0.2.1" } +rp2040-boot2 = "0.3" diff --git a/embassy-rp/src/boot2.bin b/embassy-rp/src/boot2.bin deleted file mode 100644 index fdc1fc756b0e876b93b99f5475bea32902b13656..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 256 zcmZSBYUHh`5Rot=gGsT&c}BvG1c}6mL_Kc?#hD2#ijj$oiXW6_255UqCNKg;OcfYD zxcp#Jn&2dIflW~|jp2jI56L`65KBQKO$x}@0rEkR6{u4G2csf~)6a__v!sD0FepYQ zNO?+oFoMl`4b-&&Y=+PekP0zR5vUB~9tI7D3k>c;9>Sg+3Ct%NK67+%xHE5^nZ=^O z==A#nBar-Yk$ErER*5u;wEy2f{g=p-$Ya{ez`*3dz`!8Ez`)MHz#Pw@sKmhV1;|%Y XU|7Jw$RNP+mf-z53y?sZ3 diff --git a/embassy-rp/src/lib.rs b/embassy-rp/src/lib.rs index cba7559d..99f62738 100644 --- a/embassy-rp/src/lib.rs +++ b/embassy-rp/src/lib.rs @@ -131,9 +131,32 @@ embassy_hal_common::peripherals! { WATCHDOG, } -#[link_section = ".boot2"] -#[used] -static BOOT2: [u8; 256] = *include_bytes!("boot2.bin"); +macro_rules! select_bootloader { + ( $( $feature:literal => $loader:ident, )+ default => $default:ident ) => { + $( + #[cfg(feature = $feature)] + #[link_section = ".boot2"] + #[used] + static BOOT2: [u8; 256] = rp2040_boot2::$loader; + )* + + #[cfg(not(any( $( feature = $feature),* )))] + #[link_section = ".boot2"] + #[used] + static BOOT2: [u8; 256] = rp2040_boot2::$default; + } +} + +select_bootloader! { + "boot2-at25sf128a" => BOOT_LOADER_AT25SF128A, + "boot2-gd25q64cs" => BOOT_LOADER_GD25Q64CS, + "boot2-generic-03h" => BOOT_LOADER_GENERIC_03H, + "boot2-is25lp080" => BOOT_LOADER_IS25LP080, + "boot2-ram-memcpy" => BOOT_LOADER_RAM_MEMCPY, + "boot2-w25q080" => BOOT_LOADER_W25Q080, + "boot2-w25x10cl" => BOOT_LOADER_W25X10CL, + default => BOOT_LOADER_W25Q080 +} pub mod config { #[non_exhaustive]