forked from espressif/arduino-esp32
Esp32 s3 support (#6341)
Co-authored-by: Jason2866 <24528715+Jason2866@users.noreply.github.com> Co-authored-by: Unexpected Maker <seon@unexpectedmaker.com> Co-authored-by: Rodrigo Garcia <rodrigo.garcia@espressif.com> Co-authored-by: Tomáš Pilný <34927466+PilnyTomas@users.noreply.github.com> Co-authored-by: Pedro Minatel <pedro.minatel@espressif.com> Co-authored-by: Ivan Grokhotkov <ivan@espressif.com> Co-authored-by: Jan Procházka <90197375+P-R-O-C-H-Y@users.noreply.github.com> Co-authored-by: Limor "Ladyada" Fried <limor@ladyada.net>
This commit is contained in:
81
tools/sdk/esp32s3/include/efuse/esp32s3/include/esp_efuse.h
Normal file
81
tools/sdk/esp32s3/include/efuse/esp32s3/include/esp_efuse.h
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Type of eFuse blocks ESP32S3
|
||||
*/
|
||||
typedef enum {
|
||||
EFUSE_BLK0 = 0, /**< Number of eFuse BLOCK0. REPEAT_DATA */
|
||||
|
||||
EFUSE_BLK1 = 1, /**< Number of eFuse BLOCK1. MAC_SPI_8M_SYS */
|
||||
|
||||
EFUSE_BLK2 = 2, /**< Number of eFuse BLOCK2. SYS_DATA_PART1 */
|
||||
EFUSE_BLK_SYS_DATA_PART1 = 2, /**< Number of eFuse BLOCK2. SYS_DATA_PART1 */
|
||||
|
||||
EFUSE_BLK3 = 3, /**< Number of eFuse BLOCK3. USER_DATA*/
|
||||
EFUSE_BLK_USER_DATA = 3, /**< Number of eFuse BLOCK3. USER_DATA*/
|
||||
|
||||
EFUSE_BLK4 = 4, /**< Number of eFuse BLOCK4. KEY0 */
|
||||
EFUSE_BLK_KEY0 = 4, /**< Number of eFuse BLOCK4. KEY0 */
|
||||
|
||||
EFUSE_BLK5 = 5, /**< Number of eFuse BLOCK5. KEY1 */
|
||||
EFUSE_BLK_KEY1 = 5, /**< Number of eFuse BLOCK5. KEY1 */
|
||||
|
||||
EFUSE_BLK6 = 6, /**< Number of eFuse BLOCK6. KEY2 */
|
||||
EFUSE_BLK_KEY2 = 6, /**< Number of eFuse BLOCK6. KEY2 */
|
||||
|
||||
EFUSE_BLK7 = 7, /**< Number of eFuse BLOCK7. KEY3 */
|
||||
EFUSE_BLK_KEY3 = 7, /**< Number of eFuse BLOCK7. KEY3 */
|
||||
|
||||
EFUSE_BLK8 = 8, /**< Number of eFuse BLOCK8. KEY4 */
|
||||
EFUSE_BLK_KEY4 = 8, /**< Number of eFuse BLOCK8. KEY4 */
|
||||
|
||||
EFUSE_BLK9 = 9, /**< Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY5 = 9, /**< Number of eFuse BLOCK9. KEY5 */
|
||||
EFUSE_BLK_KEY_MAX = 10,
|
||||
|
||||
EFUSE_BLK10 = 10, /**< Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
EFUSE_BLK_SYS_DATA_PART2 = 10, /**< Number of eFuse BLOCK10. SYS_DATA_PART2 */
|
||||
|
||||
EFUSE_BLK_MAX
|
||||
} esp_efuse_block_t;
|
||||
|
||||
/**
|
||||
* @brief Type of coding scheme
|
||||
*/
|
||||
typedef enum {
|
||||
EFUSE_CODING_SCHEME_NONE = 0, /**< None */
|
||||
EFUSE_CODING_SCHEME_RS = 3, /**< Reed-Solomon coding */
|
||||
} esp_efuse_coding_scheme_t;
|
||||
|
||||
/**
|
||||
* @brief Type of key purpose
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_EFUSE_KEY_PURPOSE_USER = 0, /**< User purposes (software-only use) */
|
||||
ESP_EFUSE_KEY_PURPOSE_RESERVED = 1, /**< Reserved */
|
||||
ESP_EFUSE_KEY_PURPOSE_XTS_AES_256_KEY_1 = 2, /**< XTS_AES_256_KEY_1 (flash/PSRAM encryption) */
|
||||
ESP_EFUSE_KEY_PURPOSE_XTS_AES_256_KEY_2 = 3, /**< XTS_AES_256_KEY_2 (flash/PSRAM encryption) */
|
||||
ESP_EFUSE_KEY_PURPOSE_XTS_AES_128_KEY = 4, /**< XTS_AES_128_KEY (flash/PSRAM encryption) */
|
||||
ESP_EFUSE_KEY_PURPOSE_HMAC_DOWN_ALL = 5, /**< HMAC Downstream mode */
|
||||
ESP_EFUSE_KEY_PURPOSE_HMAC_DOWN_JTAG = 6, /**< JTAG soft enable key (uses HMAC Downstream mode) */
|
||||
ESP_EFUSE_KEY_PURPOSE_HMAC_DOWN_DIGITAL_SIGNATURE = 7, /**< Digital Signature peripheral key (uses HMAC Downstream mode) */
|
||||
ESP_EFUSE_KEY_PURPOSE_HMAC_UP = 8, /**< HMAC Upstream mode */
|
||||
ESP_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST0 = 9, /**< SECURE_BOOT_DIGEST0 (Secure Boot key digest) */
|
||||
ESP_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST1 = 10, /**< SECURE_BOOT_DIGEST1 (Secure Boot key digest) */
|
||||
ESP_EFUSE_KEY_PURPOSE_SECURE_BOOT_DIGEST2 = 11, /**< SECURE_BOOT_DIGEST2 (Secure Boot key digest) */
|
||||
ESP_EFUSE_KEY_PURPOSE_MAX, /**< MAX PURPOSE */
|
||||
} esp_efuse_purpose_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,59 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <esp_types.h>
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//This is the ADC calibration value version burnt in efuse
|
||||
#define ESP_EFUSE_ADC_CALIB_VER 1
|
||||
|
||||
/**
|
||||
* @brief Get the RTC calibration efuse version
|
||||
*
|
||||
* @return Version of the stored efuse
|
||||
*/
|
||||
int esp_efuse_rtc_calib_get_ver(void);
|
||||
|
||||
/**
|
||||
* @brief Get the init code in the efuse, for the corresponding attenuation.
|
||||
*
|
||||
* @param version Version of the stored efuse
|
||||
* @param adc_unit ADC unit
|
||||
* @param atten Attenuation of the init code
|
||||
* @return The init code stored in efuse
|
||||
*/
|
||||
uint32_t esp_efuse_rtc_calib_get_init_code(int version, uint32_t adc_unit, int atten);
|
||||
|
||||
/**
|
||||
* @brief Get the calibration digits stored in the efuse, and the corresponding voltage.
|
||||
*
|
||||
* @param version Version of the stored efuse
|
||||
* @param adc_unit ADC unit
|
||||
* @param atten Attenuation to use
|
||||
* @param out_digi Output buffer of the digits
|
||||
* @param out_vol_mv Output of the voltage, in mV
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG: If efuse version or attenuation is invalid
|
||||
* - ESP_OK: if success
|
||||
*/
|
||||
esp_err_t esp_efuse_rtc_calib_get_cal_voltage(int version, uint32_t adc_unit, int atten, uint32_t* out_digi, uint32_t* out_vol_mv);
|
||||
|
||||
/**
|
||||
* @brief Get the temperature sensor calibration number delta_T stored in the efuse.
|
||||
*
|
||||
* @param version Version of the stored efuse
|
||||
*
|
||||
* @return The specification of temperature sensor calibration number in efuse.
|
||||
*/
|
||||
float esp_efuse_rtc_calib_get_cal_temp(int version);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,150 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
// md5_digest_table 9444b887379d924049af42806ca71d45
|
||||
// This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
|
||||
// If you want to change some fields, you need to change esp_efuse_table.csv file
|
||||
// then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
|
||||
// To show efuse_table run the command 'show_efuse_table'.
|
||||
|
||||
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_RD_DIS[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_GROUP_1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_GROUP_2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SPI_BOOT_CRYPT_CNT[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SECURE_BOOT_KEY_REVOKE0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SECURE_BOOT_KEY_REVOKE1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SECURE_BOOT_KEY_REVOKE2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY0_PURPOSE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY1_PURPOSE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY2_PURPOSE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY3_PURPOSE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY4_PURPOSE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY5_PURPOSE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SECURE_BOOT_EN[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SECURE_BOOT_AGGRESSIVE_REVOKE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_GROUP_3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLK1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SYS_DATA_PART1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USER_DATA[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY4[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_KEY5[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SYS_DATA_PART2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_EXCHG_PINS[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY4[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_KEY5[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_SYS_DATA_PART2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_ICACHE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DCACHE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DOWNLOAD_ICACHE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DOWNLOAD_DCACHE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_FORCE_DOWNLOAD[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_CAN[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_APP_CPU[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SOFT_DIS_JTAG[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_HARD_DIS_JTAG[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DOWNLOAD_MANUAL_ENCRYPT[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_USB_EXCHG_PINS[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_USB_EXT_PHY_ENABLE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_BTLC_GPIO_ENABLE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_VDD_SPI_XPD[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_VDD_SPI_TIEH[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_VDD_SPI_FORCE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WDT_DELAY_SEL[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_BOOT_CRYPT_CNT[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_BOOT_KEY_REVOKE0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_BOOT_KEY_REVOKE1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_BOOT_KEY_REVOKE2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY_PURPOSE_0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY_PURPOSE_1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY_PURPOSE_2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY_PURPOSE_3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY_PURPOSE_4[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY_PURPOSE_5[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_BOOT_EN[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_BOOT_AGGRESSIVE_REVOKE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_JTAG[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_SERIAL_JTAG[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_STRAP_JTAG_SEL[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_USB_PHY_SEL[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_TPUW[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_DOWNLOAD_MODE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_LEGACY_SPI_BOOT[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_UART_PRINT_CHANNEL[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_ECC_MODE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_DOWNLOAD_MODE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ENABLE_SECURITY_DOWNLOAD[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_UART_PRINT_CONTROL[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_PIN_POWER_SELECTION[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_TYPE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_PAGE_SIZE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_FLASH_ECC_EN[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_FORCE_SEND_RESUME[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_VERSION[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_MAC_FACTORY[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_CLK[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_Q_D1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D_D0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_CS[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_HD_D3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_WP_D2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_DQS[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D4[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D5[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D6[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SPI_PAD_CONFIG_D7[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_WAFER_VERSION[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MINOR[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CAL_VOL_ATTEN3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_BLK_VER_MAJOR[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_TEMP_CALIB[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_OCODE[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_INIT_CODE_ATTEN0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_INIT_CODE_ATTEN1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_INIT_CODE_ATTEN2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_INIT_CODE_ATTEN3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_INIT_CODE_ATTEN0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_INIT_CODE_ATTEN1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_INIT_CODE_ATTEN2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_INIT_CODE_ATTEN3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CAL_VOL_ATTEN0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CAL_VOL_ATTEN1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CAL_VOL_ATTEN2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CAL_VOL_ATTEN3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CAL_VOL_ATTEN0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CAL_VOL_ATTEN1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CAL_VOL_ATTEN2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA_MAC_CUSTOM[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY0[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY1[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY2[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY3[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY4[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_KEY5[];
|
||||
extern const esp_efuse_desc_t* ESP_EFUSE_SYS_DATA_PART2[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
766
tools/sdk/esp32s3/include/efuse/include/esp_efuse.h
Normal file
766
tools/sdk/esp32s3/include/efuse/include/esp_efuse.h
Normal file
@ -0,0 +1,766 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_log.h"
|
||||
#include "soc/soc_caps.h"
|
||||
#include "sdkconfig.h"
|
||||
#include_next "esp_efuse.h"
|
||||
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#include "esp32c3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#include "esp32s3/rom/secure_boot.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
||||
#include "esp32h2/rom/secure_boot.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_ERR_EFUSE 0x1600 /*!< Base error code for efuse api. */
|
||||
#define ESP_OK_EFUSE_CNT (ESP_ERR_EFUSE + 0x01) /*!< OK the required number of bits is set. */
|
||||
#define ESP_ERR_EFUSE_CNT_IS_FULL (ESP_ERR_EFUSE + 0x02) /*!< Error field is full. */
|
||||
#define ESP_ERR_EFUSE_REPEATED_PROG (ESP_ERR_EFUSE + 0x03) /*!< Error repeated programming of programmed bits is strictly forbidden. */
|
||||
#define ESP_ERR_CODING (ESP_ERR_EFUSE + 0x04) /*!< Error while a encoding operation. */
|
||||
#define ESP_ERR_NOT_ENOUGH_UNUSED_KEY_BLOCKS (ESP_ERR_EFUSE + 0x05) /*!< Error not enough unused key blocks available */
|
||||
#define ESP_ERR_DAMAGED_READING (ESP_ERR_EFUSE + 0x06) /*!< Error. Burn or reset was done during a reading operation leads to damage read data. This error is internal to the efuse component and not returned by any public API. */
|
||||
|
||||
/**
|
||||
* @brief Type definition for an eFuse field
|
||||
*/
|
||||
typedef struct {
|
||||
esp_efuse_block_t efuse_block: 8; /**< Block of eFuse */
|
||||
uint8_t bit_start; /**< Start bit [0..255] */
|
||||
uint16_t bit_count; /**< Length of bit field [1..-]*/
|
||||
} esp_efuse_desc_t;
|
||||
|
||||
/**
|
||||
* @brief Type definition for ROM log scheme
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_EFUSE_ROM_LOG_ALWAYS_ON, /**< Always enable ROM logging */
|
||||
ESP_EFUSE_ROM_LOG_ON_GPIO_LOW, /**< ROM logging is enabled when specific GPIO level is low during start up */
|
||||
ESP_EFUSE_ROM_LOG_ON_GPIO_HIGH, /**< ROM logging is enabled when specific GPIO level is high during start up */
|
||||
ESP_EFUSE_ROM_LOG_ALWAYS_OFF /**< Disable ROM logging permanently */
|
||||
} esp_efuse_rom_log_scheme_t;
|
||||
|
||||
/**
|
||||
* @brief Reads bits from EFUSE field and writes it into an array.
|
||||
*
|
||||
* The number of read bits will be limited to the minimum value
|
||||
* from the description of the bits in "field" structure or "dst_size_bits" required size.
|
||||
* Use "esp_efuse_get_field_size()" function to determine the length of the field.
|
||||
*
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
* @param[out] dst A pointer to array that will contain the result of reading.
|
||||
* @param[in] dst_size_bits The number of bits required to read.
|
||||
* If the requested number of bits is greater than the field,
|
||||
* the number will be limited to the field size.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
*/
|
||||
esp_err_t esp_efuse_read_field_blob(const esp_efuse_desc_t* field[], void* dst, size_t dst_size_bits);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Read a single bit eFuse field as a boolean value.
|
||||
*
|
||||
* @note The value must exist and must be a single bit wide. If there is any possibility of an error
|
||||
* in the provided arguments, call esp_efuse_read_field_blob() and check the returned value instead.
|
||||
*
|
||||
* @note If assertions are enabled and the parameter is invalid, execution will abort
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
* @return
|
||||
* - true: The field parameter is valid and the bit is set.
|
||||
* - false: The bit is not set, or the parameter is invalid and assertions are disabled.
|
||||
*
|
||||
*/
|
||||
bool esp_efuse_read_field_bit(const esp_efuse_desc_t *field[]);
|
||||
|
||||
/**
|
||||
* @brief Reads bits from EFUSE field and returns number of bits programmed as "1".
|
||||
*
|
||||
* If the bits are set not sequentially, they will still be counted.
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
* @param[out] out_cnt A pointer that will contain the number of programmed as "1" bits.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
*/
|
||||
esp_err_t esp_efuse_read_field_cnt(const esp_efuse_desc_t* field[], size_t* out_cnt);
|
||||
|
||||
/**
|
||||
* @brief Writes array to EFUSE field.
|
||||
*
|
||||
* The number of write bits will be limited to the minimum value
|
||||
* from the description of the bits in "field" structure or "src_size_bits" required size.
|
||||
* Use "esp_efuse_get_field_size()" function to determine the length of the field.
|
||||
* After the function is completed, the writing registers are cleared.
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
* @param[in] src A pointer to array that contains the data for writing.
|
||||
* @param[in] src_size_bits The number of bits required to write.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_write_field_blob(const esp_efuse_desc_t* field[], const void* src, size_t src_size_bits);
|
||||
|
||||
/**
|
||||
* @brief Writes a required count of bits as "1" to EFUSE field.
|
||||
*
|
||||
* If there are no free bits in the field to set the required number of bits to "1",
|
||||
* ESP_ERR_EFUSE_CNT_IS_FULL error is returned, the field will not be partially recorded.
|
||||
* After the function is completed, the writing registers are cleared.
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
* @param[in] cnt Required number of programmed as "1" bits.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_CNT_IS_FULL: Not all requested cnt bits is set.
|
||||
*/
|
||||
esp_err_t esp_efuse_write_field_cnt(const esp_efuse_desc_t* field[], size_t cnt);
|
||||
|
||||
/**
|
||||
* @brief Write a single bit eFuse field to 1
|
||||
*
|
||||
* For use with eFuse fields that are a single bit. This function will write the bit to value 1 if
|
||||
* it is not already set, or does nothing if the bit is already set.
|
||||
*
|
||||
* This is equivalent to calling esp_efuse_write_field_cnt() with the cnt parameter equal to 1,
|
||||
* except that it will return ESP_OK if the field is already set to 1.
|
||||
*
|
||||
* @param[in] field Pointer to the structure describing the efuse field.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed, or the bit was already set to value 1.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arugments, including if the efuse field is not 1 bit wide.
|
||||
*/
|
||||
esp_err_t esp_efuse_write_field_bit(const esp_efuse_desc_t* field[]);
|
||||
|
||||
/**
|
||||
* @brief Sets a write protection for the whole block.
|
||||
*
|
||||
* After that, it is impossible to write to this block.
|
||||
* The write protection does not apply to block 0.
|
||||
* @param[in] blk Block number of eFuse. (EFUSE_BLK1, EFUSE_BLK2 and EFUSE_BLK3)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_CNT_IS_FULL: Not all requested cnt bits is set.
|
||||
* - ESP_ERR_NOT_SUPPORTED: The block does not support this command.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_write_protect(esp_efuse_block_t blk);
|
||||
|
||||
/**
|
||||
* @brief Sets a read protection for the whole block.
|
||||
*
|
||||
* After that, it is impossible to read from this block.
|
||||
* The read protection does not apply to block 0.
|
||||
* @param[in] blk Block number of eFuse. (EFUSE_BLK1, EFUSE_BLK2 and EFUSE_BLK3)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_CNT_IS_FULL: Not all requested cnt bits is set.
|
||||
* - ESP_ERR_NOT_SUPPORTED: The block does not support this command.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_read_protect(esp_efuse_block_t blk);
|
||||
|
||||
/**
|
||||
* @brief Returns the number of bits used by field.
|
||||
*
|
||||
* @param[in] field A pointer to the structure describing the fields of efuse.
|
||||
*
|
||||
* @return Returns the number of bits used by field.
|
||||
*/
|
||||
int esp_efuse_get_field_size(const esp_efuse_desc_t* field[]);
|
||||
|
||||
/**
|
||||
* @brief Returns value of efuse register.
|
||||
*
|
||||
* This is a thread-safe implementation.
|
||||
* Example: EFUSE_BLK2_RDATA3_REG where (blk=2, num_reg=3)
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] blk Block number of eFuse.
|
||||
* @param[in] num_reg The register number in the block.
|
||||
*
|
||||
* @return Value of register
|
||||
*/
|
||||
uint32_t esp_efuse_read_reg(esp_efuse_block_t blk, unsigned int num_reg);
|
||||
|
||||
/**
|
||||
* @brief Write value to efuse register.
|
||||
*
|
||||
* Apply a coding scheme if necessary.
|
||||
* This is a thread-safe implementation.
|
||||
* Example: EFUSE_BLK3_WDATA0_REG where (blk=3, num_reg=0)
|
||||
* @param[in] blk Block number of eFuse.
|
||||
* @param[in] num_reg The register number in the block.
|
||||
* @param[in] val Value to write.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
*/
|
||||
esp_err_t esp_efuse_write_reg(esp_efuse_block_t blk, unsigned int num_reg, uint32_t val);
|
||||
|
||||
/**
|
||||
* @brief Return efuse coding scheme for blocks.
|
||||
*
|
||||
* Note: The coding scheme is applicable only to 1, 2 and 3 blocks. For 0 block, the coding scheme is always ``NONE``.
|
||||
*
|
||||
* @param[in] blk Block number of eFuse.
|
||||
* @return Return efuse coding scheme for blocks
|
||||
*/
|
||||
esp_efuse_coding_scheme_t esp_efuse_get_coding_scheme(esp_efuse_block_t blk);
|
||||
|
||||
/**
|
||||
* @brief Read key to efuse block starting at the offset and the required size.
|
||||
*
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* @param[in] blk Block number of eFuse.
|
||||
* @param[in] dst_key A pointer to array that will contain the result of reading.
|
||||
* @param[in] offset_in_bits Start bit in block.
|
||||
* @param[in] size_bits The number of bits required to read.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_read_block(esp_efuse_block_t blk, void* dst_key, size_t offset_in_bits, size_t size_bits);
|
||||
|
||||
/**
|
||||
* @brief Write key to efuse block starting at the offset and the required size.
|
||||
*
|
||||
* @param[in] blk Block number of eFuse.
|
||||
* @param[in] src_key A pointer to array that contains the key for writing.
|
||||
* @param[in] offset_in_bits Start bit in block.
|
||||
* @param[in] size_bits The number of bits required to write.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: The operation was successfully completed.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits
|
||||
*/
|
||||
esp_err_t esp_efuse_write_block(esp_efuse_block_t blk, const void* src_key, size_t offset_in_bits, size_t size_bits);
|
||||
|
||||
/**
|
||||
* @brief Returns chip version from efuse
|
||||
*
|
||||
* @return chip version
|
||||
*/
|
||||
uint8_t esp_efuse_get_chip_ver(void);
|
||||
|
||||
/**
|
||||
* @brief Returns chip package from efuse
|
||||
*
|
||||
* @return chip package
|
||||
*/
|
||||
uint32_t esp_efuse_get_pkg_ver(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reset efuse write registers
|
||||
*
|
||||
* Efuse write registers are written to zero, to negate
|
||||
* any changes that have been staged here.
|
||||
*
|
||||
* @note This function is not threadsafe, if calling code updates
|
||||
* efuse values from multiple tasks then this is caller's
|
||||
* responsibility to serialise.
|
||||
*/
|
||||
void esp_efuse_reset(void);
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
/**
|
||||
* @brief Disable BASIC ROM Console via efuse
|
||||
*
|
||||
* By default, if booting from flash fails the ESP32 will boot a
|
||||
* BASIC console in ROM.
|
||||
*
|
||||
* Call this function (from bootloader or app) to permanently disable the console on this chip.
|
||||
*
|
||||
*/
|
||||
void esp_efuse_disable_basic_rom_console(void);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disable ROM Download Mode via eFuse
|
||||
*
|
||||
* Permanently disables the ROM Download Mode feature. Once disabled, if the SoC is booted with
|
||||
* strapping pins set for ROM Download Mode then an error is printed instead.
|
||||
*
|
||||
* @note Not all SoCs support this option. An error will be returned if called on an ESP32
|
||||
* with a silicon revision lower than 3, as these revisions do not support this option.
|
||||
*
|
||||
* @note If ROM Download Mode is already disabled, this function does nothing and returns success.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK If the eFuse was successfully burned, or had already been burned.
|
||||
* - ESP_ERR_NOT_SUPPORTED (ESP32 only) This SoC is not capable of disabling UART download mode
|
||||
* - ESP_ERR_INVALID_STATE (ESP32 only) This eFuse is write protected and cannot be written
|
||||
*/
|
||||
esp_err_t esp_efuse_disable_rom_download_mode(void);
|
||||
|
||||
/**
|
||||
* @brief Set boot ROM log scheme via eFuse
|
||||
*
|
||||
* @note By default, the boot ROM will always print to console. This API can be called to set the log scheme only once per chip,
|
||||
* once the value is changed from the default it can't be changed again.
|
||||
*
|
||||
* @param log_scheme Supported ROM log scheme
|
||||
* @return
|
||||
* - ESP_OK If the eFuse was successfully burned, or had already been burned.
|
||||
* - ESP_ERR_NOT_SUPPORTED (ESP32 only) This SoC is not capable of setting ROM log scheme
|
||||
* - ESP_ERR_INVALID_STATE This eFuse is write protected or has been burned already
|
||||
*/
|
||||
esp_err_t esp_efuse_set_rom_log_scheme(esp_efuse_rom_log_scheme_t log_scheme);
|
||||
|
||||
#if SOC_SUPPORTS_SECURE_DL_MODE
|
||||
/**
|
||||
* @brief Switch ROM Download Mode to Secure Download mode via eFuse
|
||||
*
|
||||
* Permanently enables Secure Download mode. This mode limits the use of ROM Download Mode functions
|
||||
* to simple flash read, write and erase operations, plus a command to return a summary of currently
|
||||
* enabled security features.
|
||||
*
|
||||
* @note If Secure Download mode is already enabled, this function does nothing and returns success.
|
||||
*
|
||||
* @note Disabling the ROM Download Mode also disables Secure Download Mode.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK If the eFuse was successfully burned, or had already been burned.
|
||||
* - ESP_ERR_INVALID_STATE ROM Download Mode has been disabled via eFuse, so Secure Download mode is unavailable.
|
||||
*/
|
||||
esp_err_t esp_efuse_enable_rom_secure_download_mode(void);
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* @brief Return secure_version from efuse field.
|
||||
* @return Secure version from efuse field
|
||||
*/
|
||||
uint32_t esp_efuse_read_secure_version(void);
|
||||
|
||||
/**
|
||||
* @brief Check secure_version from app and secure_version and from efuse field.
|
||||
*
|
||||
* @param secure_version Secure version from app.
|
||||
* @return
|
||||
* - True: If version of app is equal or more then secure_version from efuse.
|
||||
*/
|
||||
bool esp_efuse_check_secure_version(uint32_t secure_version);
|
||||
|
||||
/**
|
||||
* @brief Write efuse field by secure_version value.
|
||||
*
|
||||
* Update the secure_version value is available if the coding scheme is None.
|
||||
* Note: Do not use this function in your applications. This function is called as part of the other API.
|
||||
*
|
||||
* @param[in] secure_version Secure version from app.
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_FAIL: secure version of app cannot be set to efuse field.
|
||||
* - ESP_ERR_NOT_SUPPORTED: Anti rollback is not supported with the 3/4 and Repeat coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_update_secure_version(uint32_t secure_version);
|
||||
|
||||
#if defined(BOOTLOADER_BUILD) && defined(CONFIG_EFUSE_VIRTUAL) && !defined(CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH)
|
||||
/**
|
||||
* @brief Initializes eFuses API to keep eFuses in RAM.
|
||||
*
|
||||
* This function just copies all eFuses to RAM. IDF eFuse APIs perform all operators with RAM instead of real eFuse.
|
||||
* (Used only in bootloader).
|
||||
*/
|
||||
void esp_efuse_init_virtual_mode_in_ram(void);
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH
|
||||
/**
|
||||
* @brief Initializes variables: offset and size to simulate the work of an eFuse.
|
||||
*
|
||||
* Note: To simulate the work of an eFuse need to set CONFIG_EFUSE_VIRTUAL_KEEP_IN_FLASH option
|
||||
* and to add in the partition.csv file a line `efuse_em, data, efuse, , 0x2000,`.
|
||||
*
|
||||
* @param[in] offset The starting address of the partition where the eFuse data will be located.
|
||||
* @param[in] size The size of the partition.
|
||||
*/
|
||||
void esp_efuse_init_virtual_mode_in_flash(uint32_t offset, uint32_t size);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Set the batch mode of writing fields.
|
||||
*
|
||||
* This mode allows you to write the fields in the batch mode when need to burn several efuses at one time.
|
||||
* To enable batch mode call begin() then perform as usually the necessary operations
|
||||
* read and write and at the end call commit() to actually burn all written efuses.
|
||||
* The batch mode can be used nested. The commit will be done by the last commit() function.
|
||||
* The number of begin() functions should be equal to the number of commit() functions.
|
||||
*
|
||||
* @note Please note that reading in the batch mode does not show uncommitted changes.
|
||||
*
|
||||
* Note: If batch mode is enabled by the first task, at this time the second task cannot write/read efuses.
|
||||
* The second task will wait for the first task to complete the batch operation.
|
||||
*
|
||||
* \code{c}
|
||||
* // Example of using the batch writing mode.
|
||||
*
|
||||
* // set the batch writing mode
|
||||
* esp_efuse_batch_write_begin();
|
||||
*
|
||||
* // use any writing functions as usual
|
||||
* esp_efuse_write_field_blob(ESP_EFUSE_...);
|
||||
* esp_efuse_write_field_cnt(ESP_EFUSE_...);
|
||||
* esp_efuse_set_write_protect(EFUSE_BLKx);
|
||||
* esp_efuse_write_reg(EFUSE_BLKx, ...);
|
||||
* esp_efuse_write_block(EFUSE_BLKx, ...);
|
||||
* esp_efuse_write(ESP_EFUSE_1, 3); // ESP_EFUSE_1 == 1, here we write a new value = 3. The changes will be burn by the commit() function.
|
||||
* esp_efuse_read_...(ESP_EFUSE_1); // this function returns ESP_EFUSE_1 == 1 because uncommitted changes are not readable, it will be available only after commit.
|
||||
* ...
|
||||
*
|
||||
* // esp_efuse_batch_write APIs can be called recursively.
|
||||
* esp_efuse_batch_write_begin();
|
||||
* esp_efuse_set_write_protect(EFUSE_BLKx);
|
||||
* esp_efuse_batch_write_commit(); // the burn will be skipped here, it will be done in the last commit().
|
||||
*
|
||||
* ...
|
||||
*
|
||||
* // Write all of these fields to the efuse registers
|
||||
* esp_efuse_batch_write_commit();
|
||||
* esp_efuse_read_...(ESP_EFUSE_1); // this function returns ESP_EFUSE_1 == 3.
|
||||
*
|
||||
* \endcode
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
*/
|
||||
esp_err_t esp_efuse_batch_write_begin(void);
|
||||
|
||||
/**
|
||||
* @brief Reset the batch mode of writing fields.
|
||||
*
|
||||
* It will reset the batch writing mode and any written changes.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_STATE: Tha batch mode was not set.
|
||||
*/
|
||||
esp_err_t esp_efuse_batch_write_cancel(void);
|
||||
|
||||
/**
|
||||
* @brief Writes all prepared data for the batch mode.
|
||||
*
|
||||
* Must be called to ensure changes are written to the efuse registers.
|
||||
* After this the batch writing mode will be reset.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_STATE: The deferred writing mode was not set.
|
||||
*/
|
||||
esp_err_t esp_efuse_batch_write_commit(void);
|
||||
|
||||
/**
|
||||
* @brief Checks that the given block is empty.
|
||||
*
|
||||
* @return
|
||||
* - True: The block is empty.
|
||||
* - False: The block is not empty or was an error.
|
||||
*/
|
||||
bool esp_efuse_block_is_empty(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns a read protection for the key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return True: The key block is read protected
|
||||
* False: The key block is readable.
|
||||
*/
|
||||
bool esp_efuse_get_key_dis_read(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Sets a read protection for the key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_key_dis_read(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns a write protection for the key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return True: The key block is write protected
|
||||
* False: The key block is writeable.
|
||||
*/
|
||||
bool esp_efuse_get_key_dis_write(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Sets a write protection for the key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_key_dis_write(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns true if the key block is unused, false otherwise.
|
||||
*
|
||||
* An unused key block is all zero content, not read or write protected,
|
||||
* and has purpose 0 (ESP_EFUSE_KEY_PURPOSE_USER)
|
||||
*
|
||||
* @param block key block to check.
|
||||
*
|
||||
* @return
|
||||
* - True if key block is unused,
|
||||
* - False if key block is used or the specified block index is not a key block.
|
||||
*/
|
||||
bool esp_efuse_key_block_unused(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Find a key block with the particular purpose set.
|
||||
*
|
||||
* @param[in] purpose Purpose to search for.
|
||||
* @param[out] block Pointer in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX which will be set to the key block if found.
|
||||
* Can be NULL, if only need to test the key block exists.
|
||||
*
|
||||
* @return
|
||||
* - True: If found,
|
||||
* - False: If not found (value at block pointer is unchanged).
|
||||
*/
|
||||
bool esp_efuse_find_purpose(esp_efuse_purpose_t purpose, esp_efuse_block_t *block);
|
||||
|
||||
/**
|
||||
* @brief Returns a write protection of the key purpose field for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @note For ESP32: no keypurpose, it returns always True.
|
||||
*
|
||||
* @return True: The key purpose is write protected.
|
||||
* False: The key purpose is writeable.
|
||||
*/
|
||||
bool esp_efuse_get_keypurpose_dis_write(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns the current purpose set for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return
|
||||
* - Value: If Successful, it returns the value of the purpose related to the given key block.
|
||||
* - ESP_EFUSE_KEY_PURPOSE_MAX: Otherwise.
|
||||
*/
|
||||
esp_efuse_purpose_t esp_efuse_get_key_purpose(esp_efuse_block_t block);
|
||||
|
||||
|
||||
#ifndef CONFIG_IDF_TARGET_ESP32
|
||||
/**
|
||||
* @brief Returns a pointer to a key purpose for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* To get the value of this field use esp_efuse_read_field_blob() or esp_efuse_get_key_purpose().
|
||||
*
|
||||
* @return Pointer: If Successful returns a pointer to the corresponding efuse field otherwise NULL.
|
||||
*/
|
||||
const esp_efuse_desc_t **esp_efuse_get_purpose_field(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Returns a pointer to a key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return Pointer: If Successful returns a pointer to the corresponding efuse field otherwise NULL.
|
||||
*/
|
||||
const esp_efuse_desc_t** esp_efuse_get_key(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Sets a key purpose for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
* @param[in] purpose Key purpose.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_key_purpose(esp_efuse_block_t block, esp_efuse_purpose_t purpose);
|
||||
|
||||
/**
|
||||
* @brief Sets a write protection of the key purpose field for an efuse key block.
|
||||
*
|
||||
* @param[in] block A key block in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_keypurpose_dis_write(esp_efuse_block_t block);
|
||||
|
||||
/**
|
||||
* @brief Search for an unused key block and return the first one found.
|
||||
*
|
||||
* See esp_efuse_key_block_unused for a description of an unused key block.
|
||||
*
|
||||
* @return First unused key block, or EFUSE_BLK_KEY_MAX if no unused key block is found.
|
||||
*/
|
||||
esp_efuse_block_t esp_efuse_find_unused_key_block(void);
|
||||
|
||||
/**
|
||||
* @brief Return the number of unused efuse key blocks in the range EFUSE_BLK_KEY0..EFUSE_BLK_KEY_MAX
|
||||
*/
|
||||
unsigned esp_efuse_count_unused_key_blocks(void);
|
||||
|
||||
/**
|
||||
* @brief Returns the status of the Secure Boot public key digest revocation bit.
|
||||
*
|
||||
* @param[in] num_digest The number of digest in range 0..2
|
||||
*
|
||||
* @return
|
||||
* - True: If key digest is revoked,
|
||||
* - False; If key digest is not revoked.
|
||||
*/
|
||||
bool esp_efuse_get_digest_revoke(unsigned num_digest);
|
||||
|
||||
/**
|
||||
* @brief Sets the Secure Boot public key digest revocation bit.
|
||||
*
|
||||
* @param[in] num_digest The number of digest in range 0..2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_digest_revoke(unsigned num_digest);
|
||||
|
||||
/**
|
||||
* @brief Returns a write protection of the Secure Boot public key digest revocation bit.
|
||||
*
|
||||
* @param[in] num_digest The number of digest in range 0..2
|
||||
*
|
||||
* @return True: The revocation bit is write protected.
|
||||
* False: The revocation bit is writeable.
|
||||
*/
|
||||
bool esp_efuse_get_write_protect_of_digest_revoke(unsigned num_digest);
|
||||
|
||||
/**
|
||||
* @brief Sets a write protection of the Secure Boot public key digest revocation bit.
|
||||
*
|
||||
* @param[in] num_digest The number of digest in range 0..2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_set_write_protect_of_digest_revoke(unsigned num_digest);
|
||||
|
||||
#endif // not CONFIG_IDF_TARGET_ESP32
|
||||
|
||||
/**
|
||||
* @brief Program a block of key data to an efuse block
|
||||
*
|
||||
* The burn of a key, protection bits, and a purpose happens in batch mode.
|
||||
*
|
||||
* @param[in] block Block to read purpose for. Must be in range EFUSE_BLK_KEY0 to EFUSE_BLK_KEY_MAX. Key block must be unused (esp_efuse_key_block_unused).
|
||||
* @param[in] purpose Purpose to set for this key. Purpose must be already unset.
|
||||
* @param[in] key Pointer to data to write.
|
||||
* @param[in] key_size_bytes Bytes length of data to write.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_INVALID_STATE: Error in efuses state, unused block not found.
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_write_key(esp_efuse_block_t block, esp_efuse_purpose_t purpose, const void *key, size_t key_size_bytes);
|
||||
|
||||
/**
|
||||
* @brief Program keys to unused efuse blocks
|
||||
*
|
||||
* The burn of keys, protection bits, and purposes happens in batch mode.
|
||||
*
|
||||
* @param[in] purposes Array of purposes (purpose[number_of_keys]).
|
||||
* @param[in] keys Array of keys (uint8_t keys[number_of_keys][32]). Each key is 32 bytes long.
|
||||
* @param[in] number_of_keys The number of keys to write (up to 6 keys).
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_ERR_INVALID_ARG: Error in the passed arguments.
|
||||
* - ESP_ERR_INVALID_STATE: Error in efuses state, unused block not found.
|
||||
* - ESP_ERR_NOT_ENOUGH_UNUSED_KEY_BLOCKS: Error not enough unused key blocks available
|
||||
* - ESP_ERR_EFUSE_REPEATED_PROG: Error repeated programming of programmed bits is strictly forbidden.
|
||||
* - ESP_ERR_CODING: Error range of data does not match the coding scheme.
|
||||
*/
|
||||
esp_err_t esp_efuse_write_keys(const esp_efuse_purpose_t purposes[], uint8_t keys[][32], unsigned number_of_keys);
|
||||
|
||||
|
||||
#if CONFIG_ESP32_REV_MIN_3 || !CONFIG_IDF_TARGET_ESP32
|
||||
/**
|
||||
* @brief Read key digests from efuse. Any revoked/missing digests will be marked as NULL
|
||||
*
|
||||
* @param[out] trusted_keys The number of digest in range 0..2
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successful.
|
||||
* - ESP_FAIL: If trusted_keys is NULL or there is no valid digest.
|
||||
*/
|
||||
esp_err_t esp_secure_boot_read_key_digests(ets_secure_boot_key_digests_t *trusted_keys);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user