boards: esp32: add XIP support and enable bootloader build
Disable RTC WDT enabled (by default) by 2nd stage bootloader in ESP-IDF. This WDT timer ensures correct hand-over and startup sequence from bootloader to application. Enabling bootloader caused system clock initialization to fail when clock rate is greater then 80MHz. This also fixes esp32 clock source code. Signed-off-by: Mahavir Jain <mahavir@espressif.com>
This commit is contained in:
parent
5c90612120
commit
29f87c3a0f
11 changed files with 154 additions and 26 deletions
|
@ -6,3 +6,13 @@ config SOC_ESP32
|
|||
select XTENSA
|
||||
select CLOCK_CONTROL
|
||||
select CLOCK_CONTROL_ESP32
|
||||
|
||||
config IDF_TARGET_ESP32
|
||||
bool "ESP32 as target board"
|
||||
default y
|
||||
depends on SOC_ESP32
|
||||
|
||||
config ESPTOOLPY_FLASHFREQ_80M
|
||||
bool
|
||||
default y
|
||||
depends on SOC_ESP32
|
||||
|
|
|
@ -19,14 +19,23 @@
|
|||
|
||||
#define RAMABLE_REGION dram0_0_seg :dram0_0_phdr
|
||||
#define ROMABLE_REGION iram0_0_seg :iram0_0_phdr
|
||||
#define FLASH_CODE_REGION irom0_0_seg :irom0_0_phdr
|
||||
#define FLASH_DATA_REGION drom0_0_seg :drom0_0_phdr
|
||||
|
||||
PROVIDE ( __stack = 0x3ffe3f20 );
|
||||
|
||||
/* Global symbols required for espressif hal build */
|
||||
PROVIDE ( ets_printf = 0x40007d54 );
|
||||
PROVIDE ( intr_matrix_set = 0x4000681c );
|
||||
PROVIDE ( g_ticks_per_us_app = 0x3ffe40f0 );
|
||||
PROVIDE ( g_ticks_per_us_pro = 0x3ffe01e0 );
|
||||
PROVIDE ( ets_delay_us = 0x40008534 );
|
||||
|
||||
PROVIDE ( esp32_rom_uart_tx_one_char = 0x40009200 );
|
||||
PROVIDE ( esp32_rom_uart_rx_one_char = 0x400092d0 );
|
||||
PROVIDE ( esp32_rom_uart_attach = 0x40008fd0 );
|
||||
PROVIDE ( esp32_rom_uart_tx_wait_idle = 0x40009278 );
|
||||
PROVIDE ( esp32_rom_intr_matrix_set = 0x4000681c );
|
||||
PROVIDE ( esp32_rom_intr_matrix_set = intr_matrix_set );
|
||||
PROVIDE ( esp32_rom_gpio_matrix_in = 0x40009edc );
|
||||
PROVIDE ( esp32_rom_gpio_matrix_out = 0x40009f0c );
|
||||
PROVIDE ( esp32_rom_Cache_Flush = 0x40009a14 );
|
||||
|
@ -34,13 +43,17 @@ PROVIDE ( esp32_rom_Cache_Read_Enable = 0x40009a84 );
|
|||
PROVIDE ( esp32_rom_ets_set_appcpu_boot_addr = 0x4000689c );
|
||||
PROVIDE ( esp32_rom_i2c_readReg = 0x40004148 );
|
||||
PROVIDE ( esp32_rom_i2c_writeReg = 0x400041a4 );
|
||||
PROVIDE ( esp32_rom_ets_printf = ets_printf );
|
||||
PROVIDE ( esp32_rom_g_ticks_per_us_app = g_ticks_per_us_app );
|
||||
PROVIDE ( esp32_rom_g_ticks_per_us_pro = g_ticks_per_us_app );
|
||||
PROVIDE ( esp32_rom_ets_delay_us = ets_delay_us );
|
||||
|
||||
MEMORY
|
||||
{
|
||||
iram0_0_seg(RX): org = 0x40080000, len = 0x20000
|
||||
iram0_2_seg(RX): org = 0x400D0018, len = 0x330000
|
||||
irom0_0_seg(RX): org = 0x400D0020, len = 0x330000-0x20
|
||||
dram0_0_seg(RW): org = 0x3FFB0000, len = 0x50000
|
||||
drom0_0_seg(R): org = 0x3F400010, len = 0x800000
|
||||
drom0_0_seg(R): org = 0x3F400020, len = 0x400000-0x20
|
||||
rtc_iram_seg(RWX): org = 0x400C0000, len = 0x2000
|
||||
rtc_slow_seg(RW): org = 0x50000000, len = 0x1000
|
||||
#ifdef CONFIG_GEN_ISR_TABLES
|
||||
|
@ -50,8 +63,10 @@ MEMORY
|
|||
|
||||
PHDRS
|
||||
{
|
||||
iram0_0_phdr PT_LOAD;
|
||||
drom0_0_phdr PT_LOAD;
|
||||
dram0_0_phdr PT_LOAD;
|
||||
iram0_0_phdr PT_LOAD;
|
||||
irom0_0_phdr PT_LOAD;
|
||||
}
|
||||
|
||||
/* Default entry point: */
|
||||
|
@ -221,7 +236,18 @@ SECTIONS
|
|||
_iram_text_start = ABSOLUTE(.);
|
||||
*(.iram1 .iram1.*)
|
||||
*(.iram0.literal .iram.literal .iram.text.literal .iram0.text .iram.text)
|
||||
*(.literal .text .literal.* .text.*)
|
||||
*libesp32.a:panic.*(.literal .text .literal.* .text.*)
|
||||
*librtc.a:(.literal .text .literal.* .text.*)
|
||||
*libsoc.a:rtc_*.*(.literal .text .literal.* .text.*)
|
||||
*libsoc.a:cpu_util.*(.literal .text .literal.* .text.*)
|
||||
*libhal.a:(.literal .text .literal.* .text.*)
|
||||
*libgcc.a:lib2funcs.*(.literal .text .literal.* .text.*)
|
||||
*libspi_flash.a:spi_flash_rom_patch.*(.literal .text .literal.* .text.*)
|
||||
*libgcov.a:(.literal .text .literal.* .text.*)
|
||||
*libnet80211.a:( .wifi0iram .wifi0iram.*)
|
||||
*libpp.a:( .wifi0iram .wifi0iram.*)
|
||||
*libnet80211.a:( .wifirxiram .wifirxiram.*)
|
||||
*libpp.a:( .wifirxiram .wifirxiram.*)
|
||||
_iram_text_end = ABSOLUTE(.);
|
||||
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||
|
||||
|
@ -244,7 +270,7 @@ SECTIONS
|
|||
. = ALIGN(4);
|
||||
} GROUP_LINK_IN(RAMABLE_REGION)
|
||||
|
||||
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,ALIGN(4))
|
||||
SECTION_PROLOGUE(_RODATA_SECTION_NAME,,ALIGN(16))
|
||||
{
|
||||
_rodata_start = ABSOLUTE(.);
|
||||
*(.rodata)
|
||||
|
@ -276,8 +302,23 @@ SECTIONS
|
|||
*(.gnu.version_d)
|
||||
. = ALIGN(4); /* this table MUST be 4-byte aligned */
|
||||
_rodata_end = ABSOLUTE(.);
|
||||
} GROUP_LINK_IN(RAMABLE_REGION)
|
||||
} GROUP_LINK_IN(FLASH_DATA_REGION)
|
||||
|
||||
.flash.text :
|
||||
{
|
||||
_stext = .;
|
||||
_text_start = ABSOLUTE(.);
|
||||
|
||||
*(.literal .text .literal.* .text.*)
|
||||
_text_end = ABSOLUTE(.);
|
||||
_etext = .;
|
||||
|
||||
/* Similar to _iram_start, this symbol goes here so it is
|
||||
resolved by addr2line in preference to the first symbol in
|
||||
the flash.text segment.
|
||||
*/
|
||||
_flash_cache_start = ABSOLUTE(0);
|
||||
} GROUP_LINK_IN(FLASH_CODE_REGION)
|
||||
|
||||
/* Shared RAM */
|
||||
SECTION_DATA_PROLOGUE(_BSS_SECTION_NAME,(NOLOAD),)
|
||||
|
|
|
@ -25,8 +25,8 @@ extern void z_cstart(void);
|
|||
*/
|
||||
void __attribute__((section(".iram1"))) __start(void)
|
||||
{
|
||||
volatile uint32_t *wdt_rtc_protect = (uint32_t *)RTC_CNTL_WDTWPROTECT_REG;
|
||||
volatile uint32_t *wdt_rtc_reg = (uint32_t *)RTC_CNTL_WDTCONFIG0_REG;
|
||||
volatile uint32_t *wdt_timg_reg = (uint32_t *)TIMG_WDTCONFIG0_REG(0);
|
||||
volatile uint32_t *app_cpu_config_reg = (uint32_t *)DPORT_APPCPU_CTRL_B_REG;
|
||||
extern uint32_t _init_start;
|
||||
extern uint32_t _bss_start;
|
||||
|
@ -47,11 +47,22 @@ void __attribute__((section(".iram1"))) __start(void)
|
|||
: "g"(&_bss_start)
|
||||
: "memory");
|
||||
|
||||
/* The watchdog timer is enabled in the bootloader. We're done booting,
|
||||
* so disable it.
|
||||
#if !CONFIG_BOOTLOADER_ESP_IDF
|
||||
/* The watchdog timer is enabled in the 1st stage (ROM) bootloader.
|
||||
* We're done booting, so disable it.
|
||||
* If 2nd stage bootloader from IDF is enabled, then that will take
|
||||
* care of this.
|
||||
*/
|
||||
volatile uint32_t *wdt_timg_protect = (uint32_t *)TIMG_WDTWPROTECT_REG(0);
|
||||
volatile uint32_t *wdt_timg_reg = (uint32_t *)TIMG_WDTCONFIG0_REG(0);
|
||||
|
||||
*wdt_rtc_protect = RTC_CNTL_WDT_WKEY_VALUE;
|
||||
*wdt_rtc_reg &= ~RTC_CNTL_WDT_FLASHBOOT_MOD_EN;
|
||||
*wdt_rtc_protect = 0;
|
||||
*wdt_timg_protect = TIMG_WDT_WKEY_VALUE;
|
||||
*wdt_timg_reg &= ~TIMG_WDT_FLASHBOOT_MOD_EN;
|
||||
*wdt_timg_protect = 0;
|
||||
#endif
|
||||
|
||||
/* Disable normal interrupts. */
|
||||
__asm__ __volatile__ (
|
||||
|
@ -68,6 +79,15 @@ void __attribute__((section(".iram1"))) __start(void)
|
|||
*/
|
||||
__asm__ volatile("wsr.MISC0 %0; rsync" : : "r"(&_kernel.cpus[0]));
|
||||
|
||||
#if CONFIG_BOOTLOADER_ESP_IDF
|
||||
/* ESP-IDF 2nd stage bootloader enables RTC WDT to check on startup sequence
|
||||
* related issues in application. Hence disable that as we are about to start
|
||||
* Zephyr environment.
|
||||
*/
|
||||
*wdt_rtc_protect = RTC_CNTL_WDT_WKEY_VALUE;
|
||||
*wdt_rtc_reg &= ~RTC_CNTL_WDT_EN;
|
||||
*wdt_rtc_protect = 0;
|
||||
#endif
|
||||
|
||||
/* Start Zephyr */
|
||||
z_cstart();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
#define __SOC_H__
|
||||
#include <soc/dport_reg.h>
|
||||
#include <soc/rtc_cntl_reg.h>
|
||||
#include <rom/ets_sys.h>
|
||||
#include <esp32/rom/ets_sys.h>
|
||||
|
||||
#include <zephyr/types.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -24,9 +24,7 @@ static inline void esp32_clear_mask32(uint32_t v, uint32_t mem_addr)
|
|||
sys_write32(sys_read32(mem_addr) & ~v, mem_addr);
|
||||
}
|
||||
|
||||
extern int esp32_rom_intr_matrix_set(int cpu_no,
|
||||
int interrupt_src,
|
||||
int interrupt_line);
|
||||
extern void esp32_rom_intr_matrix_set(int cpu_no, uint32_t model_num, uint32_t intr_num);
|
||||
|
||||
extern int esp32_rom_gpio_matrix_in(uint32_t gpio, uint32_t signal_index,
|
||||
bool inverted);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue