mirror of
https://github.com/espressif/esp-idf
synced 2025-03-09 17:19:09 -04:00
fix(esp_system): Correct address used to fetch application image header
This commit is contained in:
parent
beb054baad
commit
b216535f73
@ -13,6 +13,7 @@
|
||||
|
||||
#include "esp_log.h"
|
||||
#include "esp_chip_info.h"
|
||||
#include "esp_app_format.h"
|
||||
|
||||
#include "esp_efuse.h"
|
||||
#include "esp_private/cache_err_int.h"
|
||||
@ -751,18 +752,26 @@ void IRAM_ATTR call_start_cpu0(void)
|
||||
|
||||
// Read the application binary image header. This will also decrypt the header if the image is encrypted.
|
||||
__attribute__((unused)) esp_image_header_t fhdr = {0};
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
fhdr.spi_mode = ESP_IMAGE_SPI_MODE_DIO;
|
||||
fhdr.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2;
|
||||
fhdr.spi_size = ESP_IMAGE_FLASH_SIZE_4MB;
|
||||
|
||||
bootloader_flash_unlock();
|
||||
#else
|
||||
// This assumes that DROM is the first segment in the application binary, i.e. that we can read
|
||||
// the binary header through cache by accessing SOC_DROM_LOW address.
|
||||
hal_memcpy(&fhdr, (void *) SOC_DROM_LOW, sizeof(fhdr));
|
||||
|
||||
#endif // CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif
|
||||
#else
|
||||
// We can access the image header through the cache by reading from the memory-mapped virtual DROM start offset
|
||||
uint32_t fhdr_src_addr = (uint32_t)(&_rodata_reserved_start) - sizeof(esp_image_header_t) - sizeof(esp_image_segment_header_t);
|
||||
hal_memcpy(&fhdr, (void *) fhdr_src_addr, sizeof(fhdr));
|
||||
if (fhdr.magic != ESP_IMAGE_HEADER_MAGIC) {
|
||||
ESP_EARLY_LOGE(TAG, "Invalid app image header");
|
||||
abort();
|
||||
}
|
||||
|
||||
|
||||
#endif // CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
|
Loading…
x
Reference in New Issue
Block a user