esp_efuse_table.c 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421
  1. /*
  2. * SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include "sdkconfig.h"
  7. #include "esp_efuse.h"
  8. #include <assert.h>
  9. #include "esp_efuse_table.h"
  10. // md5_digest_table 6256f9b7c6783e0b651bf52b5b162aa8
  11. // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY.
  12. // If you want to change some fields, you need to change esp_efuse_table.csv file
  13. // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file.
  14. // To show efuse_table run the command 'show_efuse_table'.
  15. #define MAX_BLK_LEN CONFIG_EFUSE_MAX_BLK_LEN
  16. // The last free bit in the block is counted over the entire file.
  17. #define LAST_FREE_BIT_BLK1 MAX_BLK_LEN
  18. #define LAST_FREE_BIT_BLK2 MAX_BLK_LEN
  19. #define LAST_FREE_BIT_BLK3 192
  20. _Static_assert(LAST_FREE_BIT_BLK1 <= MAX_BLK_LEN, "The eFuse table does not match the coding scheme. Edit the table and restart the efuse_common_table or efuse_custom_table command to regenerate the new files.");
  21. _Static_assert(LAST_FREE_BIT_BLK2 <= MAX_BLK_LEN, "The eFuse table does not match the coding scheme. Edit the table and restart the efuse_common_table or efuse_custom_table command to regenerate the new files.");
  22. _Static_assert(LAST_FREE_BIT_BLK3 <= MAX_BLK_LEN, "The eFuse table does not match the coding scheme. Edit the table and restart the efuse_common_table or efuse_custom_table command to regenerate the new files.");
  23. static const esp_efuse_desc_t MAC_FACTORY[] = {
  24. {EFUSE_BLK0, 72, 8}, // Factory MAC addr [0],
  25. {EFUSE_BLK0, 64, 8}, // Factory MAC addr [1],
  26. {EFUSE_BLK0, 56, 8}, // Factory MAC addr [2],
  27. {EFUSE_BLK0, 48, 8}, // Factory MAC addr [3],
  28. {EFUSE_BLK0, 40, 8}, // Factory MAC addr [4],
  29. {EFUSE_BLK0, 32, 8}, // Factory MAC addr [5],
  30. };
  31. static const esp_efuse_desc_t MAC_FACTORY_CRC[] = {
  32. {EFUSE_BLK0, 80, 8}, // CRC8 for factory MAC address,
  33. };
  34. static const esp_efuse_desc_t MAC_CUSTOM_CRC[] = {
  35. {EFUSE_BLK3, 0, 8}, // CRC8 for custom MAC address.,
  36. };
  37. static const esp_efuse_desc_t MAC_CUSTOM[] = {
  38. {EFUSE_BLK3, 8, 48}, // Custom MAC,
  39. };
  40. static const esp_efuse_desc_t MAC_CUSTOM_VER[] = {
  41. {EFUSE_BLK3, 184, 8}, // Custom MAC version,
  42. };
  43. static const esp_efuse_desc_t SECURE_BOOT_KEY[] = {
  44. {EFUSE_BLK2, 0, MAX_BLK_LEN}, // Security boot. Key. (length = "None" - 256. "3/4" - 192. "REPEAT" - 128),
  45. };
  46. static const esp_efuse_desc_t ABS_DONE_0[] = {
  47. {EFUSE_BLK0, 196, 1}, // Secure boot V1 is enabled for bootloader image. EFUSE_RD_ABS_DONE_0,
  48. };
  49. static const esp_efuse_desc_t ABS_DONE_1[] = {
  50. {EFUSE_BLK0, 197, 1}, // Secure boot V2 is enabled for bootloader image. EFUSE_RD_ABS_DONE_1,
  51. };
  52. static const esp_efuse_desc_t ENCRYPT_FLASH_KEY[] = {
  53. {EFUSE_BLK1, 0, MAX_BLK_LEN}, // Flash encrypt. Key. (length = "None" - 256. "3/4" - 192. "REPEAT" - 128),
  54. };
  55. static const esp_efuse_desc_t ENCRYPT_CONFIG[] = {
  56. {EFUSE_BLK0, 188, 4}, // Flash encrypt. EFUSE_FLASH_CRYPT_CONFIG_M,
  57. };
  58. static const esp_efuse_desc_t DISABLE_DL_ENCRYPT[] = {
  59. {EFUSE_BLK0, 199, 1}, // Flash encrypt. Disable UART bootloader encryption. EFUSE_DISABLE_DL_ENCRYPT.,
  60. };
  61. static const esp_efuse_desc_t DISABLE_DL_DECRYPT[] = {
  62. {EFUSE_BLK0, 200, 1}, // Flash encrypt. Disable UART bootloader decryption. EFUSE_DISABLE_DL_DECRYPT.,
  63. };
  64. static const esp_efuse_desc_t DISABLE_DL_CACHE[] = {
  65. {EFUSE_BLK0, 201, 1}, // Flash encrypt. Disable UART bootloader MMU cache. EFUSE_DISABLE_DL_CACHE.,
  66. };
  67. static const esp_efuse_desc_t FLASH_CRYPT_CNT[] = {
  68. {EFUSE_BLK0, 20, 7}, // Flash encrypt. Flash encryption is enabled if this field has an odd number of bits set. EFUSE_FLASH_CRYPT_CNT.,
  69. };
  70. static const esp_efuse_desc_t DISABLE_JTAG[] = {
  71. {EFUSE_BLK0, 198, 1}, // Disable JTAG. EFUSE_RD_DISABLE_JTAG.,
  72. };
  73. static const esp_efuse_desc_t CONSOLE_DEBUG_DISABLE[] = {
  74. {EFUSE_BLK0, 194, 1}, // Disable ROM BASIC interpreter fallback. EFUSE_RD_CONSOLE_DEBUG_DISABLE.,
  75. };
  76. static const esp_efuse_desc_t UART_DOWNLOAD_DIS[] = {
  77. {EFUSE_BLK0, 27, 1}, // Disable UART download mode. Valid for ESP32 V3 and newer,
  78. };
  79. static const esp_efuse_desc_t WR_DIS_EFUSE_RD_DISABLE[] = {
  80. {EFUSE_BLK0, 0, 1}, // Write protection for EFUSE_RD_DISABLE,
  81. };
  82. static const esp_efuse_desc_t WR_DIS_FLASH_CRYPT_CNT[] = {
  83. {EFUSE_BLK0, 2, 1}, // Flash encrypt. Write protection FLASH_CRYPT_CNT,
  84. };
  85. static const esp_efuse_desc_t WR_DIS_BLK1[] = {
  86. {EFUSE_BLK0, 7, 1}, // Flash encrypt. Write protection encryption key. EFUSE_WR_DIS_BLK1,
  87. };
  88. static const esp_efuse_desc_t WR_DIS_BLK2[] = {
  89. {EFUSE_BLK0, 8, 1}, // Security boot. Write protection security key. EFUSE_WR_DIS_BLK2,
  90. };
  91. static const esp_efuse_desc_t WR_DIS_BLK3[] = {
  92. {EFUSE_BLK0, 9, 1}, // Write protection for EFUSE_BLK3. EFUSE_WR_DIS_BLK3,
  93. };
  94. static const esp_efuse_desc_t RD_DIS_BLK1[] = {
  95. {EFUSE_BLK0, 16, 1}, // Flash encrypt. efuse_key_read_protected. EFUSE_RD_DIS_BLK1,
  96. };
  97. static const esp_efuse_desc_t RD_DIS_BLK2[] = {
  98. {EFUSE_BLK0, 17, 1}, // Security boot. efuse_key_read_protected. EFUSE_RD_DIS_BLK2,
  99. };
  100. static const esp_efuse_desc_t RD_DIS_BLK3[] = {
  101. {EFUSE_BLK0, 18, 1}, // Read protection for EFUSE_BLK3. EFUSE_RD_DIS_BLK3,
  102. };
  103. static const esp_efuse_desc_t CHIP_VER_DIS_APP_CPU[] = {
  104. {EFUSE_BLK0, 96, 1}, // EFUSE_RD_CHIP_VER_DIS_APP_CPU,
  105. };
  106. static const esp_efuse_desc_t CHIP_VER_DIS_BT[] = {
  107. {EFUSE_BLK0, 97, 1}, // EFUSE_RD_CHIP_VER_DIS_BT,
  108. };
  109. static const esp_efuse_desc_t CHIP_VER_PKG[] = {
  110. {EFUSE_BLK0, 105, 3}, // EFUSE_RD_CHIP_VER_PKG least significant bits,
  111. {EFUSE_BLK0, 98, 1}, // EFUSE_RD_CHIP_VER_PKG_4BIT most significant bit,
  112. };
  113. static const esp_efuse_desc_t CHIP_CPU_FREQ_LOW[] = {
  114. {EFUSE_BLK0, 108, 1}, // EFUSE_RD_CHIP_CPU_FREQ_LOW,
  115. };
  116. static const esp_efuse_desc_t CHIP_CPU_FREQ_RATED[] = {
  117. {EFUSE_BLK0, 109, 1}, // EFUSE_RD_CHIP_CPU_FREQ_RATED,
  118. };
  119. static const esp_efuse_desc_t CHIP_VER_REV1[] = {
  120. {EFUSE_BLK0, 111, 1}, // EFUSE_RD_CHIP_VER_REV1,
  121. };
  122. static const esp_efuse_desc_t CHIP_VER_REV2[] = {
  123. {EFUSE_BLK0, 180, 1}, // EFUSE_RD_CHIP_VER_REV2,
  124. };
  125. static const esp_efuse_desc_t WAFER_VERSION_MINOR[] = {
  126. {EFUSE_BLK0, 184, 2}, // WAFER_VERSION_MINOR,
  127. };
  128. static const esp_efuse_desc_t XPD_SDIO_REG[] = {
  129. {EFUSE_BLK0, 142, 1}, // EFUSE_RD_XPD_SDIO_REG,
  130. };
  131. static const esp_efuse_desc_t SDIO_TIEH[] = {
  132. {EFUSE_BLK0, 143, 1}, // EFUSE_RD_SDIO_TIEH,
  133. };
  134. static const esp_efuse_desc_t SDIO_FORCE[] = {
  135. {EFUSE_BLK0, 144, 1}, // EFUSE_RD_SDIO_FORCE,
  136. };
  137. static const esp_efuse_desc_t ADC_VREF_AND_SDIO_DREF[] = {
  138. {EFUSE_BLK0, 136, 6}, // EFUSE_RD_ADC_VREF[0..4] or ( SDIO_DREFH[0 1],
  139. };
  140. static const esp_efuse_desc_t ADC1_TP_LOW[] = {
  141. {EFUSE_BLK3, 96, 7}, // TP_REG EFUSE_RD_ADC1_TP_LOW,
  142. };
  143. static const esp_efuse_desc_t ADC2_TP_LOW[] = {
  144. {EFUSE_BLK3, 112, 7}, // TP_REG EFUSE_RD_ADC2_TP_LOW,
  145. };
  146. static const esp_efuse_desc_t ADC1_TP_HIGH[] = {
  147. {EFUSE_BLK3, 103, 9}, // TP_REG EFUSE_RD_ADC1_TP_HIGH,
  148. };
  149. static const esp_efuse_desc_t ADC2_TP_HIGH[] = {
  150. {EFUSE_BLK3, 119, 9}, // TP_REG EFUSE_RD_ADC2_TP_HIGH,
  151. };
  152. static const esp_efuse_desc_t SECURE_VERSION[] = {
  153. {EFUSE_BLK3, 128, 32}, // Secure version for anti-rollback,
  154. };
  155. const esp_efuse_desc_t* ESP_EFUSE_MAC_FACTORY[] = {
  156. &MAC_FACTORY[0], // Factory MAC addr [0]
  157. &MAC_FACTORY[1], // Factory MAC addr [1]
  158. &MAC_FACTORY[2], // Factory MAC addr [2]
  159. &MAC_FACTORY[3], // Factory MAC addr [3]
  160. &MAC_FACTORY[4], // Factory MAC addr [4]
  161. &MAC_FACTORY[5], // Factory MAC addr [5]
  162. NULL
  163. };
  164. const esp_efuse_desc_t* ESP_EFUSE_MAC_FACTORY_CRC[] = {
  165. &MAC_FACTORY_CRC[0], // CRC8 for factory MAC address
  166. NULL
  167. };
  168. const esp_efuse_desc_t* ESP_EFUSE_MAC_CUSTOM_CRC[] = {
  169. &MAC_CUSTOM_CRC[0], // CRC8 for custom MAC address.
  170. NULL
  171. };
  172. const esp_efuse_desc_t* ESP_EFUSE_MAC_CUSTOM[] = {
  173. &MAC_CUSTOM[0], // Custom MAC
  174. NULL
  175. };
  176. const esp_efuse_desc_t* ESP_EFUSE_MAC_CUSTOM_VER[] = {
  177. &MAC_CUSTOM_VER[0], // Custom MAC version
  178. NULL
  179. };
  180. const esp_efuse_desc_t* ESP_EFUSE_SECURE_BOOT_KEY[] = {
  181. &SECURE_BOOT_KEY[0], // Security boot. Key. (length = "None" - 256. "3/4" - 192. "REPEAT" - 128)
  182. NULL
  183. };
  184. const esp_efuse_desc_t* ESP_EFUSE_ABS_DONE_0[] = {
  185. &ABS_DONE_0[0], // Secure boot V1 is enabled for bootloader image. EFUSE_RD_ABS_DONE_0
  186. NULL
  187. };
  188. const esp_efuse_desc_t* ESP_EFUSE_ABS_DONE_1[] = {
  189. &ABS_DONE_1[0], // Secure boot V2 is enabled for bootloader image. EFUSE_RD_ABS_DONE_1
  190. NULL
  191. };
  192. const esp_efuse_desc_t* ESP_EFUSE_ENCRYPT_FLASH_KEY[] = {
  193. &ENCRYPT_FLASH_KEY[0], // Flash encrypt. Key. (length = "None" - 256. "3/4" - 192. "REPEAT" - 128)
  194. NULL
  195. };
  196. const esp_efuse_desc_t* ESP_EFUSE_ENCRYPT_CONFIG[] = {
  197. &ENCRYPT_CONFIG[0], // Flash encrypt. EFUSE_FLASH_CRYPT_CONFIG_M
  198. NULL
  199. };
  200. const esp_efuse_desc_t* ESP_EFUSE_DISABLE_DL_ENCRYPT[] = {
  201. &DISABLE_DL_ENCRYPT[0], // Flash encrypt. Disable UART bootloader encryption. EFUSE_DISABLE_DL_ENCRYPT.
  202. NULL
  203. };
  204. const esp_efuse_desc_t* ESP_EFUSE_DISABLE_DL_DECRYPT[] = {
  205. &DISABLE_DL_DECRYPT[0], // Flash encrypt. Disable UART bootloader decryption. EFUSE_DISABLE_DL_DECRYPT.
  206. NULL
  207. };
  208. const esp_efuse_desc_t* ESP_EFUSE_DISABLE_DL_CACHE[] = {
  209. &DISABLE_DL_CACHE[0], // Flash encrypt. Disable UART bootloader MMU cache. EFUSE_DISABLE_DL_CACHE.
  210. NULL
  211. };
  212. const esp_efuse_desc_t* ESP_EFUSE_FLASH_CRYPT_CNT[] = {
  213. &FLASH_CRYPT_CNT[0], // Flash encrypt. Flash encryption is enabled if this field has an odd number of bits set. EFUSE_FLASH_CRYPT_CNT.
  214. NULL
  215. };
  216. const esp_efuse_desc_t* ESP_EFUSE_DISABLE_JTAG[] = {
  217. &DISABLE_JTAG[0], // Disable JTAG. EFUSE_RD_DISABLE_JTAG.
  218. NULL
  219. };
  220. const esp_efuse_desc_t* ESP_EFUSE_CONSOLE_DEBUG_DISABLE[] = {
  221. &CONSOLE_DEBUG_DISABLE[0], // Disable ROM BASIC interpreter fallback. EFUSE_RD_CONSOLE_DEBUG_DISABLE.
  222. NULL
  223. };
  224. const esp_efuse_desc_t* ESP_EFUSE_UART_DOWNLOAD_DIS[] = {
  225. &UART_DOWNLOAD_DIS[0], // Disable UART download mode. Valid for ESP32 V3 and newer
  226. NULL
  227. };
  228. const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_EFUSE_RD_DISABLE[] = {
  229. &WR_DIS_EFUSE_RD_DISABLE[0], // Write protection for EFUSE_RD_DISABLE
  230. NULL
  231. };
  232. const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT[] = {
  233. &WR_DIS_FLASH_CRYPT_CNT[0], // Flash encrypt. Write protection FLASH_CRYPT_CNT
  234. NULL
  235. };
  236. const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLK1[] = {
  237. &WR_DIS_BLK1[0], // Flash encrypt. Write protection encryption key. EFUSE_WR_DIS_BLK1
  238. NULL
  239. };
  240. const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLK2[] = {
  241. &WR_DIS_BLK2[0], // Security boot. Write protection security key. EFUSE_WR_DIS_BLK2
  242. NULL
  243. };
  244. const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLK3[] = {
  245. &WR_DIS_BLK3[0], // Write protection for EFUSE_BLK3. EFUSE_WR_DIS_BLK3
  246. NULL
  247. };
  248. const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_BLK1[] = {
  249. &RD_DIS_BLK1[0], // Flash encrypt. efuse_key_read_protected. EFUSE_RD_DIS_BLK1
  250. NULL
  251. };
  252. const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_BLK2[] = {
  253. &RD_DIS_BLK2[0], // Security boot. efuse_key_read_protected. EFUSE_RD_DIS_BLK2
  254. NULL
  255. };
  256. const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_BLK3[] = {
  257. &RD_DIS_BLK3[0], // Read protection for EFUSE_BLK3. EFUSE_RD_DIS_BLK3
  258. NULL
  259. };
  260. const esp_efuse_desc_t* ESP_EFUSE_CHIP_VER_DIS_APP_CPU[] = {
  261. &CHIP_VER_DIS_APP_CPU[0], // EFUSE_RD_CHIP_VER_DIS_APP_CPU
  262. NULL
  263. };
  264. const esp_efuse_desc_t* ESP_EFUSE_CHIP_VER_DIS_BT[] = {
  265. &CHIP_VER_DIS_BT[0], // EFUSE_RD_CHIP_VER_DIS_BT
  266. NULL
  267. };
  268. const esp_efuse_desc_t* ESP_EFUSE_CHIP_VER_PKG[] = {
  269. &CHIP_VER_PKG[0], // EFUSE_RD_CHIP_VER_PKG least significant bits
  270. &CHIP_VER_PKG[1], // EFUSE_RD_CHIP_VER_PKG_4BIT most significant bit
  271. NULL
  272. };
  273. const esp_efuse_desc_t* ESP_EFUSE_CHIP_CPU_FREQ_LOW[] = {
  274. &CHIP_CPU_FREQ_LOW[0], // EFUSE_RD_CHIP_CPU_FREQ_LOW
  275. NULL
  276. };
  277. const esp_efuse_desc_t* ESP_EFUSE_CHIP_CPU_FREQ_RATED[] = {
  278. &CHIP_CPU_FREQ_RATED[0], // EFUSE_RD_CHIP_CPU_FREQ_RATED
  279. NULL
  280. };
  281. const esp_efuse_desc_t* ESP_EFUSE_CHIP_VER_REV1[] = {
  282. &CHIP_VER_REV1[0], // EFUSE_RD_CHIP_VER_REV1
  283. NULL
  284. };
  285. const esp_efuse_desc_t* ESP_EFUSE_CHIP_VER_REV2[] = {
  286. &CHIP_VER_REV2[0], // EFUSE_RD_CHIP_VER_REV2
  287. NULL
  288. };
  289. const esp_efuse_desc_t* ESP_EFUSE_WAFER_VERSION_MINOR[] = {
  290. &WAFER_VERSION_MINOR[0], // WAFER_VERSION_MINOR
  291. NULL
  292. };
  293. const esp_efuse_desc_t* ESP_EFUSE_XPD_SDIO_REG[] = {
  294. &XPD_SDIO_REG[0], // EFUSE_RD_XPD_SDIO_REG
  295. NULL
  296. };
  297. const esp_efuse_desc_t* ESP_EFUSE_SDIO_TIEH[] = {
  298. &SDIO_TIEH[0], // EFUSE_RD_SDIO_TIEH
  299. NULL
  300. };
  301. const esp_efuse_desc_t* ESP_EFUSE_SDIO_FORCE[] = {
  302. &SDIO_FORCE[0], // EFUSE_RD_SDIO_FORCE
  303. NULL
  304. };
  305. const esp_efuse_desc_t* ESP_EFUSE_ADC_VREF_AND_SDIO_DREF[] = {
  306. &ADC_VREF_AND_SDIO_DREF[0], // EFUSE_RD_ADC_VREF[0..4] or ( SDIO_DREFH[0 1]
  307. NULL
  308. };
  309. const esp_efuse_desc_t* ESP_EFUSE_ADC1_TP_LOW[] = {
  310. &ADC1_TP_LOW[0], // TP_REG EFUSE_RD_ADC1_TP_LOW
  311. NULL
  312. };
  313. const esp_efuse_desc_t* ESP_EFUSE_ADC2_TP_LOW[] = {
  314. &ADC2_TP_LOW[0], // TP_REG EFUSE_RD_ADC2_TP_LOW
  315. NULL
  316. };
  317. const esp_efuse_desc_t* ESP_EFUSE_ADC1_TP_HIGH[] = {
  318. &ADC1_TP_HIGH[0], // TP_REG EFUSE_RD_ADC1_TP_HIGH
  319. NULL
  320. };
  321. const esp_efuse_desc_t* ESP_EFUSE_ADC2_TP_HIGH[] = {
  322. &ADC2_TP_HIGH[0], // TP_REG EFUSE_RD_ADC2_TP_HIGH
  323. NULL
  324. };
  325. const esp_efuse_desc_t* ESP_EFUSE_SECURE_VERSION[] = {
  326. &SECURE_VERSION[0], // Secure version for anti-rollback
  327. NULL
  328. };