espressif / esp-hosted

Hosted Solution (Linux/MCU) with ESP32 (Wi-Fi + BT + BLE)
Other
695 stars 162 forks source link

Problem with Spi Protocol stack #175

Closed LuciaferKelvin closed 1 year ago

LuciaferKelvin commented 1 year ago

hello there. I have a problem with mcu spi Protocol stack , My mcu work as host .The project have a F429 project with RTOS. How can I using the spi function without rtos? I had not find out any information with how to framing. And I am sure that the spi interface is work ok ,I had using ESP_LOGI function log what am I send by mcu. Could you tell me how to framing and what is the setting step ?

mantriyogesh commented 1 year ago

Hello @LuciaferKelvin

Can you please explain the scenario with logs (ESP, Host side commands, their output, snippet of commands/ codes you are trying to make work)? I am still trying to understand at what layer, what exactly is the problem.

LuciaferKelvin commented 1 year ago

@mantriyogesh hello , last question need some time to collect the info . I have a new questions. how long will the esp entry the save power mode since recive last message form route in station mode ? the esp default save power mode is (WIFI_PS_MIN_MODEM), I found that when i using icmp to ping the sta, the delay time like this . image but if I do a lot of transmision when using icmp to ping esp , the delay time like this. image so I think maybe the save power cause that problem , because the icmp ping will send the package every one second.

mantriyogesh commented 1 year ago
  1. Is host system a Linux or microcontroller?
  2. Can you change https://github.com/espressif/esp-hosted/blob/8dc9280339e1539ba4a5bae65a77b3fe99c9ce14/esp_hosted_fg/host/linux/host_control/c_support/ctrl_config.h#L61 to 3 (This will still allow modem sleep with WIFI_PS_MIN_MODEM enabled but more frequent wakeups)
  3. Disable Min modem sleep, which means modem will always be alert. Please note, ESP on boot enters into WIFI_PS_MIN_MODEM. To disable this behaviour:
    • Are you using Bluetooth? If not, you can change the power save value to WIFI_PS_NONE . ESP-Hosted right now doesn't allow it to be set to None as ESP-Hosted by default allows BT+Wi-Fi, which needs at least WIFI_PS_MIN_MODEM (to switch in between radio freq when either Bluetooth or Wi-Fi is sleeping)
    • You might have to manually mandate esp_wifi_set_ps(WIFI_PS_NONE); at the end of app_main.c
    • Do not change the power save later from host side.
  4. If you use microcontroller, also you need to check your network stack, if it behaves fine.
LuciaferKelvin commented 1 year ago
  1. I using microcontroller.
  2. not linux
mantriyogesh commented 1 year ago
  1. okay
  2. typedef enum {
    WIFI_PS_MIN_MODEM = 1,
    WIFI_PS_MAX_MODEM,
    WIFI_PS_INVALID,
    } wifi_ps_type_t;

is hosted defined structure (which you can ignore). we are re-structring to re-use this structure from esp-idf . Anyway at slave side code should have visibility of https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv414wifi_ps_type_t. from esp-idf code.

just follow point (3) from https://github.com/espressif/esp-hosted/issues/175#issuecomment-1581853363

  1. Power save is re-used from ESP-IDF as is. Details could be found from ESP-IDF documentation, https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#station-sleep
LuciaferKelvin commented 1 year ago

ok thanks a lot

LuciaferKelvin commented 1 year ago

Does WIFI_PS_NONE is WIFI_PS_INVALID?

mantriyogesh commented 1 year ago

no.

  1. Ignore structure

    typedef enum {
    WIFI_PS_MIN_MODEM = 1,
    WIFI_PS_MAX_MODEM,
    WIFI_PS_INVALID,
    } wifi_ps_type_t;

    at ESP-Hosted.

  2. Add

    esp_wifi_set_ps(WIFI_PS_NONE);

    at the end of app_main.c

It makes use of structure https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv414wifi_ps_type_t

  1. Do not set the power save from host as WIFI_PS_NONE is not supported from host.
LuciaferKelvin commented 1 year ago

is that means it must set at esp firmware code ?

mantriyogesh commented 1 year ago

yes in case of 0.4, at https://github.com/espressif/esp-hosted/blob/74e707b604280ecb2eafa60ba5ed6993ce57b457/esp/esp_driver/network_adapter/main/app_main.c#L755

LuciaferKelvin commented 1 year ago

