From 639c64a54090bcc938f85098597b30f5c7615991 Mon Sep 17 00:00:00 2001 From: dongheng Date: Wed, 29 May 2019 14:37:45 +0800 Subject: [PATCH] feat(compatibility_upgrade): add function to get old SDK's target ap SSID and passowrd Add error warning to check the wrong parition table. --- .../subproject/main/esp8266.bootloader.ld | 2 ++ .../src/bootloader_utility.c | 2 ++ .../include/internal/esp_system_internal.h | 29 +++++++++++++++++++ components/esp8266/source/reset_reason.c | 8 ++--- components/esp8266/source/system_api.c | 9 ++++++ components/spi_flash/port/port.c | 15 ++++++++-- 6 files changed, 57 insertions(+), 8 deletions(-) diff --git a/components/bootloader/subproject/main/esp8266.bootloader.ld b/components/bootloader/subproject/main/esp8266.bootloader.ld index 72c5c29a..17572a53 100644 --- a/components/bootloader/subproject/main/esp8266.bootloader.ld +++ b/components/bootloader/subproject/main/esp8266.bootloader.ld @@ -124,3 +124,5 @@ SECTIONS _heap_start = ABSOLUTE(.); } >dram_seg } + +PROVIDE ( rtc_sys_info = 0x60001100 ); diff --git a/components/bootloader_support/src/bootloader_utility.c b/components/bootloader_support/src/bootloader_utility.c index d0631844..de4c6663 100644 --- a/components/bootloader_support/src/bootloader_utility.c +++ b/components/bootloader_support/src/bootloader_utility.c @@ -493,6 +493,7 @@ static void set_cache_and_start_app( #include "esp_log.h" #include "esp_flash_partitions.h" +#include "internal/esp_system_internal.h" #ifdef CONFIG_SOC_FULL_ICACHE #define SOC_CACHE_SIZE 1 // 32KB @@ -512,6 +513,7 @@ bool bootloader_utility_load_partition_table(bootloader_state_t* bs) esp_err_t err; int num_partitions; + rtc_sys_info.old_sysconf_addr = 0; #ifdef CONFIG_ESP8266_OTA_FROM_OLD if (esp_patition_table_init_location()) { ESP_LOGE(TAG, "Failed to update partition table location"); diff --git a/components/esp8266/include/internal/esp_system_internal.h b/components/esp8266/include/internal/esp_system_internal.h index 591d0216..b90f19ac 100644 --- a/components/esp8266/include/internal/esp_system_internal.h +++ b/components/esp8266/include/internal/esp_system_internal.h @@ -23,11 +23,33 @@ extern "C" { #define RTC_SYS_RAM_SIZE 256 +/** + * @brief Station's AP base information of old SDK + */ +struct old_ap_ssid { + uint32_t len; //!< SSID length + uint8_t ssid[32]; //!< SSID data + uint8_t passwd[64]; //!< password data +} __attribute__((packed)); + +/** + * @brief System information of old SDK + */ +struct old_sysconf { + uint8_t reserved_1[0x13C]; //!< reserved data + uint8_t ap_number; //!< number of stored AP + uint8_t ap_index; //!< index of current used AP + uint8_t reserved_2[0x2]; //!< reserved data + struct old_ap_ssid ap_ssid[5]; //!< station's AP base information +} __attribute__((packed)); + /** * The size of structure must not be larger than 256 bytes and all member varible must be uint32_t type */ struct _rtc_sys_info { uint32_t hint; // software reset reason + uint32_t old_sysconf_addr; /*ota[0].offset + bs->ota[0].size - boot_base; + ESP_LOGD(TAG, "OTA partition table %x %x\n", bs->ota[0].offset, bs->ota[0].size); + + if (boot_size >= 0x10000000) { + ESP_LOGE(TAG, "OTA partition table data is error %x %x\n", bs->ota[0].offset, bs->ota[0].size); + return -1; + } + if (!esp_sdk_update_from_v2()) return 0; if (esp_get_updated_partition_table_addr() != CONFIG_PARTITION_TABLE_OFFSET) { - ESP_LOGD(TAG, "Copy firmware1 from %d total %d", boot_base + PARTITION_DATA_OFFSET, boot_size); + ESP_LOGD(TAG, "Copy firmware1 from 0x%x total %d", boot_base + PARTITION_DATA_OFFSET, boot_size); ESP_LOGI(TAG, "Start unpacking V3 firmware ...");