Obtain the firmware blobs from the user instead of hardcoding magic flash addrs.
This commit is contained in:
parent
4205eef3ec
commit
13c88a9ca3
7 changed files with 77 additions and 20 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,4 +1,2 @@
|
|||
Cargo.lock
|
||||
target/
|
||||
*.bin
|
||||
notes.txt
|
||||
|
|
|
@ -43,6 +43,17 @@ async fn net_task(stack: &'static Stack<cyw43::NetDevice<'static>>) -> ! {
|
|||
async fn main(spawner: Spawner, p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
// Include the WiFi firmware and CLM.
|
||||
let fw = include_bytes!("../../../firmware/43439A0.bin");
|
||||
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
|
||||
//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 pwr = Output::new(p.PIN_23, Level::Low);
|
||||
let cs = Output::new(p.PIN_25, Level::High);
|
||||
let clk = Output::new(p.PIN_29, Level::Low);
|
||||
|
@ -54,11 +65,11 @@ async fn main(spawner: Spawner, p: Peripherals) {
|
|||
let spi = ExclusiveDevice::new(bus, cs);
|
||||
|
||||
let state = forever!(cyw43::State::new());
|
||||
let (mut control, runner) = cyw43::new(state, pwr, spi).await;
|
||||
let (mut control, runner) = cyw43::new(state, pwr, spi, fw).await;
|
||||
|
||||
spawner.spawn(wifi_task(runner)).unwrap();
|
||||
|
||||
let net_device = control.init().await;
|
||||
let net_device = control.init(clm).await;
|
||||
|
||||
//control.join_open("MikroTik-951589").await;
|
||||
control.join_wpa2("DirbaioWifi", "HelloWorld").await;
|
||||
|
|
BIN
firmware/43439A0.bin
Executable file
BIN
firmware/43439A0.bin
Executable file
Binary file not shown.
BIN
firmware/43439A0_clm.bin
Executable file
BIN
firmware/43439A0_clm.bin
Executable file
Binary file not shown.
49
firmware/LICENSE-permissive-binary-license-1.0.txt
Normal file
49
firmware/LICENSE-permissive-binary-license-1.0.txt
Normal file
|
@ -0,0 +1,49 @@
|
|||
Permissive Binary License
|
||||
|
||||
Version 1.0, July 2019
|
||||
|
||||
Redistribution. Redistribution and use in binary form, without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1) Redistributions must reproduce the above copyright notice and the
|
||||
following disclaimer in the documentation and/or other materials
|
||||
provided with the distribution.
|
||||
|
||||
2) Unless to the extent explicitly permitted by law, no reverse
|
||||
engineering, decompilation, or disassembly of this software is
|
||||
permitted.
|
||||
|
||||
3) Redistribution as part of a software development kit must include the
|
||||
accompanying file named <20>DEPENDENCIES<45> and any dependencies listed in
|
||||
that file.
|
||||
|
||||
4) Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from
|
||||
this software without specific prior written permission.
|
||||
|
||||
Limited patent license. The copyright holders (and contributors) grant a
|
||||
worldwide, non-exclusive, no-charge, royalty-free patent license to
|
||||
make, have made, use, offer to sell, sell, import, and otherwise
|
||||
transfer this software, where such license applies only to those patent
|
||||
claims licensable by the copyright holders (and contributors) that are
|
||||
necessarily infringed by this software. This patent license shall not
|
||||
apply to any combinations that include this software. No hardware is
|
||||
licensed hereunder.
|
||||
|
||||
If you institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the software
|
||||
itself infringes your patent(s), then your rights granted under this
|
||||
license shall terminate as of the date such litigation is filed.
|
||||
|
||||
DISCLAIMER. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
CONTRIBUTORS "AS IS." ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
|
||||
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
5
firmware/README.md
Normal file
5
firmware/README.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
# WiFi firmware
|
||||
|
||||
Firmware obtained from https://github.com/Infineon/wifi-host-driver/tree/master/WiFi_Host_Driver/resources/firmware/COMPONENT_43439
|
||||
|
||||
Licensed under the [Infineon Permissive Binary License](./LICENSE-permissive-binary-license-1.0.txt)
|
26
src/lib.rs
26
src/lib.rs
|
@ -235,11 +235,9 @@ pub struct Control<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Control<'a> {
|
||||
pub async fn init(&mut self) -> NetDevice<'a> {
|
||||
pub async fn init(&mut self, clm: &[u8]) -> NetDevice<'a> {
|
||||
const CHUNK_SIZE: usize = 1024;
|
||||
|
||||
let clm = unsafe { slice::from_raw_parts(0x10140000 as *const u8, 4752) };
|
||||
|
||||
info!("Downloading CLM...");
|
||||
|
||||
let mut offs = 0;
|
||||
|
@ -528,7 +526,12 @@ pub struct Runner<'a, PWR, SPI> {
|
|||
backplane_window: u32,
|
||||
}
|
||||
|
||||
pub async fn new<'a, PWR, SPI>(state: &'a State, pwr: PWR, spi: SPI) -> (Control<'a>, Runner<'a, PWR, SPI>)
|
||||
pub async fn new<'a, PWR, SPI>(
|
||||
state: &'a State,
|
||||
pwr: PWR,
|
||||
spi: SPI,
|
||||
firmware: &[u8],
|
||||
) -> (Control<'a>, Runner<'a, PWR, SPI>)
|
||||
where
|
||||
PWR: OutputPin,
|
||||
SPI: SpiDevice,
|
||||
|
@ -543,7 +546,7 @@ where
|
|||
backplane_window: 0xAAAA_AAAA,
|
||||
};
|
||||
|
||||
runner.init().await;
|
||||
runner.init(firmware).await;
|
||||
|
||||
(Control { state }, runner)
|
||||
}
|
||||
|
@ -554,7 +557,7 @@ where
|
|||
SPI: SpiDevice,
|
||||
SPI::Bus: SpiBusRead<u32> + SpiBusWrite<u32>,
|
||||
{
|
||||
async fn init(&mut self) {
|
||||
async fn init(&mut self, firmware: &[u8]) {
|
||||
// Reset
|
||||
self.pwr.set_low().unwrap();
|
||||
Timer::after(Duration::from_millis(20)).await;
|
||||
|
@ -598,17 +601,8 @@ where
|
|||
|
||||
let ram_addr = CHIP.atcm_ram_base_address;
|
||||
|
||||
// I'm flashing the firmwares independently at hardcoded addresses, instead of baking them
|
||||
// into the program with `include_bytes!` or similar, so that flashing the program stays fast.
|
||||
//
|
||||
// Flash them like this, also don't forget to update the lengths below if you change them!.
|
||||
//
|
||||
// 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
|
||||
let fw = unsafe { slice::from_raw_parts(0x10100000 as *const u8, 224190) };
|
||||
|
||||
info!("loading fw");
|
||||
self.bp_write(ram_addr, fw).await;
|
||||
self.bp_write(ram_addr, firmware).await;
|
||||
|
||||
info!("loading nvram");
|
||||
// Round up to 4 bytes.
|
||||
|
|
Loading…
Reference in a new issue