ESP-IDF template not working?

ElectronicsInFocus
Posts: 3
Joined: Mon Jun 06, 2016 3:43 am

ESP-IDF template not working?

Postby ElectronicsInFocus » Sun Jan 08, 2017 7:38 pm

Hello
I just install ESP-IDF with Eclipse and I compiled template project and upload it to ESP32. It runs on ESP and terminal output changes then i change printf strings in main.c.

I changed SSID and password for connect to my home AP but ESP not connects to my AP.
In terminal i take:

Code: Select all

rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffc0008,len:4
load:0x3ffc000c,len:2364
load:0x40078000,len:3724
ho 0 tail 12 room 4
load:0x40080000,len:260
entry 0x40080034
I (721) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (722) heap_alloc_caps: At 3FFBD95C len 000226A4 (137 KiB): DRAM
I (726) heap_alloc_caps: At 3FFE8000 len 00018000 (96 KiB): D/IRAM
I (736) heap_alloc_caps: At 4009BC14 len 000043EC (16 KiB): IRAM
I (746) cpu_start: Pro cpu up.
I (752) cpu_start: Single core mode
I (758) cpu_start: Pro cpu start user code
I (1006) phy: phy_version: 258, Nov 29 2016, 15:51:07, 0, 0
I (1563) cpu_start: Starting scheduler on PRO CPU.
tcpip_task_hdlxxx : 3ffc134c, prio:18,stack:2048
I (1576) wifi: frc2_timer_task_hdl:3ffc2e40, prio:22, stack:2048
I (1585) wifi: pp_task_hdl : 3ffc5aa4, prio:23, stack:8192
I (1586) wifi: mode : sta (24:0a:c4:03:ee:9c)
Then i change code to work as AP:

Code: Select all

#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"

esp_err_t event_handler(void *ctx, system_event_t *event)
{
   return ESP_OK;
}

int app_main(void)
{
   nvs_flash_init();
   tcpip_adapter_init();
   ESP_ERROR_CHECK(esp_event_loop_init(event_handler, NULL));
   wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
   ESP_ERROR_CHECK(esp_wifi_init(&cfg));
   ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
   ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));

   wifi_config_t ap_config = {
           .ap = {
               .ssid = "Test123",
               .password = "test1234",
               .ssid_len = 0,           /**< Length of SSID. If softap_config.ssid_len==0, check the SSID until there is a termination character; otherwise, set the SSID length according to softap_config.ssid_len. */
			   .channel = 0,            /**< Channel of ESP32 soft-AP */
			   .authmode = WIFI_AUTH_OPEN,  /**< Auth mode of ESP32 soft-AP. Do not support AUTH_WEP in soft-AP mode */
			   .ssid_hidden = 0,        /**< Broadcast SSID or not, default 0, broadcast the SSID */
			   .max_connection = 4,     /**< Max number of stations allowed to connect in, default 4, max 4 */
			   .beacon_interval = 100   /**< Beacon interval, 100 ~ 60000 ms, default 100 ms */           }
       };
   ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_AP, &ap_config) );
   ESP_ERROR_CHECK( esp_wifi_start() );

   gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
   int level = 0;
   while (true) {
       gpio_set_level(GPIO_NUM_4, level);
       level = !level;
       vTaskDelay(300 / portTICK_PERIOD_MS);
   }

   return 0;
}
In terminal i take:

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffc0008,len:4
load:0x3ffc000c,len:2364
load:0x40078000,len:3724
ho 0 tail 12 room 4
load:0x40080000,len:260
entry 0x40080034
I (720) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (721) heap_alloc_caps: At 3FFBD95C len 000226A4 (137 KiB): DRAM
I (725) heap_alloc_caps: At 3FFE8000 len 00018000 (96 KiB): D/IRAM
I (735) heap_alloc_caps: At 4009BC14 len 000043EC (16 KiB): IRAM
I (745) cpu_start: Pro cpu up.
I (751) cpu_start: Single core mode
I (757) cpu_start: Pro cpu start user code
I (1003) phy: phy_version: 258, Nov 29 2016, 15:51:07, 0, 0
I (1542) cpu_start: Starting scheduler on PRO CPU.
tcpip_task_hdlxxx : 3ffc134c, prio:18,stack:2048
I (1555) wifi: frc2_timer_task_hdl:3ffc2e40, prio:22, stack:2048
I (1564) wifi: pp_task_hdl : 3ffc5aa4, prio:23, stack:8192
I (1565) wifi: mode : softAP (24:0a:c4:03:ee:9d)
dhcp server start:(ip: 192.168.4.1, mask: 255.255.255.0, gw: 192.168.4.1)
But ESP's AP is not in AP list.

