mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-07-15 08:32:42 +08:00
feat(bootloader): Bootloader check and loader target application
This commit is contained in:
@ -58,13 +58,11 @@ static const char *TAG = "chip_boot";
|
||||
* @brief initialize the chip including flash I/O and chip cache according to
|
||||
* boot parameters which are stored at the flash
|
||||
*/
|
||||
void chip_boot(void)
|
||||
void chip_boot(size_t start_addr, size_t map)
|
||||
{
|
||||
int ret;
|
||||
int usebin;
|
||||
uint32_t freqdiv, flash_size, sect_size;
|
||||
uint32_t freqbits;
|
||||
uint32_t cache_map;
|
||||
flash_hdr_t fhdr;
|
||||
boot_hdr_t bhdr;
|
||||
|
||||
@ -86,7 +84,7 @@ void chip_boot(void)
|
||||
|
||||
SET_PERI_REG_MASK(PERIPHS_SPI_FLASH_USRREG, BIT5);
|
||||
|
||||
ret = spi_flash_read(CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET, &fhdr, sizeof(flash_hdr_t));
|
||||
ret = spi_flash_read(start_addr, &fhdr, sizeof(flash_hdr_t));
|
||||
if (ret) {
|
||||
ESP_LOGE(TAG, "SPI flash read result %d\n", ret);
|
||||
}
|
||||
@ -122,38 +120,7 @@ void chip_boot(void)
|
||||
ESP_LOGE(TAG, "Get boot parameters %d\n", ret);
|
||||
}
|
||||
|
||||
if (bhdr.user_bin == 1) {
|
||||
if (bhdr.boot_status == 1)
|
||||
usebin = 1;
|
||||
else
|
||||
usebin = 0;
|
||||
} else {
|
||||
if (bhdr.boot_status == 1)
|
||||
usebin = 0;
|
||||
else {
|
||||
if (bhdr.version == 4) {
|
||||
bhdr.boot_status = 1;
|
||||
usebin = 0;
|
||||
} else
|
||||
usebin = 1;
|
||||
}
|
||||
}
|
||||
|
||||
cache_map = 0;
|
||||
if (fhdr.spi_size_map == FLASH_SIZE_16M_MAP_1024_1024
|
||||
|| fhdr.spi_size_map == FLASH_SIZE_32M_MAP_1024_1024
|
||||
|| fhdr.spi_size_map == FLASH_SIZE_64M_MAP_1024_1024
|
||||
|| fhdr.spi_size_map == FLASH_SIZE_128M_MAP_1024_1024) {
|
||||
if (bhdr.version >= 4
|
||||
&& bhdr.version <= 0x1f) {
|
||||
if (usebin == 1)
|
||||
cache_map = 1;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Need boot 1.4+\n");
|
||||
}
|
||||
}
|
||||
|
||||
cache_init(cache_map, 0, 0);
|
||||
cache_init(map, 0, 0);
|
||||
|
||||
if (bhdr.to_qio == 0)
|
||||
user_spi_flash_dio_to_qio_pre_init();
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
#define FLASH_MAP_ADDR 0x40200000
|
||||
|
||||
extern void chip_boot(void);
|
||||
extern void chip_boot(size_t start_addr, size_t map);
|
||||
extern int rtc_init(void);
|
||||
extern int mac_init(void);
|
||||
extern int base_gpio_init(void);
|
||||
@ -66,7 +66,7 @@ static void user_init_entry(void *param)
|
||||
wifi_task_delete(NULL);
|
||||
}
|
||||
|
||||
void call_user_start(void)
|
||||
void call_user_start(size_t start_addr, size_t map)
|
||||
{
|
||||
int i;
|
||||
int *p;
|
||||
@ -91,6 +91,8 @@ void call_user_start(void)
|
||||
for (p = &_bss_start; p < &_bss_end; p++)
|
||||
*p = 0;
|
||||
|
||||
chip_boot(start_addr, map);
|
||||
|
||||
__asm__ __volatile__(
|
||||
"rsil a2, 2\n"
|
||||
"movi a1, _chip_interrupt_tmp\n"
|
||||
@ -99,8 +101,6 @@ void call_user_start(void)
|
||||
"movi a2, 0x40100000\n"
|
||||
"wsr a2, vecbase\n");
|
||||
|
||||
chip_boot();
|
||||
|
||||
wifi_os_init();
|
||||
|
||||
assert(wifi_task_create(user_init_entry, "uiT", 2048, NULL, wifi_task_get_max_priority()) != NULL);
|
||||
|
Reference in New Issue
Block a user