espressif / esp-iot-solution

Espressif IoT Library. IoT Device Drivers, Documentations And Solutions.
Apache License 2.0
1.92k stars 766 forks source link

The USB dongle example does not work properly (AEGHB-173) #193

Open xhcyf opened 2 years ago

xhcyf commented 2 years ago

Environment

Problem Description

//Detailed problem description goes here. I want to use usb dongle example to verify WiFi dongle function, the compile is fine and download FW to devkit. But when the USB initialization is done and FW runs connected or disconnected rndis, FW will be reset.

Expected Behavior

the devkit will be run in WiFi dongle mode

Actual Behavior

the FW reset

Steps to repropduce

this issue can be reproduced every time

Code to reproduce this issue

I made a small change to the usb_dongle_main function in the example.

/* Register commands with the FreeRTOS+CLI command interpreter. */
//vRegisterCLICommands();

const char *ssid = "xxxxxx", *psd = "xxxxxxx";
wifi_cmd_sta_join(ssid,psd);

Debug Logs

Rebooting... �ESP-ROM:esp32s3-20210327 Build:Mar 27 2021 rst:0xc (RTC_SW_CPU_RST),boot:0x8 (SPI_FAST_FLASH_BOOT) Saved PC:0x4037559c 0x4037559c: esp_restart_noos at C:/Work/Espressif/frameworks/esp-idf-v4.4/components/esp_system/port/soc/esp32s3/system_internal.c:143 (discriminator 1)

SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd0108,len:0x1650 load:0x403b6000,len:0xb1c load:0x403ba000,len:0x2f48 entry 0x403b622c I (29) boot: ESP-IDF v4.4-dirty 2nd stage bootloader I (29) boot: compile time 14:21:30 I (29) boot: chip revision: 0 I (31) boot.esp32s3: Boot SPI Speed : 80MHz I (36) boot.esp32s3: SPI Mode : DIO I (41) boot.esp32s3: SPI Flash Size : 4MB I (45) boot: Enabling RNG early entropy source... I (51) boot: Partition Table: I (54) boot: ## Label Usage Type ST Offset Length I (62) boot: 0 nvs WiFi data 01 02 00009000 00004000 I (69) boot: 1 otadata OTA data 01 00 0000d000 00002000 I (77) boot: 2 phy_init RF data 01 01 0000f000 00001000 I (84) boot: 3 factory factory app 00 00 00010000 00100000 I (91) boot: 4 ota_0 OTA app 00 10 00110000 00100000 I (99) boot: 5 ota_1 OTA app 00 11 00210000 00100000 I (106) boot: End of partition table I (111) boot: Defaulting to factory image I (115) esp_image: segment 0: paddr=00010020 vaddr=3c070020 size=14cc8h ( 85192) map I (139) esp_image: segment 1: paddr=00024cf0 vaddr=3fc94710 size=03efch ( 16124) load I (143) esp_image: segment 2: paddr=00028bf4 vaddr=40374000 size=07424h ( 29732) load I (152) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=6f790h (456592) map I (235) esp_image: segment 4: paddr=0009f7b8 vaddr=4037b424 size=092e4h ( 37604) load I (244) esp_image: segment 5: paddr=000a8aa4 vaddr=50000000 size=00010h ( 16) load I (251) boot: Loaded app from partition at offset 0x10000 I (251) boot: Disabling RNG early entropy source... I (264) cpu_start: Pro cpu up. I (264) cpu_start: Single core mode I (273) cpu_start: Pro cpu start user code I (273) cpu_start: cpu freq: 160000000 I (273) cpu_start: Application information: I (275) cpu_start: Project name: usb_dongle I (281) cpu_start: App version: 1 I (285) cpu_start: Compile time: Jun 21 2022 13:24:36 I (291) cpu_start: ELF file SHA256: c457c08d78f65180... I (297) cpu_start: ESP-IDF: v4.4-dirty I (302) heap_init: Initializing. RAM available for dynamic allocation: I (310) heap_init: At 3FC9D488 len 00042B78 (266 KiB): D/IRAM I (316) heap_init: At 3FCE0000 len 0000EE34 (59 KiB): STACK/DRAM I (323) heap_init: At 3FCF0000 len 00008000 (32 KiB): DRAM I (329) heap_init: At 600FE000 len 00002000 (8 KiB): RTCRAM I (336) spi_flash: detected chip: generic I (340) spi_flash: flash io: dio W (344) spi_flash: Detected size(8192k) larger than the size in the binary image header(4096k). Using the size in the binary image header. I (357) sleep: Configure to isolate all GPIO pins in sleep state I (364) sleep: Enable automatic switching of GPIO sleep configuration I (371) coexist: coexist rom version e7ae62f I (376) cpu_start: Starting scheduler on PRO CPU. I (387) pp: pp rom version: e7ae62f I (387) net80211: net80211 rom version: e7ae62f I (397) system_api: Base MAC address is not set I (397) system_api: read default base MAC address from EFUSE I (407) wifi_init: rx ba win: 6 I (407) wifi_init: tcpip mbox: 32 I (407) wifi_init: udp mbox: 6 I (417) wifi_init: tcp mbox: 6 I (417) wifi_init: tcp tx win: 5744 I (427) wifi_init: tcp rx win: 5744 I (427) wifi_init: tcp mss: 1440 I (427) wifi_init: WiFi IRAM OP enabled I (437) wifi_init: WiFi RX IRAM OP enabled I (437) phy_init: phy_version 302,3ddfab3,Dec 3 2021,14:39:12 I (487) USB_Dongle: USB initialization I (487) tusb_desc: using default config desc I (487) tusb_desc: config desc size=75 I (487) tusb_desc: ┌─────────────────────────────────┐ │ USB Device Descriptor Summary │ ├───────────────────┬─────────────┤ │bDeviceClass │ 0 │ ├───────────────────┼─────────────┤ │bDeviceSubClass │ 0 │ ├───────────────────┼─────────────┤ │bDeviceProtocol │ 0 │ ├───────────────────┼─────────────┤ │bMaxPacketSize0 │ 64 │ ├───────────────────┼─────────────┤ │idVendor │ 0x303a │ ├───────────────────┼─────────────┤ │idProduct │ 0x4012 │ ├───────────────────┼─────────────┤ │bcdDevice │ 0x100 │ ├───────────────────┼─────────────┤ │iManufacturer │ 0x1 │ ├───────────────────┼─────────────┤ │iProduct │ 0x2 │ ├───────────────────┼─────────────┤ │iSerialNumber │ 0x3 │ ├───────────────────┼─────────────┤ │bNumConfigurations │ 0x1 │ └───────────────────┴─────────────┘ I (657) TinyUSB: TinyUSB Driver installed I (667) uart: queue free spaces: 20 I (667) USB_Dongle: USB initialization DONE Guru Meditation Error: Core 0 panic'ed (StoreProhibited). Exception was unhandled.

