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
This commit is contained in:
9names 2021-12-05 01:00:09 +11:00 committed by GitHub
parent 88bd408bc1
commit 0e7abdc705
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 120 additions and 135 deletions

View file

@ -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"]

View file

@ -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!(

View file

@ -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"]

View file

@ -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() -> ! {

View file

@ -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() -> ! {

View file

@ -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!(

View file

@ -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"]

View file

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

View file

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

View file

@ -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!(

View file

@ -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"]

View file

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

View file

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

View file

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

View file

@ -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]

View file

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

View file

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

View file

@ -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 {

View file

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

View file

@ -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<UsbDevice<hal::usb::UsbBus>> = None;

View file

@ -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<UsbDevice<hal::usb::UsbBus>> = None;

View file

@ -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!(

View file

@ -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"]

View file

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

View file

@ -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,

View file

@ -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"]
default = ["boot2", "rt"]
boot2 = ["rp2040-boot2"]
rt = ["cortex-m-rt","rp2040-hal/rt"]

View file

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

View file

@ -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!(

View file

@ -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"]

View file

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

View file

@ -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!(

View file

@ -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"]

View file

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

View file

@ -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!(

View file

@ -4,6 +4,8 @@ MEMORY {
RAM : ORIGIN = 0x20000000, LENGTH = 256K
}
EXTERN(BOOT2_FIRMWARE)
SECTIONS {
/* ### Boot loader */
.boot2 ORIGIN(BOOT2) :

View file

@ -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" }