it was crashed. `ESP-ROM:esp32c3-api1-20210207 Build:Feb 7 2021 rst:0x3 (RTC_SW_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT) Saved PC:0x403806ba riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x403806ba: [WinError 2] ????????????????????????????????? SPIWP:0xee mode:DIO, clock div:1 load:0x3fcd5810,len:0x16bc load:0x403cc710,len:0x930 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x403cc710: [WinError 2] ????????????????????????????????? load:0x403ce710,len:0x2d28 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x403ce710: [WinError 2] ????????????????????????????????? entry 0x403cc710 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x403cc710: [WinError 2] ????????????????????????????????? I (35) boot: ESP-IDF v4.4.3-dirty 2nd stage bootloader I (35) boot: compile time 16:21:57 I (35) boot: chip revision: 4 I (37) boot_comm: chip revision: 4, min. bootloader chip revision: 3 I (44) boot.esp32c3: SPI Speed : 80MHz I (49) boot.esp32c3: SPI Mode : DIO I (54) boot.esp32c3: SPI Flash Size : 4MB I (58) boot: Enabling RNG early entropy source... I (64) boot: Partition Table: I (67) boot: ## Label Usage Type ST Offset Length I (75) boot: 0 nvs WiFi data 01 02 00009000 00004000 I (82) boot: 1 otadata OTA data 01 00 0000d000 00002000 I (90) boot: 2 phy_init RF data 01 01 0000f000 00001000 I (97) boot: 3 factory factory app 00 00 00010000 00100000 I (105) boot: 4 ota_0 OTA app 00 10 00110000 00100000 I (112) boot: 5 ota_1 OTA app 00 11 00210000 00100000 I (120) boot: End of partition table I (124) boot: Defaulting to factory image I (129) boot_comm: chip revision: 4, min. application chip revision: 3 I (136) esp_image: segment 0: paddr=00010020 vaddr=3c0a0020 size=1c908h (117000) map I (163) esp_image: segment 1: paddr=0002c930 vaddr=3fc92a00 size=03328h ( 13096) load I (165) esp_image: segment 2: paddr=0002fc60 vaddr=40380000 size=003b8h ( 952) load I (169) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=95980h (612736) map I (273) esp_image: segment 4: paddr=000c59a8 vaddr=403803b8 size=12510h ( 75024) load I (287) esp_image: segment 5: paddr=000d7ec0 vaddr=50000010 size=00010h ( 16) load I (293) boot: Loaded app from partition at offset 0x10000 I (293) boot: Disabling RNG early entropy source... I (307) cpu_start: Pro cpu up. I (315) cpu_start: Pro cpu start user code I (316) cpu_start: cpu freq: 160000000 I (316) cpu_start: Application information: I (318) cpu_start: Project name: network_adapter I (324) cpu_start: App version: 1 I (328) cpu_start: Compile time: Jun 8 2023 16:20:30 I (334) cpu_start: ELF file SHA256: bc34575f258c9b20... I (340) cpu_start: ESP-IDF: v4.4.3-dirty I (346) heap_init: Initializing. RAM available for dynamic allocation: I (353) heap_init: At 3FC9B020 len 000416F0 (261 KiB): DRAM I (359) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM I (366) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM I (373) spi_flash: detected chip: generic I (377) spi_flash: flash io: dio I (381) sleep: Configure to isolate all GPIO pins in sleep state I (388) sleep: Enable automatic switching of GPIO sleep configuration I (395) coexist: coexist rom version 9387209 I (400) cpu_start: Starting scheduler. I (404) NETWORK_ADAPTER: I (404) NETWORK_ADAPTER: ESP-Hosted Firmware version :: 0.4 I (414) NETWORK_ADAPTER: Transport used :: SPI I (424) NETWORK_ADAPTER: I (434) NETWORK_ADAPTER: Supported features are: I (444) NETWORK_ADAPTER: - WLAN over SPI I (444) ESP_BT: - BT/BLE I (454) ESP_BT: - HCI Over SPI I (454) ESP_BT: - BLE only I (464) BTDM_INIT: BT controller compile version [421c279] I (464) phy_init: phy_version 912,d001756,Jun 2 2022,16:28:07 I (504) system_api: Base MAC address is not set I (504) system_api: read default base MAC address from EFUSE I (504) BTDM_INIT: Bluetooth MAC: 34:85:18:d1:ae:de

I (504) NETWORK_ADAPTER: ESP Bluetooth MAC addr: 34-85-18-d1-ae-de

I (514) SPI_DRIVER: Using SPI interface I (514) gpio: GPIO[3]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (524) gpio: GPIO[4]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0 I (1534) pp: pp rom version: 9387209 I (1534) net80211: net80211 rom version: 9387209

abort() was called at PC 0x42074ead on core 0 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x42074ead: [WinError 2] ????????????????????????????????? Core 0 register dump: MEPC : 0x403808c0 RA : 0x40389572 SP : 0x3fcb2c10 GP : 0x3fc93200 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x403808c0: [WinError 2] ????????????????????????????????? riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x40389572: [WinError 2] ????????????????????????????????? TP : 0x3fc96c24 T0 : 0x37363534 T1 : 0x7271706f T2 : 0x33323130 S0/FP : 0x00000004 S1 : 0x3fcb2c74 A0 : 0x3fcb2c3c A1 : 0x3fcb2c72 A2 : 0x00000000 A3 : 0x3fcb2c69 A4 : 0x00000001 A5 : 0x3fc9a000
A6 : 0x7a797877 A7 : 0x76757473 S2 : 0xffffffff S3 : 0x3ff1b5a8 S4 : 0x3fce0000 S5 : 0x3fce0000 S6 : 0x3fce0000 S7 : 0x3fce0000
S8 : 0x3ff1b000 S9 : 0x3fce0000 S10 : 0x3fcdf934 S11 : 0x00000000 T3 : 0x6e6d6c6b T4 : 0x6a696867 T5 : 0x66656463 T6 : 0x62613938
MSTATUS : 0x00001881 MTVEC : 0x40380001 MCAUSE : 0x00000007 MTVAL : 0x00000000 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x40380001: [WinError 2] ????????????????????????????????? MHARTID : 0x00000000

Stack memory: 3fcb2c10: 0x00000002 0x00000004 0x3fcb2c70 0x40390544 0x00000000 0x00000012 0x00000001 0x3fc95220 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x40390544: [WinError 2] ????????????????????????????????? 3fcb2c30: 0x3fcb2c74 0x3fc9523c 0x3fcb2c70 0x726f6261 0x20292874 0x20736177 0x6c6c6163 0x61206465 3fcb2c50: 0x43502074 0x34783020 0x34373032 0x20646165 0x63206e6f 0x2065726f 0x00000030 0x3ff10000 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x43502074: [WinError 2] ????????????????????????????????? 3fcb2c70: 0xffff0030 0x37303234 0x64616534 0x42074e00 0x00000000 0x00000000 0x3fce0000 0x42074eb0 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x42074e00: [WinError 2] ????????????????????????????????? riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x42074eb0: [WinError 2] ????????????????????????????????? 3fcb2c90: 0x3fc9883c 0xffffffff 0x3fcb12d0 0x42061d0a 0x00000000 0x3fcdf918 0x3fcb12d0 0x4205f956 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x42061d0a: [WinError 2] ????????????????????????????????? riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x4205f956: [WinError 2] ????????????????????????????????? 3fcb2cb0: 0x00000000 0x3fcdf918 0x3fce0000 0x4004094c 0x00000000 0x00000000 0x00000006 0x3fcb12d0 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x4004094c: [WinError 2] ????????????????????????????????? 3fcb2cd0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 3fcb2cf0: 0x00000000 0x00000000 0x00000000 0x4038cc12 0x00000000 0x00000000 0x00000000 0x00000000 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x4038cc12: [WinError 2] ????????????????????????????????? 3fcb2d10: 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0x00000154 0x3fcb2be0 3fcb2d30: 0x3fc9b034 0x3fc96734 0x3fc96734 0x3fcb2d2c 0x3fc9672c 0x00000002 0x3fcb0c64 0x3fcb0c64 3fcb2d50: 0x3fcb2d2c 0x00000000 0x00000017 0x3fcb1328 0x69666977 0xceefa200 0x92128143 0x0000245e 3fcb2d70: 0x00000000 0x3fcb2d20 0x00000017 0x00000000 0x00000000 0x00000000 0x00000000 0x3fc9b9d8 3fcb2d90: 0x3fc9ba40 0x3fc9baa8 0x00000000 0x00000000 0x00000001 0x00000000 0x00000000 0x00000000 3fcb2db0: 0x4208217c 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 riscv32-esp-elf-addr2line -pfiaC -e d:\Program\ESP32\esp-hosted-release-v0.4\esp\esp_driver\network_adapter\build\network_adapter.elf 0x4208217c: [WinError 2] ????????????????????????????????? 3fcb2dd0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 3fcb2df0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 3fcb2e10: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 3fcb2e30: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 3fcb2e50: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 3fcb2e70: 0x00000000 0x00000000 0x00000000 0x3f000000 0x00000054 0x3fcb2e84 0x3fcb2e84 0x3fcb2e84 3fcb2e90: 0x3fcb2e84 0x00000000 0x3fcb2e9c 0xffffffff 0x3fcb2e9c 0x3fcb2e9c 0x00000000 0x3fcb2eb0 3fcb2eb0: 0xffffffff 0x3fcb2eb0 0x3fcb2eb0 0x00000000 0x00000001 0x00000000 0x6600ffff 0x00000000 3fcb2ed0: 0xb33fffff 0x00000000 0x00000820 0x6f6d706f 0x00006564 0x2e617473 0x64697373 0x00000000 3fcb2ef0: 0x2e617473 0x68747561 0x65646f6d 0x00010000 0x00000000 0x00000003 0x00000002 0x3fc98cb4 3fcb2f10: 0x2e617473 0x64697373 0x00000000 0x2e617473 0x68747561 0x65646f6d 0x00000000 0x2e617473 3fcb2f30: 0x00240701 0x00000000 0x00000000 0x00000000 0x3fc98cb8 0x2e617473 0x68747561 0x65646f6d 3fcb2f50: 0x00000000 0x2e617473 0x64777370 0x00000000 0x2e617473 0x00010002 0x00000001 0x00000007 3fcb2f70: 0x00000001 0x3fc98ce2 0x2e617473 0x64777370 0x00000000 0x2e617473 0x006b6d70 0x2e617473 3fcb2f90: 0x6e616863 0x00000000 0x00410603 0x00000000 0x00000000 0x00000000 0x3fc98ce3 0x2e617473 3fcb2fb0: 0x006b6d70 0x2e617473 0x6e616863 0x00000000 0x6f747561 0x6e6f632e 0x0000006e 0x00200704 3fcb2fd0: 0x00000000 0x00000000 0x00000000 0x3fc98d24 0x2e617473 0x6e616863 0x00000000 0x6f747561 3fcb2ff0: 0x6e6f632e 0x0000006e 0x69737362 0x65732e64 0x00010005 0x00000000 0x0000000e 0x00000000

ELF file SHA256: bc34575f258c9b20

Rebooting...`

LuciaferKelvin commented 1 year ago

image

mantriyogesh commented 1 year ago

So you are using bluetooth.

  1. You can disable bluetooth by 1a) menuconfig
    $ cd esp/esp_driver/network_adapter
    $ rm -rf sdkconfig build/
    $ idf.py menuconfig

    Navigate to Component config > Bluetooth Disable 'Bluetooth'

    $ idf.py build flash monitor

OR

1b) always disable by default : change file sdkconfig.defaults.esp32c3 such that CONFIG_BT_ENABLED=n

$ cd esp/esp_driver/network_adapter
--- a/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c3
+++ b/esp/esp_driver/network_adapter/sdkconfig.defaults.esp32c3
 CONFIG_FREERTOS_UNICORE=y
 CONFIG_SDIO_DAT2_DISABLED=

 # BT Configuration
-CONFIG_BT_ENABLED=y
-CONFIG_BT_CONTROLLER_ONLY=y
-CONFIG_BT_BLUEDROID_ENABLED=
-CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
-CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
-CONFIG_BTDM_CTRL_MODE_BTDM=n
-CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y
+CONFIG_BT_ENABLED=n
+#CONFIG_BT_CONTROLLER_ONLY=y
+#CONFIG_BT_BLUEDROID_ENABLED=
+#CONFIG_BTDM_CTRL_MODE_BLE_ONLY=y
+#CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=n
+#CONFIG_BTDM_CTRL_MODE_BTDM=n
+#CONFIG_BTDM_CTRL_HCI_MODE_VHCI=y

 CONFIG_ESP32_WIFI_NVS_ENABLED=
$ rm -rf sdkconfig build/
$ idf.py build flash monitor
  1. To Verify: In ESP log, 'Supported features' will not show 'BT/BLE'
LuciaferKelvin commented 1 year ago

ok I will try it

LuciaferKelvin commented 1 year ago

is there any error here? image seems the BT-BLE still on , I had delet the folder named build.and rebuild the project setting then flash and monitor.

LuciaferKelvin commented 1 year ago

the log like this:

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x403806ba
0x403806ba: esp_restart_noos_dig at D:/Program/ESP32/ESP-IDF/esp-idf/components/esp_system/esp_system.c:44 (discriminator 1)

SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x16bc
load:0x403cc710,len:0x930
load:0x403ce710,len:0x2d28
entry 0x403cc710
I (35) boot: ESP-IDF v4.4.3-dirty 2nd stage bootloader
I (35) boot: compile time 21:43:12
I (35) boot: chip revision: 4
I (37) boot_comm: chip revision: 4, min. bootloader chip revision: 3
I (44) boot.esp32c3: SPI Speed      : 80MHz
I (49) boot.esp32c3: SPI Mode       : DIO
I (54) boot.esp32c3: SPI Flash Size : 4MB
I (58) boot: Enabling RNG early entropy source...
I (64) boot: Partition Table:
I (67) boot: ## Label            Usage          Type ST Offset   Length
I (75) boot:  0 nvs              WiFi data        01 02 00009000 00004000
I (82) boot:  1 otadata          OTA data         01 00 0000d000 00002000
I (90) boot:  2 phy_init         RF data          01 01 0000f000 00001000
I (97) boot:  3 factory          factory app      00 00 00010000 00100000
I (105) boot:  4 ota_0            OTA app          00 10 00110000 00100000
I (112) boot:  5 ota_1            OTA app          00 11 00210000 00100000
I (120) boot: End of partition table
I (124) boot: Defaulting to factory image
I (129) boot_comm: chip revision: 4, min. application chip revision: 3
I (136) esp_image: segment 0: paddr=00010020 vaddr=3c0a0020 size=1c908h (117000) map
I (163) esp_image: segment 1: paddr=0002c930 vaddr=3fc92a00 size=03328h ( 13096) load
I (165) esp_image: segment 2: paddr=0002fc60 vaddr=40380000 size=003b8h (   952) load
I (169) esp_image: segment 3: paddr=00030020 vaddr=42000020 size=95980h (612736) map
I (273) esp_image: segment 4: paddr=000c59a8 vaddr=403803b8 size=12510h ( 75024) load
I (287) esp_image: segment 5: paddr=000d7ec0 vaddr=50000010 size=00010h (    16) load
I (293) boot: Loaded app from partition at offset 0x10000
I (293) boot: Disabling RNG early entropy source...
I (307) cpu_start: Pro cpu up.
I (315) cpu_start: Pro cpu start user code
I (316) cpu_start: cpu freq: 160000000
I (316) cpu_start: Application information:
I (318) cpu_start: Project name:     network_adapter
I (324) cpu_start: App version:      1
I (328) cpu_start: Compile time:     Jun  8 2023 21:42:34
I (334) cpu_start: ELF file SHA256:  a4d73242f5214dd5...
I (340) cpu_start: ESP-IDF:          v4.4.3-dirty
I (346) heap_init: Initializing. RAM available for dynamic allocation:
I (353) heap_init: At 3FC9B020 len 000416F0 (261 KiB): DRAM
I (359) heap_init: At 3FCDC710 len 00002950 (10 KiB): STACK/DRAM
I (366) heap_init: At 50000020 len 00001FE0 (7 KiB): RTCRAM
I (373) spi_flash: detected chip: generic
I (377) spi_flash: flash io: dio
I (381) sleep: Configure to isolate all GPIO pins in sleep state
I (388) sleep: Enable automatic switching of GPIO sleep configuration
I (395) coexist: coexist rom version 9387209
I (400) cpu_start: Starting scheduler.
I (404) NETWORK_ADAPTER: *********************************************************************
I (404) NETWORK_ADAPTER:                 ESP-Hosted Firmware version :: 0.4
I (414) NETWORK_ADAPTER:                 Transport used :: SPI
I (424) NETWORK_ADAPTER: *********************************************************************
I (434) NETWORK_ADAPTER: Supported features are:
I (444) NETWORK_ADAPTER: - WLAN over SPI
I (444) ESP_BT: - BT/BLE
I (454) ESP_BT:    - HCI Over SPI
I (454) ESP_BT:    - BLE only
I (464) BTDM_INIT: BT controller compile version [421c279]
I (464) phy_init: phy_version 912,d001756,Jun  2 2022,16:28:07
I (494) system_api: Base MAC address is not set
I (504) system_api: read default base MAC address from EFUSE
I (504) BTDM_INIT: Bluetooth MAC: 34:85:18:d1:ae:de

I (504) NETWORK_ADAPTER: ESP Bluetooth MAC addr: 34-85-18-d1-ae-de

I (514) SPI_DRIVER: Using SPI interface
I (514) gpio: GPIO[3]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (524) gpio: GPIO[4]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (1534) pp: pp rom version: 9387209
I (1534) net80211: net80211 rom version: 9387209

abort() was called at PC 0x42074ead on core 0
0x42074ead: pm_set_sleep_type at ??:?

Core  0 register dump:
MEPC    : 0x403808c0  RA      : 0x40389572  SP      : 0x3fcb3020  GP      : 0x3fc93200
0x403808c0: panic_abort at D:/Program/ESP32/ESP-IDF/esp-idf/components/esp_system/panic.c:402

0x40389572: __ubsan_include at D:/Program/ESP32/ESP-IDF/esp-idf/components/esp_system/ubsan.c:294

TP      : 0x3fc97034  T0      : 0x37363534  T1      : 0x7271706f  T2      : 0x33323130
S0/FP   : 0x00000004  S1      : 0x3fcb3084  A0      : 0x3fcb304c  A1      : 0x3fcb3082
A2      : 0x00000000  A3      : 0x3fcb3079  A4      : 0x00000001  A5      : 0x3fc9a000
A6      : 0x7a797877  A7      : 0x76757473  S2      : 0xffffffff  S3      : 0x3ff1b5a8
S4      : 0x3fce0000  S5      : 0x3fce0000  S6      : 0x3fce0000  S7      : 0x3fce0000  
S8      : 0x3ff1b000  S9      : 0x3fce0000  S10     : 0x3fcdf934  S11     : 0x00000000
T3      : 0x6e6d6c6b  T4      : 0x6a696867  T5      : 0x66656463  T6      : 0x62613938  
MSTATUS : 0x00001881  MTVEC   : 0x40380001  MCAUSE  : 0x00000007  MTVAL   : 0x00000000
0x40380001: _vector_table at ??:?

MHARTID : 0x00000000

Stack memory:
3fcb3020: 0x00000002 0x00000004 0x3fcb3080 0x40390544 0x00000000 0x00000012 0x00000001 0x3fc95220
0x40390544: abort at D:/Program/ESP32/ESP-IDF/esp-idf/components/newlib/abort.c:43 (discriminator 3)

3fcb3040: 0x3fcb3084 0x3fc9523c 0x3fcb3080 0x726f6261 0x20292874 0x20736177 0x6c6c6163 0x61206465
3fcb3060: 0x43502074 0x34783020 0x34373032 0x20646165 0x63206e6f 0x2065726f 0x00000030 0x3ff10000
3fcb3080: 0xffff0030 0x37303234 0x64616534 0x42074e00 0x00000000 0x00000000 0x3fce0000 0x42074eb0
0x42074e00: pm_set_sleep_type at ??:?

