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