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

WiFi switching causes panic #503

Closed
hhy50 opened this issue Oct 18, 2024 · 5 comments
Closed

WiFi switching causes panic #503

hhy50 opened this issue Oct 18, 2024 · 5 comments

Comments

@hhy50
Copy link

hhy50 commented Oct 18, 2024

I want to switch to different Wi-Fi every time the connect_wifi is called.
but, it only succeeds the first time it is called, and second time it will cause the process to panic.

code:

static STARTED: AtomicBool = AtomicBool::new(false);
static ESP_WIFI_INSTANCE: OnceLock<Mutex<EspWifi<'_>>> = OnceLock::new();

#[derive(Debug, Default)]
pub struct Config<'a> {
    pub ssid: &'a str,
    pub passwd: &'a str,
}

/// init wifi instance
pub fn init<'a>(
    modem: modem::Modem,
    sys_loop: EspEventLoop<System>,
    nvs: Option<EspDefaultNvsPartition>,
) -> anyhow::Result<()> {
    sys_loop.subscribe::<WifiEvent, _>(|event| match event {
        WifiEvent::StaConnected => {
            log::info!("Esp Wifi connected");
        }
        WifiEvent::StaDisconnected => {
            log::warn!("Esp Wifi Disconnect");
        }
        other => {
            log::warn!("Wifi event: {:?}", other);
        }
    })?;
    let mut esp_wifi = EspWifi::new(modem, sys_loop, nvs)?;
    if let Err(_) = ESP_WIFI_INSTANCE.set(Mutex::new(esp_wifi)) {
        return Err(anyhow!("set ESP_WIFI_INSTANCE failed"));
    }
    Ok(())
}

pub fn connect_wifi(config: &Config) -> anyhow::Result<()> {
    log::info!("connect_wifi....");
    let connected = ESP_WIFI_INSTANCE.get().unwrap().lock().is_connected();
    let _ = match connected.ok() {
        Some(true) => {
            ESP_WIFI_INSTANCE.get().unwrap().lock().disconnect()?;
            wait_wifi_conn_status(false, Duration::from_secs(10));
        }
        _ => (),
    };
    let wifi_conf: Configuration = Configuration::Client(ClientConfiguration {
        ssid: config.ssid.try_into().unwrap(),
        password: config.passwd.try_into().unwrap(),
        auth_method: AuthMethod::WPA2Personal,
        ..Default::default()
    });
    ESP_WIFI_INSTANCE
        .get()
        .unwrap()
        .lock()
        .set_configuration(&wifi_conf)?;
    if !STARTED.load(std::sync::atomic::Ordering::Acquire) {
        ESP_WIFI_INSTANCE.get().unwrap().lock().start()?;
    }
    ESP_WIFI_INSTANCE.get().unwrap().lock().connect()?;
    wait_wifi_conn_status(true, Duration::from_secs(10));
    Ok(())
}

fn wait_wifi_conn_status(conn: bool, timeout: Duration) {
    let timeout = SystemTime::now().checked_add(timeout).unwrap();
    log::info!("wait_wifi_conn_status status [{}] start...", conn);
    let is_conn = || {
        let is_conn = ESP_WIFI_INSTANCE.get().unwrap().lock().is_connected();
        is_conn.unwrap()
    };
    while timeout > SystemTime::now() && is_conn() != conn {
        thread::sleep(Duration::from_secs(1));
    }
    log::info!("wait_wifi_conn_status end...");
}

log:

