2021-05-31 00:43:23 -04:00
|
|
|
/*
|
2022-02-10 01:11:54 -05:00
|
|
|
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
|
2021-05-31 00:43:23 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2019-06-18 07:34:05 -04:00
|
|
|
|
|
|
|
#include "esp_efuse.h"
|
|
|
|
#include "esp_efuse_utility.h"
|
|
|
|
#include "esp_efuse_table.h"
|
|
|
|
#include "stdlib.h"
|
|
|
|
#include "esp_types.h"
|
|
|
|
#include "assert.h"
|
|
|
|
#include "esp_err.h"
|
|
|
|
#include "esp_log.h"
|
|
|
|
#include "soc/efuse_periph.h"
|
|
|
|
#include "bootloader_random.h"
|
|
|
|
#include "sys/param.h"
|
|
|
|
|
2021-06-16 19:21:36 -04:00
|
|
|
static __attribute__((unused)) const char *TAG = "efuse";
|
2019-06-18 07:34:05 -04:00
|
|
|
|
|
|
|
// Contains functions that provide access to efuse fields which are often used in IDF.
|
|
|
|
|
|
|
|
// Returns chip package from efuse
|
|
|
|
uint32_t esp_efuse_get_pkg_ver(void)
|
|
|
|
{
|
|
|
|
uint32_t pkg_ver = 0;
|
2020-06-08 10:14:21 -04:00
|
|
|
esp_efuse_read_field_blob(ESP_EFUSE_PKG_VERSION, &pkg_ver, 4);
|
2019-06-18 07:34:05 -04:00
|
|
|
return pkg_ver;
|
|
|
|
}
|
|
|
|
|
2020-04-25 02:36:53 -04:00
|
|
|
esp_err_t esp_efuse_disable_rom_download_mode(void)
|
|
|
|
{
|
|
|
|
return esp_efuse_write_field_bit(ESP_EFUSE_DIS_DOWNLOAD_MODE);
|
|
|
|
}
|
|
|
|
|
2021-01-26 08:07:22 -05:00
|
|
|
esp_err_t esp_efuse_set_rom_log_scheme(esp_efuse_rom_log_scheme_t log_scheme)
|
|
|
|
{
|
|
|
|
int cur_log_scheme = 0;
|
|
|
|
esp_efuse_read_field_blob(ESP_EFUSE_UART_PRINT_CONTROL, &cur_log_scheme, 2);
|
|
|
|
if (!cur_log_scheme) { // not burned yet
|
|
|
|
return esp_efuse_write_field_blob(ESP_EFUSE_UART_PRINT_CONTROL, &log_scheme, 2);
|
|
|
|
} else {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-25 02:36:53 -04:00
|
|
|
esp_err_t esp_efuse_enable_rom_secure_download_mode(void)
|
|
|
|
{
|
|
|
|
if (esp_efuse_read_field_bit(ESP_EFUSE_DIS_DOWNLOAD_MODE)) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
return esp_efuse_write_field_bit(ESP_EFUSE_ENABLE_SECURITY_DOWNLOAD);
|
|
|
|
}
|