2021-05-31 00:43:23 -04:00
|
|
|
/*
|
2021-12-22 09:18:43 -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"
|
2022-03-17 09:58:15 -04:00
|
|
|
#include "soc/chip_revision.h"
|
2021-12-22 09:18:43 -05:00
|
|
|
#include "hal/efuse_hal.h"
|
2019-06-18 07:34:05 -04:00
|
|
|
#include "sys/param.h"
|
2021-09-16 08:57:57 -04:00
|
|
|
#include "soc/syscon_reg.h"
|
2019-06-18 07:34:05 -04:00
|
|
|
|
|
|
|
const static char *TAG = "efuse";
|
|
|
|
|
|
|
|
// 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-08-05 02:56:01 -04:00
|
|
|
esp_efuse_read_field_blob(ESP_EFUSE_CHIP_VER_PKG, &pkg_ver, 4);
|
2019-06-18 07:34:05 -04:00
|
|
|
return pkg_ver;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Disable BASIC ROM Console via efuse
|
|
|
|
void esp_efuse_disable_basic_rom_console(void)
|
|
|
|
{
|
2020-04-25 02:36:53 -04:00
|
|
|
if (!esp_efuse_read_field_bit(ESP_EFUSE_CONSOLE_DEBUG_DISABLE)) {
|
2019-06-18 07:34:05 -04:00
|
|
|
esp_efuse_write_field_cnt(ESP_EFUSE_CONSOLE_DEBUG_DISABLE, 1);
|
2020-06-01 08:33:23 -04:00
|
|
|
ESP_LOGI(TAG, "Disable BASIC ROM Console fallback via efuse...");
|
2019-06-18 07:34:05 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-25 02:36:53 -04:00
|
|
|
esp_err_t esp_efuse_disable_rom_download_mode(void)
|
|
|
|
{
|
2022-03-17 09:58:15 -04:00
|
|
|
#if CONFIG_ESP32_REV_MIN_FULL < 300
|
2020-04-25 02:36:53 -04:00
|
|
|
/* Check if we support this revision at all */
|
2022-03-17 09:58:15 -04:00
|
|
|
if (!ESP_CHIP_REV_ABOVE(efuse_hal_chip_revision(), 300)) {
|
2020-04-25 02:36:53 -04:00
|
|
|
return ESP_ERR_NOT_SUPPORTED;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (esp_efuse_read_field_bit(ESP_EFUSE_UART_DOWNLOAD_DIS)) {
|
|
|
|
return ESP_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* WR_DIS_FLASH_CRYPT_CNT also covers UART_DOWNLOAD_DIS on ESP32 */
|
|
|
|
if(esp_efuse_read_field_bit(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT)) {
|
|
|
|
return ESP_ERR_INVALID_STATE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return esp_efuse_write_field_bit(ESP_EFUSE_UART_DOWNLOAD_DIS);
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
return ESP_ERR_NOT_SUPPORTED;
|
|
|
|
}
|