Also i try this WiFi scan example (https://github.com/VALERE91/ESP32_WifiScan) and it works fine.

MalteJ
Posts: 62
Joined: Wed Sep 21, 2016 10:26 pm

Re: ESP-IDF template not working?

Postby MalteJ » Mon Jan 09, 2017 1:25 am

I have had a similar problem:
http://www.esp32.com/viewtopic.php?f=13&t=904

Best,
Malte

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

Re: ESP-IDF template not working?

Postby kolban » Mon Jan 09, 2017 3:14 am

Another thought just struck me ... the diagnostics written to the console are not by default at their most verbose. Try and run "make menuconfig" and change the settings ....

Component Config > Log output -> Default log verbosity = verbose

I'm not sure what details it might show that might be useful, but I think it will indeed show more. If you switch these details on and the problem isn't obvious, consider posting that output here.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ElectronicsInFocus
Posts: 3
Joined: Mon Jun 06, 2016 3:43 am

Re: ESP-IDF template not working?

Postby ElectronicsInFocus » Mon Jan 09, 2017 4:24 pm

Terminal output in Station mode:

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffc0008,len:4
load:0x3ffc000c,len:2364
load:0x40078000,len:3724
ho 0 tail 12 room 4
load:0x40080000,len:260
entry 0x40080034
I (723) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (723) heap_alloc_caps: At 3FFBD95C len 000226A4 (137 KiB): DRAM
I (728) heap_alloc_caps: At 3FFE8000 len 00018000 (96 KiB): D/IRAM
I (738) heap_alloc_caps: At 4009BC14 len 000043EC (16 KiB): IRAM
I (748) cpu_start: Pro cpu up.
I (754) cpu_start: Single core mode
I (760) cpu_start: Pro cpu start user code
V (789) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (789) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (826) intr_alloc: Connected src 56 to int 2 (cpu 0)
V (875) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (931) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (1004) intr_alloc: Connected src 16 to int 3 (cpu 0)
D (1055) nvs: nvs_flash_init_custom start=9 count=6
D (1133) phy_init: loading PHY init data from application binary
D (1155) nvs: nvs_open phy 0
D (1182) nvs: nvs_get cal_version 4
V (1216) phy_init: phy_get_rf_cal_version: 258

D (1258) nvs: nvs_get_str_or_blob cal_mac
D (1297) nvs: nvs_get_str_or_blob cal_data
D (1344) nvs: nvs_close 1
V (1359) phy_init: register_chipv7_phy, init_data=0x3f402128, cal_data=0x3ffbe968, mode=0
I (1595) phy: phy_version: 258, Nov 29 2016, 15:51:07, 0, 0
D (1595) nvs: nvs_open phy 1
V (1596) phy_init: phy_get_rf_cal_version: 258

D (1620) nvs: nvs_set cal_version 4 258
D (1661) nvs: nvs_set_blob cal_mac 6
D (1694) nvs: nvs_set_blob cal_data 1904
D (2272) nvs: nvs_close 2
I (2273) cpu_start: Starting scheduler on PRO CPU.
tcpip_task_hdlxxx : 3ffc1378, prio:18,stack:2048
D (2287) nvs: nvs_open misc 1
D (2290) nvs: nvs_get_str_or_blob log
I (2294) wifi: frc2_timer_task_hdl:3ffc2e54, prio:22, stack:2048
D (2299) nvs: nvs_open nvs.net80211 1
D (2303) nvs: nvs_get opmode 1
D (2306) nvs: nvs_get country 1
D (2309) nvs: nvs_get_str_or_blob sta.ssid
D (2314) nvs: nvs_get_str_or_blob sta.mac
D (2318) nvs: nvs_get sta.authmode 1
D (2321) nvs: nvs_get_str_or_blob sta.pswd
D (2325) nvs: nvs_get_str_or_blob sta.pmk
D (2330) nvs: nvs_get sta.chan 1
D (2333) nvs: nvs_get auto.conn 1
D (2336) nvs: nvs_get bssid.set 1
D (2340) nvs: nvs_get_str_or_blob sta.bssid
D (2344) nvs: nvs_get sta.phym 1
D (2347) nvs: nvs_set sta.phym 1 4
D (2351) nvs: nvs_get sta.phybw 1
D (2354) nvs: nvs_get_str_or_blob sta.apsw
D (2358) nvs: nvs_get_str_or_blob sta.apinfo
D (2363) nvs: nvs_get_str_or_blob ap.ssid
D (2367) nvs: nvs_get_str_or_blob ap.mac
D (2371) nvs: nvs_get_str_or_blob ap.passwd
D (2375) nvs: nvs_get_str_or_blob ap.pmk
D (2379) nvs: nvs_get ap.chan 1
D (2382) nvs: nvs_get ap.authmode 1
D (2386) nvs: nvs_get ap.hidden 1
D (2389) nvs: nvs_get ap.max.conn 1
D (2392) nvs: nvs_get bcn.interval 2
D (2396) nvs: nvs_get ap.phym 1
D (2399) nvs: nvs_set ap.phym 1 4
D (2403) nvs: nvs_get ap.phybw 1
D (2406) nvs: nvs_get ap.sndchan 1
D (2410) nvs: nvs_set_blob sta.mac 6
D (2414) nvs: nvs_set_blob ap.mac 6
I (2418) wifi: pp_task_hdl : 3ffc5ab8, prio:23, stack:8192
I (2423) wifi: mode : sta (24:0a:c4:03:ee:9c)
D (2426) event: SYSTEM_EVENT_STA_START
V (2430) event: enter default callback
V (2434) event: exit default callback
I (3611) wifi: n:8 0, o:1 0, ap:255 255, sta:8 0, prof:1
I (4259) wifi: state: init -> auth (b0)
I (5260) wifi: state: auth -> init (2)
D (5260) event: SYSTEM_EVENT_STA_DISCONNECTED, ssid:ZyXEL-R, ssid_len:7, bssid:04:bf:6d:65:01:96, reason:2
V (5262) event: enter default callback
V (5266) event: exit default callback
i think that sta disconnect reason=2 is WIFI_REASON_AUTH_EXPIRE, but why? SSID and password 100% right, i copied it from my AP web-interface.

Terminal output in AP mode:

Code: Select all

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0x00
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3ffc0008,len:4
load:0x3ffc000c,len:2364
load:0x40078000,len:3724
ho 0 tail 12 room 4
load:0x40080000,len:260
entry 0x40080034
I (723) heap_alloc_caps: Initializing. RAM available for dynamic allocation:
I (723) heap_alloc_caps: At 3FFBD95C len 000226A4 (137 KiB): DRAM
I (727) heap_alloc_caps: At 3FFE8000 len 00018000 (96 KiB): D/IRAM
I (738) heap_alloc_caps: At 4009BC14 len 000043EC (16 KiB): IRAM
I (748) cpu_start: Pro cpu up.
I (753) cpu_start: Single core mode
I (760) cpu_start: Pro cpu start user code
V (788) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (789) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (826) intr_alloc: Connected src 56 to int 2 (cpu 0)
V (874) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): checking args
V (930) intr_alloc: esp_intr_alloc_intrstatus (cpu 0): Args okay. Resulting flags 0xE
D (1003) intr_alloc: Connected src 16 to int 3 (cpu 0)
D (1054) nvs: nvs_flash_init_custom start=9 count=6
D (1132) phy_init: loading PHY init data from application binary
D (1154) nvs: nvs_open phy 0
D (1182) nvs: nvs_get cal_version 4
V (1215) phy_init: phy_get_rf_cal_version: 258

