From bd3335c1277b14b9bd98fb74edede882cc4dbf5b Mon Sep 17 00:00:00 2001 From: Brandon Ros Date: Mon, 21 Aug 2023 15:12:45 -0400 Subject: [PATCH] same ol BT_CTRL_REG_ADDR = 8fc0f42a error --- cyw43/src/bluetooth.rs | 11 +---------- cyw43/src/lib.rs | 1 - cyw43/src/runner.rs | 9 +++------ examples/rp/src/bin/wifi_blinky.rs | 1 - 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/cyw43/src/bluetooth.rs b/cyw43/src/bluetooth.rs index 95ec513b..b7f2c318 100644 --- a/cyw43/src/bluetooth.rs +++ b/cyw43/src/bluetooth.rs @@ -18,23 +18,15 @@ pub(crate) async fn upload_bluetooth_firmware( firmware_offsets: &[(u32, usize)], firmware: &[u8], ) { - assert!(firmware.len() == 5952); - // read version - let version_length = firmware[0]; - let _version = &firmware[1..=version_length as usize]; - // skip version + 1 extra byte as per cybt_shared_bus_driver.c - let firmware = &firmware[version_length as usize + 2..]; // buffer let mut aligned_data_buffer: [u8; 0x100] = [0; 0x100]; // structs let mut pointer = 0; for (index, &(dest_addr, num_fw_bytes)) in firmware_offsets.iter().enumerate() { - Timer::after(Duration::from_millis(100)).await; let fw_bytes = &firmware[(pointer)..(pointer + num_fw_bytes)]; assert!(fw_bytes.len() == num_fw_bytes); //debug!("index = {}/{} dest_addr = {:08x} num_fw_bytes = {} fw_bytes = {:02x}", index, firmware_offsets.len(), dest_addr, num_fw_bytes, fw_bytes); - debug!("index = {}/{} dest_addr = {:08x} num_fw_bytes = {} pointer = {}", index, firmware_offsets.len(), dest_addr, num_fw_bytes, pointer); - assert!(firmware.len() == 5952); + //debug!("index = {}/{} dest_addr = {:08x} num_fw_bytes = {} pointer = {}", index, firmware_offsets.len(), dest_addr, num_fw_bytes, pointer); let mut dest_start_addr = dest_addr; let mut aligned_data_buffer_index: usize = 0; // pad start @@ -158,7 +150,6 @@ pub(crate) async fn bt_set_intr(bus: &mut Bus< } pub(crate) async fn init_bluetooth(bus: &mut Bus, firmware_offsets: &[(u32, usize)], firmware: &[u8]) { - assert!(firmware.len() == 5952); bus.bp_write32(CHIP.bluetooth_base_address + BT2WLAN_PWRUP_ADDR, BT2WLAN_PWRUP_WAKE) .await; upload_bluetooth_firmware(bus, firmware_offsets, firmware).await; diff --git a/cyw43/src/lib.rs b/cyw43/src/lib.rs index 3ce602fc..94f63982 100644 --- a/cyw43/src/lib.rs +++ b/cyw43/src/lib.rs @@ -226,7 +226,6 @@ where let mut runner = Runner::new(ch_runner, Bus::new(pwr, spi), &state.ioctl_state, &state.events); - assert!(bluetooth_firmware.len() == 5952); runner.init(firmware, bluetooth_firmware_offsets, bluetooth_firmware).await; ( diff --git a/cyw43/src/runner.rs b/cyw43/src/runner.rs index 43d6f497..05ef1294 100644 --- a/cyw43/src/runner.rs +++ b/cyw43/src/runner.rs @@ -74,8 +74,6 @@ where } pub(crate) async fn init(&mut self, firmware: &[u8], bluetooth_firmware_offsets: &[(u32, usize)], bluetooth_firmware: &[u8]) { - assert!(bluetooth_firmware.len() == 5952); - self.bus.init().await; // Init ALP (Active Low Power) clock @@ -118,6 +116,9 @@ where debug!("loading fw"); self.bus.bp_write(ram_addr, firmware).await; + debug!("loading bluetooth fw"); + bluetooth::init_bluetooth(&mut self.bus, bluetooth_firmware_offsets, bluetooth_firmware).await; + debug!("loading nvram"); // Round up to 4 bytes. let nvram_len = (NVRAM.len() + 3) / 4 * 4; @@ -197,10 +198,6 @@ where while self.bus.read8(FUNC_BACKPLANE, REG_BACKPLANE_CHIP_CLOCK_CSR).await & 0x80 == 0 {} debug!("clock ok"); - debug!("loading bluetooth fw"); - assert!(bluetooth_firmware.len() == 5952); - bluetooth::init_bluetooth(&mut self.bus, bluetooth_firmware_offsets, bluetooth_firmware).await; - #[cfg(feature = "firmware-logs")] self.log_init().await; diff --git a/examples/rp/src/bin/wifi_blinky.rs b/examples/rp/src/bin/wifi_blinky.rs index fa44bc66..5203f6e3 100644 --- a/examples/rp/src/bin/wifi_blinky.rs +++ b/examples/rp/src/bin/wifi_blinky.rs @@ -33,7 +33,6 @@ async fn main(spawner: Spawner) { let p = embassy_rp::init(Default::default()); let bluetooth_firmware_offsets = &cyw43_firmware::BLUETOOTH_FIRMWARE_OFFSETS; let bluetooth_firmware = &cyw43_firmware::BLUETOOTH_FIRMWARE; - defmt::assert!(bluetooth_firmware.len() == 5952); let fw = include_bytes!("../../../../cyw43-firmware/43439A0.bin"); let clm = include_bytes!("../../../../cyw43-firmware/43439A0_clm.bin");