I (30) boot: ESP-IDF v5.1.2-342-gbcf1645e44 2nd stage bootloader
I (30) boot: compile time Dec 12 2023 10:50:58
I (31) boot: chip revision: v0.4
I (35) boot.esp32c3: SPI Speed      : 40MHz
I (39) boot.esp32c3: SPI Mode       : DIO
I (44) boot.esp32c3: SPI Flash Size : 4MB
I (49) boot: Enabling RNG early entropy source...
I (54) boot: Partition Table:
I (58) boot: ## Label            Usage          Type ST Offset   Length
I (65) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (72) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (80) boot:  2 factory          factory app      00 00 00010000 003f0000
I (87) boot: End of partition table
I (92) esp_image: segment 0: paddr=00010020 vaddr=3c0e0020 size=304f0h (197872) map
I (144) esp_image: segment 1: paddr=00040518 vaddr=3fc93600 size=033d8h ( 13272) load
I (147) esp_image: segment 2: paddr=000438f8 vaddr=40380000 size=0c720h ( 50976) load
I (162) esp_image: segment 3: paddr=00050020 vaddr=42000020 size=d3f98h (868248) map
I (355) esp_image: segment 4: paddr=00123fc0 vaddr=4038c720 size=06e2ch ( 28204) load
I (368) boot: Loaded app from partition at offset 0x10000
I (369) boot: Disabling RNG early entropy source...
I (380) cpu_start: Unicore app
I (389) cpu_start: Pro cpu start user code
I (389) cpu_start: cpu freq: 160000000 Hz
I (389) cpu_start: Application information:
I (392) cpu_start: Project name:     libespidf
I (397) cpu_start: App version:      9818bd7
I (402) cpu_start: Compile time:     Oct 18 2024 10:29:18
I (408) cpu_start: ELF file SHA256:  000000000...
I (414) cpu_start: ESP-IDF:          v5.2
I (418) cpu_start: Min chip rev:     v0.3
I (423) cpu_start: Max chip rev:     v1.99 
I (428) cpu_start: Chip rev:         v0.4
I (433) heap_init: Initializing. RAM available for dynamic allocation:
I (440) heap_init: At 3FC9C6A0 len 00023960 (142 KiB): RAM
I (446) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (453) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (460) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (468) spi_flash: detected chip: generic
I (471) spi_flash: flash io: dio
I (476) sleep: Configure to isolate all GPIO pins in sleep state
I (482) sleep: Enable automatic switching of GPIO sleep configuration
I (489) coexist: coex firmware version: 77cd7f8
I (494) coexist: coexist rom version 9387209
I (500) main_task: Started on CPU0
I (500) main_task: Calling app_main()
I (520) billiards_esp32::device::peripheral::bluetooth: Empty Ble DeviceName, Generate Default DeviceName: txy_e4b0630064ba
I (520) BLE_INIT: BT controller compile version [b877d66]
I (520) BLE_INIT: Bluetooth MAC: e4:b0:63:00:64:ba
I (530) phy_init: phy_version 1130,b4e4b80,Sep  5 2023,11:09:30
I (600) esp32_nimble::ble_device: BLE Host Task Started
I (600) NimBLE: GAP procedure initiated: stop advertising.

I (600) NimBLE: GAP procedure initiated: stop advertising.

I (610) esp32_nimble::ble_device: Device Address: E4:B0:63:0:64:BA
I (620) NimBLE: GAP procedure initiated: advertise; 
I (620) NimBLE: disc_mode=2
I (620) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (630) NimBLE: 

I (640) billiards_esp32::device::peripheral::bluetooth: ble_advertising stated...
I (640) pp: pp rom version: 9387209
I (650) net80211: net80211 rom version: 9387209
I (660) wifi:wifi driver task: 3fcbfe08, prio:23, stack:6656, core=0
I (660) wifi:wifi firmware version: cc1dd81
I (660) wifi:wifi certification version: v7.0
I (670) wifi:config NVS flash: disabled
I (670) wifi:config nano formating: disabled
I (670) wifi:Init data frame dynamic rx buffer num: 32
I (680) wifi:Init static rx mgmt buffer num: 10
I (680) wifi:Init management short buffer num: 32
I (690) wifi:Init dynamic tx buffer num: 32
I (690) wifi:Init static tx FG buffer num: 2
I (700) wifi:Init static rx buffer size: 1600
I (700) wifi:Init static rx buffer num: 10
I (700) wifi:Init dynamic rx buffer num: 32
I (710) wifi_init: rx ba win: 6
I (710) wifi_init: tcpip mbox: 32
I (720) wifi_init: udp mbox: 6
I (720) wifi_init: tcp mbox: 6
I (720) wifi_init: tcp tx win: 5760
I (730) wifi_init: tcp rx win: 5760
I (730) wifi_init: tcp mss: 1440
I (740) wifi_init: WiFi IRAM OP enabled
I (740) wifi_init: WiFi RX IRAM OP enabled
I (750) esp_idf_svc::nvs: NvsDefault dropped
I (2298110) billiards_esp32::device::peripheral::bluetooth: New Client connected
I (2320010) billiards_esp32::device::peripheral::wifi: connect_wifi....
I (2320020) wifi:mode : sta (e4:b0:63:00:64:b8)
I (2320020) wifi:enable tsf
I (2320020) billiards_esp32::device::peripheral::wifi: wait_wifi_conn_status status [true] start...
I (2323400) wifi:new:<13,0>, old:<1,0>, ap:<255,255>, sta:<13,0>, prof:1
I (2323670) wifi:state: init -> auth (b0)
I (2323670) wifi:state: auth -> assoc (0)
I (2323680) wifi:state: assoc -> run (10)
I (2323690) wifi:<ba-add>idx:0 (ifx:0, 12:82:3d:8e:83:74), tid:5, ssn:0, winSize:64
I (2323790) wifi:<ba-add>idx:1 (ifx:0, 12:82:3d:8e:83:74), tid:0, ssn:2, winSize:64
I (2323790) wifi:connected with XSXC, aid = 17, channel 13, BW20, bssid = 12:82:3d:8e:83:74
I (2323790) wifi:security: WPA2-PSK, phy: bgn, rssi: -49
I (2323800) wifi:pm start, type: 1

I (2323800) wifi:dp: 1, bi: 102400, li: 3, scale listen interval from 307200 us to 307200 us
I (2323810) wifi:set rx beacon pti, rx_bcn_pti: 14, bcn_timeout: 25000, mt_pti: 14, mt_time: 10000
I (2323940) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (2324030) billiards_esp32::device::peripheral::wifi: wait_wifi_conn_status end...
I (2324820) esp_netif_handlers: sta ip: 192.168.110.77, mask: 255.255.255.0, gw: 192.168.110.1
I (2357130) billiards_esp32::device::peripheral::wifi: connect_wifi....
I (2357140) wifi:state: run -> init (0)
I (2357140) wifi:pm stop, total sleep time: 24554613 us / 33340448 us

I (2357150) wifi:<ba-del>idx:1, tid:0
I (2357150) wifi:<ba-del>idx:0, tid:5
I (2357150) wifi:new:<13,0>, old:<13,0>, ap:<255,255>, sta:<13,0>, prof:1
I (2357160) billiards_esp32::device::peripheral::wifi: wait_wifi_conn_status status [false] start...
I (2358170) billiards_esp32::device::peripheral::wifi: wait_wifi_conn_status end...
I (2358170) billiards_esp32::device::peripheral::wifi: wait_wifi_conn_status status [true] start...
I (2361550) wifi:new:<6,0>, old:<13,0>, ap:<255,255>, sta:<6,0>, prof:1
I (2361820) wifi:state: init -> auth (b0)
thread '<unnamed>' panicked at /Users/hanhaiyang/.cargo/registry/src/index.crates.io-6f17d22bba15001f/esp-idf-svc-0.49.1/src/wifi.rs:2195:57:
called `Result::unwrap()` on an `Err` value: "Invalid"
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

abort() was called at PC 0x4200f7bd on core 0
0x4200f7bd - panic_abort::__rust_start_panic::abort
    at ??:??
Core  0 register dump:
MEPC    : 0x40380698  RA      : 0x40388a5e  SP      : 0x3fcaf890  GP      : 0x3fc93e00  
0x40380698 - panic_abort
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/esp_system/panic.c:472
0x40388a5e - __ubsan_include
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/esp_system/ubsan.c:313
0x3fc93e00 - coex_schm_ble_mesh_config_bt_default_wifi_connecting
    at ??:??
