esp_efuse_fields.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "esp_efuse.h"
  7. #include "esp_efuse_utility.h"
  8. #include "esp_efuse_table.h"
  9. #include "stdlib.h"
  10. #include "esp_types.h"
  11. #include "assert.h"
  12. #include "esp_err.h"
  13. #include "esp_log.h"
  14. #include "soc/efuse_periph.h"
  15. #include "hal/efuse_hal.h"
  16. #include "bootloader_random.h"
  17. #include "sys/param.h"
  18. #include "soc/syscon_reg.h"
  19. const static char *TAG = "efuse";
  20. // Contains functions that provide access to efuse fields which are often used in IDF.
  21. // Returns chip package from efuse
  22. uint32_t esp_efuse_get_pkg_ver(void)
  23. {
  24. uint32_t pkg_ver = 0;
  25. esp_efuse_read_field_blob(ESP_EFUSE_CHIP_VER_PKG, &pkg_ver, 4);
  26. return pkg_ver;
  27. }
  28. // Disable BASIC ROM Console via efuse
  29. void esp_efuse_disable_basic_rom_console(void)
  30. {
  31. if (!esp_efuse_read_field_bit(ESP_EFUSE_CONSOLE_DEBUG_DISABLE)) {
  32. esp_efuse_write_field_cnt(ESP_EFUSE_CONSOLE_DEBUG_DISABLE, 1);
  33. ESP_LOGI(TAG, "Disable BASIC ROM Console fallback via efuse...");
  34. }
  35. }
  36. esp_err_t esp_efuse_disable_rom_download_mode(void)
  37. {
  38. #ifndef CONFIG_ESP32_REV_MIN_3
  39. /* Check if we support this revision at all */
  40. if (efuse_hal_get_major_chip_version() < 3) {
  41. return ESP_ERR_NOT_SUPPORTED;
  42. }
  43. #endif
  44. if (esp_efuse_read_field_bit(ESP_EFUSE_UART_DOWNLOAD_DIS)) {
  45. return ESP_OK;
  46. }
  47. /* WR_DIS_FLASH_CRYPT_CNT also covers UART_DOWNLOAD_DIS on ESP32 */
  48. if(esp_efuse_read_field_bit(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT)) {
  49. return ESP_ERR_INVALID_STATE;
  50. }
  51. return esp_efuse_write_field_bit(ESP_EFUSE_UART_DOWNLOAD_DIS);
  52. }
  53. esp_err_t esp_efuse_set_rom_log_scheme(esp_efuse_rom_log_scheme_t log_scheme)
  54. {
  55. return ESP_ERR_NOT_SUPPORTED;
  56. }