mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-27 20:27:43 +08:00
Merge branch 'feature/add_old_sdk_param' into 'master'
compatibility_upgrade: add function to get old SDK's target ap SSID and passowrd See merge request sdk/ESP8266_RTOS_SDK!959
This commit is contained in:
@ -124,3 +124,5 @@ SECTIONS
|
||||
_heap_start = ABSOLUTE(.);
|
||||
} >dram_seg
|
||||
}
|
||||
|
||||
PROVIDE ( rtc_sys_info = 0x60001100 );
|
||||
|
@ -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");
|
||||
|
@ -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; /*<! old SDK system configuration parameters base address,
|
||||
if your bootloader is older than v3.2, please don't use this */
|
||||
};
|
||||
|
||||
extern struct _rtc_sys_info rtc_sys_info;
|
||||
@ -56,6 +78,13 @@ void esp_reset_reason_set_hint(esp_reset_reason_t hint);
|
||||
*/
|
||||
esp_reset_reason_t esp_reset_reason_early(void);
|
||||
|
||||
/**
|
||||
* @brief Get old SDK configuration parameters base address
|
||||
*
|
||||
* @return 0 if it is not upgraded from old SDK or the absolute address of the flash
|
||||
*/
|
||||
uint32_t esp_get_old_sysconf_addr(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -41,12 +41,8 @@ static inline void esp_reset_reason_clear_hint()
|
||||
|
||||
static inline uint32_t esp_reset_reason_get_hint(uint32_t hw_reset)
|
||||
{
|
||||
if (hw_reset == POWERON_RESET && rtc_sys_info.hint != ESP_RST_SW) {
|
||||
uint32_t *p = (uint32_t *)&rtc_sys_info;
|
||||
|
||||
for (int i = 0; i < RTC_SYS_RAM_SIZE / sizeof(uint32_t); i++)
|
||||
*p++ = 0;
|
||||
}
|
||||
if (hw_reset == POWERON_RESET && rtc_sys_info.hint != ESP_RST_SW)
|
||||
rtc_sys_info.hint = 0;
|
||||
|
||||
return rtc_sys_info.hint;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "internal/esp_system_internal.h"
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
@ -352,3 +353,11 @@ uint32_t esp_get_minimum_free_heap_size(void)
|
||||
{
|
||||
return heap_caps_get_minimum_free_size(MALLOC_CAP_32BIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get old SDK configuration parameters base address
|
||||
*/
|
||||
uint32_t esp_get_old_sysconf_addr(void)
|
||||
{
|
||||
return rtc_sys_info.old_sysconf_addr;
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "esp8266/rom_functions.h"
|
||||
#include "esp8266/eagle_soc.h"
|
||||
#include "internal/phy_init_data.h"
|
||||
#include "internal/esp_system_internal.h"
|
||||
|
||||
#define PARTITION_DATA_OFFSET (s_v2_flash_bin_size / 2)
|
||||
|
||||
@ -60,7 +61,7 @@ typedef union s_boot_param {
|
||||
uint8_t enhance_boot_flag : 1;
|
||||
} boot_base;
|
||||
|
||||
ROM_FLASH_BUF_DECLARE(__data, 32);
|
||||
ROM_FLASH_BUF_DECLARE(__data, 1280); // To copy all old SDK configuration data
|
||||
} boot_param_t;
|
||||
|
||||
static const char *TAG = "partition_port";
|
||||
@ -241,6 +242,9 @@ static uint32_t esp_get_updated_partition_table_addr(void)
|
||||
|
||||
offset = s_sys_param.flag ? 1 : 0;
|
||||
|
||||
rtc_sys_info.old_sysconf_addr = ((s_sys_param.flag ? 0 : 1) + sect) * SPI_FLASH_SEC_SIZE;
|
||||
ESP_LOGD(TAG, "Set old SDK system parameter address is %x @ %p", rtc_sys_info.old_sysconf_addr, &rtc_sys_info.old_sysconf_addr);
|
||||
|
||||
ret = spi_flash_read_data((sect + offset) * SPI_FLASH_SEC_SIZE, &s_boot_param, sizeof(boot_param_t));
|
||||
if (ret) {
|
||||
ESP_LOGE(TAG, "read V2 boot param error %d", ret);
|
||||
@ -527,11 +531,18 @@ int esp_patition_table_init_data(void *partition_info)
|
||||
const bootloader_state_t *bs = (const bootloader_state_t *)partition_info;
|
||||
const uint32_t boot_size = bs->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 ...");
|
||||
|
||||
|
Reference in New Issue
Block a user