TP      : 0x3fc80394  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130  
S0/FP   : 0x3fcaf8cc  S1      : 0x3fcaf8cc  A0      : 0x3fcaf8cc  A1      : 0x3fcaf8ae  
A2      : 0x00000000  A3      : 0x3fcaf8f9  A4      : 0x00000001  A5      : 0x3fc9b000  
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0x3fcaf8b0  S3      : 0x3c0eb41c  
0x3c0eb41c - $d
    at ??:??
S4      : 0x00000001  S5      : 0x3c0e8a6c  S6      : 0x00000000  S7      : 0x00000002  
0x3c0e8a6c - $d
    at ??:??
S8      : 0x3fcc8990  S9      : 0x00000000  S10     : 0x00000000  S11     : 0x00000000  
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001801  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000  
0x40380001 - _vector_table
    at ??:??
MHARTID : 0x00000000  

Stack memory:
3fcaf890: 0x00000000 0x3c0e8a6c 0x3fcaf8cc 0x4038f730 0x00000000 0x00000000 0x3fccb2c8 0x40380030
0x3c0e8a6c - $d
    at ??:??
0x4038f730 - __assert_func
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/newlib/assert.c:34
0x40380030 - _vector_table
    at ??:??
3fcaf8b0: 0x30303234 0x64623766 0x3fccb200 0x3fc95b7c 0x3fcaf8b0 0x3fc95b98 0x3fcaf8ac 0x726f6261
3fcaf8d0: 0x20292874 0x20736177 0x6c6c6163 0x61206465 0x43502074 0x34783020 0x66303032 0x20646237
3fcaf8f0: 0x63206e6f 0x2065726f 0x00000030 0x3c0e0000 0x3fc9a878 0x00000000 0x3fc96a70 0x4200f7c0
0x3fc9a878 - std::sys::backtrace::lock::LOCK
    at ??:??
0x3fc96a70 - std::io::stdio::stderr::INSTANCE
    at ??:??
0x4200f7c0 - panic_abort::__rust_start_panic::abort
    at ??:??
3fcaf910: 0xe4268700 0x9b9e0166 0x2676c42e 0xd0e24b02 0xe4268700 0x9b9e0166 0x2676c42e 0xd0e24b02
3fcaf930: 0x3fcaf9b0 0x3c0eb458 0x3c0e8a6c 0x3c0e8a6c 0x3fccb26c 0x00000036 0x3c0eb374 0x00000009
0x3c0eb458 - $d
    at ??:??
0x3c0e8a6c - $d
    at ??:??
0x3c0e8a6c - $d
    at ??:??
0x3c0eb374 - $d
    at ??:??
3fcaf950: 0x3fcc9e04 0xa5a5a5a5 0x3c0eb304 0x00000004 0x3fcaf970 0x00000003 0x00000000 0xa5a5a5a5
3fcaf970: 0x00000009 0x00000001 0x00000004 0x00000000 0x00000000 0x42006096 0xa5a5a5a5 0x3fcca1a4
0x42006096 - <&T as core::fmt::Display>::fmt
    at ??:??
3fcaf990: 0x00000000 0x00000000 0xffffffff 0x00000028 0x3fccb1b4 0x3c0f1efc 0x3fcafa54 0x42030246
0x42030246 - std::panicking::begin_panic_handler::{{closure}}
    at ??:??
3fcaf9b0: 0x00000056 0x3fccb26c 0x00000036 0x3fcaf9c4 0x000000ff 0x3fcaf9f8 0x3c0e8a6c 0x3fcaf9d4
0x3c0e8a6c - $d
    at ??:??
3fcaf9d0: 0x00000000 0x3fcaf9f8 0x3c0e8a6c 0xa5a50001 0x000000c0 0xa5a5a5a5 0x3c0e9c3c 0x0000002b
0x3c0e8a6c - $d
    at ??:??
0x3c0e9c3c - $d
    at ??:??
3fcaf9f0: 0x3fcafa28 0x3c0eabc0 0x3c0eb624 0x00000002 0x3fcafa10 0x00000002 0x00000000 0xa5a5a5a5
0x3c0eabc0 - $d
    at ??:??
0x3c0eb624 - $d
    at ??:??
3fcafa10: 0x3fcaf9e8 0x42006096 0x3fcaf9f0 0x420060a6 0x3fccb154 0x00000028 0x3c0e8a12 0x00000007
0x42006096 - <&T as core::fmt::Display>::fmt
    at ??:??
0x420060a6 - <&T as core::fmt::Display>::fmt
    at ??:??
0x3c0e8a12 - $d
    at ??:??
3fcafa30: 0xa5a5a5a5 0x3c0f1efc 0x3fcc8954 0x420310ac 0xa5a5a5a5 0x3c0f1efc 0x3fcbfdb0 0x4200c546
0x420310ac - pthread_mutex_lock
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/pthread/pthread.c:641
0x4200c546 - esp_idf_svc::eventloop::EspEventLoop<T>::subscribe::{{closure}}
    at ??:??
3fcafa50: 0xa5a5a5a5 0x0d010105 0xa5a5a500 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
3fcafa70: 0x403899ea 0x403899de 0x3fcafaf0 0x3fc93e00 0x3fc80394 0x4005890e 0x3fc9b000 0x00000000
0x403899ea - vPortYield
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:652
0x403899de - vPortYield
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:652
0x3fc93e00 - coex_schm_ble_mesh_config_bt_default_wifi_connecting
    at ??:??
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
3fcafa90: 0x3fcc8a08 0x00000000 0x00000001 0x00000001 0x3fc9b000 0x3fc9b000 0x00000001 0x600c0000
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
3fcafab0: 0x00000000 0x00000014 0x00000000 0xffffffff 0x403899ea 0x403899de 0x3fcafb40 0x3fc93e00
0x403899ea - vPortYield
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:652
0x403899de - vPortYield
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:652
0x3fc93e00 - coex_schm_ble_mesh_config_bt_default_wifi_connecting
    at ??:??
3fcafad0: 0x3fc80394 0x4005890e 0x3fc9b000 0xffffffff 0x3fcc8a08 0x00000000 0x00000001 0x00000001
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
3fcafaf0: 0x3fc9b000 0x3fc9b000 0x00000001 0x600c0000 0xa0000000 0x00000014 0x00000000 0xffffffff
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
3fcafb10: 0x3fcc8a2c 0x00000000 0x00000000 0x3fcca1a4 0x00000000 0x00000000 0x00000000 0x00000000
3fcafb30: 0x403899ea 0x403899de 0x3fcafbb0 0x3fc93e00 0x3fc80394 0x4005890e 0x3fc9b000 0xffffffff
0x403899ea - vPortYield
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:652
0x403899de - vPortYield
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c:652
0x3fc93e00 - coex_schm_ble_mesh_config_bt_default_wifi_connecting
    at ??:??
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
3fcafb50: 0x3fcaeed8 0x00000000 0x00000001 0x00000001 0x3fc9b000 0x3fc9b000 0x00000001 0x600c0000
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
3fcafb70: 0xa0000000 0x00000014 0x3fcafc00 0x00000000 0xffffffff 0x3fcaeefc 0x00000000 0x00000000
3fcafb90: 0x00000000 0x00000000 0x00000000 0x4038956e 0x3fc9b000 0x00000001 0x3fcc8990 0x3fcca1a4
0x4038956e - xQueueSemaphoreTake
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/freertos/FreeRTOS-Kernel/queue.c:1731
0x3fc9b000 - ble_gattc_proc_mem
    at ??:??
3fcafbb0: 0x00000000 0x00000000 0xffffffff 0x00000028 0x3fccb1b4 0x3c0f1efc 0x3fcbfdec 0x4200c358
0x4200c358 - esp_idf_svc::eventloop::EspSubscription<T>::handle
    at ??:??
3fcafbd0: 0x00000000 0x00000000 0x3fcaf130 0x3c0f1efc 0x0000000b 0x00000028 0x3fccb1b4 0xffffffff
3fcafbf0: 0x3fcc896c 0x00000000 0x3fcaeebc 0x420d1300 0x00000101 0x3c0f1efc 0x00000028 0x3fccb1b4
0x420d1300 - esp_event_loop_run
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/esp_event/esp_event.c:592
3fcafc10: 0x00000101 0x3c0f1efc 0x00000028 0x3fccb1b4 0x00000000 0x00000000 0x00000000 0x00000000
3fcafc30: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x3fcaeebc 0x420d13ea
0x420d13ea - esp_event_loop_run_task
    at /Users/hanhaiyang/Desktop/billiards_esp32/.embuild/espressif/esp-idf/v5.2/components/esp_event/esp_event.c:108