D (1257) nvs: nvs_get_str_or_blob cal_mac
D (1297) nvs: nvs_get_str_or_blob cal_data
D (1343) nvs: nvs_close 1
V (1359) phy_init: register_chipv7_phy, init_data=0x3f402134, cal_data=0x3ffbe968, mode=0
I (1557) phy: phy_version: 258, Nov 29 2016, 15:51:07, 0, 0
D (1558) nvs: nvs_open phy 1
V (1558) phy_init: phy_get_rf_cal_version: 258

D (1583) nvs: nvs_set cal_version 4 258
D (1624) nvs: nvs_set_blob cal_mac 6
D (1657) nvs: nvs_set_blob cal_data 1904
D (2215) nvs: nvs_close 2
I (2216) cpu_start: Starting scheduler on PRO CPU.
tcpip_task_hdlxxx : 3ffc1378, prio:18,stack:2048
D (2231) nvs: nvs_open misc 1
D (2234) nvs: nvs_get_str_or_blob log
I (2238) wifi: frc2_timer_task_hdl:3ffc2e54, prio:22, stack:2048
D (2243) nvs: nvs_open nvs.net80211 1
D (2247) nvs: nvs_get opmode 1
D (2250) nvs: nvs_get country 1
D (2253) nvs: nvs_get_str_or_blob sta.ssid
D (2258) nvs: nvs_get_str_or_blob sta.mac
D (2262) nvs: nvs_get sta.authmode 1
D (2265) nvs: nvs_get_str_or_blob sta.pswd
D (2270) nvs: nvs_get_str_or_blob sta.pmk
D (2274) nvs: nvs_get sta.chan 1
D (2277) nvs: nvs_get auto.conn 1
D (2280) nvs: nvs_get bssid.set 1
D (2284) nvs: nvs_get_str_or_blob sta.bssid
D (2288) nvs: nvs_get sta.phym 1
D (2291) nvs: nvs_set sta.phym 1 4
D (2295) nvs: nvs_get sta.phybw 1
D (2298) nvs: nvs_get_str_or_blob sta.apsw
D (2302) nvs: nvs_get_str_or_blob sta.apinfo
D (2307) nvs: nvs_get_str_or_blob ap.ssid
D (2311) nvs: nvs_get_str_or_blob ap.mac
D (2315) nvs: nvs_get_str_or_blob ap.passwd
D (2319) nvs: nvs_get_str_or_blob ap.pmk
D (2323) nvs: nvs_get ap.chan 1
D (2326) nvs: nvs_get ap.authmode 1
D (2330) nvs: nvs_get ap.hidden 1
D (2333) nvs: nvs_get ap.max.conn 1
D (2337) nvs: nvs_get bcn.interval 2
D (2340) nvs: nvs_get ap.phym 1
D (2343) nvs: nvs_set ap.phym 1 4
D (2347) nvs: nvs_get ap.phybw 1
D (2350) nvs: nvs_get ap.sndchan 1
D (2354) nvs: nvs_set_blob sta.mac 6
D (2358) nvs: nvs_set_blob ap.mac 6
I (2362) wifi: pp_task_hdl : 3ffc5ab8, prio:23, stack:8192
I (2367) wifi: mode : softAP (24:0a:c4:03:ee:9d)
D (2371) event: SYSTEM_EVENT_AP_START
V (2374) event: enter default callback
dhcp server start:(ip: 192.168.4.1, mask: 255.255.255.0, gw: 192.168.4.1)
V (2384) event: exit default callback

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

