esp-rs / esp-hal

no_std Hardware Abstraction Layers for ESP32 microcontrollers
https://docs.esp-rs.org/esp-hal/
Apache License 2.0
698 stars 191 forks source link

esp_wifi does not compile with esp_ieee802154 imported at the same time #1932

Open turulix opened 1 month ago

turulix commented 1 month ago

Hey im trying to use both WIFI and IEEE802154 at the same time on my ESP32C6.

#[global_allocator]
static ALLOCATOR: esp_alloc::EspHeap = esp_alloc::EspHeap::empty();

fn init_heap() {
    const HEAP_SIZE: usize = 32 * 1024;
    static mut HEAP: MaybeUninit<[u8; HEAP_SIZE]> = MaybeUninit::uninit();

    unsafe {
        ALLOCATOR.init(HEAP.as_mut_ptr() as *mut u8, HEAP_SIZE);
    }
}

#[entry]
fn main() -> ! {
    let mut peripherals = Peripherals::take();
    let system = SystemControl::new(peripherals.SYSTEM);
    init_heap();
    esp_println::logger::init_logger_from_env();

    let clocks = ClockControl::max(system.clock_control).freeze();
    let rng = Rng::new(peripherals.RNG);
    let timer = TimerGroup::new(peripherals.TIMG0, &clocks, None);
    let timer: ErasedTimer = timer.timer0.into();
    let timer = PeriodicTimer::new(timer);

    let mut ieee802154 = esp_ieee802154::Ieee802154::new(peripherals.IEEE802154, &mut peripherals.RADIO_CLK);
    let init = esp_wifi::initialize(
        EspWifiInitFor::Wifi,
        timer,
        rng.clone(),
        peripherals.RADIO_CLK,
        &clocks,
    ).unwrap();

    loop {}
}

Commenting out either the esp_wifi part or ieee802154 part and removing all imports associated with them works fine. But compiling with both in place results in an error: failed to load bitcode of module "esp_wifi-715e490f8c6e0fb1.esp_wifi.abe10e676f975f83-cgu.0.rcgu.o": error

bjoernQ commented 4 weeks ago

WiFi and 802.15.4 co-existence is not supported - while it is on esp-idf even there it's not recommended (e.g. that's why the ESP Thread Border Router is ESP32-S3 plus ESP32-H2)

However, both should be useable (but not at the same time) - e.g. for Matter commissioning via BLE and then using Thread