3fcafc50: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcafc70: 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x00000150 0x3fcaf770



ELF file SHA256: 000000000

Rebooting...
I (30) boot: ESP-IDF v5.1.2-342-gbcf1645e44 2nd stage bootloader
I (30) boot: compile time Dec 12 2023 10:50:58
I (31) boot: chip revision: v0.4
I (36) boot.esp32c3: SPI Speed      : 40MHz
I (39) boot.esp32c3: SPI Mode       : DIO
I (44) boot.esp32c3: SPI Flash Size : 4MB
I (49) boot: Enabling RNG early entropy source...
I (54) boot: Partition Table:
I (58) boot: ## Label            Usage          Type ST Offset   Length
I (65) boot:  0 nvs              WiFi data        01 02 00009000 00006000
I (73) boot:  1 phy_init         RF data          01 01 0000f000 00001000
I (80) boot:  2 factory          factory app      00 00 00010000 003f0000
I (88) boot: End of partition table
I (92) esp_image: segment 0: paddr=00010020 vaddr=3c0e0020 size=304f0h (197872) map
I (144) esp_image: segment 1: paddr=00040518 vaddr=3fc93600 size=033d8h ( 13272) load
I (148) esp_image: segment 2: paddr=000438f8 vaddr=40380000 size=0c720h ( 50976) load
I (163) esp_image: segment 3: paddr=00050020 vaddr=42000020 size=d3f98h (868248) map
I (355) esp_image: segment 4: paddr=00123fc0 vaddr=4038c720 size=06e2ch ( 28204) load
I (369) boot: Loaded app from partition at offset 0x10000
I (369) boot: Disabling RNG early entropy source...
I (380) cpu_start: Unicore app
I (389) cpu_start: Pro cpu start user code
I (389) cpu_start: cpu freq: 160000000 Hz
I (389) cpu_start: Application information:
I (392) cpu_start: Project name:     libespidf
I (397) cpu_start: App version:      9818bd7
I (402) cpu_start: Compile time:     Oct 18 2024 10:29:18
I (408) cpu_start: ELF file SHA256:  000000000...
I (414) cpu_start: ESP-IDF:          v5.2
I (419) cpu_start: Min chip rev:     v0.3
I (423) cpu_start: Max chip rev:     v1.99 
I (428) cpu_start: Chip rev:         v0.4
I (433) heap_init: Initializing. RAM available for dynamic allocation:
I (440) heap_init: At 3FC9C6A0 len 00023960 (142 KiB): RAM
I (446) heap_init: At 3FCC0000 len 0001C710 (113 KiB): Retention RAM
I (453) heap_init: At 3FCDC710 len 00002950 (10 KiB): Retention RAM
I (460) heap_init: At 50000010 len 00001FD8 (7 KiB): RTCRAM
I (468) spi_flash: detected chip: generic
I (471) spi_flash: flash io: dio
I (476) sleep: Configure to isolate all GPIO pins in sleep state
I (482) sleep: Enable automatic switching of GPIO sleep configuration
I (489) coexist: coex firmware version: 77cd7f8
I (494) coexist: coexist rom version 9387209
I (500) main_task: Started on CPU0
I (500) main_task: Calling app_main()
I (520) billiards_esp32::device::peripheral::bluetooth: Empty Ble DeviceName, Generate Default DeviceName: txy_e4b0630064ba
I (520) BLE_INIT: BT controller compile version [b877d66]
I (520) BLE_INIT: Bluetooth MAC: e4:b0:63:00:64:ba
I (530) phy_init: phy_version 1130,b4e4b80,Sep  5 2023,11:09:30
I (590) esp32_nimble::ble_device: BLE Host Task Started
I (600) NimBLE: GAP procedure initiated: stop advertising.