Re: ESP-IDF template not working?

Postby kolban » Mon Jan 09, 2017 5:29 pm

Some random thoughts ...

1) In your AP test when the ESP32 was being an AP, what SSID did you advertize? (looking to see if it was special in some way)
2) How are you testing that the ESP32 as an AP doesn't show up?
3) What country are you in? I notice there is an API to set the WiFi country (esp_wifi_set_country). I don't know how that is used, but it might be worth a test?
4) Do you have a different access point to test the ESP32 as a station?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: ESP-IDF template not working?

Postby ESP_Sprite » Tue Jan 10, 2017 2:12 am

You may also try to erase the entire flash with esptool.py before reflashing. It seems the current master has a small bug that can cause old NVS data (from a previous esp-idf) to stop the WiFi driver from working.

ElectronicsInFocus
Posts: 3
Joined: Mon Jun 06, 2016 3:43 am

Re: ESP-IDF template not working?

Postby ElectronicsInFocus » Tue Jan 10, 2017 3:13 pm

You are right!
I just load 32Mbit BIN file filled by 0xFF byte and it connects to my AP.
I use ESPFlashDownloadTool_v3.4.4 and load file to address 0x000000.
Thank you!

Who is online

Users browsing this forum: Majestic-12 [Bot] and 216 guests