esp-idf: ESP-NOW Examples crash during runtime (esp_wifi_set_channel failure) (IDFGH-2156)

Environment

  • Development Kit: ESP32-Wrover-Kit|
  • Kit version (for WroverKit/PicoKit/DevKitC): [v4]
  • Module or chip used: ESP32-WROOM-32
  • IDF version (run git describe --tags to find it): v4.1-dev-474-g2e6398aff
  • Build System: Make
  • Compiler version (run xtensa-esp32-elf-gcc --version to find it): xtensa-esp32-elf-gcc (crosstool-NG crosstool-ng-1.22.0-80-g6c4433a) 5.2.0
  • Operating System: macOS
  • Power Supply: N/A

Problem Description

ESP-NOW example in master fails at esp_wifi_set_channel command in both station and softAp mode.

Expected Behavior

ESP-NOW examples to work as per Readme. For esp_wifi_set_channel to execute without error.

Actual Behavior

E (747) wifi: esp_wifi_set_channel 1454 wifi not start or sniffer not enabled, should start wifi or enable sniffer first
ESP_ERROR_CHECK failed: esp_err_t 0x3002 (ESP_ERR_WIFI_NOT_STARTED) at 0x4008b7ac

Steps to repropduce

  1. step1

// It helps if you attach a picture of your setup/wiring here.

Code to reproduce this issue

cd $IDF_PATH/examples/wifi/espnow
make flash monitor

Debug Logs

I (393) cpu_start: App cpu up.
I (418) heap_init: Initializing. RAM available for dynamic allocation:
I (424) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (430) heap_init: At 3FFB9228 len 00026DD8 (155 KiB): DRAM
I (437) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (443) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (449) heap_init: At 400905C4 len 0000FA3C (62 KiB): IRAM
I (456) cpu_start: Pro cpu start user code
I (474) spi_flash: detected chip: generic
I (475) spi_flash: flash io: dio
I (475) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (577) wifi: wifi driver task: 3ffc0b18, prio:23, stack:3584, core=0
I (577) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (577) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (607) wifi: wifi firmware version: 932678a
I (607) wifi: config NVS flash: enabled
I (607) wifi: config nano formating: disabled
I (607) wifi: Init dynamic tx buffer num: 32
I (607) wifi: Init data frame dynamic rx buffer num: 32
I (617) wifi: Init management frame dynamic rx buffer num: 32
I (617) wifi: Init management short buffer num: 32
I (627) wifi: Init static rx buffer size: 1600
I (627) wifi: Init static rx buffer num: 10
I (637) wifi: Init dynamic rx buffer num: 32
I (727) phy: phy_version: 4102, 2fa7a43, Jul 15 2019, 13:06:06, 0, 0
I (727) wifi: mode : softAP (80:7d:3a:8f:73:d5)
I (727) wifi: Total power save buffer number: 16
I (737) wifi: Init max length of beacon: 752/752
I (737) wifi: Init max length of beacon: 752/752
E (747) wifi: esp_wifi_set_channel 1454 wifi not start or sniffer not enabled, should start wifi or enable sniffer first
ESP_ERROR_CHECK failed: esp_err_t 0x3002 (ESP_ERR_WIFI_NOT_STARTED) at 0x4008b7ac

Other items if possible

espnow_error.zip

E (747) wifi: esp_wifi_set_channel 1454 wifi not start or sniffer not enabled, should start wifi or enable sniffer first
ESP_ERROR_CHECK failed: esp_err_t 0x3002 (ESP_ERR_WIFI_NOT_STARTED) at 0x4008b7ac
0x4008b7ac: _esp_error_check_failed at /Users/aturner/Code/Hardware/esp/esp-idf/components/esp32/panic.c:739

file: "/Users/aturner/Code/Hardware/esp/esp-idf/examples/wifi/espnow/main/espnow_example_main.c" line 56
func: example_wifi_init
expression: esp_wifi_set_channel(CONFIG_ESPNOW_CHANNEL, 0)

ELF file SHA256: 2c4833bb6dade5e36082cee79fbc0b4836774d831ee44cef4991977a2e70f0fb

Backtrace: 0x4008b221:0x3ffbaf30 0x4008b7af:0x3ffbaf50 0x400d2acd:0x3ffbaf70 0x400d3236:0x3ffbb030 0x400d0fba:0x3ffbb050 0x4008d759:0x3ffbb070
0x4008b221: invoke_abort at /Users/aturner/Code/Hardware/esp/esp-idf/components/esp32/panic.c:734

0x4008b7af: _esp_error_check_failed at /Users/aturner/Code/Hardware/esp/esp-idf/components/esp32/panic.c:740

0x400d2acd: example_wifi_init at /Users/aturner/Code/Hardware/esp/esp-idf/examples/wifi/espnow/main/espnow_example_main.c:56 (discriminator 1)

0x400d3236: app_main at /Users/aturner/Code/Hardware/esp/esp-idf/examples/wifi/espnow/main/espnow_example_main.c:373

0x400d0fba: main_task at /Users/aturner/Code/Hardware/esp/esp-idf/components/esp32/cpu_start.c:569

0x4008d759: vPortTaskWrapper at /Users/aturner/Code/Hardware/esp/esp-idf/components/freertos/port.c:403


Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:7008

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 20 (4 by maintainers)

Commits related to this issue

Most upvoted comments

this is NOT bug, in the latest v3.3, we added the limitation to esp_wifi_set_channel(), it can be called only both of following conditions are met:

  1. esp_wifi_start() is returned
  2. sniffer is enabled

Should always work unless STA mode is connected to an AP or a scan is in progress. Required for espnow and esp_wifi_80211_tx.

https://github.com/espressif/esp-idf/issues/4005