Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use cyw43 FW file size instead of magic numbers #3575

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions examples/rp/src/bin/bluetooth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,13 @@ async fn main(spawner: Spawner) {
// probe-rs download 43439A0.bin --format bin --chip RP2040 --base-address 0x10100000
// probe-rs download 43439A0_clm.bin --format bin --chip RP2040 --base-address 0x10140000
// probe-rs download 43439A0_btfw.bin --format bin --chip RP2040 --base-address 0x10141400
//let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 224190) };
//let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
//let btfw = unsafe { core::slice::from_raw_parts(0x10141400 as *const u8, 6164) };
//
//const FW_SZ:usize = include_bytes!("../../../../cyw43-firmware/43439A0.bin").len();
//const CLM_SZ:usize = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin").len();
//const BTFW_SZ:usize = include_bytes!("../../../../cyw43-firmware/43439A0_btfw.bin").len();
//let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, FW_SZ) };
//let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, CLM_SZ) };
//let btfw = unsafe { core::slice::from_raw_parts(0x10141400 as *const u8, BTFW_SZ) };

let pwr = Output::new(p.PIN_23, Level::Low);
let cs = Output::new(p.PIN_25, Level::High);
Expand Down
11 changes: 7 additions & 4 deletions examples/rp/src/bin/wifi_ap_tcp_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@ async fn main(spawner: Spawner) {

// 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 download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x10100000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x10140000
//let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
//let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
// probe-rs download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x101b0000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x101f8000
//
//const FW_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0.bin").len();
//const CLM_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin").len();
//let fw = unsafe { core::slice::from_raw_parts(0x101b0000 as *const u8, FW_SZ) };
//let clm = unsafe { core::slice::from_raw_parts(0x101f8000 as *const u8, CLM_SZ) };

let pwr = Output::new(p.PIN_23, Level::Low);
let cs = Output::new(p.PIN_25, Level::High);
Expand Down
11 changes: 7 additions & 4 deletions examples/rp/src/bin/wifi_blinky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,13 @@ async fn main(spawner: Spawner) {

// 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 download ../../cyw43-firmware/43439A0.bin --binary-format bin --chip RP2040 --base-address 0x10100000
// probe-rs download ../../cyw43-firmware/43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x10140000
//let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
//let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
// probe-rs download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x101b0000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x101f8000
//
//const FW_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0.bin").len();
//const CLM_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin").len();
//let fw = unsafe { core::slice::from_raw_parts(0x101b0000 as *const u8, FW_SZ) };
//let clm = unsafe { core::slice::from_raw_parts(0x101f8000 as *const u8, CLM_SZ) };

let pwr = Output::new(p.PIN_23, Level::Low);
let cs = Output::new(p.PIN_25, Level::High);
Expand Down
11 changes: 7 additions & 4 deletions examples/rp/src/bin/wifi_scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,13 @@ async fn main(spawner: Spawner) {

// 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 download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x10100000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x10140000
//let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
//let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
// probe-rs download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x101b0000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x101f8000
//
//const FW_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0.bin").len();
//const CLM_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin").len();
//let fw = unsafe { core::slice::from_raw_parts(0x101b0000 as *const u8, FW_SZ) };
//let clm = unsafe { core::slice::from_raw_parts(0x101f8000 as *const u8, CLM_SZ) };

let pwr = Output::new(p.PIN_23, Level::Low);
let cs = Output::new(p.PIN_25, Level::High);
Expand Down
11 changes: 7 additions & 4 deletions examples/rp/src/bin/wifi_tcp_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,13 @@ async fn main(spawner: Spawner) {

// 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 download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x10100000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x10140000
//let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
//let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
// probe-rs download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x101b0000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x101f8000
//
//const FW_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0.bin").len();
//const CLM_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin").len();
//let fw = unsafe { core::slice::from_raw_parts(0x101b0000 as *const u8, FW_SZ) };
//let clm = unsafe { core::slice::from_raw_parts(0x101f8000 as *const u8, CLM_SZ) };

let pwr = Output::new(p.PIN_23, Level::Low);
let cs = Output::new(p.PIN_25, Level::High);
Expand Down
12 changes: 8 additions & 4 deletions examples/rp/src/bin/wifi_webrequest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@ async fn main(spawner: Spawner) {

let fw = include_bytes!("../../../../cyw43-firmware/43439A0.bin");
let clm = include_bytes!("../../../../cyw43-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 download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x10100000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x10140000
// let fw = unsafe { core::slice::from_raw_parts(0x10100000 as *const u8, 230321) };
// let clm = unsafe { core::slice::from_raw_parts(0x10140000 as *const u8, 4752) };
// probe-rs download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x101b0000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x101f8000
//
//const FW_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0.bin").len();
//const CLM_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin").len();
//let fw = unsafe { core::slice::from_raw_parts(0x101b0000 as *const u8, FW_SZ) };
//let clm = unsafe { core::slice::from_raw_parts(0x101f8000 as *const u8, CLM_SZ) };

let pwr = Output::new(p.PIN_23, Level::Low);
let cs = Output::new(p.PIN_25, Level::High);
Expand Down
13 changes: 10 additions & 3 deletions tests/rp/src/bin/cyw43-perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ teleprobe_meta::target!(b"rpi-pico");

use cyw43::JoinOptions;
use cyw43_pio::PioSpi;
use defmt::{panic, *};
use defmt::{assert, info, panic, unwrap};
use embassy_executor::Spawner;
use embassy_net::{Config, StackResources};
use embassy_rp::gpio::{Level, Output};
Expand Down Expand Up @@ -48,8 +48,15 @@ async fn main(spawner: Spawner) {
// cyw43 firmware needs to be flashed manually:
// probe-rs download 43439A0.bin --binary-format bin --chip RP2040 --base-address 0x101b0000
// probe-rs download 43439A0_clm.bin --binary-format bin --chip RP2040 --base-address 0x101f8000
let fw = unsafe { core::slice::from_raw_parts(0x101b0000 as *const u8, 230321) };
let clm = unsafe { core::slice::from_raw_parts(0x101f8000 as *const u8, 4752) };

const FW_ADDR: usize = 0x101b0000;
const CLM_ADDR: usize = 0x101f8000;
const FW_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0.bin").len();
const CLM_SZ: usize = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin").len();
// ensure that FW and CLM do not overlap
crate::assert!(CLM_ADDR < (FW_ADDR + FW_SZ));
let fw = unsafe { core::slice::from_raw_parts(FW_ADDR as *const u8, FW_SZ) };
let clm = unsafe { core::slice::from_raw_parts(CLM_ADDR as *const u8, CLM_SZ) };

let pwr = Output::new(p.PIN_23, Level::Low);
let cs = Output::new(p.PIN_25, Level::High);
Expand Down