Core 0 register dump: PC : 0x420095d4 PS : 0x00060d30 A0 : 0x820095f1 A1 : 0x3fcf2d60
0x420095d4: rndis_indicate_status at C:/Work/Espressif/frameworks/esp-iot-solution/components/usb/tinyusb/additions/tusb/src/lib/networking/rndis_reports.c:241

A2 : 0x4001000c A3 : 0x00000001 A4 : 0x00000001 A5 : 0x0000000c A6 : 0x00000000 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000007
A10 : 0x00060d23 A11 : 0x00000000 A12 : 0x00060d20 A13 : 0x3fcf2ca0
A14 : 0x00000037 A15 : 0x3fcf2ca0 SAR : 0x00000004 EXCCAUSE: 0x0000001d EXCVADDR: 0x00000000 LBEG : 0x400570e8 LEND : 0x400570f3 LCOUNT : 0x00000000

Backtrace:0x420095d1:0x3fcf2d600x420095ee:0x3fcf2d80 0x42007265:0x3fcf2da0 0x42006cfd:0x3fcf2e50 0x4206f48b:0x3fcf2e80 0x4037efe5:0x3fcf2ea0 0x420095d1: rndis_indicate_status at C:/Work/Espressif/frameworks/esp-iot-solution/components/usb/tinyusb/additions/tusb/src/lib/networking/rndis_reports.c:241

0x420095ee: rndis_disconnect at C:/Work/Espressif/frameworks/esp-iot-solution/components/usb/tinyusb/additions/tusb/src/lib/networking/rndis_reports.c:253

0x42007265: wifi_cmd_sta_join at C:\Users\cxuer\Desktop\esp\usb_dongle\build/../main/cmd_wifi.c:247

0x42006cfd: app_main at C:\Users\cxuer\Desktop\esp\usb_dongle\build/../main/usb_dongle_main.c:133 (discriminator 2)

0x4206f48b: main_task at C:/Work/Espressif/frameworks/esp-idf-v4.4/components/freertos/port/port_common.c:129 (discriminator 2)

0x4037efe5: vPortTaskWrapper at C:/Work/Espressif/frameworks/esp-idf-v4.4/components/freertos/port/xtensa/port.c:131

xhcyf commented 2 years ago

Add some latest information, I commented out NET_DISCONNECT and NET_CONNECT in the wifi_cmd_sta_join function, and then all functions worked fine.

daetery commented 1 year ago

/ Register commands with the FreeRTOS+CLI command interpreter. / //vRegisterCLICommands();

/ If you add delay, it works normally without commenting out NET_DISCONNECT and NET_CONNECT in wifi_cmd_sta_join. / usleep(1000 * 300);

const char ssid = "xxxxxx", psd = "xxxxxxx"; wifi_cmd_sta_join(ssid,psd);