soc: espressif: Add hardware initialization
Bring hardware initialization to zephyr code base. Signed-off-by: Lucas Tamborrino <lucas.tamborrino@espressif.com>
This commit is contained in:
parent
2df905dc2c
commit
cdbd2b5558
21 changed files with 802 additions and 145 deletions
12
soc/espressif/common/include/hw_init.h
Normal file
12
soc/espressif/common/include/hw_init.h
Normal file
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef _SOC_ESPRESSIF_COMMON_HW_INIT_H_
|
||||
#define _SOC_ESPRESSIF_COMMON_HW_INIT_H_
|
||||
|
||||
int hardware_init(void);
|
||||
|
||||
#endif /* _SOC_ESPRESSIF_COMMON_HW_INIT_H_ */
|
|
@ -14,46 +14,69 @@
|
|||
#include <esp_rom_sys.h>
|
||||
#include <esp_err.h>
|
||||
|
||||
#define MMU_FLASH_MASK (~(CONFIG_MMU_PAGE_SIZE - 1))
|
||||
|
||||
#include <esp_app_format.h>
|
||||
#include <zephyr/storage/flash_map.h>
|
||||
#include "esp_rom_uart.h"
|
||||
#include "esp_flash.h"
|
||||
#include "esp_log.h"
|
||||
#include "bootloader_init.h"
|
||||
#include "bootloader_random.h"
|
||||
#include "bootloader_soc.h"
|
||||
#include <esp_rom_uart.h>
|
||||
#include <esp_flash.h>
|
||||
#include <esp_log.h>
|
||||
#include <bootloader_clock.h>
|
||||
#include <bootloader_common.h>
|
||||
|
||||
#include <esp_cpu.h>
|
||||
|
||||
#if CONFIG_SOC_SERIES_ESP32C6
|
||||
#include <soc/hp_apm_reg.h>
|
||||
#include <soc/lp_apm_reg.h>
|
||||
#include <soc/lp_apm0_reg.h>
|
||||
#include <soc/pcr_reg.h>
|
||||
#endif /* CONFIG_SOC_SERIES_ESP32C6 */
|
||||
|
||||
#include <esp_flash_internal.h>
|
||||
#include <bootloader_flash.h>
|
||||
#include <bootloader_flash_priv.h>
|
||||
#include <hal/efuse_ll.h>
|
||||
#include <hal/efuse_hal.h>
|
||||
#include <hal/wdt_hal.h>
|
||||
#include <soc/chip_revision.h>
|
||||
#include <soc/rtc.h>
|
||||
#ifndef CONFIG_SOC_SERIES_ESP32
|
||||
#include <soc/assist_debug_reg.h>
|
||||
#include <soc/system_reg.h>
|
||||
#endif
|
||||
|
||||
#include "hw_init.h"
|
||||
#include "soc_init.h"
|
||||
#include "soc_random.h"
|
||||
|
||||
#define TAG "boot"
|
||||
|
||||
#define CHECKSUM_ALIGN 16
|
||||
#define IS_PADD(addr) (addr == 0)
|
||||
#define IS_DRAM(addr) (addr >= SOC_DRAM_LOW && addr < SOC_DRAM_HIGH)
|
||||
#define IS_IRAM(addr) (addr >= SOC_IRAM_LOW && addr < SOC_IRAM_HIGH)
|
||||
#define IS_IROM(addr) (addr >= SOC_IROM_LOW && addr < SOC_IROM_HIGH)
|
||||
#define IS_DROM(addr) (addr >= SOC_DROM_LOW && addr < SOC_DROM_HIGH)
|
||||
#define IS_SRAM(addr) (IS_IRAM(addr) || IS_DRAM(addr))
|
||||
#define IS_MMAP(addr) (IS_IROM(addr) || IS_DROM(addr))
|
||||
#define IS_NONE(addr) (!IS_IROM(addr) && !IS_DROM(addr) \
|
||||
&& !IS_IRAM(addr) && !IS_DRAM(addr) && !IS_PADD(addr))
|
||||
#define IS_PADD(addr) (addr == 0)
|
||||
#define IS_DRAM(addr) (addr >= SOC_DRAM_LOW && addr < SOC_DRAM_HIGH)
|
||||
#define IS_IRAM(addr) (addr >= SOC_IRAM_LOW && addr < SOC_IRAM_HIGH)
|
||||
#define IS_IROM(addr) (addr >= SOC_IROM_LOW && addr < SOC_IROM_HIGH)
|
||||
#define IS_DROM(addr) (addr >= SOC_DROM_LOW && addr < SOC_DROM_HIGH)
|
||||
#define IS_SRAM(addr) (IS_IRAM(addr) || IS_DRAM(addr))
|
||||
#define IS_MMAP(addr) (IS_IROM(addr) || IS_DROM(addr))
|
||||
#define IS_NONE(addr) \
|
||||
(!IS_IROM(addr) && !IS_DROM(addr) && !IS_IRAM(addr) && !IS_DRAM(addr) && !IS_PADD(addr))
|
||||
|
||||
#define HDR_ATTR __attribute__((section(".entry_addr"))) __attribute__((used))
|
||||
|
||||
void __start(void);
|
||||
static HDR_ATTR void (*_entry_point)(void) = &__start;
|
||||
|
||||
extern esp_image_header_t bootloader_image_hdr;
|
||||
esp_image_header_t WORD_ALIGNED_ATTR bootloader_image_hdr;
|
||||
extern uint32_t _image_irom_start, _image_irom_size, _image_irom_vaddr;
|
||||
extern uint32_t _image_drom_start, _image_drom_size, _image_drom_vaddr;
|
||||
|
||||
#ifndef CONFIG_MCUBOOT
|
||||
static uint32_t _app_irom_start = (FIXED_PARTITION_OFFSET(slot0_partition) +
|
||||
(uint32_t)&_image_irom_start);
|
||||
static uint32_t _app_irom_start =
|
||||
(FIXED_PARTITION_OFFSET(slot0_partition) + (uint32_t)&_image_irom_start);
|
||||
static uint32_t _app_irom_size = (uint32_t)&_image_irom_size;
|
||||
|
||||
static uint32_t _app_drom_start = (FIXED_PARTITION_OFFSET(slot0_partition) +
|
||||
(uint32_t)&_image_drom_start);
|
||||
static uint32_t _app_drom_start =
|
||||
(FIXED_PARTITION_OFFSET(slot0_partition) + (uint32_t)&_image_drom_start);
|
||||
static uint32_t _app_drom_size = (uint32_t)&_image_drom_size;
|
||||
#endif
|
||||
|
||||
|
@ -61,15 +84,14 @@ static uint32_t _app_irom_vaddr = ((uint32_t)&_image_irom_vaddr);
|
|||
static uint32_t _app_drom_vaddr = ((uint32_t)&_image_drom_vaddr);
|
||||
|
||||
#ifndef CONFIG_BOOTLOADER_MCUBOOT
|
||||
static esp_err_t spi_flash_read(uint32_t address, void *buffer, size_t length)
|
||||
static int spi_flash_read(uint32_t address, void *buffer, size_t length)
|
||||
{
|
||||
return esp_flash_read(NULL, buffer, address, length);
|
||||
}
|
||||
#endif /* CONFIG_BOOTLOADER_MCUBOOT */
|
||||
|
||||
void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
|
||||
uint32_t app_drom_size, uint32_t app_irom_start,
|
||||
uint32_t app_irom_vaddr, uint32_t app_irom_size)
|
||||
void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr, uint32_t app_drom_size,
|
||||
uint32_t app_irom_start, uint32_t app_irom_vaddr, uint32_t app_irom_size)
|
||||
{
|
||||
uint32_t app_irom_start_aligned = app_irom_start & MMU_FLASH_MASK;
|
||||
uint32_t app_irom_vaddr_aligned = app_irom_vaddr & MMU_FLASH_MASK;
|
||||
|
@ -88,8 +110,7 @@ void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
|
|||
|
||||
while (segments++ < 16) {
|
||||
|
||||
if (spi_flash_read(offset, &segment_hdr,
|
||||
sizeof(esp_image_segment_header_t)) != ESP_OK) {
|
||||
if (spi_flash_read(offset, &segment_hdr, sizeof(esp_image_segment_header_t)) != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to read segment header at %x", offset);
|
||||
abort();
|
||||
}
|
||||
|
@ -101,13 +122,14 @@ void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
|
|||
}
|
||||
|
||||
ESP_EARLY_LOGI(TAG, "%s: lma 0x%08x vma 0x%08x len 0x%-6x (%u)",
|
||||
IS_NONE(segment_hdr.load_addr) ? "???" :
|
||||
IS_MMAP(segment_hdr.load_addr) ?
|
||||
IS_IROM(segment_hdr.load_addr) ? "IMAP" : "DMAP" :
|
||||
IS_PADD(segment_hdr.load_addr) ? "padd" :
|
||||
IS_DRAM(segment_hdr.load_addr) ? "DRAM" : "IRAM",
|
||||
offset + sizeof(esp_image_segment_header_t),
|
||||
segment_hdr.load_addr, segment_hdr.data_len, segment_hdr.data_len);
|
||||
IS_NONE(segment_hdr.load_addr) ? "???"
|
||||
: IS_MMAP(segment_hdr.load_addr)
|
||||
? IS_IROM(segment_hdr.load_addr) ? "IMAP" : "DMAP"
|
||||
: IS_PADD(segment_hdr.load_addr) ? "padd"
|
||||
: IS_DRAM(segment_hdr.load_addr) ? "DRAM"
|
||||
: "IRAM",
|
||||
offset + sizeof(esp_image_segment_header_t), segment_hdr.load_addr,
|
||||
segment_hdr.data_len, segment_hdr.data_len);
|
||||
|
||||
/* Fix drom and irom produced be the linker, as it could
|
||||
* be invalidated by the elf2image and flash load offset
|
||||
|
@ -153,20 +175,20 @@ void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
|
|||
#if CONFIG_SOC_SERIES_ESP32
|
||||
int rc = 0;
|
||||
uint32_t drom_page_count =
|
||||
(app_drom_size + CONFIG_MMU_PAGE_SIZE - 1) / CONFIG_MMU_PAGE_SIZE;
|
||||
(app_drom_size + CONFIG_MMU_PAGE_SIZE - 1) / CONFIG_MMU_PAGE_SIZE;
|
||||
|
||||
rc |= cache_flash_mmu_set(0, 0, app_drom_vaddr_aligned,
|
||||
app_drom_start_aligned, 64, drom_page_count);
|
||||
rc |= cache_flash_mmu_set(1, 0, app_drom_vaddr_aligned,
|
||||
app_drom_start_aligned, 64, drom_page_count);
|
||||
rc |= cache_flash_mmu_set(0, 0, app_drom_vaddr_aligned, app_drom_start_aligned, 64,
|
||||
drom_page_count);
|
||||
rc |= cache_flash_mmu_set(1, 0, app_drom_vaddr_aligned, app_drom_start_aligned, 64,
|
||||
drom_page_count);
|
||||
|
||||
uint32_t irom_page_count =
|
||||
(app_irom_size + CONFIG_MMU_PAGE_SIZE - 1) / CONFIG_MMU_PAGE_SIZE;
|
||||
(app_irom_size + CONFIG_MMU_PAGE_SIZE - 1) / CONFIG_MMU_PAGE_SIZE;
|
||||
|
||||
rc |= cache_flash_mmu_set(0, 0, app_irom_vaddr_aligned,
|
||||
app_irom_start_aligned, 64, irom_page_count);
|
||||
rc |= cache_flash_mmu_set(1, 0, app_irom_vaddr_aligned,
|
||||
app_irom_start_aligned, 64, irom_page_count);
|
||||
rc |= cache_flash_mmu_set(0, 0, app_irom_vaddr_aligned, app_irom_start_aligned, 64,
|
||||
irom_page_count);
|
||||
rc |= cache_flash_mmu_set(1, 0, app_irom_vaddr_aligned, app_irom_start_aligned, 64,
|
||||
irom_page_count);
|
||||
if (rc != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to setup XIP, aborting");
|
||||
abort();
|
||||
|
@ -174,13 +196,11 @@ void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
|
|||
#else
|
||||
uint32_t actual_mapped_len = 0;
|
||||
|
||||
mmu_hal_map_region(0, MMU_TARGET_FLASH0,
|
||||
app_drom_vaddr_aligned, app_drom_start_aligned,
|
||||
app_drom_size, &actual_mapped_len);
|
||||
mmu_hal_map_region(0, MMU_TARGET_FLASH0, app_drom_vaddr_aligned, app_drom_start_aligned,
|
||||
app_drom_size, &actual_mapped_len);
|
||||
|
||||
mmu_hal_map_region(0, MMU_TARGET_FLASH0,
|
||||
app_irom_vaddr_aligned, app_irom_start_aligned,
|
||||
app_irom_size, &actual_mapped_len);
|
||||
mmu_hal_map_region(0, MMU_TARGET_FLASH0, app_irom_vaddr_aligned, app_irom_start_aligned,
|
||||
app_irom_size, &actual_mapped_len);
|
||||
#endif /* CONFIG_SOC_SERIES_ESP32 */
|
||||
|
||||
/* ----------------------Enable corresponding buses---------------- */
|
||||
|
@ -206,22 +226,20 @@ void map_rom_segments(uint32_t app_drom_start, uint32_t app_drom_vaddr,
|
|||
|
||||
#if !defined(CONFIG_SOC_SERIES_ESP32) && !defined(CONFIG_SOC_SERIES_ESP32S2)
|
||||
/* Configure the Cache MMU size for instruction and rodata in flash. */
|
||||
uint32_t cache_mmu_irom_size = ((app_irom_size + CONFIG_MMU_PAGE_SIZE - 1) /
|
||||
CONFIG_MMU_PAGE_SIZE) * sizeof(uint32_t);
|
||||
uint32_t cache_mmu_irom_size =
|
||||
((app_irom_size + CONFIG_MMU_PAGE_SIZE - 1) / CONFIG_MMU_PAGE_SIZE) *
|
||||
sizeof(uint32_t);
|
||||
|
||||
/* Split the cache usage by the segment sizes */
|
||||
Cache_Set_IDROM_MMU_Size(cache_mmu_irom_size,
|
||||
CACHE_DROM_MMU_MAX_END - cache_mmu_irom_size);
|
||||
Cache_Set_IDROM_MMU_Size(cache_mmu_irom_size, CACHE_DROM_MMU_MAX_END - cache_mmu_irom_size);
|
||||
#endif
|
||||
/* Show map segments continue using same log format as during MCUboot phase */
|
||||
ESP_EARLY_LOGI(TAG, "%s segment: paddr=%08xh, vaddr=%08xh, size=%05Xh (%6d) map",
|
||||
"DROM",
|
||||
app_drom_start_aligned, app_drom_vaddr_aligned,
|
||||
app_drom_size, app_drom_size);
|
||||
ESP_EARLY_LOGI(TAG, "%s segment: paddr=%08xh, vaddr=%08xh, size=%05Xh (%6d) map",
|
||||
"IROM",
|
||||
app_irom_start_aligned, app_irom_vaddr_aligned,
|
||||
app_irom_size, app_irom_size);
|
||||
ESP_EARLY_LOGI(TAG, "%s segment: paddr=%08xh, vaddr=%08xh, size=%05Xh (%6d) map", "DROM",
|
||||
app_drom_start_aligned, app_drom_vaddr_aligned, app_drom_size,
|
||||
app_drom_size);
|
||||
ESP_EARLY_LOGI(TAG, "%s segment: paddr=%08xh, vaddr=%08xh, size=%05Xh (%6d) map", "IROM",
|
||||
app_irom_start_aligned, app_irom_vaddr_aligned, app_irom_size,
|
||||
app_irom_size);
|
||||
esp_rom_uart_tx_wait_idle(0);
|
||||
}
|
||||
|
||||
|
@ -233,29 +251,32 @@ void __start(void)
|
|||
* relaxed by the linker to access something relative to __global_pointer$)
|
||||
*/
|
||||
__asm__ __volatile__(".option push\n"
|
||||
".option norelax\n"
|
||||
"la gp, __global_pointer$\n"
|
||||
".option pop");
|
||||
".option norelax\n"
|
||||
"la gp, __global_pointer$\n"
|
||||
".option pop");
|
||||
#endif /* CONFIG_RISCV_GP */
|
||||
|
||||
#ifndef CONFIG_BOOTLOADER_MCUBOOT
|
||||
/* Init fundamental components */
|
||||
if (bootloader_init()) {
|
||||
if (hardware_init()) {
|
||||
ESP_EARLY_LOGE(TAG, "HW init failed, aborting");
|
||||
abort();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_MCUBOOT) && !defined(CONFIG_SOC_ESP32S3_APPCPU)
|
||||
map_rom_segments(_app_drom_start, _app_drom_vaddr, _app_drom_size,
|
||||
_app_irom_start, _app_irom_vaddr, _app_irom_size);
|
||||
map_rom_segments(_app_drom_start, _app_drom_vaddr, _app_drom_size, _app_irom_start,
|
||||
_app_irom_vaddr, _app_irom_size);
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_SOC_SERIES_ESP32C2
|
||||
/* Disable RNG entropy source as it was already used */
|
||||
bootloader_random_disable();
|
||||
|
||||
soc_random_disable();
|
||||
#endif /* CONFIG_SOC_SERIES_ESP32C2 */
|
||||
#if defined(CONFIG_SOC_SERIES_ESP32S3) || defined(CONFIG_SOC_SERIES_ESP32C3)
|
||||
/* Disable glitch detection as it can be falsely triggered by EMI interference */
|
||||
bootloader_ana_clock_glitch_reset_config(false);
|
||||
|
||||
ESP_EARLY_LOGI(TAG, "Disabling glitch detection");
|
||||
ana_clock_glitch_reset_config(false);
|
||||
#endif /* CONFIG_SOC_SERIES_ESP32S2 */
|
||||
ESP_EARLY_LOGI(TAG, "Jumping to the main image...");
|
||||
__esp_platform_start();
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ endif()
|
|||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_sources_ifndef(CONFIG_BOOTLOADER_MCUBOOT hw_init.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_NEWLIB_LIBC newlib_fix.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_GDBSTUB gdbstub.c)
|
||||
|
|
|
@ -274,6 +274,12 @@ SECTIONS
|
|||
*libzephyr.a:log_output.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:log_backend_uart.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:console_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_random.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:hw_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:rtc_*.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:cpu_util.*(.literal .text .literal.* .text.*)
|
||||
*libdrivers__flash.a:flash_esp32.*(.literal .text .literal.* .text.*)
|
||||
|
@ -403,21 +409,14 @@ SECTIONS
|
|||
.loader.text :
|
||||
{
|
||||
. = ALIGN(4);
|
||||
*libzephyr.a:bootloader_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_esp32.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_common.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_mem.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_console.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
|
@ -520,6 +519,12 @@ SECTIONS
|
|||
*libzephyr.a:log_backend_uart.*(.rodata .rodata.*)
|
||||
*libzephyr.a:log_output.*(.rodata .rodata.*)
|
||||
*libzephyr.a:loader.*(.rodata .rodata.*)
|
||||
*libzephyr.a:flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:console_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_random.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:hw_init.*(.rodata .rodata.*)
|
||||
*libdrivers__flash.a:flash_esp32.*(.rodata .rodata.*)
|
||||
*libdrivers__serial.a:uart_esp32.*(.rodata .rodata.*)
|
||||
*libzephyr.a:esp_memory_utils.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
|
@ -625,14 +630,10 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_data_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_init.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_esp32.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_common.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
|
||||
*libzephyr.a:cpu_util.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
|
|
94
soc/espressif/esp32/hw_init.c
Normal file
94
soc/espressif/esp32/hw_init.c
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "hw_init.h"
|
||||
#include <stdint.h>
|
||||
#include <esp_cpu.h>
|
||||
#include <soc/rtc.h>
|
||||
#include <esp_rom_sys.h>
|
||||
|
||||
#include <bootloader_clock.h>
|
||||
#include <bootloader_flash.h>
|
||||
#include <esp_flash_internal.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <console_init.h>
|
||||
#include <flash_init.h>
|
||||
#include <soc_flash_init.h>
|
||||
#include <soc_init.h>
|
||||
#include <soc_random.h>
|
||||
|
||||
const static char *TAG = "hw_init";
|
||||
|
||||
int hardware_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
#if XCHAL_ERRATUM_572
|
||||
uint32_t memctl = XCHAL_CACHE_MEMCTL_DEFAULT;
|
||||
|
||||
WSR(MEMCTL, memctl);
|
||||
#endif /*XCHAL_ERRATUM_572*/
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
|
||||
esp_cpu_configure_region_protection();
|
||||
#endif
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) {
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
esp_rom_delay_us(10);
|
||||
}
|
||||
#endif /* CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V */
|
||||
|
||||
bootloader_clock_configure();
|
||||
|
||||
/* initialize console, from now on, we can log */
|
||||
esp_console_init();
|
||||
print_banner();
|
||||
|
||||
spi_flash_init_chip_state();
|
||||
err = esp_flash_init_default_chip();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to init flash chip, error %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
reset_mmu();
|
||||
flash_update_id();
|
||||
|
||||
err = bootloader_flash_xmc_startup();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = read_bootloader_header();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = check_bootloader_validity();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = init_spi_flash();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
check_wdt_reset();
|
||||
config_wdt();
|
||||
soc_random_enable();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -10,6 +10,8 @@ zephyr_sources(
|
|||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_sources_ifndef(CONFIG_BOOTLOADER_MCUBOOT hw_init.c)
|
||||
|
||||
# get flash size to use in esptool as string
|
||||
math(EXPR esptoolpy_flashsize "${CONFIG_FLASH_SIZE} / 0x100000")
|
||||
|
||||
|
|
|
@ -170,6 +170,11 @@ SECTIONS
|
|||
*(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
|
||||
*libzephyr.a:panic.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:console_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:hw_init.*(.literal .text .literal.* .text.*)
|
||||
*libarch__riscv__core.a:(.literal .text .literal.* .text.*)
|
||||
*libsubsys__net__l2__ethernet.a:(.literal .text .literal.* .text.*)
|
||||
*libsubsys__net__lib__config.a:(.literal .text .literal.* .text.*)
|
||||
|
@ -303,21 +308,15 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_text_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_esp32c2.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32c2.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_mem.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_console.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_ops.*(.literal .text .literal.* .text.*)
|
||||
|
@ -422,6 +421,11 @@ SECTIONS
|
|||
*libdrivers__serial.a:uart_esp32.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:periph_ctrl.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:console_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:hw_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:cache_utils.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
||||
/* [mapping:hal] */
|
||||
|
@ -502,15 +506,10 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_data_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_soc.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_esp32c2.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash.*(.srodata .srodata.* .rodata .rodata.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32c2.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_panic.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
||||
*libzephyr.a:cpu_region_protect.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
|
94
soc/espressif/esp32c2/hw_init.c
Normal file
94
soc/espressif/esp32c2/hw_init.c
Normal file
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "hw_init.h"
|
||||
#include <stdint.h>
|
||||
#include <esp_cpu.h>
|
||||
#include <soc/rtc.h>
|
||||
#include <esp_rom_sys.h>
|
||||
|
||||
#include <hal/cache_hal.h>
|
||||
#include <hal/mmu_hal.h>
|
||||
|
||||
#include <bootloader_clock.h>
|
||||
#include <bootloader_flash.h>
|
||||
#include <esp_flash_internal.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <console_init.h>
|
||||
#include <flash_init.h>
|
||||
#include <soc_flash_init.h>
|
||||
#include <soc_init.h>
|
||||
#include <soc_random.h>
|
||||
|
||||
const static char *TAG = "hw_init";
|
||||
|
||||
int hardware_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
ana_reset_config();
|
||||
super_wdt_auto_feed();
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
|
||||
esp_cpu_configure_region_protection();
|
||||
#endif
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) {
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
esp_rom_delay_us(10);
|
||||
}
|
||||
#endif /* CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V */
|
||||
|
||||
bootloader_clock_configure();
|
||||
|
||||
/* initialize console, from now on, we can log */
|
||||
esp_console_init();
|
||||
print_banner();
|
||||
|
||||
spi_flash_init_chip_state();
|
||||
err = esp_flash_init_default_chip();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to init flash chip, error %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
cache_hal_init();
|
||||
mmu_hal_init();
|
||||
flash_update_id();
|
||||
|
||||
err = bootloader_flash_xmc_startup();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = read_bootloader_header();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = check_bootloader_validity();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = init_spi_flash();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
check_wdt_reset();
|
||||
config_wdt();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -10,6 +10,8 @@ zephyr_sources(
|
|||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_sources_ifndef(CONFIG_BOOTLOADER_MCUBOOT hw_init.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_PM power.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
||||
|
||||
|
|
|
@ -230,6 +230,13 @@ SECTIONS
|
|||
*(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
|
||||
*libzephyr.a:panic.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:console_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:hw_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_random.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libarch__riscv__core.a:(.literal .text .literal.* .text.*)
|
||||
*libsubsys__net__l2__ethernet.a:(.literal .text .literal.* .text.*)
|
||||
*libsubsys__net__lib__config.a:(.literal .text .literal.* .text.*)
|
||||
|
@ -330,7 +337,6 @@ SECTIONS
|
|||
*libzephyr.a:esp_cache.*(.literal .literal.* .text .text.*)
|
||||
*libzephyr.a:cache_utils.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:bootloader_soc.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
|
||||
*libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable)
|
||||
|
||||
|
@ -363,21 +369,15 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_text_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_esp32c3.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32c3.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_mem.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_console.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
||||
|
@ -480,6 +480,13 @@ SECTIONS
|
|||
*libdrivers__serial.a:uart_esp32.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:periph_ctrl.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:console_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:hw_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_random.*(.rodata .rodata.*)
|
||||
|
||||
*libzephyr.a:cache_utils.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
||||
/* [mapping:hal] */
|
||||
|
@ -560,15 +567,10 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_data_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_soc.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_esp32c3.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash.*(.srodata .srodata.* .rodata .rodata.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32c3.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_panic.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
||||
*libzephyr.a:cpu_region_protect.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
|
98
soc/espressif/esp32c3/hw_init.c
Normal file
98
soc/espressif/esp32c3/hw_init.c
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "hw_init.h"
|
||||
#include <stdint.h>
|
||||
#include <esp_cpu.h>
|
||||
#include <soc/rtc.h>
|
||||
#include <esp_rom_sys.h>
|
||||
|
||||
#include <hal/cache_hal.h>
|
||||
#include <hal/mmu_hal.h>
|
||||
|
||||
#include <bootloader_clock.h>
|
||||
#include <bootloader_flash.h>
|
||||
#include <esp_flash_internal.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <console_init.h>
|
||||
#include <flash_init.h>
|
||||
#include <soc_flash_init.h>
|
||||
#include <soc_init.h>
|
||||
#include <soc_random.h>
|
||||
|
||||
const static char *TAG = "hw_init";
|
||||
|
||||
int hardware_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
soc_hw_init();
|
||||
|
||||
ana_reset_config();
|
||||
super_wdt_auto_feed();
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
|
||||
esp_cpu_configure_region_protection();
|
||||
#endif
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) {
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
esp_rom_delay_us(10);
|
||||
}
|
||||
#endif /* CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V */
|
||||
|
||||
bootloader_clock_configure();
|
||||
|
||||
/* initialize console, from now on, we can log */
|
||||
esp_console_init();
|
||||
print_banner();
|
||||
|
||||
spi_flash_init_chip_state();
|
||||
err = esp_flash_init_default_chip();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to init flash chip, error %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
cache_hal_init();
|
||||
mmu_hal_init();
|
||||
flash_update_id();
|
||||
|
||||
err = bootloader_flash_xmc_startup();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = read_bootloader_header();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = check_bootloader_validity();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = init_spi_flash();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
check_wdt_reset();
|
||||
config_wdt();
|
||||
|
||||
soc_random_enable();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -10,6 +10,8 @@ zephyr_sources(
|
|||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_sources_ifndef(CONFIG_BOOTLOADER_MCUBOOT hw_init.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_PM power.c)
|
||||
zephyr_library_sources_ifdef(CONFIG_POWEROFF poweroff.c)
|
||||
|
||||
|
|
|
@ -274,6 +274,13 @@ SECTIONS
|
|||
*(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
|
||||
*libzephyr.a:panic.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:console_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:hw_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_random.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libarch__riscv__core.a:(.literal .text .literal.* .text.*)
|
||||
*libsubsys__net__l2__ethernet.a:(.literal .text .literal.* .text.*)
|
||||
*libsubsys__net__lib__config.a:(.literal .text .literal.* .text.*)
|
||||
|
@ -385,10 +392,6 @@ SECTIONS
|
|||
*libzephyr.a:esp_cache.*(.literal .literal.* .text .text.*)
|
||||
*libzephyr.a:cache_utils.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:bootloader_soc.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
|
||||
*libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable)
|
||||
|
||||
#if defined(CONFIG_ESP32_WIFI_IRAM_OPT)
|
||||
*libnet80211.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.* .wifi_extra_iram.*)
|
||||
*libpp.a:( .wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.* .wifi_extra_iram.*)
|
||||
|
@ -417,21 +420,16 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_text_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_esp32c6.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32c6.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_mem.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_console.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_ops.*(.literal .text .literal.* .text.*)
|
||||
|
@ -529,6 +527,13 @@ SECTIONS
|
|||
*libdrivers__serial.a:uart_esp32.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:periph_ctrl.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:flash_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:soc_flash_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:console_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:soc_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:hw_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:soc_random.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
||||
*libzephyr.a:cache_utils.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
||||
/* [mapping:hal] */
|
||||
|
@ -624,13 +629,9 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_data_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_soc.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_esp32c6.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash.*(.srodata .srodata.* .rodata .rodata.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32c6.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_panic.*(.rodata .rodata.* .srodata .srodata.*)
|
||||
|
|
115
soc/espressif/esp32c6/hw_init.c
Normal file
115
soc/espressif/esp32c6/hw_init.c
Normal file
|
@ -0,0 +1,115 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "hw_init.h"
|
||||
#include <stdint.h>
|
||||
#include <esp_cpu.h>
|
||||
#include <soc/rtc.h>
|
||||
#include <esp_rom_sys.h>
|
||||
|
||||
#include <hal/cache_hal.h>
|
||||
#include <hal/mmu_hal.h>
|
||||
|
||||
#include <soc/hp_apm_reg.h>
|
||||
#include <soc/lp_apm_reg.h>
|
||||
#include <soc/lp_apm0_reg.h>
|
||||
#include <soc/pcr_reg.h>
|
||||
|
||||
#include <bootloader_clock.h>
|
||||
#include <bootloader_flash.h>
|
||||
#include <esp_flash_internal.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <console_init.h>
|
||||
#include <flash_init.h>
|
||||
#include <soc_flash_init.h>
|
||||
#include <soc_init.h>
|
||||
#include <soc_random.h>
|
||||
|
||||
const static char *TAG = "hw_init";
|
||||
|
||||
int hardware_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
soc_hw_init();
|
||||
|
||||
ana_reset_config();
|
||||
super_wdt_auto_feed();
|
||||
|
||||
/* By default, these access path filters are enable and allow the
|
||||
* access to masters only if they are in TEE mode. Since all masters
|
||||
* except HP CPU boots in REE mode, default setting of these filters
|
||||
* will deny the access to all masters except HP CPU.
|
||||
* So, at boot disabling these filters. They will enable as per the
|
||||
* use case by TEE initialization code.
|
||||
*/
|
||||
REG_WRITE(LP_APM_FUNC_CTRL_REG, 0);
|
||||
REG_WRITE(LP_APM0_FUNC_CTRL_REG, 0);
|
||||
REG_WRITE(HP_APM_FUNC_CTRL_REG, 0);
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
|
||||
esp_cpu_configure_region_protection();
|
||||
#endif
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) {
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
esp_rom_delay_us(10);
|
||||
}
|
||||
#endif /* CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V */
|
||||
|
||||
bootloader_clock_configure();
|
||||
|
||||
/* initialize console, from now on, we can log */
|
||||
esp_console_init();
|
||||
print_banner();
|
||||
|
||||
spi_flash_init_chip_state();
|
||||
err = esp_flash_init_default_chip();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to init flash chip, error %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
cache_hal_init();
|
||||
mmu_hal_init();
|
||||
|
||||
flash_update_id();
|
||||
|
||||
err = bootloader_flash_xmc_startup();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = read_bootloader_header();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = check_bootloader_validity();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = init_spi_flash();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
check_wdt_reset();
|
||||
config_wdt();
|
||||
|
||||
soc_random_enable();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -8,6 +8,8 @@ zephyr_sources(
|
|||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_sources_ifndef(CONFIG_BOOTLOADER_MCUBOOT hw_init.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_NEWLIB_LIBC newlib_fix.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_PM power.c)
|
||||
|
|
|
@ -343,6 +343,13 @@ SECTIONS
|
|||
*libzephyr.a:log_backend_uart.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:log_minimal.*(.literal .literal.* .text .text.*)
|
||||
*libzephyr.a:loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:console_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:hw_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_random.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:esp_mmu_map.*(.literal .literal.* .text .text.*)
|
||||
*libdrivers__flash.a:flash_esp32.*(.literal .text .literal.* .text.*)
|
||||
*libdrivers__timer.a:xtensa_sys_timer.*(.literal .text .literal.* .text.*)
|
||||
|
@ -469,21 +476,14 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_text_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_esp32s2.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32s2.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_common.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_mem.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_console.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
|
@ -590,6 +590,13 @@ SECTIONS
|
|||
*libzephyr.a:log_output.*(.rodata .rodata.*)
|
||||
*libzephyr.a:log_minimal.*(.rodata .rodata.*)
|
||||
*libzephyr.a:loader.*(.rodata .rodata.*)
|
||||
*libzephyr.a:flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:console_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:hw_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_random.*(.rodata .rodata.*)
|
||||
|
||||
*libdrivers__serial.a:uart_esp32.*(.rodata .rodata.*)
|
||||
*libdrivers__flash.a:flash_esp32.*(.rodata .rodata.*)
|
||||
*libzephyr.a:esp_mmu_map.*(.rodata .rodata.*)
|
||||
|
@ -702,12 +709,9 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_data_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_init.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_esp32s3.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32s2.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_random_esp32s2.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
|
||||
|
|
102
soc/espressif/esp32s2/hw_init.c
Normal file
102
soc/espressif/esp32s2/hw_init.c
Normal file
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "hw_init.h"
|
||||
#include <stdint.h>
|
||||
#include <esp_cpu.h>
|
||||
#include <soc/rtc.h>
|
||||
#include <soc/extmem_reg.h>
|
||||
#include <esp_rom_sys.h>
|
||||
|
||||
#include <hal/cache_hal.h>
|
||||
#include <hal/mmu_hal.h>
|
||||
|
||||
#include <bootloader_clock.h>
|
||||
#include <bootloader_flash.h>
|
||||
#include <esp_flash_internal.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <console_init.h>
|
||||
#include <flash_init.h>
|
||||
#include <soc_flash_init.h>
|
||||
#include <soc_init.h>
|
||||
#include <soc_random.h>
|
||||
|
||||
const static char *TAG = "hw_init";
|
||||
|
||||
int hardware_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
super_wdt_auto_feed();
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
|
||||
esp_cpu_configure_region_protection();
|
||||
#endif
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) {
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
esp_rom_delay_us(10);
|
||||
}
|
||||
#endif /* CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V */
|
||||
|
||||
bootloader_clock_configure();
|
||||
|
||||
/* initialize console, from now on, we can log */
|
||||
esp_console_init();
|
||||
print_banner();
|
||||
|
||||
spi_flash_init_chip_state();
|
||||
err = esp_flash_init_default_chip();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to init flash chip, error %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
cache_hal_init();
|
||||
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);
|
||||
|
||||
flash_update_id();
|
||||
|
||||
err = bootloader_flash_xmc_startup();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = read_bootloader_header();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = check_bootloader_validity();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = init_spi_flash();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
check_wdt_reset();
|
||||
config_wdt();
|
||||
|
||||
soc_random_enable();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -19,6 +19,8 @@ endif()
|
|||
|
||||
zephyr_include_directories(.)
|
||||
|
||||
zephyr_sources_ifndef(CONFIG_BOOTLOADER_MCUBOOT hw_init.c)
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_NEWLIB_LIBC newlib_fix.c)
|
||||
|
||||
# Power Management
|
||||
|
|
|
@ -300,6 +300,12 @@ SECTIONS
|
|||
*libzephyr.a:log_backend_uart.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:log_minimal.*(.literal .literal.* .text .text.*)
|
||||
*libzephyr.a:loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_flash_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:console_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:hw_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:soc_random.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:esp_mmu_map.*(.literal .literal.* .text .text.*)
|
||||
*libdrivers__interrupt_controller.a:(.literal .literal.* .text .text.*)
|
||||
*liblib__libc__minimal.a:string.*(.literal .text .literal.* .text.*)
|
||||
|
@ -394,10 +400,6 @@ SECTIONS
|
|||
/* [mapping:esp_mm] */
|
||||
*libzephyr.a:esp_cache.*(.literal .literal.* .text .text.*)
|
||||
|
||||
*libzephyr.a:bootloader_soc.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random*.*(.literal.bootloader_random_disable .text.bootloader_random_disable)
|
||||
*libzephyr.a:bootloader_random*.*(.literal.bootloader_random_enable .text.bootloader_random_enable)
|
||||
|
||||
#if defined(CONFIG_ESP32_WIFI_IRAM_OPT)
|
||||
*libnet80211.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiextrairam .wifiextrairam.*)
|
||||
*libpp.a:(.wifi0iram .wifi0iram.* .wifislpiram .wifislpiram.* .wifiorslpiram .wifiorslpiram.* .wifiextrairam .wifiextrairam.*)
|
||||
|
@ -426,20 +428,14 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_text_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_esp32s3.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32s3.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_clock_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_common_loader.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_mem.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_random.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_utility.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_console.*(.literal .text .literal.* .text.*)
|
||||
*libzephyr.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||
|
||||
*libzephyr.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||
|
@ -548,6 +544,12 @@ SECTIONS
|
|||
*libzephyr.a:log_output.*(.rodata .rodata.*)
|
||||
*libzephyr.a:log_minimal.*(.rodata .rodata.*)
|
||||
*libzephyr.a:loader.*(.rodata .rodata.*)
|
||||
*libzephyr.a:flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_flash_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:console_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:hw_init.*(.rodata .rodata.*)
|
||||
*libzephyr.a:soc_random.*(.rodata .rodata.*)
|
||||
*libdrivers__serial.a:uart_esp32.*(.rodata .rodata.*)
|
||||
*libdrivers__flash.a:flash_esp32.*(.rodata .rodata.*)
|
||||
*libzephyr.a:esp_mmu_map.*(.rodata .rodata.*)
|
||||
|
@ -663,12 +665,9 @@ SECTIONS
|
|||
{
|
||||
. = ALIGN(4);
|
||||
_loader_data_start = ABSOLUTE(.);
|
||||
*libzephyr.a:bootloader_init.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_esp32s3.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_clock_init.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_wdt.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_flash_config_esp32s3.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
*libzephyr.a:bootloader_efuse.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
|
||||
*libzephyr.a:cpu_util.*(.rodata .rodata.* .sdata2 .sdata2.* .srodata .srodata.*)
|
||||
|
|
103
soc/espressif/esp32s3/hw_init.c
Normal file
103
soc/espressif/esp32s3/hw_init.c
Normal file
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include "hw_init.h"
|
||||
#include <stdint.h>
|
||||
#include <esp_cpu.h>
|
||||
#include <soc/rtc.h>
|
||||
#include <esp_rom_sys.h>
|
||||
|
||||
#include <hal/cache_hal.h>
|
||||
#include <hal/mmu_hal.h>
|
||||
|
||||
#include <bootloader_clock.h>
|
||||
#include <bootloader_flash.h>
|
||||
#include <esp_flash_internal.h>
|
||||
#include <esp_log.h>
|
||||
|
||||
#include <console_init.h>
|
||||
#include <flash_init.h>
|
||||
#include <soc_flash_init.h>
|
||||
#include <soc_init.h>
|
||||
#include <soc_random.h>
|
||||
|
||||
const static char *TAG = "hw_init";
|
||||
|
||||
int hardware_init(void)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
#if XCHAL_ERRATUM_572
|
||||
uint32_t memctl = XCHAL_CACHE_MEMCTL_DEFAULT;
|
||||
|
||||
WSR(MEMCTL, memctl);
|
||||
#endif /*XCHAL_ERRATUM_572*/
|
||||
|
||||
ana_reset_config();
|
||||
super_wdt_auto_feed();
|
||||
|
||||
#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
|
||||
esp_cpu_configure_region_protection();
|
||||
#endif
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
|
||||
if (cfg.enable == 1 && cfg.tieh == RTC_VDDSDIO_TIEH_1_8V) {
|
||||
cfg.drefh = 3;
|
||||
cfg.drefm = 3;
|
||||
cfg.drefl = 3;
|
||||
cfg.force = 1;
|
||||
rtc_vddsdio_set_config(cfg);
|
||||
esp_rom_delay_us(10);
|
||||
}
|
||||
#endif /* CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V */
|
||||
|
||||
bootloader_clock_configure();
|
||||
|
||||
/* initialize console, from now on, we can log */
|
||||
esp_console_init();
|
||||
print_banner();
|
||||
|
||||
spi_flash_init_chip_state();
|
||||
err = esp_flash_init_default_chip();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "Failed to init flash chip, error %d", err);
|
||||
return err;
|
||||
}
|
||||
|
||||
cache_hal_init();
|
||||
mmu_hal_init();
|
||||
|
||||
flash_update_id();
|
||||
|
||||
err = bootloader_flash_xmc_startup();
|
||||
if (err != 0) {
|
||||
ESP_EARLY_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return err;
|
||||
}
|
||||
|
||||
err = read_bootloader_header();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = check_bootloader_validity();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
err = init_spi_flash();
|
||||
if (err != 0) {
|
||||
return err;
|
||||
}
|
||||
|
||||
check_wdt_reset();
|
||||
config_wdt();
|
||||
|
||||
soc_random_enable();
|
||||
|
||||
return 0;
|
||||
}
|
2
west.yml
2
west.yml
|
@ -157,7 +157,7 @@ manifest:
|
|||
groups:
|
||||
- hal
|
||||
- name: hal_espressif
|
||||
revision: 8d7054f34e6d05e2917410ff0630ee88f553521d
|
||||
revision: 6605f649d151f255011c7dfdd35cd568caa871a4
|
||||
path: modules/hal/espressif
|
||||
west-commands: west/west-commands.yml
|
||||
groups:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue