mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'feature/clock_glitch_enable_v4.3' into 'release/v4.3'
bootloader: Enable clock glitch detection (v4.3) See merge request espressif/esp-idf!15225
This commit is contained in:
commit
c33ac6d1a9
@ -48,6 +48,7 @@ SECTIONS
|
|||||||
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||||
|
*libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
||||||
|
@ -36,6 +36,7 @@ SECTIONS
|
|||||||
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||||
|
*libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
||||||
|
@ -35,6 +35,7 @@ SECTIONS
|
|||||||
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||||
|
*libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
||||||
|
@ -36,6 +36,7 @@ SECTIONS
|
|||||||
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_sha.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_console_loader.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:bootloader_panic.*(.literal .text .literal.* .text.*)
|
||||||
|
*libbootloader_support.a:bootloader_soc.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:esp_image_format.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:flash_encrypt.*(.literal .text .literal.* .text.*)
|
||||||
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
*libbootloader_support.a:flash_partitions.*(.literal .text .literal.* .text.*)
|
||||||
|
@ -27,6 +27,7 @@ if(BOOTLOADER_BUILD)
|
|||||||
"src/bootloader_panic.c"
|
"src/bootloader_panic.c"
|
||||||
"src/${IDF_TARGET}/bootloader_sha.c"
|
"src/${IDF_TARGET}/bootloader_sha.c"
|
||||||
"src/${IDF_TARGET}/flash_encrypt.c"
|
"src/${IDF_TARGET}/flash_encrypt.c"
|
||||||
|
"src/${IDF_TARGET}/bootloader_soc.c"
|
||||||
"src/${IDF_TARGET}/bootloader_${IDF_TARGET}.c"
|
"src/${IDF_TARGET}/bootloader_${IDF_TARGET}.c"
|
||||||
)
|
)
|
||||||
list(APPEND priv_requires hal)
|
list(APPEND priv_requires hal)
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure analog super WDT reset
|
||||||
|
*
|
||||||
|
* @param enable Boolean to enable or disable super WDT reset
|
||||||
|
*/
|
||||||
|
void bootloader_ana_super_wdt_reset_config(bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure analog brownout reset
|
||||||
|
*
|
||||||
|
* @param enable Boolean to enable or disable brownout reset
|
||||||
|
*/
|
||||||
|
void bootloader_ana_bod_reset_config(bool enable);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Configure analog clock glitch reset
|
||||||
|
*
|
||||||
|
* @param enable Boolean to enable or disable clock glitch reset
|
||||||
|
*/
|
||||||
|
void bootloader_ana_clock_glitch_reset_config(bool enable);
|
@ -77,6 +77,7 @@
|
|||||||
#include "bootloader_utility.h"
|
#include "bootloader_utility.h"
|
||||||
#include "bootloader_sha.h"
|
#include "bootloader_sha.h"
|
||||||
#include "bootloader_console.h"
|
#include "bootloader_console.h"
|
||||||
|
#include "bootloader_soc.h"
|
||||||
#include "esp_efuse.h"
|
#include "esp_efuse.h"
|
||||||
|
|
||||||
static const char *TAG = "boot";
|
static const char *TAG = "boot";
|
||||||
@ -637,6 +638,12 @@ static void load_image(const esp_image_metadata_t *image_data)
|
|||||||
ESP_LOGI(TAG, "Disabling RNG early entropy source...");
|
ESP_LOGI(TAG, "Disabling RNG early entropy source...");
|
||||||
bootloader_random_disable();
|
bootloader_random_disable();
|
||||||
|
|
||||||
|
/* Disable glitch reset after all the security checks are completed.
|
||||||
|
* Glitch detection can be falsely triggered by EMI interference (high RF TX power, etc)
|
||||||
|
* and to avoid such false alarms, disable it.
|
||||||
|
*/
|
||||||
|
bootloader_ana_clock_glitch_reset_config(false);
|
||||||
|
|
||||||
// copy loaded segments to RAM, set up caches for mapped segments, and start application
|
// copy loaded segments to RAM, set up caches for mapped segments, and start application
|
||||||
unpack_load_app(image_data);
|
unpack_load_app(image_data);
|
||||||
}
|
}
|
||||||
|
21
components/bootloader_support/src/esp32/bootloader_soc.c
Normal file
21
components/bootloader_support/src/esp32/bootloader_soc.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootloader_ana_bod_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
@ -45,6 +45,7 @@
|
|||||||
#include "regi2c_ctrl.h"
|
#include "regi2c_ctrl.h"
|
||||||
#include "bootloader_console.h"
|
#include "bootloader_console.h"
|
||||||
#include "bootloader_flash_priv.h"
|
#include "bootloader_flash_priv.h"
|
||||||
|
#include "bootloader_soc.h"
|
||||||
|
|
||||||
static const char *TAG = "boot.esp32c3";
|
static const char *TAG = "boot.esp32c3";
|
||||||
|
|
||||||
@ -272,7 +273,7 @@ static inline void bootloader_hardware_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void bootloader_glitch_reset_disable(void)
|
static inline void bootloader_ana_reset_config(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
For origin chip & ECO1: only support swt reset;
|
For origin chip & ECO1: only support swt reset;
|
||||||
@ -280,10 +281,27 @@ static inline void bootloader_glitch_reset_disable(void)
|
|||||||
For ECO3: fix clock glitch reset bug, support all reset, include: swt & brownout & clock glitch reset.
|
For ECO3: fix clock glitch reset bug, support all reset, include: swt & brownout & clock glitch reset.
|
||||||
*/
|
*/
|
||||||
uint8_t chip_version = bootloader_common_get_chip_revision();
|
uint8_t chip_version = bootloader_common_get_chip_revision();
|
||||||
if (chip_version < 2) {
|
switch (chip_version) {
|
||||||
REG_SET_FIELD(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SEL, RTC_CNTL_FIB_SUPER_WDT_RST);
|
case 0:
|
||||||
} else if (chip_version == 2) {
|
case 1:
|
||||||
REG_SET_FIELD(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SEL, RTC_CNTL_FIB_SUPER_WDT_RST | RTC_CNTL_FIB_BOR_RST);
|
//Enable WDT reset. Disable BOR and GLITCH reset
|
||||||
|
bootloader_ana_super_wdt_reset_config(true);
|
||||||
|
bootloader_ana_bod_reset_config(false);
|
||||||
|
bootloader_ana_clock_glitch_reset_config(false);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
//Enable WDT and BOR reset. Disable GLITCH reset
|
||||||
|
bootloader_ana_super_wdt_reset_config(true);
|
||||||
|
bootloader_ana_bod_reset_config(true);
|
||||||
|
bootloader_ana_clock_glitch_reset_config(false);
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
default:
|
||||||
|
//Enable WDT, BOR, and GLITCH reset
|
||||||
|
bootloader_ana_super_wdt_reset_config(true);
|
||||||
|
bootloader_ana_bod_reset_config(true);
|
||||||
|
bootloader_ana_clock_glitch_reset_config(true);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +310,7 @@ esp_err_t bootloader_init(void)
|
|||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
bootloader_hardware_init();
|
bootloader_hardware_init();
|
||||||
bootloader_glitch_reset_disable();
|
bootloader_ana_reset_config();
|
||||||
bootloader_super_wdt_auto_feed();
|
bootloader_super_wdt_auto_feed();
|
||||||
// protect memory region
|
// protect memory region
|
||||||
bootloader_init_mem();
|
bootloader_init_mem();
|
||||||
|
41
components/bootloader_support/src/esp32c3/bootloader_soc.c
Normal file
41
components/bootloader_support/src/esp32c3/bootloader_soc.c
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "soc/soc.h"
|
||||||
|
#include "soc/rtc_cntl_reg.h"
|
||||||
|
|
||||||
|
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_SUPER_WDT_RST);
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
REG_SET_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||||
|
} else {
|
||||||
|
REG_CLR_BIT(RTC_CNTL_SWD_CONF_REG, RTC_CNTL_SWD_BYPASS_RST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootloader_ana_bod_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_BOR_RST);
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
REG_SET_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ANA_RST_EN);
|
||||||
|
} else {
|
||||||
|
REG_CLR_BIT(RTC_CNTL_BROWN_OUT_REG, RTC_CNTL_BROWN_OUT_ANA_RST_EN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
REG_CLR_BIT(RTC_CNTL_FIB_SEL_REG, RTC_CNTL_FIB_GLITCH_RST);
|
||||||
|
|
||||||
|
if (enable) {
|
||||||
|
REG_SET_BIT(RTC_CNTL_ANA_CONF_REG, RTC_CNTL_GLITCH_RST_EN);
|
||||||
|
} else {
|
||||||
|
REG_CLR_BIT(RTC_CNTL_ANA_CONF_REG, RTC_CNTL_GLITCH_RST_EN);
|
||||||
|
}
|
||||||
|
}
|
21
components/bootloader_support/src/esp32s2/bootloader_soc.c
Normal file
21
components/bootloader_support/src/esp32s2/bootloader_soc.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootloader_ana_bod_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
21
components/bootloader_support/src/esp32s3/bootloader_soc.c
Normal file
21
components/bootloader_support/src/esp32s3/bootloader_soc.c
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
void bootloader_ana_super_wdt_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootloader_ana_bod_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
void bootloader_ana_clock_glitch_reset_config(bool enable)
|
||||||
|
{
|
||||||
|
(void)enable;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user