From 0e7abdc7050c034b9c6100336099d3cfa95b0139 Mon Sep 17 00:00:00 2001 From: 9names <60134748+9names@users.noreply.github.com> Date: Sun, 5 Dec 2021 01:00:09 +1100 Subject: [PATCH] Make BSPs provide boot2 as a default feature (#153) * Add boot2 feature. Add boot2 linkage into each BSP optional on feature * Enable boot2 feature in BSPs by default. Remove boot2 decl from all BSP examples * Add EXTERN in memory.x for BOOT2_FIRMWARE, rename bootloader static slice to BOOT2_FIRMWARE * Update new examples and itsy_bitsy BSP to use boot2 feature * Remove boot2 as a dev-dependency for the BSPs, no longer needed * Add no_mangle BOOT2_FIRMWARE to adafruit_macropad * Fix itsy-bitsy blinky - it wasn't using the BSP, so it didn't get BOOT2_FIRMWARE linked in --- boards/adafruit_macropad/Cargo.toml | 5 ++- boards/adafruit_macropad/src/lib.rs | 10 +++++ boards/feather_rp2040/Cargo.toml | 5 ++- .../feather_rp2040/examples/feather_blinky.rs | 3 -- .../examples/feather_neopixel_rainbow.rs | 3 -- boards/feather_rp2040/src/lib.rs | 8 ++++ boards/itsy_bitsy_rp2040/Cargo.toml | 5 ++- .../examples/itsy_bitsy_blinky.rs | 45 ++++++++----------- .../examples/itsy_bitsy_rainbow.rs | 4 -- boards/itsy_bitsy_rp2040/src/lib.rs | 8 ++++ boards/pico/Cargo.toml | 5 ++- boards/pico/examples/pico_blinky.rs | 6 --- boards/pico/examples/pico_countdown_blinky.rs | 4 -- boards/pico/examples/pico_gpio_in_out.rs | 6 --- .../pico_i2c_controller_peripheral/main.rs | 4 -- boards/pico/examples/pico_i2c_pio.rs | 6 --- boards/pico/examples/pico_pwm_blink.rs | 6 --- boards/pico/examples/pico_rtic.rs | 4 -- boards/pico/examples/pico_usb_serial.rs | 6 --- .../examples/pico_usb_serial_interrupt.rs | 6 --- .../pico/examples/pico_usb_twitchy_mouse.rs | 6 --- boards/pico/src/lib.rs | 8 ++++ boards/pico_explorer/Cargo.toml | 11 ++--- .../examples/pico_explorer_showcase.rs | 4 -- boards/pico_explorer/src/lib.rs | 9 ++++ boards/pico_lipo_16mb/Cargo.toml | 8 ++-- .../examples/pico_lipo_16mb_blinky.rs | 6 --- boards/pico_lipo_16mb/src/lib.rs | 8 ++++ boards/pro_micro_rp2040/Cargo.toml | 11 ++--- .../examples/pro_micro_rainbow.rs | 6 --- boards/pro_micro_rp2040/src/lib.rs | 8 ++++ boards/qt_py_rp2040/Cargo.toml | 5 ++- boards/qt_py_rp2040/examples/qt_py_rainbow.rs | 4 -- boards/qt_py_rp2040/src/lib.rs | 8 ++++ memory.x | 2 + rp2040-hal/Cargo.toml | 2 +- 36 files changed, 120 insertions(+), 135 deletions(-) diff --git a/boards/adafruit_macropad/Cargo.toml b/boards/adafruit_macropad/Cargo.toml index 32910aa..6ceb84f 100644 --- a/boards/adafruit_macropad/Cargo.toml +++ b/boards/adafruit_macropad/Cargo.toml @@ -11,9 +11,12 @@ license = "MIT OR Apache-2.0" [dependencies] cortex-m = "0.7.2" +rp2040-boot2 = { version = "0.2.0", optional = true } rp2040-hal = { path = "../../rp2040-hal", version = "0.3.0"} cortex-m-rt = { version = "0.7", optional = true } [features] -default = ["rt"] +default = ["rt", "boot2"] +boot2 = ["rp2040-boot2"] rt = ["cortex-m-rt","rp2040-hal/rt"] + diff --git a/boards/adafruit_macropad/src/lib.rs b/boards/adafruit_macropad/src/lib.rs index 3cc1355..c3b1cfe 100644 --- a/boards/adafruit_macropad/src/lib.rs +++ b/boards/adafruit_macropad/src/lib.rs @@ -7,6 +7,16 @@ extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; +// Adafruit macropad uses W25Q64JVxQ flash chip. Should work with BOOT_LOADER_W25Q080 (untested) + +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; + pub use hal::pac; hal::bsp_pins!( diff --git a/boards/feather_rp2040/Cargo.toml b/boards/feather_rp2040/Cargo.toml index d2cb665..944fbc0 100644 --- a/boards/feather_rp2040/Cargo.toml +++ b/boards/feather_rp2040/Cargo.toml @@ -11,6 +11,7 @@ license = "MIT OR Apache-2.0" [dependencies] cortex-m = "0.7.2" +rp2040-boot2 = { version = "0.2.0", optional = true } rp2040-hal = { path = "../../rp2040-hal", version = "0.3.0"} cortex-m-rt = { version = "0.7", optional = true } embedded-time = "0.12.0" @@ -18,12 +19,12 @@ embedded-time = "0.12.0" [dev-dependencies] panic-halt= "0.2.0" embedded-hal ="0.2.5" -rp2040-boot2 = "0.2" nb = "1.0.0" smart-leds = "0.3.0" pio = { git = "https://github.com/rp-rs/pio-rs.git", branch = "main" } ws2812-pio = { git = "https://github.com/ithinuel/ws2812-pio-rs", rev = "7a11616f994025f5c99f28b283d2b25d60d46a43" } [features] -default = ["rt"] +default = ["boot2", "rt"] +boot2 = ["rp2040-boot2"] rt = ["cortex-m-rt","rp2040-hal/rt"] diff --git a/boards/feather_rp2040/examples/feather_blinky.rs b/boards/feather_rp2040/examples/feather_blinky.rs index 9bfda5d..6aba967 100644 --- a/boards/feather_rp2040/examples/feather_blinky.rs +++ b/boards/feather_rp2040/examples/feather_blinky.rs @@ -17,9 +17,6 @@ use feather_rp2040::{ Pins, XOSC_CRYSTAL_FREQ, }; use panic_halt as _; -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GD25Q64CS; #[entry] fn main() -> ! { diff --git a/boards/feather_rp2040/examples/feather_neopixel_rainbow.rs b/boards/feather_rp2040/examples/feather_neopixel_rainbow.rs index 939df16..8ea51a1 100644 --- a/boards/feather_rp2040/examples/feather_neopixel_rainbow.rs +++ b/boards/feather_rp2040/examples/feather_neopixel_rainbow.rs @@ -24,9 +24,6 @@ use panic_halt as _; use rp2040_hal::pio::PIOExt; use smart_leds::{brightness, SmartLedsWrite, RGB8}; use ws2812_pio::Ws2812; -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GD25Q64CS; #[entry] fn main() -> ! { diff --git a/boards/feather_rp2040/src/lib.rs b/boards/feather_rp2040/src/lib.rs index ec3f501..379346f 100644 --- a/boards/feather_rp2040/src/lib.rs +++ b/boards/feather_rp2040/src/lib.rs @@ -7,6 +7,14 @@ extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_GD25Q64CS; + pub use hal::pac; hal::bsp_pins!( diff --git a/boards/itsy_bitsy_rp2040/Cargo.toml b/boards/itsy_bitsy_rp2040/Cargo.toml index 7028966..731e5b9 100644 --- a/boards/itsy_bitsy_rp2040/Cargo.toml +++ b/boards/itsy_bitsy_rp2040/Cargo.toml @@ -11,6 +11,7 @@ license = "MIT OR Apache-2.0" [dependencies] cortex-m = "0.7.2" +rp2040-boot2 = { version = "0.2.0", optional = true } rp2040-hal = { path = "../../rp2040-hal", version = "0.3.0"} cortex-m-rt = { version = "0.7", optional = true } embedded-time = "0.12.0" @@ -18,12 +19,12 @@ embedded-time = "0.12.0" [dev-dependencies] panic-halt= "0.2.0" embedded-hal ="0.2.5" -rp2040-boot2 = "0.2" smart-leds = "0.3" nb = "1.0.0" pio = { git = "https://github.com/rp-rs/pio-rs.git", branch = "main" } ws2812-pio = { git = "https://github.com/ithinuel/ws2812-pio-rs", rev = "7a11616f994025f5c99f28b283d2b25d60d46a43" } [features] -default = ["rt"] +default = ["rt", "boot2"] +boot2 = ["rp2040-boot2"] rt = ["cortex-m-rt","rp2040-hal/rt"] diff --git a/boards/itsy_bitsy_rp2040/examples/itsy_bitsy_blinky.rs b/boards/itsy_bitsy_rp2040/examples/itsy_bitsy_blinky.rs index 250eb8e..9f0ff70 100644 --- a/boards/itsy_bitsy_rp2040/examples/itsy_bitsy_blinky.rs +++ b/boards/itsy_bitsy_rp2040/examples/itsy_bitsy_blinky.rs @@ -1,6 +1,6 @@ //! # GPIO 'Blinky' Example //! -//! This application demonstrates how to control a GPIO pin on the RP2040. +//! Blinks the LED on a Adafruit itsy-bitsy RP2040 board //! //! It may need to be adapted to your particular board layout and/or pin assignment. //! @@ -16,27 +16,21 @@ use cortex_m_rt::entry; // be linked) use panic_halt as _; -// Alias for our HAL crate -use rp2040_hal as hal; - -// A shorter alias for the Peripheral Access Crate, which provides low-level -// register access -use hal::pac; - // Some traits we need use embedded_hal::digital::v2::OutputPin; use embedded_time::fixed_point::FixedPoint; -use rp2040_hal::clocks::Clock; -/// The linker will place this boot block at the start of our program image. We -// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; +use itsy_bitsy_rp2040::{ + hal::{ + clocks::{init_clocks_and_plls, Clock}, + pac, + sio::Sio, + watchdog::Watchdog, + }, + Pins, XOSC_CRYSTAL_FREQ, +}; -/// External high-speed crystal on the Raspberry Pi Pico board is 12 MHz. Adjust -/// if your board has a different frequency -const XTAL_FREQ_HZ: u32 = 12_000_000u32; +use cortex_m::delay::Delay; /// Entry point to our bare-metal application. /// @@ -52,11 +46,11 @@ fn main() -> ! { let core = pac::CorePeripherals::take().unwrap(); // Set up the watchdog driver - needed by the clock setup code - let mut watchdog = hal::watchdog::Watchdog::new(pac.WATCHDOG); + let mut watchdog = Watchdog::new(pac.WATCHDOG); // Configure the clocks - let clocks = hal::clocks::init_clocks_and_plls( - XTAL_FREQ_HZ, + let clocks = init_clocks_and_plls( + XOSC_CRYSTAL_FREQ, pac.XOSC, pac.CLOCKS, pac.PLL_SYS, @@ -67,24 +61,21 @@ fn main() -> ! { .ok() .unwrap(); - let mut delay = cortex_m::delay::Delay::new(core.SYST, clocks.system_clock.freq().integer()); + let mut delay = Delay::new(core.SYST, clocks.system_clock.freq().integer()); // The single-cycle I/O block controls our GPIO pins - let sio = hal::sio::Sio::new(pac.SIO); + let sio = Sio::new(pac.SIO); - // Set the pins to their default state - let pins = hal::gpio::Pins::new( + let pins = Pins::new( pac.IO_BANK0, pac.PADS_BANK0, sio.gpio_bank0, &mut pac.RESETS, ); + let mut led_pin = pins.d13.into_push_pull_output(); - // Configure GPIO25 as an output - let mut led_pin = pins.gpio11.into_push_pull_output(); loop { led_pin.set_high().unwrap(); - // TODO: Replace with proper 1s delays once we have clocks working delay.delay_ms(500); led_pin.set_low().unwrap(); delay.delay_ms(500); diff --git a/boards/itsy_bitsy_rp2040/examples/itsy_bitsy_rainbow.rs b/boards/itsy_bitsy_rp2040/examples/itsy_bitsy_rainbow.rs index 34089d2..0ba776d 100644 --- a/boards/itsy_bitsy_rp2040/examples/itsy_bitsy_rainbow.rs +++ b/boards/itsy_bitsy_rp2040/examples/itsy_bitsy_rainbow.rs @@ -22,10 +22,6 @@ use itsy_bitsy_rp2040::{ Pins, XOSC_CRYSTAL_FREQ, }; -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - #[entry] fn main() -> ! { let mut pac = pac::Peripherals::take().unwrap(); diff --git a/boards/itsy_bitsy_rp2040/src/lib.rs b/boards/itsy_bitsy_rp2040/src/lib.rs index 79a4680..e7c52e3 100644 --- a/boards/itsy_bitsy_rp2040/src/lib.rs +++ b/boards/itsy_bitsy_rp2040/src/lib.rs @@ -7,6 +7,14 @@ extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; + pub use hal::pac; hal::bsp_pins!( diff --git a/boards/pico/Cargo.toml b/boards/pico/Cargo.toml index 7c2bfd0..ac313a1 100644 --- a/boards/pico/Cargo.toml +++ b/boards/pico/Cargo.toml @@ -11,6 +11,7 @@ license = "MIT OR Apache-2.0" [dependencies] cortex-m = "0.7.2" +rp2040-boot2 = { version = "0.2.0", optional = true } rp2040-hal = { path = "../../rp2040-hal", version = "0.3.0"} cortex-m-rt = { version = "0.7", optional = true } embedded-time = "0.12.0" @@ -36,12 +37,12 @@ optional = true panic-halt= "0.2.0" embedded-hal ="0.2.5" cortex-m-rtic = "0.6.0-alpha.5" -rp2040-boot2 = "0.2" nb = "1.0" i2c-pio = { git = "https://github.com/ithinuel/i2c-pio-rs", rev = "fb6167d02b7fbc46a83f344f5242823bcd16e271" } [features] -default = ["rt"] +default = ["boot2", "rt"] +boot2 = ["rp2040-boot2"] rt = ["cortex-m-rt","rp2040-hal/rt"] embassy-traits = ["futures", "embassy", "embassy_traits"] diff --git a/boards/pico/examples/pico_blinky.rs b/boards/pico/examples/pico_blinky.rs index f4630aa..eb2e1bd 100644 --- a/boards/pico/examples/pico_blinky.rs +++ b/boards/pico/examples/pico_blinky.rs @@ -34,12 +34,6 @@ use pico::hal::pac; // higher-level drivers. use pico::hal; -//// The linker will place this boot block at the start of our program image. We -//// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - /// Entry point to our bare-metal application. /// /// The `#[entry]` macro ensures the Cortex-M start-up code calls this function diff --git a/boards/pico/examples/pico_countdown_blinky.rs b/boards/pico/examples/pico_countdown_blinky.rs index 0233d7d..209e9f3 100644 --- a/boards/pico/examples/pico_countdown_blinky.rs +++ b/boards/pico/examples/pico_countdown_blinky.rs @@ -33,10 +33,6 @@ use pico::hal::pac; // higher-level drivers. use pico::hal; -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - #[entry] fn main() -> ! { // Grab our singleton objects diff --git a/boards/pico/examples/pico_gpio_in_out.rs b/boards/pico/examples/pico_gpio_in_out.rs index a91fc16..fa79c88 100644 --- a/boards/pico/examples/pico_gpio_in_out.rs +++ b/boards/pico/examples/pico_gpio_in_out.rs @@ -30,12 +30,6 @@ use pico::hal::pac; // higher-level drivers. use pico::hal; -//// The linker will place this boot block at the start of our program image. We -//// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - /// Entry point to our bare-metal application. /// /// The `#[entry]` macro ensures the Cortex-M start-up code calls this function diff --git a/boards/pico/examples/pico_i2c_controller_peripheral/main.rs b/boards/pico/examples/pico_i2c_controller_peripheral/main.rs index 814b9e9..4cfa374 100644 --- a/boards/pico/examples/pico_i2c_controller_peripheral/main.rs +++ b/boards/pico/examples/pico_i2c_controller_peripheral/main.rs @@ -41,10 +41,6 @@ use panic_halt as _; mod controller; mod peripheral; -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - const ADDRESS: u16 = 0x55; #[embassy::task] diff --git a/boards/pico/examples/pico_i2c_pio.rs b/boards/pico/examples/pico_i2c_pio.rs index 43db613..774fdb7 100644 --- a/boards/pico/examples/pico_i2c_pio.rs +++ b/boards/pico/examples/pico_i2c_pio.rs @@ -38,12 +38,6 @@ use pico::hal::pac; // higher-level drivers. use pico::hal; -//// The linker will place this boot block at the start of our program image. We -//// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - /// Prints the temperature received from the sensor fn print_temperature(serial: &mut impl FmtWrite, temp: [u8; 2]) { let temp_i16 = i16::from_be_bytes(temp) >> 5; diff --git a/boards/pico/examples/pico_pwm_blink.rs b/boards/pico/examples/pico_pwm_blink.rs index 657e1de..2e06aa1 100644 --- a/boards/pico/examples/pico_pwm_blink.rs +++ b/boards/pico/examples/pico_pwm_blink.rs @@ -34,12 +34,6 @@ use pico::hal::pac; // higher-level drivers. use pico::hal; -//// The linker will place this boot block at the start of our program image. We -//// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - // The minimum PWM value (i.e. LED brightness) we want const LOW: u16 = 0; diff --git a/boards/pico/examples/pico_rtic.rs b/boards/pico/examples/pico_rtic.rs index 44704c8..9c4d903 100644 --- a/boards/pico/examples/pico_rtic.rs +++ b/boards/pico/examples/pico_rtic.rs @@ -4,10 +4,6 @@ use panic_halt as _; use rp2040_hal as hal; -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - #[rtic::app(device = crate::hal::pac, peripherals = true)] mod app { diff --git a/boards/pico/examples/pico_usb_serial.rs b/boards/pico/examples/pico_usb_serial.rs index f337705..c1fe02b 100644 --- a/boards/pico/examples/pico_usb_serial.rs +++ b/boards/pico/examples/pico_usb_serial.rs @@ -33,12 +33,6 @@ use usb_device::{class_prelude::*, prelude::*}; // USB Communications Class Device support use usbd_serial::SerialPort; -//// The linker will place this boot block at the start of our program image. We -//// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - /// Entry point to our bare-metal application. /// /// The `#[entry]` macro ensures the Cortex-M start-up code calls this function diff --git a/boards/pico/examples/pico_usb_serial_interrupt.rs b/boards/pico/examples/pico_usb_serial_interrupt.rs index 6cbc00f..84739a5 100644 --- a/boards/pico/examples/pico_usb_serial_interrupt.rs +++ b/boards/pico/examples/pico_usb_serial_interrupt.rs @@ -45,12 +45,6 @@ use usb_device::{class_prelude::*, prelude::*}; // USB Communications Class Device support use usbd_serial::SerialPort; -//// The linker will place this boot block at the start of our program image. We -//// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - /// The USB Device Driver (shared with the interrupt). static mut USB_DEVICE: Option> = None; diff --git a/boards/pico/examples/pico_usb_twitchy_mouse.rs b/boards/pico/examples/pico_usb_twitchy_mouse.rs index a160a3a..ca08191 100644 --- a/boards/pico/examples/pico_usb_twitchy_mouse.rs +++ b/boards/pico/examples/pico_usb_twitchy_mouse.rs @@ -44,12 +44,6 @@ use usbd_hid::descriptor::generator_prelude::*; use usbd_hid::descriptor::MouseReport; use usbd_hid::hid_class::HIDClass; -//// The linker will place this boot block at the start of our program image. We -//// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - /// The USB Device Driver (shared with the interrupt). static mut USB_DEVICE: Option> = None; diff --git a/boards/pico/src/lib.rs b/boards/pico/src/lib.rs index 8fa255e..49f9946 100644 --- a/boards/pico/src/lib.rs +++ b/boards/pico/src/lib.rs @@ -7,6 +7,14 @@ extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; + pub use hal::pac; hal::bsp_pins!( diff --git a/boards/pico_explorer/Cargo.toml b/boards/pico_explorer/Cargo.toml index a693d47..58d1575 100644 --- a/boards/pico_explorer/Cargo.toml +++ b/boards/pico_explorer/Cargo.toml @@ -18,14 +18,15 @@ st7789 = "0.6.1" display-interface-spi = "0.4.1" embedded-time = "0.12.0" embedded-graphics = "0.7.1" - -[features] -default = ["rt"] -rt = ["cortex-m-rt","rp2040-hal/rt"] +rp2040-boot2 = { version = "0.2.0", optional = true } [dev-dependencies] display-interface = "0.4.1" panic-halt = "0.2.0" arrayvec = { version="0.7.1", default-features=false } -rp2040-boot2 = "0.2" nb = "1.0.0" + +[features] +default = ["boot2", "rt"] +boot2 = ["rp2040-boot2"] +rt = ["cortex-m-rt","rp2040-hal/rt"] diff --git a/boards/pico_explorer/examples/pico_explorer_showcase.rs b/boards/pico_explorer/examples/pico_explorer_showcase.rs index 1643752..701b2f7 100644 --- a/boards/pico_explorer/examples/pico_explorer_showcase.rs +++ b/boards/pico_explorer/examples/pico_explorer_showcase.rs @@ -16,10 +16,6 @@ use hal::{adc::Adc, clocks::*, sio::Sio, watchdog::Watchdog}; use panic_halt as _; use pico_explorer::{hal, pac, Button, PicoExplorer, XOSC_CRYSTAL_FREQ}; -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - // See 4.9.5 from RP2040 datasheet fn calc_temp(adc_value: f32, refv: f64) -> f64 { let vbe: f64 = f64::from(adc_value) * refv; diff --git a/boards/pico_explorer/src/lib.rs b/boards/pico_explorer/src/lib.rs index 5c5b58d..5e1547f 100644 --- a/boards/pico_explorer/src/lib.rs +++ b/boards/pico_explorer/src/lib.rs @@ -7,6 +7,15 @@ extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; + +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; + use display_interface_spi::SPIInterface; use embedded_graphics::{ draw_target::DrawTarget, diff --git a/boards/pico_lipo_16mb/Cargo.toml b/boards/pico_lipo_16mb/Cargo.toml index 0e24538..e834c9a 100644 --- a/boards/pico_lipo_16mb/Cargo.toml +++ b/boards/pico_lipo_16mb/Cargo.toml @@ -13,16 +13,16 @@ license = "MIT OR Apache-2.0" cortex-m = "0.7.2" rp2040-hal = { path = "../../rp2040-hal", version = "0.3.0"} cortex-m-rt = { version = "0.7", optional = true } +rp2040-boot2 = { version = "0.2.0", optional = true } [dev-dependencies] embedded-time = "0.12.0" panic-halt= "0.2.0" embedded-hal ="0.2.5" cortex-m-rtic = "0.6.0-alpha.5" -rp2040-boot2 = "0.2" nb = "1.0" - [features] -default = ["rt"] -rt = ["cortex-m-rt","rp2040-hal/rt"] \ No newline at end of file +default = ["boot2", "rt"] +boot2 = ["rp2040-boot2"] +rt = ["cortex-m-rt","rp2040-hal/rt"] diff --git a/boards/pico_lipo_16mb/examples/pico_lipo_16mb_blinky.rs b/boards/pico_lipo_16mb/examples/pico_lipo_16mb_blinky.rs index f2813f6..1a5c976 100644 --- a/boards/pico_lipo_16mb/examples/pico_lipo_16mb_blinky.rs +++ b/boards/pico_lipo_16mb/examples/pico_lipo_16mb_blinky.rs @@ -34,12 +34,6 @@ use pico_lipo_16_mb::hal::pac; // higher-level drivers. use pico_lipo_16_mb::hal; -//// The linker will place this boot block at the start of our program image. We -//// need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - /// Entry point to our bare-metal application. /// /// The `#[entry]` macro ensures the Cortex-M start-up code calls this function diff --git a/boards/pico_lipo_16mb/src/lib.rs b/boards/pico_lipo_16mb/src/lib.rs index 2d1616c..ebe0952 100644 --- a/boards/pico_lipo_16mb/src/lib.rs +++ b/boards/pico_lipo_16mb/src/lib.rs @@ -7,6 +7,14 @@ extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; + pub use hal::pac; hal::bsp_pins!( diff --git a/boards/pro_micro_rp2040/Cargo.toml b/boards/pro_micro_rp2040/Cargo.toml index 50b6c9f..82b68a4 100644 --- a/boards/pro_micro_rp2040/Cargo.toml +++ b/boards/pro_micro_rp2040/Cargo.toml @@ -14,16 +14,17 @@ cortex-m = "0.7.2" rp2040-hal = { path = "../../rp2040-hal", version = "0.3.0" } cortex-m-rt = { version = "0.7.0", optional = true } embedded-hal = { version = "0.2.4", features = ["unproven"] } - -[features] -default = ["rt"] -rt = ["cortex-m-rt", "rp2040-hal/rt"] +rp2040-boot2 = { version = "0.2.0", optional = true } [dev-dependencies] panic-halt = "0.2.0" -rp2040-boot2 = "0.2" smart-leds = "0.3.0" embedded-time = "0.12.0" nb = "1.0.0" pio = { git = "https://github.com/rp-rs/pio-rs.git", branch = "main" } ws2812-pio = { git = "https://github.com/ithinuel/ws2812-pio-rs", rev = "7a11616f994025f5c99f28b283d2b25d60d46a43" } + +[features] +default = ["boot2", "rt"] +boot2 = ["rp2040-boot2"] +rt = ["cortex-m-rt","rp2040-hal/rt"] diff --git a/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs b/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs index 0e8ab28..899f2ec 100644 --- a/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs +++ b/boards/pro_micro_rp2040/examples/pro_micro_rainbow.rs @@ -28,12 +28,6 @@ use rp2040_hal::pio::PIOExt; use smart_leds::{brightness, SmartLedsWrite, RGB8}; use ws2812_pio::Ws2812; -//// The linker will place this boot block at the start of our program image. -/// We need this to help the ROM bootloader get our code up and running. -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; - /// Entry point to our bare-metal application. /// /// The `#[entry]` macro ensures the Cortex-M start-up code calls this diff --git a/boards/pro_micro_rp2040/src/lib.rs b/boards/pro_micro_rp2040/src/lib.rs index e7dd0db..5370630 100644 --- a/boards/pro_micro_rp2040/src/lib.rs +++ b/boards/pro_micro_rp2040/src/lib.rs @@ -6,6 +6,14 @@ extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_W25Q080; + pub use hal::pac; hal::bsp_pins!( diff --git a/boards/qt_py_rp2040/Cargo.toml b/boards/qt_py_rp2040/Cargo.toml index 0c66edb..a38b122 100644 --- a/boards/qt_py_rp2040/Cargo.toml +++ b/boards/qt_py_rp2040/Cargo.toml @@ -14,16 +14,17 @@ cortex-m = "0.7.2" rp2040-hal = { path = "../../rp2040-hal", version = "0.3.0"} cortex-m-rt = { version = "0.7", optional = true } embedded-time = "0.12.0" +rp2040-boot2 = { version = "0.2.0", optional = true } [dev-dependencies] panic-halt= "0.2.0" embedded-hal ="0.2.5" -rp2040-boot2 = "0.2" smart-leds = "0.3" nb = "1.0.0" pio = { git = "https://github.com/rp-rs/pio-rs.git", branch = "main" } ws2812-pio = { git = "https://github.com/ithinuel/ws2812-pio-rs", rev = "7a11616f994025f5c99f28b283d2b25d60d46a43" } [features] -default = ["rt"] +default = ["boot2", "rt"] +boot2 = ["rp2040-boot2"] rt = ["cortex-m-rt","rp2040-hal/rt"] diff --git a/boards/qt_py_rp2040/examples/qt_py_rainbow.rs b/boards/qt_py_rp2040/examples/qt_py_rainbow.rs index 3edb1b2..47cf261 100644 --- a/boards/qt_py_rp2040/examples/qt_py_rainbow.rs +++ b/boards/qt_py_rp2040/examples/qt_py_rainbow.rs @@ -22,10 +22,6 @@ use qt_py_rp2040::{ Pins, XOSC_CRYSTAL_FREQ, }; -#[link_section = ".boot2"] -#[used] -pub static BOOT2: [u8; 256] = rp2040_boot2::BOOT_LOADER_GD25Q64CS; - #[entry] fn main() -> ! { let mut pac = pac::Peripherals::take().unwrap(); diff --git a/boards/qt_py_rp2040/src/lib.rs b/boards/qt_py_rp2040/src/lib.rs index 218b69c..c32c2bd 100644 --- a/boards/qt_py_rp2040/src/lib.rs +++ b/boards/qt_py_rp2040/src/lib.rs @@ -7,6 +7,14 @@ extern crate cortex_m_rt; #[cfg(feature = "rt")] pub use cortex_m_rt::entry; +//// The linker will place this boot block at the start of our program image. We +//// need this to help the ROM bootloader get our code up and running. +#[cfg(feature = "boot2")] +#[link_section = ".boot2"] +#[no_mangle] +#[used] +pub static BOOT2_FIRMWARE: [u8; 256] = rp2040_boot2::BOOT_LOADER_GD25Q64CS; + pub use hal::pac; hal::bsp_pins!( diff --git a/memory.x b/memory.x index 23918e1..4077aab 100644 --- a/memory.x +++ b/memory.x @@ -4,6 +4,8 @@ MEMORY { RAM : ORIGIN = 0x20000000, LENGTH = 256K } +EXTERN(BOOT2_FIRMWARE) + SECTIONS { /* ### Boot loader */ .boot2 ORIGIN(BOOT2) : diff --git a/rp2040-hal/Cargo.toml b/rp2040-hal/Cargo.toml index a511954..542dba1 100644 --- a/rp2040-hal/Cargo.toml +++ b/rp2040-hal/Cargo.toml @@ -39,7 +39,7 @@ optional = true [dev-dependencies] cortex-m-rt = "0.7" panic-halt = "0.2.0" -rp2040-boot2 = "0.2" +rp2040-boot2 = "0.2.0" hd44780-driver = "0.4.0" pio-proc = { git = "https://github.com/rp-rs/pio-rs.git", branch = "main" }