mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 01:29:21 -04:00
Merge branch 'bugfix/ram_load_app_mmap' into 'master'
ram_load_app: fixed mmap can't run on main flash issue See merge request espressif/esp-idf!24601
This commit is contained in:
commit
bf86aeb19e
@ -58,6 +58,7 @@ void bootloader_flash_clock_config(const esp_image_header_t* pfhdr);
|
||||
*/
|
||||
void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
/**
|
||||
* @brief Configure SPI flash read dummy based on different mode and frequency.
|
||||
*
|
||||
@ -66,6 +67,10 @@ void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr);
|
||||
#else
|
||||
// The meaning has changed on this chip. Deprecated, Call `bootloader_configure_spi_pins()` and `bootloader_flash_set_dummy_out()` directly.
|
||||
void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr) __attribute__((deprecated));
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
/**
|
||||
|
@ -18,6 +18,15 @@ extern "C" {
|
||||
*/
|
||||
esp_err_t bootloader_init_spi_flash(void);
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
/**
|
||||
* @brief Config all flash related stuff according to the header. The consistency of all flash configs is ensured.
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_hardware_init(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2018-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -16,6 +16,7 @@
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "soc/soc_pins.h"
|
||||
#include "soc/chip_revision.h"
|
||||
@ -269,13 +270,10 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
Cache_Read_Disable(0);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(g_rom_flashchip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff);
|
||||
// TODO: set mode
|
||||
// TODO: set frequency
|
||||
Cache_Flush(0);
|
||||
Cache_Read_Enable(0);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
@ -354,6 +352,7 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
ESP_EARLY_LOGI(TAG, "SPI Flash Size : %s", str);
|
||||
}
|
||||
|
||||
|
||||
static void IRAM_ATTR bootloader_init_flash_configure(void)
|
||||
{
|
||||
bootloader_flash_gpio_config(&bootloader_image_hdr);
|
||||
@ -379,8 +378,102 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
|
||||
Cache_Read_Disable(0);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
Cache_Flush(0);
|
||||
Cache_Read_Enable(0);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
static void bootloader_flash_set_spi_mode(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
switch(pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
break;
|
||||
default:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
}
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
}
|
||||
|
||||
void bootloader_flash_hardware_init(void)
|
||||
{
|
||||
esp_rom_spiflash_attach(esp_rom_efuse_get_flash_gpio_info(), false);
|
||||
|
||||
// reset MMU
|
||||
/* completely reset MMU in case serial bootloader was running */
|
||||
Cache_Read_Disable(0);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
Cache_Read_Disable(1);
|
||||
#endif
|
||||
Cache_Flush(0);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
Cache_Flush(1);
|
||||
#endif
|
||||
mmu_init(0);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
/* The lines which manipulate DPORT_APP_CACHE_MMU_IA_CLR bit are
|
||||
necessary to work around a hardware bug. */
|
||||
DPORT_REG_SET_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
|
||||
mmu_init(1);
|
||||
DPORT_REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MMU_IA_CLR);
|
||||
#endif
|
||||
|
||||
/* normal ROM boot exits with DROM0 cache unmasked,
|
||||
but serial bootloader exits with it masked. */
|
||||
DPORT_REG_CLR_BIT(DPORT_PRO_CACHE_CTRL1_REG, DPORT_PRO_CACHE_MASK_DROM0);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
DPORT_REG_CLR_BIT(DPORT_APP_CACHE_CTRL1_REG, DPORT_APP_CACHE_MASK_DROM0);
|
||||
#endif
|
||||
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
// Check and run XMC startup flow
|
||||
esp_err_t ret = bootloader_flash_xmc_startup();
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
/* Alternative of bootloader_init_spi_flash */
|
||||
// RAM app doesn't have headers in the flash. Make a default one for it.
|
||||
esp_image_header_t WORD_ALIGNED_ATTR hdr = {
|
||||
.spi_mode = ESP_IMAGE_SPI_MODE_DIO,
|
||||
.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2,
|
||||
.spi_size = ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
};
|
||||
bootloader_flash_set_spi_mode(&hdr);
|
||||
bootloader_flash_clock_config(&hdr);
|
||||
bootloader_flash_gpio_config(&hdr);
|
||||
bootloader_flash_dummy_config(&hdr);
|
||||
bootloader_flash_cs_timing_config();
|
||||
|
||||
/* Remaining parts in bootloader_init_spi_flash */
|
||||
bootloader_flash_unlock();
|
||||
|
||||
Cache_Read_Disable(0);
|
||||
update_flash_config(&hdr);
|
||||
Cache_Flush(0);
|
||||
Cache_Read_Enable(0);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
}
|
||||
#endif //CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
@ -71,6 +71,7 @@ void IRAM_ATTR bootloader_flash_set_dummy_out(void)
|
||||
REG_SET_BIT(SPI_MEM_CTRL_REG(1), SPI_MEM_FDUMMY_OUT | SPI_MEM_D_POL | SPI_MEM_Q_POL);
|
||||
}
|
||||
|
||||
//deprecated
|
||||
void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t *pfhdr)
|
||||
{
|
||||
bootloader_configure_spi_pins(1);
|
||||
@ -127,10 +128,8 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(rom_spiflash_legacy_data->chip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff); // TODO: set mode
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
@ -220,7 +219,8 @@ static void bootloader_print_mmu_page_size(void)
|
||||
|
||||
static void IRAM_ATTR bootloader_init_flash_configure(void)
|
||||
{
|
||||
bootloader_flash_dummy_config(&bootloader_image_hdr);
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_dummy_out();
|
||||
bootloader_flash_cs_timing_config();
|
||||
}
|
||||
|
||||
@ -243,8 +243,76 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
|
||||
bootloader_print_mmu_page_size();
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
static void bootloader_flash_set_spi_mode(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
switch(pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
break;
|
||||
default:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
}
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
}
|
||||
|
||||
void bootloader_flash_hardware_init(void)
|
||||
{
|
||||
esp_rom_spiflash_attach(0, false);
|
||||
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
mmu_hal_init();
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
|
||||
/* Alternative of bootloader_init_spi_flash */
|
||||
// RAM app doesn't have headers in the flash. Make a default one for it.
|
||||
esp_image_header_t WORD_ALIGNED_ATTR hdr = {
|
||||
.spi_mode = ESP_IMAGE_SPI_MODE_DIO,
|
||||
.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2,
|
||||
.spi_size = ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
};
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_spi_mode(&hdr);
|
||||
bootloader_flash_clock_config(&hdr);
|
||||
bootloader_flash_set_dummy_out();
|
||||
bootloader_flash_cs_timing_config();
|
||||
|
||||
bootloader_spi_flash_resume();
|
||||
bootloader_flash_unlock();
|
||||
|
||||
bootloader_print_mmu_page_size();
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
}
|
||||
#endif //CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
@ -75,6 +75,7 @@ void IRAM_ATTR bootloader_flash_set_dummy_out(void)
|
||||
REG_SET_BIT(SPI_MEM_CTRL_REG(1), SPI_MEM_FDUMMY_OUT | SPI_MEM_D_POL | SPI_MEM_Q_POL);
|
||||
}
|
||||
|
||||
//deprecated
|
||||
void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t *pfhdr)
|
||||
{
|
||||
bootloader_configure_spi_pins(1);
|
||||
@ -138,10 +139,8 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(rom_spiflash_legacy_data->chip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff); // TODO: set mode
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
@ -222,7 +221,8 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
|
||||
static void IRAM_ATTR bootloader_init_flash_configure(void)
|
||||
{
|
||||
bootloader_flash_dummy_config(&bootloader_image_hdr);
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_dummy_out();
|
||||
bootloader_flash_cs_timing_config();
|
||||
}
|
||||
|
||||
@ -251,8 +251,78 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
static void bootloader_flash_set_spi_mode(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
switch(pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
break;
|
||||
default:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
}
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
}
|
||||
|
||||
void bootloader_flash_hardware_init(void)
|
||||
{
|
||||
esp_rom_spiflash_attach(esp_rom_efuse_get_flash_gpio_info(), false);
|
||||
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
mmu_hal_init();
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
// Check and run XMC startup flow
|
||||
esp_err_t ret = bootloader_flash_xmc_startup();
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
/* Alternative of bootloader_init_spi_flash */
|
||||
// RAM app doesn't have headers in the flash. Make a default one for it.
|
||||
esp_image_header_t WORD_ALIGNED_ATTR hdr = {
|
||||
.spi_mode = ESP_IMAGE_SPI_MODE_DIO,
|
||||
.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2,
|
||||
.spi_size = ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
};
|
||||
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_spi_mode(&hdr);
|
||||
bootloader_flash_clock_config(&hdr);
|
||||
bootloader_flash_set_dummy_out();
|
||||
bootloader_flash_cs_timing_config();
|
||||
|
||||
bootloader_spi_flash_resume();
|
||||
bootloader_flash_unlock();
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
}
|
||||
#endif //CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
@ -103,10 +103,8 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(rom_spiflash_legacy_data->chip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff); // TODO: set mode
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
@ -214,8 +212,78 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
static void bootloader_flash_set_spi_mode(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
switch(pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
break;
|
||||
default:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
}
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
}
|
||||
|
||||
void bootloader_flash_hardware_init(void)
|
||||
{
|
||||
esp_rom_spiflash_attach(0, false);
|
||||
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
mmu_hal_init();
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
// Check and run XMC startup flow
|
||||
esp_err_t ret = bootloader_flash_xmc_startup();
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
/* Alternative of bootloader_init_spi_flash */
|
||||
// RAM app doesn't have headers in the flash. Make a default one for it.
|
||||
esp_image_header_t WORD_ALIGNED_ATTR hdr = {
|
||||
.spi_mode = ESP_IMAGE_SPI_MODE_DIO,
|
||||
.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2,
|
||||
.spi_size = ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
};
|
||||
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_spi_mode(&hdr);
|
||||
bootloader_flash_clock_config(&hdr);
|
||||
// TODO: set proper dummy output
|
||||
bootloader_flash_cs_timing_config();
|
||||
|
||||
bootloader_spi_flash_resume();
|
||||
bootloader_flash_unlock();
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
}
|
||||
#endif //CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
@ -110,10 +110,8 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(rom_spiflash_legacy_data->chip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff); // TODO: set mode
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
@ -216,8 +214,79 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
static void bootloader_flash_set_spi_mode(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
switch(pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
break;
|
||||
default:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
}
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
}
|
||||
|
||||
void bootloader_flash_hardware_init(void)
|
||||
{
|
||||
esp_rom_spiflash_attach(0, false);
|
||||
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
mmu_hal_init();
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
// Check and run XMC startup flow
|
||||
esp_err_t ret = bootloader_flash_xmc_startup();
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
/* Alternative of bootloader_init_spi_flash */
|
||||
// RAM app doesn't have headers in the flash. Make a default one for it.
|
||||
esp_image_header_t WORD_ALIGNED_ATTR hdr = {
|
||||
.spi_mode = ESP_IMAGE_SPI_MODE_DIO,
|
||||
.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2,
|
||||
.spi_size = ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
};
|
||||
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_spi_mode(&hdr);
|
||||
bootloader_flash_clock_config(&hdr);
|
||||
bootloader_flash_clock_init();
|
||||
// TODO: set proper dummy output
|
||||
bootloader_flash_cs_timing_config();
|
||||
|
||||
bootloader_spi_flash_resume();
|
||||
bootloader_flash_unlock();
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
}
|
||||
#endif //CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
@ -97,10 +97,8 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(rom_spiflash_legacy_data->chip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff); // TODO: set mode
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
@ -202,8 +200,77 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
static void bootloader_flash_set_spi_mode(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
switch(pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
break;
|
||||
default:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
}
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
}
|
||||
|
||||
void bootloader_flash_hardware_init(void)
|
||||
{
|
||||
esp_rom_spiflash_attach(0, false);
|
||||
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//reset mmu
|
||||
mmu_hal_init();
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
// Check and run XMC startup flow
|
||||
esp_err_t ret = bootloader_flash_xmc_startup();
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
/* Alternative of bootloader_init_spi_flash */
|
||||
// RAM app doesn't have headers in the flash. Make a default one for it.
|
||||
esp_image_header_t WORD_ALIGNED_ATTR hdr = {
|
||||
.spi_mode = ESP_IMAGE_SPI_MODE_DIO,
|
||||
.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2,
|
||||
.spi_size = ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
};
|
||||
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_spi_mode(&hdr);
|
||||
bootloader_flash_clock_config(&hdr);
|
||||
bootloader_flash_cs_timing_config();
|
||||
|
||||
bootloader_spi_flash_resume();
|
||||
bootloader_flash_unlock();
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
}
|
||||
#endif //CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
@ -81,6 +81,7 @@ void IRAM_ATTR bootloader_flash_set_dummy_out(void)
|
||||
REG_SET_BIT(SPI_MEM_CTRL_REG(1), SPI_MEM_FDUMMY_OUT | SPI_MEM_D_POL | SPI_MEM_Q_POL);
|
||||
}
|
||||
|
||||
//deprecated
|
||||
void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
bootloader_configure_spi_pins(1);
|
||||
@ -152,12 +153,10 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
default:
|
||||
size = 2;
|
||||
}
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(g_rom_flashchip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff);
|
||||
// TODO: set mode
|
||||
// TODO: set frequency
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
@ -247,7 +246,8 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
|
||||
static void IRAM_ATTR bootloader_init_flash_configure(void)
|
||||
{
|
||||
bootloader_flash_dummy_config(&bootloader_image_hdr);
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_dummy_out();
|
||||
bootloader_flash_cs_timing_config();
|
||||
}
|
||||
|
||||
@ -269,8 +269,78 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
#endif
|
||||
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
static void bootloader_flash_set_spi_mode(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
switch(pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
break;
|
||||
default:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
}
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
}
|
||||
|
||||
void bootloader_flash_hardware_init(void)
|
||||
{
|
||||
esp_rom_spiflash_attach(esp_rom_efuse_get_flash_gpio_info(), false);
|
||||
|
||||
// init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
mmu_hal_init();
|
||||
// Workaround: normal ROM bootloader exits with DROM0 cache unmasked, but 2nd bootloader exits with it masked.
|
||||
REG_CLR_BIT(EXTMEM_PRO_ICACHE_CTRL1_REG, EXTMEM_PRO_ICACHE_MASK_DROM0);
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
// Check and run XMC startup flow
|
||||
esp_err_t ret = bootloader_flash_xmc_startup();
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
/* Alternative of bootloader_init_spi_flash */
|
||||
// RAM app doesn't have headers in the flash. Make a default one for it.
|
||||
esp_image_header_t WORD_ALIGNED_ATTR hdr = {
|
||||
.spi_mode = ESP_IMAGE_SPI_MODE_DIO,
|
||||
.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2,
|
||||
.spi_size = ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
};
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_spi_mode(&hdr);
|
||||
bootloader_flash_clock_config(&hdr);
|
||||
bootloader_flash_set_dummy_out();
|
||||
bootloader_flash_cs_timing_config();
|
||||
|
||||
bootloader_flash_unlock();
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
}
|
||||
#endif //CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
@ -87,6 +87,7 @@ void IRAM_ATTR bootloader_flash_set_dummy_out(void)
|
||||
REG_SET_BIT(SPI_MEM_CTRL_REG(1), SPI_MEM_FDUMMY_OUT | SPI_MEM_D_POL | SPI_MEM_Q_POL);
|
||||
}
|
||||
|
||||
//deprecated
|
||||
void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t *pfhdr)
|
||||
{
|
||||
bootloader_configure_spi_pins(1);
|
||||
@ -159,12 +160,10 @@ static void update_flash_config(const esp_image_header_t *bootloader_hdr)
|
||||
size = 2;
|
||||
}
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
// Set flash chip size
|
||||
esp_rom_spiflash_config_param(g_rom_flashchip.device_id, size * 0x100000, 0x10000, 0x1000, 0x100, 0xffff);
|
||||
// TODO: set mode
|
||||
// TODO: set frequency
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
}
|
||||
|
||||
static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
@ -254,7 +253,8 @@ static void print_flash_info(const esp_image_header_t *bootloader_hdr)
|
||||
|
||||
static void IRAM_ATTR bootloader_init_flash_configure(void)
|
||||
{
|
||||
bootloader_flash_dummy_config(&bootloader_image_hdr);
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_dummy_out();
|
||||
bootloader_flash_cs_timing_config();
|
||||
}
|
||||
|
||||
@ -292,8 +292,87 @@ esp_err_t bootloader_init_spi_flash(void)
|
||||
bootloader_flash_32bits_address_map_enable(bootloader_flash_get_spi_mode());
|
||||
#endif
|
||||
print_flash_info(&bootloader_image_hdr);
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&bootloader_image_hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
static void bootloader_flash_set_spi_mode(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
esp_rom_spiflash_read_mode_t mode;
|
||||
switch(pfhdr->spi_mode) {
|
||||
case ESP_IMAGE_SPI_MODE_QIO:
|
||||
mode = ESP_ROM_SPIFLASH_QIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_QOUT:
|
||||
mode = ESP_ROM_SPIFLASH_QOUT_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_DIO:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_FAST_READ:
|
||||
mode = ESP_ROM_SPIFLASH_FASTRD_MODE;
|
||||
break;
|
||||
case ESP_IMAGE_SPI_MODE_SLOW_READ:
|
||||
mode = ESP_ROM_SPIFLASH_SLOWRD_MODE;
|
||||
break;
|
||||
default:
|
||||
mode = ESP_ROM_SPIFLASH_DIO_MODE;
|
||||
}
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
}
|
||||
|
||||
void bootloader_flash_hardware_init(void)
|
||||
{
|
||||
esp_rom_spiflash_attach(esp_rom_efuse_get_flash_gpio_info(), false);
|
||||
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
mmu_hal_init();
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
// Check and run XMC startup flow
|
||||
esp_err_t ret = bootloader_flash_xmc_startup();
|
||||
assert(ret == ESP_OK);
|
||||
|
||||
/* Alternative of bootloader_init_spi_flash */
|
||||
// RAM app doesn't have headers in the flash. Make a default one for it.
|
||||
esp_image_header_t WORD_ALIGNED_ATTR hdr = {
|
||||
.spi_mode = ESP_IMAGE_SPI_MODE_DIO,
|
||||
.spi_speed = ESP_IMAGE_SPI_SPEED_DIV_2,
|
||||
.spi_size = ESP_IMAGE_FLASH_SIZE_2MB,
|
||||
};
|
||||
bootloader_configure_spi_pins(1);
|
||||
bootloader_flash_set_spi_mode(&hdr);
|
||||
bootloader_flash_clock_config(&hdr);
|
||||
bootloader_flash_set_dummy_out();
|
||||
bootloader_flash_cs_timing_config();
|
||||
|
||||
#if CONFIG_BOOTLOADER_FLASH_DC_AWARE
|
||||
// Reset flash, clear volatile bits DC[0:1]. Make it work under default mode to boot.
|
||||
bootloader_spi_flash_reset();
|
||||
#endif
|
||||
|
||||
bootloader_spi_flash_resume();
|
||||
bootloader_flash_unlock();
|
||||
|
||||
#if CONFIG_BOOTLOADER_CACHE_32BIT_ADDR_QUAD_FLASH || CONFIG_BOOTLOADER_CACHE_32BIT_ADDR_OCTAL_FLASH
|
||||
bootloader_flash_32bits_address_map_enable(bootloader_flash_get_spi_mode());
|
||||
#endif
|
||||
|
||||
cache_hal_disable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
update_flash_config(&hdr);
|
||||
cache_hal_enable(CACHE_LL_LEVEL_EXT_MEM, CACHE_TYPE_ALL);
|
||||
|
||||
//ensure the flash is write-protected
|
||||
bootloader_enable_wp();
|
||||
|
||||
}
|
||||
#endif //CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
@ -23,7 +23,9 @@
|
||||
|
||||
static const char *TAG = "boot";
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr;
|
||||
#endif
|
||||
|
||||
void bootloader_clear_bss_section(void)
|
||||
{
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
static const char *TAG = "boot.esp32";
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
static void bootloader_reset_mmu(void)
|
||||
{
|
||||
/* completely reset MMU in case serial bootloader was running */
|
||||
@ -208,7 +208,7 @@ esp_err_t bootloader_init(void)
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// reset MMU
|
||||
bootloader_reset_mmu();
|
||||
// update flash ID
|
||||
@ -218,7 +218,6 @@ esp_err_t bootloader_init(void)
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ret;
|
||||
}
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
@ -227,12 +226,11 @@ esp_err_t bootloader_init(void)
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // #if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif //#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif // #if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
|
@ -120,14 +120,13 @@ esp_err_t bootloader_init(void)
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
mmu_hal_init();
|
||||
// update flash ID
|
||||
bootloader_flash_update_id();
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
@ -136,12 +135,11 @@ esp_err_t bootloader_init(void)
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif //#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
|
@ -159,7 +159,7 @@ esp_err_t bootloader_init(void)
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
@ -171,7 +171,6 @@ esp_err_t bootloader_init(void)
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ret;
|
||||
}
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
@ -180,12 +179,11 @@ esp_err_t bootloader_init(void)
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif //#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif //#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
|
@ -143,7 +143,7 @@ esp_err_t bootloader_init(void)
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
@ -155,7 +155,6 @@ esp_err_t bootloader_init(void)
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ret;
|
||||
}
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
@ -164,12 +163,11 @@ esp_err_t bootloader_init(void)
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
|
@ -132,7 +132,7 @@ esp_err_t bootloader_init(void)
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
@ -144,7 +144,6 @@ esp_err_t bootloader_init(void)
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ret;
|
||||
}
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
@ -153,12 +152,11 @@ esp_err_t bootloader_init(void)
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif //#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
|
@ -136,7 +136,7 @@ esp_err_t bootloader_init(void)
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//reset mmu
|
||||
@ -148,7 +148,6 @@ esp_err_t bootloader_init(void)
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ret;
|
||||
}
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
@ -157,12 +156,11 @@ esp_err_t bootloader_init(void)
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
|
@ -139,7 +139,7 @@ esp_err_t bootloader_init(void)
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
@ -153,7 +153,6 @@ esp_err_t bootloader_init(void)
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ret;
|
||||
}
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
@ -162,12 +161,11 @@ esp_err_t bootloader_init(void)
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
|
@ -178,7 +178,7 @@ esp_err_t bootloader_init(void)
|
||||
/* print 2nd bootloader banner */
|
||||
bootloader_print_banner();
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
//init cache hal
|
||||
cache_hal_init();
|
||||
//init mmu
|
||||
@ -190,7 +190,6 @@ esp_err_t bootloader_init(void)
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ret;
|
||||
}
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// read bootloader header
|
||||
if ((ret = bootloader_read_bootloader_header()) != ESP_OK) {
|
||||
return ret;
|
||||
@ -199,12 +198,11 @@ esp_err_t bootloader_init(void)
|
||||
if ((ret = bootloader_check_bootloader_validity()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// initialize spi flash
|
||||
if ((ret = bootloader_init_spi_flash()) != ESP_OK) {
|
||||
return ret;
|
||||
}
|
||||
#endif // #if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif // !CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
// check whether a WDT reset happend
|
||||
bootloader_check_wdt_reset();
|
||||
|
@ -101,6 +101,7 @@
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM
|
||||
#include "esp_rom_spiflash.h"
|
||||
#include "bootloader_init.h"
|
||||
#include "esp_private/bootloader_flash_internal.h"
|
||||
#endif // CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
//This dependency will be removed in the future
|
||||
@ -429,14 +430,10 @@ void IRAM_ATTR call_start_cpu0(void)
|
||||
// When the APP is loaded into ram for execution, some hardware initialization behaviors
|
||||
// in the bootloader are still necessary
|
||||
#if CONFIG_APP_BUILD_TYPE_RAM
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if SOC_SPI_MEM_SUPPORT_CONFIG_GPIO_BY_EFUSE
|
||||
esp_rom_spiflash_attach(esp_rom_efuse_get_flash_gpio_info(), false);
|
||||
#else
|
||||
esp_rom_spiflash_attach(0, false);
|
||||
#endif
|
||||
#endif //#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
bootloader_init();
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
bootloader_flash_hardware_init();
|
||||
#endif //#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#endif //#if CONFIG_APP_BUILD_TYPE_RAM
|
||||
|
||||
#ifndef CONFIG_BOOTLOADER_WDT_ENABLE
|
||||
@ -722,22 +719,19 @@ void IRAM_ATTR call_start_cpu0(void)
|
||||
}
|
||||
#endif //CONFIG_ESP_SYSTEM_MEMPROT_FEATURE && !CONFIG_ESP_SYSTEM_MEMPROT_TEST
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
// External devices (including SPI0/1, cache) should be initialized
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_RAM
|
||||
// Normal startup flow. We arrive here with the help of 1st, 2nd bootloader. There are valid headers (app/bootloader)
|
||||
|
||||
// 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
|
||||
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
|
||||
|
||||
#if !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#if !CONFIG_SPIRAM_BOOT_INIT
|
||||
// If psram is uninitialized, we need to improve some flash configuration.
|
||||
@ -756,6 +750,10 @@ void IRAM_ATTR call_start_cpu0(void)
|
||||
}
|
||||
bootloader_flash_update_size(app_flash_size);
|
||||
#endif //CONFIG_SPI_FLASH_SIZE_OVERRIDE
|
||||
#else
|
||||
// CONFIG_APP_BUILD_TYPE_RAM && !CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
bootloader_flash_unlock();
|
||||
#endif
|
||||
#endif //!CONFIG_APP_BUILD_TYPE_PURE_RAM_APP
|
||||
|
||||
#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
|
||||
|
@ -173,12 +173,6 @@ tools/test_apps/system/panic:
|
||||
temporary: true
|
||||
reason: target(s) not supported yet # TODO: IDF-7511
|
||||
|
||||
tools/test_apps/system/ram_loadable_app:
|
||||
disable:
|
||||
- if: IDF_TARGET == "esp32h2"
|
||||
temporary: true
|
||||
reason: lack of runners
|
||||
|
||||
tools/test_apps/system/startup:
|
||||
disable:
|
||||
- if: CONFIG_NAME == "main_task_cpu1" and IDF_TARGET not in ["esp32", "esp32s3"]
|
||||
|
@ -1,5 +1,5 @@
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
|
||||
# RAM loadable app Example
|
||||
|
||||
|
@ -5,12 +5,7 @@ import pytest
|
||||
from pytest_embedded_idf.dut import IdfDut
|
||||
|
||||
|
||||
@pytest.mark.esp32
|
||||
@pytest.mark.esp32c2
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.esp32c6
|
||||
@pytest.mark.esp32s2
|
||||
@pytest.mark.esp32s3
|
||||
@pytest.mark.supported_targets
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize('config', ['pure_ram',], indirect=True,)
|
||||
def test_pure_ram_loadable_app(dut: IdfDut) -> None:
|
||||
@ -18,11 +13,7 @@ def test_pure_ram_loadable_app(dut: IdfDut) -> None:
|
||||
dut.expect('Time since boot: 3 seconds...', timeout=10)
|
||||
|
||||
|
||||
@pytest.mark.esp32c2
|
||||
@pytest.mark.esp32c3
|
||||
@pytest.mark.esp32c6
|
||||
@pytest.mark.esp32s2
|
||||
@pytest.mark.esp32s3
|
||||
@pytest.mark.supported_targets
|
||||
@pytest.mark.generic
|
||||
@pytest.mark.parametrize('config', ['defaults',], indirect=True,)
|
||||
def test_ram_loadable_app(dut: IdfDut) -> None:
|
||||
|
@ -1,6 +0,0 @@
|
||||
CONFIG_APP_BUILD_TYPE_RAM=y
|
||||
|
||||
# Reset is meaningless to ram_app
|
||||
CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y
|
||||
|
||||
CONFIG_APP_BUILD_TYPE_PURE_RAM_APP=y
|
Loading…
x
Reference in New Issue
Block a user