0x42074eb0: pm_set_sleep_type at ??:?

3fcb30a0: 0x3fc9883c 0xffffffff 0x3fcab764 0x42061d0a 0x00000000 0x3fcdf918 0x3fcab764 0x4205f956
0x42061d0a: wifi_set_ps_process at ??:?

0x4205f956: ieee80211_ioctl_process at ??:?

3fcb30c0: 0x00000000 0x3fcdf918 0x3fce0000 0x4004094c 0x00000000 0x00000000 0x00000006 0x3fcab764
3fcb30e0: 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000 0x00000000
3fcb3100: 0x00000000 0x00000000 0x00000000 0x4038cc12 0x00000000 0x00000000 0x00000000 0x00000000
0x4038cc12: prvTaskExitError at D:/Program/ESP32/ESP-IDF/esp-idf/components/freertos/port/riscv/port.c:178

3fcb3120: 0x00000000 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5 0xa5a5a5a5
3fcb3140: 0x00000820 0x6f6d706f 0x00006564 0x2e617473 0x64697373 0x00000000 0x2e617473 0x68747561
3fcb3160: 0x65646f6d 0x00010000 0x00000000 0x00000003 0x00000002 0x3fc98cb4 0x2e617473 0x64697373
3fcb3180: 0x00000000 0x2e617473 0x68747561 0x65646f6d 0x00000000 0x2e617473 0x00240701 0x00000000
3fcb31a0: 0x00000000 0x00000000 0x3fc98cb8 0x2e617473 0x68747561 0x65646f6d 0x00000000 0x2e617473
3fcb31c0: 0x64777370 0x00000000 0x2e617473 0x00010002 0x00000001 0x00000007 0x00000001 0x3fc98ce2
3fcb31e0: 0x2e617473 0x64777370 0x00000000 0x2e617473 0x006b6d70 0x2e617473 0x6e616863 0x00000000
3fcb3200: 0x00410603 0x00000000 0x00000000 0x00000000 0x3fc98ce3 0x2e617473 0x006b6d70 0x2e617473
3fcb3220: 0x6e616863 0x00000000 0x6f747561 0x6e6f632e 0x0000006e 0x00200704 0x00000000 0x00000000
3fcb3240: 0x00000000 0x3fc98d24 0x2e617473 0x6e616863 0x00000000 0x6f747561 0x6e6f632e 0x0000006e
3fcb3260: 0x69737362 0x65732e64 0x00010005 0x00000000 0x0000000e 0x00000000 0x3fc98d44 0x6f747561
3fcb3280: 0x6e6f632e 0x0000006e 0x69737362 0x65732e64 0x00000074 0x2e617473 0x69737362 0x00010006
3fcb32a0: 0x00000000 0x00000001 0x00000001 0x3fc98d45 0x69737362 0x65732e64 0x00000074 0x2e617473
3fcb32c0: 0x69737362 0x00000064 0x2e617473 0x5f73696c 0x00010007 0x00000000 0x00000001 0x00000000
3fcb32e0: 0x3fc98d46 0x2e617473 0x69737362 0x00000064 0x2e617473 0x5f73696c 0x76746e69 0x00006c61
3fcb3300: 0x2e617473 0x00060708 0x00000000 0x00000000 0x00000000 0x3fc98d47 0x2e617473 0x5f73696c
3fcb3320: 0x76746e69 0x00006c61 0x2e617473 0x6d796870 0x00000000 0x2e617473 0x00020209 0x00000001
3fcb3340: 0x0000ffff 0x00000003 0x3fc98d4e 0x2e617473 0x6d796870 0x00000000 0x2e617473 0x62796870
3fcb3360: 0x00000077 0x2e617473 0x77737061 0x0001000a 0x00000001 0x00000004 0x00000003 0x3fc98d50
3fcb3380: 0x2e617473 0x62796870 0x00000077 0x2e617473 0x77737061 0x00000000 0x2e617473 0x6e697061
3fcb33a0: 0x0001000b 0x00000001 0x00000003 0x00000002 0x3fc98d51 0x2e617473 0x77737061 0x00000000
3fcb33c0: 0x2e617473 0x6e697061 0x00006f66 0x2e617473 0x6e616373 0x0002070c 0x00000000 0x00000000
3fcb33e0: 0x00000000 0x3fc98d52 0x2e617473 0x6e697061 0x00006f66 0x2e617473 0x6e616373 0x74656d5f
3fcb3400: 0x00646f68 0x2e617473 0x02bc070d 0x00000000 0x00000000 0x00000000 0x3fc98d54 0x2e617473

ELF file SHA256: a4d73242f5214dd5
mantriyogesh commented 1 year ago
$ cd esp/esp_driver/network_adapter
$ rm -rf sdkconfig build/
$ idf.py build flash monitor

As I see you are following (1b), please follow the steps mentioned in https://github.com/espressif/esp-hosted/issues/175#issuecomment-1582222392

LuciaferKelvin commented 1 year ago

