From 44ea1dd4a5e47152cb5dd630be6bf667edba1341 Mon Sep 17 00:00:00 2001 From: Sebastien Date: Sun, 29 Sep 2019 23:28:36 -0400 Subject: [PATCH] update sector size to 512 bytes for ota --- build-scripts/OTA-16M-sdkconfig.defaults | 4 ++++ build-scripts/OTA-I2S-16MFlash-sdkconfig.defaults | 5 +++-- build-scripts/OTA-I2S-4MFlash-sdkconfig.defaults | 5 +++-- build-scripts/OTA-SqueezeAmp-sdkconfig.defaults | 5 +++-- components/squeezelite-ota/component.mk | 1 + components/squeezelite-ota/squeezelite-ota.c | 8 +++++--- components/squeezelite-ota/squeezelite-ota.h | 2 +- components/wifi-manager/http_server.c | 7 +++---- main/esp_app_main.c | 3 +-- 9 files changed, 24 insertions(+), 16 deletions(-) diff --git a/build-scripts/OTA-16M-sdkconfig.defaults b/build-scripts/OTA-16M-sdkconfig.defaults index a56fc455..f5f5ed39 100644 --- a/build-scripts/OTA-16M-sdkconfig.defaults +++ b/build-scripts/OTA-16M-sdkconfig.defaults @@ -16,6 +16,10 @@ CONFIG_INCLUDE_MAD=y CONFIG_INCLUDE_VORBIS=y CONFIG_INCLUDE_ALAC=y CONFIG_OTA_ALLOW_HTTP=y +CONFIG_WL_SECTOR_SIZE_512=y +#CONFIG_WL_SECTOR_SIZE_4096 is not defined +CONFIG_WL_SECTOR_SIZE=512 +CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 CONFIG_BTAUDIO=y CONFIG_OUTPUT_NAME="" diff --git a/build-scripts/OTA-I2S-16MFlash-sdkconfig.defaults b/build-scripts/OTA-I2S-16MFlash-sdkconfig.defaults index 3c99a4fa..4720cff6 100644 --- a/build-scripts/OTA-I2S-16MFlash-sdkconfig.defaults +++ b/build-scripts/OTA-I2S-16MFlash-sdkconfig.defaults @@ -793,8 +793,9 @@ CONFIG_VFS_SUPPORT_TERMIOS=y CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 -CONFIG_WL_SECTOR_SIZE_4096=y -CONFIG_WL_SECTOR_SIZE=4096 +CONFIG_WL_SECTOR_SIZE_512=y +#CONFIG_WL_SECTOR_SIZE_4096 is not defined +CONFIG_WL_SECTOR_SIZE=512 CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 diff --git a/build-scripts/OTA-I2S-4MFlash-sdkconfig.defaults b/build-scripts/OTA-I2S-4MFlash-sdkconfig.defaults index 9d4e8cf2..4530e562 100644 --- a/build-scripts/OTA-I2S-4MFlash-sdkconfig.defaults +++ b/build-scripts/OTA-I2S-4MFlash-sdkconfig.defaults @@ -792,8 +792,9 @@ CONFIG_VFS_SUPPORT_TERMIOS=y CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 -CONFIG_WL_SECTOR_SIZE_4096=y -CONFIG_WL_SECTOR_SIZE=4096 +CONFIG_WL_SECTOR_SIZE_512=y +#CONFIG_WL_SECTOR_SIZE_4096 is not defined +CONFIG_WL_SECTOR_SIZE=512 CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 diff --git a/build-scripts/OTA-SqueezeAmp-sdkconfig.defaults b/build-scripts/OTA-SqueezeAmp-sdkconfig.defaults index ece9302b..9d8af4ff 100644 --- a/build-scripts/OTA-SqueezeAmp-sdkconfig.defaults +++ b/build-scripts/OTA-SqueezeAmp-sdkconfig.defaults @@ -781,8 +781,9 @@ CONFIG_VFS_SUPPORT_TERMIOS=y CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 CONFIG_SEMIHOSTFS_HOST_PATH_MAX_LEN=128 -CONFIG_WL_SECTOR_SIZE_4096=y -CONFIG_WL_SECTOR_SIZE=4096 +CONFIG_WL_SECTOR_SIZE_512=y +#CONFIG_WL_SECTOR_SIZE_4096 is not defined +CONFIG_WL_SECTOR_SIZE=512 CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 diff --git a/components/squeezelite-ota/component.mk b/components/squeezelite-ota/component.mk index 12966858..ffb00330 100644 --- a/components/squeezelite-ota/component.mk +++ b/components/squeezelite-ota/component.mk @@ -6,5 +6,6 @@ # todo: add support for https COMPONENT_ADD_INCLUDEDIRS := . COMPONENT_ADD_INCLUDEDIRS += include +COMPONENT_EXTRA_INCLUDES += $(PROJECT_PATH)/main/ CFLAGS += -DLOG_LOCAL_LEVEL=ESP_LOG_INFO -DCONFIG_OTA_ALLOW_HTTP=1 COMPONENT_EMBED_TXTFILES := ${PROJECT_PATH}/server_certs/github.pem \ No newline at end of file diff --git a/components/squeezelite-ota/squeezelite-ota.c b/components/squeezelite-ota/squeezelite-ota.c index fa4ff944..9ba8f07c 100644 --- a/components/squeezelite-ota/squeezelite-ota.c +++ b/components/squeezelite-ota/squeezelite-ota.c @@ -21,6 +21,7 @@ #include "esp_err.h" #include "tcpip_adapter.h" #include "squeezelite-ota.h" +#include "nvs_utilities.h" #include #include #include @@ -183,7 +184,7 @@ esp_err_t CODE_RAM_LOCATION init_config(esp_http_client_config_t * conf, const c memset(conf, 0x00, sizeof(esp_http_client_config_t)); conf->cert_pem = (char *)server_cert_pem_start; conf->event_handler = _http_event_handler; - conf->buffer_size = 1024*2; + conf->buffer_size = 1024; conf->disable_auto_redirect=true; conf->skip_cert_common_name_check = false; conf->url = strdup(url); @@ -262,7 +263,7 @@ esp_err_t process_recovery_ota(const char * bin_url){ #define OTA_CORE 1 #endif ESP_LOGI(TAG, "Starting ota on core %u for : %s", OTA_CORE,urlPtr); - ret=xTaskCreatePinnedToCore(&ota_task, "ota_task", 1024*40, (void *)urlPtr, ESP_TASK_MAIN_PRIO+3, NULL, OTA_CORE); + ret=xTaskCreatePinnedToCore(&ota_task, "ota_task", 1024*10, (void *)urlPtr, ESP_TASK_MAIN_PRIO+3, NULL, OTA_CORE); if (ret != pdPASS) { ESP_LOGI(TAG, "create thread %s failed", "ota_task"); return ESP_FAIL; @@ -277,8 +278,9 @@ esp_err_t start_ota(const char * bin_url, bool bFromAppMain) return process_recovery_ota(bin_url); #else ESP_LOGW(TAG, "Called to update the firmware from url: %s",bin_url); + store_nvs_value(NVS_TYPE_STR, "fwurl", bin_url); ESP_LOGW(TAG, "Rebooting to recovery to complete the installation"); - return guided_factory(); + return guided_factory(); return ESP_OK; #endif } diff --git a/components/squeezelite-ota/squeezelite-ota.h b/components/squeezelite-ota/squeezelite-ota.h index c880b29f..d0927d37 100644 --- a/components/squeezelite-ota/squeezelite-ota.h +++ b/components/squeezelite-ota/squeezelite-ota.h @@ -8,7 +8,7 @@ #pragma once #include "esp_attr.h" #if RECOVERY_APPLICATION -#define CODE_RAM_LOCATION IRAM_ATTR +#define CODE_RAM_LOCATION #else #define CODE_RAM_LOCATION #endif diff --git a/components/wifi-manager/http_server.c b/components/wifi-manager/http_server.c index a0a4803b..fe7e26da 100644 --- a/components/wifi-manager/http_server.c +++ b/components/wifi-manager/http_server.c @@ -92,7 +92,6 @@ void CODE_RAM_LOCATION http_server_start(){ xTaskCreate(&http_server, "http_server", 1024*5, NULL, WIFI_MANAGER_TASK_PRIORITY-1, &task_http_server); } } - void CODE_RAM_LOCATION http_server(void *pvParameters) { struct netconn *conn, *newconn; @@ -368,8 +367,7 @@ void CODE_RAM_LOCATION http_server_netconn_serve(struct netconn *conn) { ESP_LOGI(TAG, "OTA parameter found!"); otaURL=strdup(last_parm); bOTA=true; - } - if(strcmp(last_parm_name, "autoexec")==0){ + }else if(strcmp(last_parm_name, "autoexec")==0){ autoexec_flag = atoi(last_parm); wifi_manager_save_autoexec_flag(autoexec_flag); } @@ -398,7 +396,8 @@ void CODE_RAM_LOCATION http_server_netconn_serve(struct netconn *conn) { if(bOTA){ ESP_LOGI(TAG, "Restarting to process OTA for url %s",otaURL); netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY); //200ok - esp_restart(); + start_ota(otaURL,false); + free(otaURL); } } diff --git a/main/esp_app_main.c b/main/esp_app_main.c index 8d9366ee..8beacdb0 100644 --- a/main/esp_app_main.c +++ b/main/esp_app_main.c @@ -143,14 +143,13 @@ void app_main() wifi_event_group = xEventGroupCreate(); xEventGroupClearBits(wifi_event_group, CONNECTED_BIT); fwurl = process_ota_url(); - + /* start the wifi manager */ led_blink(LED_GREEN, 250, 250); wifi_manager_start(); wifi_manager_set_callback(EVENT_STA_GOT_IP, &cb_connection_got_ip); wifi_manager_set_callback(WIFI_EVENT_STA_DISCONNECTED, &cb_connection_sta_disconnected); console_start(); - if(fwurl && strlen(fwurl)>0){ while(!bWifiConnected){ wait_for_wifi();