I (600) NimBLE: GAP procedure initiated: stop advertising.

I (600) esp32_nimble::ble_device: Device Address: E4:B0:63:0:64:BA
I (610) NimBLE: GAP procedure initiated: advertise; 
I (610) NimBLE: disc_mode=2
I (620) NimBLE:  adv_channel_map=0 own_addr_type=0 adv_filter_policy=0 adv_itvl_min=0 adv_itvl_max=0
I (630) NimBLE: 

I (630) billiards_esp32::device::peripheral::bluetooth: ble_advertising stated...
I (640) pp: pp rom version: 9387209
I (640) net80211: net80211 rom version: 9387209
I (660) wifi:wifi driver task: 3fcbfe08, prio:23, stack:6656, core=0
I (660) wifi:wifi firmware version: cc1dd81
I (660) wifi:wifi certification version: v7.0
I (660) wifi:config NVS flash: disabled
I (670) wifi:config nano formating: disabled
I (670) wifi:Init data frame dynamic rx buffer num: 32
I (670) wifi:Init static rx mgmt buffer num: 10
I (680) wifi:Init management short buffer num: 32
I (680) wifi:Init dynamic tx buffer num: 32
I (690) wifi:Init static tx FG buffer num: 2
I (690) wifi:Init static rx buffer size: 1600
I (700) wifi:Init static rx buffer num: 10
I (700) wifi:Init dynamic rx buffer num: 32
I (700) wifi_init: rx ba win: 6
I (710) wifi_init: tcpip mbox: 32
I (710) wifi_init: udp mbox: 6
I (710) wifi_init: tcp mbox: 6
I (720) wifi_init: tcp tx win: 5760
I (720) wifi_init: tcp rx win: 5760
I (730) wifi_init: tcp mss: 1440
I (730) wifi_init: WiFi IRAM OP enabled
I (730) wifi_init: WiFi RX IRAM OP enabled
I (740) esp_idf_svc::nvs: NvsDefault dropped
ivmarkov added a commit that referenced this issue Oct 18, 2024
@ivmarkov
Copy link
Collaborator

Can you try with the esp-idf-svc from master instead? I think there is a problem with a recent event (home channel change) that was added via a contribution.

I just work-arounded the problem on master so you might want to try it out. To do it, just add these lines to your Cargo.toml and don't change anything else. Then rebuild:

[patch.crates-io]
esp-idf-svc = { git = "https://github.com/esp-rs/esp-idf-svc" }
esp-idf-hal = { git = "https://github.com/esp-rs/esp-idf-hal" }
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys" }

@hhy50
Copy link
Author

hhy50 commented Oct 18, 2024

Can you try with the esp-idf-svc from master instead? I think there is a problem with a recent event (home channel change) that was added via a contribution.

I just work-arounded the problem on master so you might want to try it out. To do it, just add these lines to your Cargo.toml and don't change anything else. Then rebuild:

[patch.crates-io]
esp-idf-svc = { git = "https://github.com/esp-rs/esp-idf-svc" }
esp-idf-hal = { git = "https://github.com/esp-rs/esp-idf-hal" }
esp-idf-sys = { git = "https://github.com/esp-rs/esp-idf-sys" }

I'll try it

@hhy50
Copy link
Author

hhy50 commented Oct 18, 2024

@ivmarkov ok, It can run normally now

@hhy50
Copy link
Author

hhy50 commented Oct 18, 2024

@ivmarkov I still have a problem, that is, the wifi event subscribed in init() has never been triggered. This problem has always existed before

@ivmarkov
Copy link
Collaborator

@ivmarkov I still have a problem, that is, the wifi event subscribed in init() has never been triggered. This problem has always existed before

That's because you are not keeping around the Subscription object returned to you by subscribe. As a result, the subscription you are doing gets dropped immediately, and you end up in an unsubscribed state.

By the way, for these questions, it might be much better if you just join the ESP-RS Matrix room (linked in the readme of this crate).

@github-project-automation github-project-automation bot moved this from Todo to Done in esp-rs Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants