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