Skip to content

Commit

Permalink
Get firmware from cyw43 driver
Browse files Browse the repository at this point in the history
  • Loading branch information
jannic committed Sep 8, 2022
1 parent a81cc29 commit 14922a8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 73 deletions.
2 changes: 1 addition & 1 deletion boards/rp-pico-w/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ default = ["boot2", "rt", "critical-section-impl"]
critical-section-impl = ["rp2040-hal/critical-section-impl"]
boot2 = ["rp2040-boot2"]
rt = ["cortex-m-rt","rp2040-hal/rt"]
fix_fw = []
fix_fw = ["cyw43/fix_fw"]
Binary file removed boards/rp-pico-w/examples/firmware/43439A0.bin
Binary file not shown.
Binary file removed boards/rp-pico-w/examples/firmware/43439A0_clm.bin
Binary file not shown.

This file was deleted.

5 changes: 0 additions & 5 deletions boards/rp-pico-w/examples/firmware/README.md

This file was deleted.

28 changes: 10 additions & 18 deletions boards/rp-pico-w/examples/pico_w_blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,9 @@ use embassy_executor::Spawner;
use embassy_net::Stack;
use embassy_time::{Duration, Timer};

/// The function configures the RP2040 peripherals, then blinks the LED in an
/// infinite loop.
/// The function configures the RP2040 peripherals, initializes
/// networking, then blinks the LED in an infinite loop.
/// TODO: add some simple network service
#[entry]
fn main() -> ! {
info!("start");
Expand Down Expand Up @@ -89,15 +90,17 @@ fn main() -> ! {
});
}

// TODO documentation
unsafe fn forever_mut<T>(r: &'_ mut T) -> &'static mut T {
core::mem::transmute(r)
}

// TODO documentation
unsafe fn forever<T>(r: &'_ T) -> &'static T {
core::mem::transmute(r)
}

async fn run(spawner: Spawner, pins: rp_pico_w::Pins, state: &'static cyw43::State) {
async fn run(spawner: Spawner, pins: rp_pico_w::Pins, state: &'static cyw43::State) -> ! {
// These are implicitly used by the spi driver if they are in the correct mode
let mut spi_cs: hal::gpio::dynpin::DynPin = pins.wl_cs.into();
// TODO should be high from the beginning :-(
Expand All @@ -120,19 +123,8 @@ async fn run(spawner: Spawner, pins: rp_pico_w::Pins, state: &'static cyw43::Sta

let pwr = pins.wl_on.into_push_pull_output();

#[cfg(not(feature = "fix_fw"))]
let fw = include_bytes!("firmware/43439A0.bin");
#[cfg(not(feature = "fix_fw"))]
let clm = include_bytes!("firmware/43439A0_clm.bin");

// To make flashing faster for development, you may want to flash the firmwares independently
// at hardcoded addresses, instead of baking them into the program with `include_bytes!`:
// probe-rs-cli download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
// probe-rs-cli download 43439A0.clm_blob --format bin --chip RP2040 --base-address 0x10140000
#[cfg(feature = "fix_fw")]
let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 224190) };
#[cfg(feature = "fix_fw")]
let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
let fw = cyw43::firmware::firmware();
let clm = cyw43::firmware::clm();

use embassy_futures::yield_now;
yield_now().await;
Expand Down Expand Up @@ -191,10 +183,10 @@ async fn run(spawner: Spawner, pins: rp_pico_w::Pins, state: &'static cyw43::Sta
loop {
info!("on");
control.gpio_set(0, true).await;
Timer::after(Duration::from_millis(200)).await;
Timer::after(Duration::from_millis(500)).await;

info!("off");
control.gpio_set(0, false).await;
Timer::after(Duration::from_millis(200)).await;
Timer::after(Duration::from_millis(500)).await;
}
}

0 comments on commit 14922a8

Please sign in to comment.