hello @mantriyogesh I had meet a new question. the station has kick out by route when connected route for a while. and the the route show "disassociated due to inactivity". my mcu just could recive "not connected"status form esp. Is there has any api could my mcu get more information when meet with the case like this? my esp firmware version is v0.4.

LuciaferKelvin commented 1 year ago

my beacon interval is set as default. seems the time interval is 300ms

mantriyogesh commented 1 year ago

Hello @LuciaferKelvin As you were interested in the MCU implementation, you should be notifird with the solution we are developing , ESP as Host at https://github.com/espressif/esp-hosted/issues/186

In this STM also is ported as host.

Most importantly, we have much simplified the port layer, in case you are interested.

For your original question, you can actually enable verbose logs at slave and re-run to understand the disconnection details. Also please consider upgrading to 0.0.5 (better to upgrade to code in issue #186, which is under development, but will be released in some time out)

To enable debug logs, please follow the steps to flash the firmware using source code.

$ idf.py menuconfig

Change default log level to verbose,

navigate to : Component config > Log output > Default log verbosity change the log level to Verbose

escape+ to exit.

Flash to esp

$ idf.py flash monitor

:warning: Please make sure that,

  1. You are using correct ESP commit at ESP while doing this.
  2. ESP and host both pointing to same code base and git commit version.
LuciaferKelvin commented 1 year ago

image I had made the log level become to verbose. Could you explain what is the means of the logs showing pic?

mantriyogesh commented 1 year ago

Just to debug & localise the problem, You can also try to assess the problem before doing entering debugging if anything improves:

  1. Just Change the AP config so that AP will use 'auto' channel selection, bandwidth to 40MHz.
  2. Change the AP itself to some other AP or mobile hotspot

Verbose puts a lot logs from across the system. The above logs could be ignored, or commented if not important in your session. but anyway, did you reproduce the issue with verbose logs?

Additionally, below logs would be helpful:

  1. Enable additional wifi debug logs using: https://github.com/espressif/esp-hosted/blob/74e707b604280ecb2eafa60ba5ed6993ce57b457/esp/esp_driver/network_adapter/main/app_main.c#L179

Just before esp_wifi_internal_set_log_level(), Add,

g_wifi_log_module = WIFI_LOG_MODULE_ALL;
g_wifi_log_submodule |= WIFI_LOG_SUBMODULE_ALL;
  1. ESP supplicant logs Component config > Wi-Fi => Enable 'Print debug messages from WPA Supplicant'

  2. system wide verbose logs: Component config > Log output > Default log verbosity => Select 'Verbose'

  3. Possibly, take wifi sniffer capture from start of the scenario (make sure you start sniffer before first connection, otherwise cannot decrypt the pcap). Sniffer tells the whole picture happening on RF level.

Please get full textual slave and host side logs to understand the issue.

LuciaferKelvin commented 1 year ago

image its that means the ap was no response esp station beacon frame?

mantriyogesh commented 1 year ago

Please send full and textual log at both SLAVE and HOST. No images please. I did not understand what you trying to mean by 'its that means the ap was no response esp station beacon frame?'

To confirm any specific message is sent/not sent by AP OR slave station, sniffer logs will exactly point what is wrong.

LuciaferKelvin commented 1 year ago

I cant show the host log because I had reproject host code . Now my host is using LWIP. The ESP only as a netif . And the log is too many,The log in the pic has refreashed. In that pic log : D (83276) event: no handler have been registered for event WIFI_EVENT:21 posted to loop 0x3fcafb08 I have find out the EVENT 21, It is WIFI_EVENT_STA_BEACON_TIMEOUT. Is that means the Ap had not repsonse the ESP station beacon frame at all ? Then the ESP station had reconnecting the AP.

mantriyogesh commented 1 year ago

Possible but actual scenario can only be understood by sniffer logs. If you have some Linux box, sniffer are very easy to setup.

That is the reason, I asked you to try with another AP as well.

Also, were you able to do (2) & (3) from https://github.com/espressif/esp-hosted/issues/175#issuecomment-1581853363?

  1. Disable the Bluetooth at the ESP slave using $ cd esp/esp_driver/network_adapter/ $ idf.py menuconfig Component config > Bluetooth => unselect 'Bluetooth' escape to exit.

  2. Edit slave side file esp/esp_driver/network_adapter/main/app_main.c -> in function initialise_wifi() add

    esp_wifi_set_ps(WIFI_PS_NONE);

    and stop using power save mode from host (to avoid any rewrite)

  3. Can you please confirm if listen_interval used is 3? It is also okay, if you do not set anything, in that case it would be 0, which internally will automatically change to 3.

Using above (1) , (2) and (3), ESP Wi-Fi modem will not enter power save and listen interval to 3 make sure that ESP will wakeup as per IEEEE expectations.

LuciaferKelvin commented 1 year ago

I cant using the linux because company rules. I will try to set it in the vscode on windows. by the way , if I start the SoftAp.Will the power save mode change be WIFI_PS_NONE? I had done a experiment. When I only set the station mode, then try to ping ESP. The time interval between 10ms and 150ms. When I set both of SoftAp mode and Station mode, the try to ping ESP. The time interval between 10ms and 20ms. It that means the power save mode was close?

LuciaferKelvin commented 1 year ago

all of that ping is ping ESP station not SoftAp.

mantriyogesh commented 1 year ago

Oh I was under impression that you had problem in station mode.

mantriyogesh commented 1 year ago

there is no power save in softap mode, as wifi will be always active.

LuciaferKelvin commented 1 year ago

Yes , the problem is in station mode. That way is only for test disable the power save mode.

mantriyogesh commented 1 year ago

I am not able to understand the problem. Can you please let me know the exact issue you face and with what conditions?

When I only set the station mode, then try to ping ESP. The time interval between 10ms and 150ms.

Is this the problem? In only station mode, please follow https://github.com/espressif/esp-hosted/issues/175#issuecomment-1637562040

If station+softAP mode, anyway power save will be off and Wi-Fi will always be active, so, no need to do changes for power save as long as softap is running(started).

LuciaferKelvin commented 1 year ago

I can set the softap mode. I had done the development with station and softap. Just not using the softap at the project. I can open the softap any time. then let the station disable the power save mode . At that way, I will need not change the firmware . It a bit diffcult to change the setting in vscode on windows.

LuciaferKelvin commented 1 year ago

I am not able to understand the problem. Can you please let me know the exact issue you face and with what conditions?

When I only set the station mode, then try to ping ESP. The time interval between 10ms and 150ms.

Is this the problem? In only station mode, please follow #175 (comment)

If station+softAP mode, anyway power save will be off and Wi-Fi will always be active, so, no need to do changes for power save as long as softap is running(started).

that is because station is in power save mode . i am sure about that. Because if I make the data transmission quickly and keep it. the ping time interval also between 10ms and 20ms. if set softap, the resault also like this. if not set softap or not make the data transmission , the ping time interval between 10ms and 150ms.

LuciaferKelvin commented 1 year ago

like https://github.com/espressif/esp-hosted/issues/175#issuecomment-1581839170

mantriyogesh commented 1 year ago

Anyway, to summarise, if you setup station mode and don't use softap, and do ping test, the ping rtt varies from 10ms to 150ms. If station+softap mode used, you observe less rtt for same test.

When only station mode is setup, please disable power save and use listen_interval from https://github.com/espressif/esp-hosted/issues/175#issuecomment-1637562040 and let us know the result.

LuciaferKelvin commented 1 year ago

ok

LuciaferKelvin commented 1 year ago

hello @mantriyogesh . Still same problem with last question had I asked for help. I do a test start the softap and station in order to disable power save mode. It doesn`t make it.The station is still kick out by ap or disconnect ap . The disassoc reason is 1 when ap kick out esp. The disassoc reason report 4 by esp when esp disconnected the ap. And I found a new condition. The condition is only set up station mode. The esp is send a lot of null data frame to ap even the ap response the ack frame. Is it the normal condition? image

mantriyogesh commented 1 year ago

Can you please let me know

  1. Which host is being used? Any details of host?
  2. Is this tested over lastest master?
  3. What is the git commit used?
LuciaferKelvin commented 1 year ago

1.The firmwork is release 0.4.Host is the mcu. 2.I cant understand what is your mens? 3.same to 2.

LuciaferKelvin commented 1 year ago

I know the reason. The power save mode .

LuciaferKelvin commented 1 year ago

Hello @mantriyogesh . what is the reason will let the negotiated rate very low, but the SNR is high? I using two of the equipments make a test which is using esp to connect with the ap,the ap is the same route. One equipment negotiated rate is 1.0Mbit/s ,and the SNR is 32 db in 11gn.It always lost with ap, and reconnected. Another equipment negotiated rate is 26.0Mbit/s , and the SNR is 28dB. it is working normaly.And never lost the connection with the ap. The two equipments using the same software and hardware,and the esp-host firmware also same with each other. Do you had ever meet the issue like this?

mantriyogesh commented 1 year ago

@kapilkedawat any inputs?

kapilkedawat commented 1 year ago

Hi @LuciaferKelvin,

Can you please share sniffer capture at https://github.com/espressif/esp-hosted/issues/175#issuecomment-1645542652?

LuciaferKelvin commented 1 year ago

that is the onmiPeek sniffer capture log , Do you need it ?

LuciaferKelvin commented 1 year ago

@kapilkedawat I can send it to you by email, not in here.

LuciaferKelvin commented 1 year ago

@mantriyogesh hello, I want to using the BLE function based on esp hosted firmware which version is release v0.4. How to send the AT cmd to esp32c3? Is it by HCI interface?

mantriyogesh commented 1 year ago

Please check on ESP-AT repo: https://github.com/espressif/esp-at

LuciaferKelvin commented 1 year ago

I want to using the STA ,AP,BLE function at the same time . Is it support that case on the esp hosted release v0.4?

LuciaferKelvin commented 1 year ago

now I can using the ap and sta function at the same times, I can not sure if it could support BLE as same.