efuse_hal.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "sdkconfig.h"
  7. #include <sys/param.h>
  8. #include "soc/soc_caps.h"
  9. #include "hal/efuse_ll.h"
  10. #include "hal/assert.h"
  11. #include "hal/efuse_hal.h"
  12. #include "esp_attr.h"
  13. void efuse_hal_get_mac(uint8_t *mac)
  14. {
  15. *((uint32_t*)&mac[0]) = efuse_ll_get_mac0();
  16. *((uint16_t*)&mac[4]) = (uint16_t) efuse_ll_get_mac1();
  17. }
  18. IRAM_ATTR uint32_t efuse_hal_chip_revision(void)
  19. {
  20. return efuse_hal_get_major_chip_version() * 100 + efuse_hal_get_minor_chip_version();
  21. }
  22. IRAM_ATTR bool efuse_hal_get_disable_wafer_version_major(void)
  23. {
  24. return efuse_ll_get_disable_wafer_version_major();
  25. }
  26. IRAM_ATTR bool efuse_hal_flash_encryption_enabled(void)
  27. {
  28. uint32_t flash_crypt_cnt = efuse_ll_get_flash_crypt_cnt();
  29. bool enabled = false;
  30. while (flash_crypt_cnt) {
  31. if (flash_crypt_cnt & 1) {
  32. enabled = !enabled;
  33. }
  34. flash_crypt_cnt >>= 1;
  35. }
  36. return enabled;
  37. }
  38. #if SOC_ECDSA_SUPPORTED
  39. void efuse_hal_set_ecdsa_key(int efuse_blk)
  40. {
  41. efuse_ll_set_ecdsa_key_blk(efuse_blk);
  42. efuse_ll_rs_bypass_update();
  43. efuse_hal_read();
  44. }
  45. #endif