- ESP-ROM:esp32s2-rc4-20191025
- Build:Oct 25 2019
- rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
- SPIWP:0xee
- mode:DIO, clock div:1
- load:0x3ffe6100,len:0x1820
- load:0x4004c000,len:0x9e8
- load:0x40050000,len:0x2b70
- SHA-256 comparison failed:
- Calculated: 0bd0e2d0d51814779bd45c31e7ba7f878e91b119708a62bd71f9edfca00a948f
- Expected: 38198821cae9ebb0df857e77da8b30e97263995b3a399610ede168c82c6a8570
- Attempting to boot anyway...
- entry 0x4004c1ec
- I (40) boot: ESP-IDF v4.3 2nd stage bootloader
- I (40) boot: compile time 15:06:22
- I (40) boot: chip revision: 0
- I (42) boot.esp32s2: SPI Speed : 80MHz
- I (47) boot.esp32s2: SPI Mode : DIO
- I (52) boot.esp32s2: SPI Flash Size : 4MB
- I (56) boot: Enabling RNG early entropy source...
- I (62) boot: Partition Table:
- I (65) boot: ## Label Usage Type ST Offset Length
- I (73) boot: 0 nvs WiFi data 01 02 00009000 00006000
- I (80) boot: 1 phy_init RF data 01 01 0000f000 00001000
- I (87) boot: 2 factory factory app 00 00 00010000 00100000
- I (95) boot: End of partition table
- I (99) esp_image: segment 0: paddr=00010020 vaddr=3f000020 size=17c40h ( 97344) map
- I (129) esp_image: segment 1: paddr=00027c68 vaddr=3ffc6400 size=03e74h ( 15988) load
- I (133) esp_image: segment 2: paddr=0002bae4 vaddr=40022000 size=04534h ( 17716) load
- I (139) esp_image: segment 3: paddr=00030020 vaddr=40080020 size=76074h (483444) map
- I (247) esp_image: segment 4: paddr=000a609c vaddr=40026534 size=0fec0h ( 65216) load
- I (264) esp_image: segment 5: paddr=000b5f64 vaddr=50000000 size=00010h ( 16) load
- I (275) boot: Loaded app from partition at offset 0x10000
- I (276) boot: Disabling RNG early entropy source...
- I (287) ca�f�~��^.�Սѥ���cache : size 8KB, 4Ways, cache line size 32Byte
- I (287) cpu_start: Pro cpu up.
- I (301) cpu_start: Pro cpu start user code
- I (301) cpu_start: cpu freq: 160000000
- I (301) cpu_start: Application information:
- I (306) cpu_start: Project name: main
- I (310) cpu_start: App version: 4ddd2b4-dirty
- I (316) cpu_start: Compile time: Jun 27 2021 15:04:20
- I (322) cpu_start: ELF file SHA256: acd0d70b5b69b0de...
- I (328) cpu_start: ESP-IDF: v4.3
- I (333) heap_init: Initializing. RAM available for dynamic allocation:
- I (340) heap_init: At 3FF9E000 len 00002000 (8 KiB): RTCRAM
- I (346) heap_init: At 3FFCEB38 len 0002D4C8 (181 KiB): DRAM
- I (352) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
- I (359) spi_flash: detected chip: generic
- I (363) spi_flash: flash io: dio
- I (371) cpu_start: Starting scheduler on PRO CPU.
- start
- open
- 32 64 6
- read finish
- 1
- Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.
- Core 0 register dump:
- PC : 0x4001abc4 PS : 0x00060f30 A0 : 0x80086344 A1 : 0x3ffd0110
- A2 : 0x3ffd0148 A3 : 0x00000000 A4 : 0x00000040 A5 : 0x3ffd0148
- A6 : 0x00000000 A7 : 0x00000004 A8 : 0x00000040 A9 : 0x3ffd00c0
- A10 : 0x0000000a A11 : 0x3ff9e894 A12 : 0x3ffca6cc A13 : 0x00000000
- A14 : 0x00000000 A15 : 0x3ffcffd0 SAR : 0x0000001f EXCCAUSE: 0x0000001c
- EXCVADDR: 0x00000000 LBEG : 0x3ffca6cc LEND : 0x00000000 LCOUNT : 0x400243a9
- 0x400243a9: _xt_user_exc at C:/Users/Hyenamn/esp-idf/components/freertos/port/xtensa/xtensa_vectors.S:627
- Backtrace:0x4001abc1:0x3ffd0110 0x40086341:0x3ffd0120 0x400f5d93:0x3ffd01d0 0x4002cfad:0x3ffd01f0
- 0x40086341: app_main at C:\Users\Hyenamn\Desktop\projects\esp32_vfd_clock\build/../main/main.c:176
- 0x400f5d93: main_task at C:/Users/Hyenamn/esp-idf/components/freertos/port/port_common.c:133 (discriminator 2)
- 0x4002cfad: vPortTaskWrapper at C:/Users/Hyenamn/esp-idf/components/freertos/port/xtensa/port.c:168
- ELF file SHA256: acd0d70b5b69b0de
改自smart_config示例,reboot后尝试读取保存的ssid、password、bssid时报错,通过prinf deubg 发现ssid可以成功读之后就报错了。
代码:
- /* Esptouch example
- This example code is in the Public Domain (or CC0 licensed, at your option.)
- Unless required by applicable law or agreed to in writing, this
- software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied.
- */
- #include <string.h>
- #include <stdlib.h>
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "freertos/event_groups.h"
- #include "esp_wifi.h"
- #include "esp_wpa2.h"
- #include "esp_event.h"
- #include "esp_log.h"
- #include "esp_system.h"
- #include "nvs_flash.h"
- #include "esp_netif.h"
- #include "esp_smartconfig.h"
- #define STORAGE_NAMESPACE "WIFI_CONF"
- /* FreeRTOS event group to signal when we are connected & ready to make a request */
- static EventGroupHandle_t s_wifi_event_group;
- /* The event group allows multiple bits for each event,
- but we only care about one event - are we connected
- to the AP with an IP? */
- static const int CONNECTED_BIT = BIT0;
- static const int ESPTOUCH_DONE_BIT = BIT1;
- static const char *TAG = "smartconfig_example";
- size_t ssid_size=33,passwd_size=65,bssid_size=8;
- static void smartconfig_example_task(void * parm);
- static void event_handler(void* arg, esp_event_base_t event_base,
- int32_t event_id, void* event_data)
- {
- if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) {
- xTaskCreate(smartconfig_example_task, "smartconfig_example_task", 4096, NULL, 3, NULL);
- } else if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
- esp_wifi_connect();
- xEventGroupClearBits(s_wifi_event_group, CONNECTED_BIT);
- } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
- xEventGroupSetBits(s_wifi_event_group, CONNECTED_BIT);
- } else if (event_base == SC_EVENT && event_id == SC_EVENT_SCAN_DONE) {
- ESP_LOGI(TAG, "Scan done");
- } else if (event_base == SC_EVENT && event_id == SC_EVENT_FOUND_CHANNEL) {
- ESP_LOGI(TAG, "Found channel");
- } else if (event_base == SC_EVENT && event_id == SC_EVENT_GOT_SSID_PSWD) {
- ESP_LOGI(TAG, "Got SSID and password");
- smartconfig_event_got_ssid_pswd_t *evt = (smartconfig_event_got_ssid_pswd_t *)event_data;
- wifi_config_t wifi_config;
- uint8_t ssid[33] = { 0 };
- uint8_t password[65] = { 0 };
- uint8_t bssid[8] = { 0 };
- uint8_t rvd_data[33] = { 0 };
- bzero(&wifi_config, sizeof(wifi_config_t));
- memcpy(wifi_config.sta.ssid, evt->ssid, sizeof(wifi_config.sta.ssid));
- memcpy(wifi_config.sta.password, evt->password, sizeof(wifi_config.sta.password));
- wifi_config.sta.bssid_set = evt->bssid_set;
- if (wifi_config.sta.bssid_set == true) {
- memcpy(wifi_config.sta.bssid, evt->bssid, sizeof(wifi_config.sta.bssid));
- }
- memcpy(bssid, evt->bssid, sizeof(evt->bssid));
- memcpy(ssid, evt->ssid, sizeof(evt->ssid));
- memcpy(password, evt->password, sizeof(evt->password));
- printf("ssid:%d\tpassword:%d\tbssid:%d\n",sizeof(evt->ssid),sizeof(evt->password),sizeof(evt->bssid));
- ESP_LOGI(TAG, "SSID:%s", ssid);
- ESP_LOGI(TAG, "PASSWORD:%s", password);
- nvs_handle_t my_handle;
- nvs_open(STORAGE_NAMESPACE, NVS_READWRITE, &my_handle);
- nvs_set_u8(my_handle,"SSID_LEN",sizeof(evt->ssid));
- nvs_set_u8(my_handle,"PASSWORD_LEN",sizeof(evt->password));
- nvs_set_u8(my_handle,"BSSID_LEN",sizeof(evt->bssid));
- nvs_set_blob(my_handle,"SSID",evt->ssid,sizeof(evt->ssid));
- nvs_set_blob(my_handle,"PASSWORD",evt->password,sizeof(evt->password));
- nvs_set_blob(my_handle,"BSSID",evt->bssid,sizeof(evt->bssid));
- nvs_commit(my_handle);
- nvs_close(my_handle);
- if (evt->type == SC_TYPE_ESPTOUCH_V2) {
- ESP_ERROR_CHECK( esp_smartconfig_get_rvd_data(rvd_data, sizeof(rvd_data)) );
- ESP_LOGI(TAG, "RVD_DATA:");
- for (int i=0; i<33; i++) {
- printf("%02x ", rvd_data[i]);
- }
- printf("\n");
- }
- ESP_ERROR_CHECK( esp_wifi_disconnect() );
- ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
- esp_wifi_connect();
- } else if (event_base == SC_EVENT && event_id == SC_EVENT_SEND_ACK_DONE) {
- xEventGroupSetBits(s_wifi_event_group, ESPTOUCH_DONE_BIT);
- }
- }
- static void initialise_wifi(void)
- {
- ESP_ERROR_CHECK(esp_netif_init());
- s_wifi_event_group = xEventGroupCreate();
- ESP_ERROR_CHECK(esp_event_loop_create_default());
- esp_netif_t *sta_netif = esp_netif_create_default_wifi_sta();
- assert(sta_netif);
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
- ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
- ESP_ERROR_CHECK( esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) );
- ESP_ERROR_CHECK( esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &event_handler, NULL) );
- ESP_ERROR_CHECK( esp_event_handler_register(SC_EVENT, ESP_EVENT_ANY_ID, &event_handler, NULL) );
- ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
- ESP_ERROR_CHECK( esp_wifi_start() );
- }
- static void smartconfig_example_task(void * parm)
- {
- EventBits_t uxBits;
- ESP_ERROR_CHECK( esp_smartconfig_set_type(SC_TYPE_ESPTOUCH) );
- smartconfig_start_config_t cfg = SMARTCONFIG_START_CONFIG_DEFAULT();
- ESP_ERROR_CHECK( esp_smartconfig_start(&cfg) );
- while (1) {
- uxBits = xEventGroupWaitBits(s_wifi_event_group, CONNECTED_BIT | ESPTOUCH_DONE_BIT, true, false, portMAX_DELAY);
- if(uxBits & CONNECTED_BIT) {
- ESP_LOGI(TAG, "WiFi Connected to ap");
- }
- if(uxBits & ESPTOUCH_DONE_BIT) {
- ESP_LOGI(TAG, "smartconfig over");
- esp_smartconfig_stop();
- vTaskDelete(NULL);
- }
- }
- }
- void app_main(void)
- {
- ESP_ERROR_CHECK( nvs_flash_init() );
- nvs_handle_t my_handle;
- uint8_t ssidLen=0,passwordLen=0,bssidLen=0;
- printf("start\n");
- esp_err_t err1,err2,err3;
- nvs_open(STORAGE_NAMESPACE, NVS_READWRITE, &my_handle);
- printf("open\n");
- err1 = nvs_get_u8(my_handle,"SSID_LEN",&ssidLen);
- err2 = nvs_get_u8(my_handle,"PASSWORD_LEN",&passwordLen);
- err3 = nvs_get_u8(my_handle,"BSSID_LEN",&bssidLen);
- printf("%d\t%d\t%d\n",ssidLen,passwordLen,bssidLen);
- if(err1 == ESP_OK && err2 == ESP_OK && err3 == ESP_OK){
- uint8_t* ssid=malloc(ssidLen);
- nvs_get_blob(my_handle,"SSID",ssid,&ssidLen);
- uint8_t* password=malloc(passwordLen);
- nvs_get_blob(my_handle,"PASSWORD",password,&passwordLen);
- uint8_t* bssid=malloc(bssidLen);
- nvs_get_blob(my_handle,"BSSID",bssid,&bssidLen);
- printf("read finish\n");
- nvs_commit(my_handle);
- nvs_close(my_handle);
- vTaskDelay(1000/ portTICK_PERIOD_MS);
- wifi_config_t wifi_config;
- memcpy(wifi_config.sta.ssid, ssid, ssidLen);
- printf("1\n");
- memcpy(wifi_config.sta.password, password, passwordLen);
- printf("1\n");
- memcpy(wifi_config.sta.bssid, bssid, bssidLen);
- printf("1\n");
- esp_wifi_set_config(WIFI_IF_STA, &wifi_config);
- }else{
- printf("err1:%s\terr2:%s\terr3:%s\n",esp_err_to_name(err1),esp_err_to_name(err2),esp_err_to_name(err3));
- nvs_commit(my_handle);
- nvs_close(my_handle);
- initialise_wifi();
- }
- }