WiFi AP mode now fail with new API

catotonic
Posts: 36
Joined: Sun Jul 16, 2017 6:55 pm
Location: Houston, TX
Contact:

WiFi AP mode now fail with new API

Postby catotonic » Wed Nov 29, 2017 9:39 pm

I am not sure, but ever since I downloaded and upgraded the firmware on 11/26/17 and have not been able to run the WiFi AP example that I ran before.
I downloaded the newer API because of the issue I was having with fat.h header file being recognized but now I am having problems with setting up WiFi in AP mode.
I also reloaded the tool chain and ran git upgrade recursive.

The error happens when calling esp_wifi_init(&wifi_init_config)
The application compiles and runs but keeps resetting.

Below is a listing showing a backtrace before restarting:

D (241) tcpip_adapter: call api in lwip: ret=0x0, give sem
D (241) tcpip_adapter: check: remote, if=1 fn=0x401180bc
0x401180bc: tcpip_adapter_set_ip_info_api at C:/msys32/home/johnk/esp/esp-idf/components/tcpip_adapter/tcpip_adapter_lwip.c:1065


D (251) tcpip_adapter: check: local, if=1 fn=0x40117db4
0x40117db4: tcpip_adapter_dhcps_start_api at C:/msys32/home/johnk/esp/esp-idf/components/tcpip_adapter/tcpip_adapter_lwip.c:1065


D (251) tcpip_adapter: dhcp server re init
D (261) tcpip_adapter: call api in lwip: ret=0x0, give sem
D (261) tcpip_adapter: check: remote, if=1 fn=0x40117db4
0x40117db4: tcpip_adapter_dhcps_start_api at C:/msys32/home/johnk/esp/esp-idf/components/tcpip_adapter/tcpip_adapter_lwip.c:1065


ESP_ERROR_CHECK failed: esp_err_t 0x1101 at 0x40106c32
0x40106c32: app_main at C:/msys32/home/johnk/blink/main/wifi_ap.c:163 (discriminator 1)

file: "C:/msys32/home/johnk/blink/main/wifi_ap.c" line 163
func: app_main
expression: esp_wifi_init(&wifi_init_config)

Backtrace: 0x4008798c:0x3ffbabc0 0x40087cf9:0x3ffbabe0 0x40106c32:0x3ffbac00 0x400d0e96:0x3ffbad00
0x4008798c: invoke_abort at C:/msys32/home/johnk/esp/esp-idf/components/esp32/panic.c:572

0x40087cf9: _esp_error_check_failed at C:/msys32/home/johnk/esp/esp-idf/components/esp32/panic.c:584

0x40106c32: app_main at C:/msys32/home/johnk/blink/main/wifi_ap.c:163 (discriminator 1)

0x400d0e96: main_task at C:/msys32/home/johnk/esp/esp-idf/components/esp32/cpu_start.c:456


Rebooting...

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: WiFi AP mode now fail with new API

Postby kolban » Thu Nov 30, 2017 5:35 am

What is the statement at line 163?

C:/msys32/home/johnk/blink/main/wifi_ap.c:163
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

catotonic
Posts: 36
Joined: Sun Jul 16, 2017 6:55 pm
Location: Houston, TX
Contact:

Re: WiFi AP mode now fail with new API

Postby catotonic » Thu Nov 30, 2017 12:27 pm

159 ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
160
161 // initialize the wifi stack in AccessPoint mode with config in RAM
162 wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
163 ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config));
164 ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
165 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));

catotonic
Posts: 36
Joined: Sun Jul 16, 2017 6:55 pm
Location: Houston, TX
Contact:

Re: WiFi AP mode now fail with new API

Postby catotonic » Thu Nov 30, 2017 1:11 pm

@Kolban
This code is from http://www.lucadentella.it/2017/05/20/e ... ess-point/ tutorial
https://github.com/lucadentella/esp32-t ... .projbuild
I had downloaded it in the past and it ran with no problems. After reloading the API and toolchain, I was planning on using it as a base to build a web server but found it would no longer run.

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: WiFi AP mode now fail with new API

Postby kolban » Thu Nov 30, 2017 3:33 pm

The macro ESP_ERROR_CHECK calls an ESP32 function and if the result is **not** ESP_OK, it throws an exception. Unfortunately, it doesn't log what the exception is. Personally, because of this, I have stopped using ESP_ERROR_CHECK and instead code as:

Code: Select all

esp_err_t rc = esp_wifi_init(&wifi_init_config);
if (rc != ESP_OK) {
   ESP_LOGE("err", "Error with esp_wifi_init: %d", rc);
   abort();
}
That way I can see the underlying error code.

If you wish to paste bin the full application (assuming it is relatively simple), I for one would compile it on my environment and see if I can recreate.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: WiFi AP mode now fail with new API

Postby WiFive » Thu Nov 30, 2017 6:10 pm

Two common fixes are add nvs_flash_init at beginning of program and erase flash to get rid of old calibration data

catotonic
Posts: 36
Joined: Sun Jul 16, 2017 6:55 pm
Location: Houston, TX
Contact:

Re: WiFi AP mode now fail with new API

Postby catotonic » Thu Nov 30, 2017 10:56 pm

Update:
I opened another archived WiFi_AP applications that used to run and it also fails at the same place:
line 30 - wifi_init_config_t wifi_init_config = WIFI_INIT_CONFIG_DEFAULT();
line 31 - ESP_ERROR_CHECK(esp_wifi_init(&wifi_init_config));
I am using API Ver 3.0 because of issues with 2.1. but it looks like I traded one set of problems for another.
I don't know if the API is broken or if there is a document somewhere explaining what I need to change.

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: WiFi AP mode now fail with new API

Postby WiFive » Fri Dec 01, 2017 12:50 am

Did you read my post?

catotonic
Posts: 36
Joined: Sun Jul 16, 2017 6:55 pm
Location: Houston, TX
Contact:

Re: WiFi AP mode now fail with new API

Postby catotonic » Fri Dec 01, 2017 1:31 pm

@kolban
"re: did you read my post."
No, sorry. Too busy writing not not enough reading ;)
Thank you for the suggestion. My post before this talked about my second application also failing at the same point. It was not wrapped in the ESP_ERROR_CHECK you wrote about.

I did change my code per your suggestion and got the following:
********
E (271) err: Error with esp_wifi_init: 4353
abort() was called at PC 0x40106c46 on core 0
0x40106c46: app_main at C:/msys32/home/johnk/blink/main/wifi_ap.c:166 (discriminator 1)
*******
Not smart enough to know what it means, hopefully someone else does.

Per your request of the sample code:
It can be found Lucadentella's Github site at:
https://github.com/lucadentella/esp32-t ... ccesspoint
This if from his tutorial at:
http://www.lucadentella.it/en/2017/05/2 ... ess-point/
His code did work before I upgraded the API to:
I (34) boot: ESP-IDF v3.0-dev-1327-g02304ad8-dirty 2nd stage bootloader
Should I also be posting this as a pull request on esp-idf Github also to get the attention of Rudi or others?
Do the people at Rudi's level read this forum much or is it mainly a community forum?
I don't know proper protocol for if, when and how to do such things.
Thanks,

Thanks

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: WiFi AP mode now fail with new API

Postby kolban » Fri Dec 01, 2017 3:41 pm

Based on the error code returned (4353) and also based on Mr WiFive suggestion (his posts are short but don't underestimate his insight) see the following:

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

As Mr WiFive says, and as the other issue alludes to, it appears that the solution is to initialize NVS ... see:

nvs_flash_init();

If that indeed does work, you might want to raise an issue here https://github.com/lucadentella/esp32-tutorial/issues to have the author examine his source and see if a change is needed to help future users.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

Who is online

Users browsing this forum: Bing [Bot], MicroController and 87 guests