mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-10-21 07:02:24 +08:00
fix(esp8266): Fix esp8266 load RTC segment when reset from deep sleep
Now only 1MB flash is mapped to SoC bus.
This commit is contained in:
@@ -30,9 +30,7 @@
|
||||
#include "esp_task_wdt.h"
|
||||
#include "internal/esp_wifi_internal.h"
|
||||
#include "internal/esp_system_internal.h"
|
||||
|
||||
#define FLASH_MAP_ADDR 0x40200000
|
||||
#define FLASH_MAP_SIZE 0x00100000
|
||||
#include "esp8266/eagle_soc.h"
|
||||
|
||||
extern void chip_boot(void);
|
||||
extern int rtc_init(void);
|
||||
@@ -44,6 +42,16 @@ extern int wifi_nvs_init(void);
|
||||
extern esp_err_t esp_pthread_init(void);
|
||||
extern void phy_get_bb_evm(void);
|
||||
|
||||
static inline int should_load(uint32_t load_addr)
|
||||
{
|
||||
if (IS_USR_RTC(load_addr)) {
|
||||
if (esp_reset_reason_early() == ESP_RST_DEEPSLEEP)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void user_init_entry(void *param)
|
||||
{
|
||||
void (**func)(void);
|
||||
@@ -97,7 +105,7 @@ void call_user_start(size_t start_addr)
|
||||
|
||||
extern int _bss_start, _bss_end;
|
||||
|
||||
esp_image_header_t *head = (esp_image_header_t *)(FLASH_MAP_ADDR + (start_addr & (FLASH_MAP_SIZE - 1)));
|
||||
esp_image_header_t *head = (esp_image_header_t *)(FLASH_BASE + (start_addr & (FLASH_SIZE - 1)));
|
||||
esp_image_segment_header_t *segment = (esp_image_segment_header_t *)((uintptr_t)head + sizeof(esp_image_header_t));
|
||||
|
||||
/* The data in flash cannot be accessed by byte in this stage, so just access by word and get the segment count. */
|
||||
@@ -106,6 +114,9 @@ void call_user_start(size_t start_addr)
|
||||
for (i = 0; i < segment_count - 1; i++) {
|
||||
segment = (esp_image_segment_header_t *)((uintptr_t)segment + sizeof(esp_image_segment_header_t) + segment->data_len);
|
||||
|
||||
if (!should_load(segment->load_addr))
|
||||
continue;
|
||||
|
||||
uint32_t *dest = (uint32_t *)segment->load_addr;
|
||||
uint32_t *src = (uint32_t *)((uintptr_t)segment + sizeof(esp_image_segment_header_t));
|
||||
uint32_t size = segment->data_len / sizeof(uint32_t);
|
||||
|
Reference in New Issue
Block a user