1# This file describes eFuses fields and registers for ESP32-S3(beta2) chip 2# 3# SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD 4# 5# SPDX-License-Identifier: GPL-2.0-or-later 6 7from ..mem_definition_base import EfuseBlocksBase, EfuseFieldsBase, EfuseRegistersBase 8 9 10# fmt: off 11class EfuseDefineRegisters(EfuseRegistersBase): 12 13 EFUSE_ADDR_MASK = 0x00000FFF 14 EFUSE_MEM_SIZE = (0x01FC + 4) 15 16 # EFUSE registers & command/conf values 17 DR_REG_EFUSE_BASE = 0x6001A000 18 EFUSE_PGM_DATA0_REG = DR_REG_EFUSE_BASE 19 EFUSE_CHECK_VALUE0_REG = DR_REG_EFUSE_BASE + 0x020 20 EFUSE_CLK_REG = DR_REG_EFUSE_BASE + 0x1C8 21 EFUSE_CONF_REG = DR_REG_EFUSE_BASE + 0x1CC 22 EFUSE_STATUS_REG = DR_REG_EFUSE_BASE + 0x1D0 23 EFUSE_CMD_REG = DR_REG_EFUSE_BASE + 0x1D4 24 EFUSE_RD_RS_ERR0_REG = DR_REG_EFUSE_BASE + 0x1C0 25 EFUSE_RD_RS_ERR1_REG = DR_REG_EFUSE_BASE + 0x1C4 26 EFUSE_RD_REPEAT_ERR0_REG = DR_REG_EFUSE_BASE + 0x17C 27 EFUSE_RD_REPEAT_ERR1_REG = DR_REG_EFUSE_BASE + 0x180 28 EFUSE_RD_REPEAT_ERR2_REG = DR_REG_EFUSE_BASE + 0x184 29 EFUSE_RD_REPEAT_ERR3_REG = DR_REG_EFUSE_BASE + 0x188 30 EFUSE_RD_REPEAT_ERR4_REG = DR_REG_EFUSE_BASE + 0x18C 31 EFUSE_DAC_CONF_REG = DR_REG_EFUSE_BASE + 0x1E8 32 EFUSE_RD_TIM_CONF_REG = DR_REG_EFUSE_BASE + 0x1EC 33 EFUSE_WR_TIM_CONF1_REG = DR_REG_EFUSE_BASE + 0x1F4 34 EFUSE_WR_TIM_CONF2_REG = DR_REG_EFUSE_BASE + 0x1F8 35 EFUSE_DATE_REG = DR_REG_EFUSE_BASE + 0x1FC 36 EFUSE_WRITE_OP_CODE = 0x5A5A 37 EFUSE_READ_OP_CODE = 0x5AA5 38 EFUSE_PGM_CMD_MASK = 0x3 39 EFUSE_PGM_CMD = 0x2 40 EFUSE_READ_CMD = 0x1 41 42 BLOCK_ERRORS = [ 43 # error_reg, err_num_mask, err_num_offs, fail_bit 44 (EFUSE_RD_REPEAT_ERR0_REG, None, None, None), # BLOCK0 45 (EFUSE_RD_RS_ERR0_REG, 0x7, 0, 3), # MAC_SPI_8M_0 46 (EFUSE_RD_RS_ERR0_REG, 0x7, 4, 7), # BLOCK_SYS_DATA 47 (EFUSE_RD_RS_ERR0_REG, 0x7, 8, 11), # BLOCK_USR_DATA 48 (EFUSE_RD_RS_ERR0_REG, 0x7, 12, 15), # BLOCK_KEY0 49 (EFUSE_RD_RS_ERR0_REG, 0x7, 16, 19), # BLOCK_KEY1 50 (EFUSE_RD_RS_ERR0_REG, 0x7, 20, 23), # BLOCK_KEY2 51 (EFUSE_RD_RS_ERR0_REG, 0x7, 24, 27), # BLOCK_KEY3 52 (EFUSE_RD_RS_ERR0_REG, 0x7, 28, 31), # BLOCK_KEY4 53 (EFUSE_RD_RS_ERR1_REG, 0x7, 0, 3), # BLOCK_KEY5 54 (EFUSE_RD_RS_ERR1_REG, 0x7, 4, 7), # BLOCK_SYS_DATA2 55 ] 56 57 # EFUSE_WR_TIM_CONF2_REG 58 EFUSE_PWR_OFF_NUM_S = 0 59 EFUSE_PWR_OFF_NUM_M = 0xFFFF << EFUSE_PWR_OFF_NUM_S 60 61 62class EfuseDefineBlocks(EfuseBlocksBase): 63 64 __base_rd_regs = EfuseDefineRegisters.DR_REG_EFUSE_BASE 65 __base_wr_regs = EfuseDefineRegisters.EFUSE_PGM_DATA0_REG 66 # List of efuse blocks 67 BLOCKS = [ 68 # Name, Alias, Index, Read address, Write address, Write protect bit, Read protect bit, Len, key_purpose 69 ("BLOCK0", [], 0, __base_rd_regs + 0x02C, __base_wr_regs, None, None, 6, None), 70 ("MAC_SPI_8M_0", ["BLOCK1"], 1, __base_rd_regs + 0x044, __base_wr_regs, 20, None, 6, None), 71 ("BLOCK_SYS_DATA", ["BLOCK2"], 2, __base_rd_regs + 0x05C, __base_wr_regs, 21, None, 8, None), 72 ("BLOCK_USR_DATA", ["BLOCK3"], 3, __base_rd_regs + 0x07C, __base_wr_regs, 22, None, 8, None), 73 ("BLOCK_KEY0", ["BLOCK4"], 4, __base_rd_regs + 0x09C, __base_wr_regs, 23, 0, 8, "KEY_PURPOSE_0"), 74 ("BLOCK_KEY1", ["BLOCK5"], 5, __base_rd_regs + 0x0BC, __base_wr_regs, 24, 1, 8, "KEY_PURPOSE_1"), 75 ("BLOCK_KEY2", ["BLOCK6"], 6, __base_rd_regs + 0x0DC, __base_wr_regs, 25, 2, 8, "KEY_PURPOSE_2"), 76 ("BLOCK_KEY3", ["BLOCK7"], 7, __base_rd_regs + 0x0FC, __base_wr_regs, 26, 3, 8, "KEY_PURPOSE_3"), 77 ("BLOCK_KEY4", ["BLOCK8"], 8, __base_rd_regs + 0x11C, __base_wr_regs, 27, 4, 8, "KEY_PURPOSE_4"), 78 ("BLOCK_KEY5", ["BLOCK9"], 9, __base_rd_regs + 0x13C, __base_wr_regs, 28, 5, 8, "KEY_PURPOSE_5"), 79 ("BLOCK_SYS_DATA2", ["BLOCK10"], 10, __base_rd_regs + 0x15C, __base_wr_regs, 29, 6, 8, None), 80 ] 81 82 def get_burn_block_data_names(self): 83 list_of_names = [] 84 for block in self.BLOCKS: 85 blk = self.get(block) 86 if blk.name: 87 list_of_names.append(blk.name) 88 if blk.alias: 89 for alias in blk.alias: 90 list_of_names.append(alias) 91 return list_of_names 92 93 94class EfuseDefineFields(EfuseFieldsBase): 95 96 # List of efuse fields from TRM the chapter eFuse Controller. 97 EFUSES = [ 98 # 99 # Table 51: Parameters in BLOCK0 100 # Name Category Block Word Pos Type:len WR_DIS RD_DIS Class Description Dictionary 101 ("WR_DIS", "efuse", 0, 0, 0, "uint:32", None, None, None, "Disables programming of individual eFuses", None), 102 ("RD_DIS", "efuse", 0, 1, 0, "uint:7", 0, None, None, "Disables software reading from BLOCK4-10", None), 103 ("DIS_ICACHE", "config", 0, 1, 8, "bool", 2, None, None, "Disables ICache", None), 104 ("DIS_DCACHE", "config", 0, 1, 9, "bool", 2, None, None, "Disables DCache", None), 105 ("DIS_DOWNLOAD_ICACHE", "config", 0, 1, 10, "bool", 2, None, None, "Disables Icache when SoC is in Download mode", None), 106 ("DIS_DOWNLOAD_DCACHE", "config", 0, 1, 11, "bool", 2, None, None, "Disables Dcache when SoC is in Download mode", None), 107 ("DIS_FORCE_DOWNLOAD", "config", 0, 1, 12, "bool", 2, None, None, "Disables forcing chip into Download mode", None), 108 ("DIS_USB", "usb config", 0, 1, 13, "bool", 2, None, None, "Disables the USB OTG hardware", None), 109 ("DIS_CAN", "config", 0, 1, 14, "bool", 2, None, None, "Disables the TWAI Controller hardware", None), 110 ("DIS_APP_CPU", "config", 0, 1, 15, "bool", 2, None, None, "Disables APP CPU", None), 111 ("SOFT_DIS_JTAG", "security", 0, 1, 16, "uint:3", 31, None, None, "Software disables JTAG by programming " 112 "odd number of 1 bit(s). " 113 "JTAG can be re-enabled via HMAC peripheral", 114 None), 115 ("HARD_DIS_JTAG", "security", 0, 1, 19, "bool", 2, None, None, "Hardware disables JTAG permanently", None), 116 117 ("DIS_DOWNLOAD_MANUAL_ENCRYPT", "security", 0, 1, 20, "bool", 2, None, None, "Disables flash encryption when in download boot modes", 118 None), 119 ("USB_EXCHG_PINS", "usb config", 0, 1, 25, "bool", 30, None, None, "Exchanges USB D+ and D- pins", None), 120 ("EXT_PHY_ENABLE", "usb config", 0, 1, 26, "bool", 30, None, None, "Enables external USB PHY", None), 121 ("BTLC_GPIO_ENABLE", "usb config", 0, 1, 27, "uint:2", 30, None, None, "Enables BTLC GPIO", None), 122 ("VDD_SPI_XPD", "VDD_SPI config", 0, 2, 4, "bool", 3, None, None, "The VDD_SPI regulator is powered on", None), 123 ("VDD_SPI_TIEH", "VDD_SPI config", 0, 2, 5, "bool", 3, None, None, "The VDD_SPI power supply voltage at reset", 124 {0: "Connect to 1.8V LDO", 125 1: "Connect to VDD_RTC_IO"}), 126 ("VDD_SPI_FORCE", "VDD_SPI config", 0, 2, 6, "bool", 3, None, None, "Force using VDD_SPI_XPD and VDD_SPI_TIEH " 127 "to configure VDD_SPI LDO", None), 128 ("WDT_DELAY_SEL", "WDT config", 0, 2, 16, "uint:2", 3, None, None, "Selects RTC WDT timeout threshold at startup", None), 129 ("SPI_BOOT_CRYPT_CNT", "security", 0, 2, 18, "uint:3", 4, None, "bitcount", "Enables encryption and decryption, when an SPI boot " 130 "mode is set. Enabled when 1 or 3 bits are set," 131 "disabled otherwise", 132 {0: "Disable", 133 1: "Enable", 134 3: "Disable", 135 7: "Enable"}), 136 ("SECURE_BOOT_KEY_REVOKE0", "security", 0, 2, 21, "bool", 5, None, None, "Revokes use of secure boot key digest 0", None), 137 ("SECURE_BOOT_KEY_REVOKE1", "security", 0, 2, 22, "bool", 6, None, None, "Revokes use of secure boot key digest 1", None), 138 ("SECURE_BOOT_KEY_REVOKE2", "security", 0, 2, 23, "bool", 7, None, None, "Revokes use of secure boot key digest 2", None), 139 ("KEY_PURPOSE_0", "security", 0, 2, 24, "uint:4", 8, None, "keypurpose", "KEY0 purpose", None), 140 ("KEY_PURPOSE_1", "security", 0, 2, 28, "uint:4", 9, None, "keypurpose", "KEY1 purpose", None), 141 ("KEY_PURPOSE_2", "security", 0, 3, 0, "uint:4", 10, None, "keypurpose", "KEY2 purpose", None), 142 ("KEY_PURPOSE_3", "security", 0, 3, 4, "uint:4", 11, None, "keypurpose", "KEY3 purpose", None), 143 ("KEY_PURPOSE_4", "security", 0, 3, 8, "uint:4", 12, None, "keypurpose", "KEY4 purpose", None), 144 ("KEY_PURPOSE_5", "security", 0, 3, 12, "uint:4", 13, None, "keypurpose", "KEY5 purpose", None), 145 ("SECURE_BOOT_EN", "security", 0, 3, 20, "bool", 15, None, None, "Enables secure boot", None), 146 ("SECURE_BOOT_AGGRESSIVE_REVOKE", "security", 0, 3, 21, "bool", 16, None, None, "Enables aggressive secure boot key revocation mode", 147 None), 148 ("FLASH_TPUW", "config", 0, 3, 28, "uint:4", 18, None, None, "Configures flash startup delay after SoC power-up, " 149 "unit is (ms/2). When the value is 15, delay is 7.5 ms", 150 None), 151 ("DIS_DOWNLOAD_MODE", "security", 0, 4, 0, "bool", 18, None, None, "Disables all Download boot modes", None), 152 ("DIS_DIRECT_BOOT", "config", 0, 4, 1, "bool", 18, None, None, "Disables direct boot mode", None), 153 ("DIS_USB_SERIAL_JTAG_ROM_PRINT", "config", 0, 4, 2, "bool", 18, None, None, "Disables USB-Serial-JTAG ROM printing", None), 154 ("FLASH_ECC_MODE", "config", 0, 4, 3, "bool", 18, None, None, "Configures the ECC mode for SPI flash", 155 {0: "16-byte to 18-byte mode", 156 1: "16-byte to 17-byte mode"}), 157 ("DIS_USB_SERIAL_JTAG_DOWNLOAD_MODE", "config", 0, 4, 4, "bool", 18, None, None, "Disables USB-Serial-JTAG download feature in " 158 "UART download boot mode", None), 159 ("ENABLE_SECURITY_DOWNLOAD", "security", 0, 4, 5, "bool", 18, None, None, "Enables secure UART download mode " 160 "(read/write flash only)", None), 161 ("UART_PRINT_CONTROL", "config", 0, 4, 6, "uint:2", 18, None, None, "Sets the default UART boot message output mode", 162 {0: "Enabled", 163 1: "Enable when GPIO 46 is low at reset", 164 2: "Enable when GPIO 46 is high at rest", 165 3: "Disabled"}), 166 ("PIN_POWER_SELECTION", "VDD_SPI config", 0, 4, 8, "bool", 18, None, None, "Sets default power supply for GPIO33..37", 167 {0: "VDD3P3_CPU", 168 1: "VDD_SPI"}), 169 ("FLASH_TYPE", "config", 0, 4, 9, "bool", 18, None, None, "Selects SPI flash type", 170 {0: "4 data lines", 171 1: "8 data lines"}), 172 ("FLASH_PAGE_SIZE", "config", 0, 4, 10, "uint:2", 18, None, None, "Sets the size of flash page", None), 173 ("FLASH_ECC_EN", "config", 0, 4, 12, "bool", 18, None, None, "Enables ECC in Flash boot mode", None), 174 ("FORCE_SEND_RESUME", "config", 0, 4, 13, "bool", 18, None, None, "Forces ROM code to send an SPI flash resume command " 175 "during SPI boot", None), 176 ("SECURE_VERSION", "identity", 0, 4, 14, "uint:16", 18, None, "bitcount", "Secure version (used by ESP-IDF anti-rollback feature)", 177 None), 178 ("DIS_USB_OTG_DOWNLOAD_MODE", "config", 0, 4, 31, "bool", 19, None, None, "Disables USB-OTG download feature in " 179 "UART download boot mode", None), 180 ("DISABLE_WAFER_VERSION_MAJOR", "config", 0, 5, 0, "bool", 19, None, None, "Disables check of wafer version major", None), 181 ("DISABLE_BLK_VERSION_MAJOR", "config", 0, 5, 1, "bool", 19, None, None, "Disables check of blk version major", None), 182 # 183 # Table 53: Parameters in BLOCK1-10 184 # Name Category Block Word Pos Type:len WR_DIS RD_DIS Class Description Dictionary 185 ("MAC", "identity", 1, 0, 0, "bytes:6", 20, None, "mac", "Factory MAC Address", None), 186 ("SPI_PAD_CONFIG_CLK", "spi_pad_config", 1, 1, 16, "uint:6", 20, None, None, "SPI CLK pad", None), 187 ("SPI_PAD_CONFIG_Q", "spi_pad_config", 1, 1, 22, "uint:6", 20, None, None, "SPI Q (D1) pad", None), 188 ("SPI_PAD_CONFIG_D", "spi_pad_config", 1, 1, 28, "uint:6", 20, None, None, "SPI D (D0) pad", None), 189 ("SPI_PAD_CONFIG_CS", "spi_pad_config", 1, 2, 2, "uint:6", 20, None, None, "SPI CS pad", None), 190 ("SPI_PAD_CONFIG_HD", "spi_pad_config", 1, 2, 8, "uint:6", 20, None, None, "SPI HD (D3) pad", None), 191 ("SPI_PAD_CONFIG_WP", "spi_pad_config", 1, 2, 14, "uint:6", 20, None, None, "SPI WP (D2) pad", None), 192 ("SPI_PAD_CONFIG_DQS", "spi_pad_config", 1, 2, 20, "uint:6", 20, None, None, "SPI DQS pad", None), 193 ("SPI_PAD_CONFIG_D4", "spi_pad_config", 1, 2, 26, "uint:6", 20, None, None, "SPI D4 pad", None), 194 ("SPI_PAD_CONFIG_D5", "spi_pad_config", 1, 3, 0, "uint:6", 20, None, None, "SPI D5 pad", None), 195 ("SPI_PAD_CONFIG_D6", "spi_pad_config", 1, 3, 6, "uint:6", 20, None, None, "SPI D6 pad", None), 196 ("SPI_PAD_CONFIG_D7", "spi_pad_config", 1, 3, 12, "uint:6", 20, None, None, "SPI D7 pad", None), 197 198 ("WAFER_VERSION_MINOR_LO", "identity", 1, 3, 18, "uint:3", 20, None, None, "WAFER_VERSION_MINOR least significant bits", None), 199 ("PKG_VERSION", "identity", 1, 3, 21, "uint:3", 20, None, None, "Package version", None), 200 ("BLK_VERSION_MINOR", "identity", 1, 3, 24, "uint:3", 20, None, None, "BLOCK version minor", None), 201 ("WAFER_VERSION_MINOR_HI", "identity", 1, 5, 23, "uint:1", 20, None, None, "WAFER_VERSION_MINOR most significant bits", None), 202 ("WAFER_VERSION_MAJOR", "identity", 1, 5, 24, "uint:2", 20, None, None, "WAFER_VERSION_MAJOR", None), 203 204 ("OPTIONAL_UNIQUE_ID", "identity", 2, 0, 0, "bytes:16", 21, None, "keyblock", "Optional unique 128-bit ID", None), 205 ("BLK_VERSION_MAJOR", "identity", 2, 4, 0, "uint:2", 21, None, None, "BLOCK version major", 206 {0: "No calibration", 207 1: "With calibration"}), 208 ("CUSTOM_MAC", "identity", 3, 6, 8, "bytes:6", 22, None, "mac", "Custom MAC Address", None), 209 ] 210 211 KEYBLOCKS = [ 212 # Name Category Block Word Pos Type:len WR_DIS RD_DIS Class Description Dictionary 213 ('BLOCK_USR_DATA', "config", 3, 0, 0, "bytes:32", 22, None, None, "User data", None), 214 ('BLOCK_KEY0', "security", 4, 0, 0, "bytes:32", 23, 0, "keyblock", "Encryption key0 or user data", None), 215 ('BLOCK_KEY1', "security", 5, 0, 0, "bytes:32", 24, 1, "keyblock", "Encryption key1 or user data", None), 216 ('BLOCK_KEY2', "security", 6, 0, 0, "bytes:32", 25, 2, "keyblock", "Encryption key2 or user data", None), 217 ('BLOCK_KEY3', "security", 7, 0, 0, "bytes:32", 26, 3, "keyblock", "Encryption key3 or user data", None), 218 ('BLOCK_KEY4', "security", 8, 0, 0, "bytes:32", 27, 4, "keyblock", "Encryption key4 or user data", None), 219 ('BLOCK_KEY5', "security", 9, 0, 0, "bytes:32", 28, 5, "keyblock", "Encryption key5 or user data", None), 220 ('BLOCK_SYS_DATA2', "security", 10, 0, 0, "bytes:32", 29, 6, None, "System data (part 2)", None), 221 ] 222 223 # if BLK_VERSION_MAJOR is 1, these efuse fields are in BLOCK2 224 BLOCK2_CALIBRATION_EFUSES = [ 225 # Name Category Block Word Pos Type:len WR_DIS RD_DIS Class Description Dictionary 226 ('TEMP_SENSOR_CAL', "calibration", 2, 4, 7, "uint:9", 21, None, "t_sensor", "??? Temperature calibration", None), 227 ('ADC1_MODE0_D2', "calibration", 2, 4, 16, "uint:8", 21, None, "adc_tp", "??? ADC1 calibration 1", None), 228 ('ADC1_MODE1_D2', "calibration", 2, 4, 24, "uint:8", 21, None, "adc_tp", "??? ADC1 calibration 2", None), 229 ('ADC1_MODE2_D2', "calibration", 2, 5, 0, "uint:8", 21, None, "adc_tp", "??? ADC1 calibration 3", None), 230 ('ADC1_MODE3_D2', "calibration", 2, 5, 8, "uint:8", 21, None, "adc_tp", "??? ADC1 calibration 4", None), 231 ('ADC2_MODE0_D2', "calibration", 2, 5, 16, "uint:8", 21, None, "adc_tp", "??? ADC2 calibration 5", None), 232 ('ADC2_MODE1_D2', "calibration", 2, 5, 24, "uint:8", 21, None, "adc_tp", "??? ADC2 calibration 6", None), 233 ('ADC2_MODE2_D2', "calibration", 2, 6, 0, "uint:8", 21, None, "adc_tp", "??? ADC2 calibration 7", None), 234 ('ADC2_MODE3_D2', "calibration", 2, 6, 8, "uint:8", 21, None, "adc_tp", "??? ADC2 calibration 8", None), 235 ('ADC1_MODE0_D1', "calibration", 2, 6, 16, "uint:6", 21, None, "adc_tp", "??? ADC1 calibration 9", None), 236 ('ADC1_MODE1_D1', "calibration", 2, 6, 22, "uint:6", 21, None, "adc_tp", "??? ADC1 calibration 10", None), 237 ('ADC1_MODE2_D1', "calibration", 2, 6, 28, "uint:6", 21, None, "adc_tp", "??? ADC1 calibration 11", None), 238 ('ADC1_MODE3_D1', "calibration", 2, 7, 2, "uint:6", 21, None, "adc_tp", "??? ADC1 calibration 12", None), 239 ('ADC2_MODE0_D1', "calibration", 2, 7, 8, "uint:6", 21, None, "adc_tp", "??? ADC2 calibration 13", None), 240 ('ADC2_MODE1_D1', "calibration", 2, 7, 14, "uint:6", 21, None, "adc_tp", "??? ADC2 calibration 14", None), 241 ('ADC2_MODE2_D1', "calibration", 2, 7, 20, "uint:6", 21, None, "adc_tp", "??? ADC2 calibration 15", None), 242 ('ADC2_MODE3_D1', "calibration", 2, 7, 26, "uint:6", 21, None, "adc_tp", "??? ADC2 calibration 16", None), 243 ] 244 245 CALC = [ 246 ("WAFER_VERSION_MINOR", "identity", 0, None, None, "uint:4", None, None, "wafer", "calc WAFER VERSION MINOR = WAFER_VERSION_MINOR_HI << 3 + WAFER_VERSION_MINOR_LO (read only)", None), 247 ] 248# fmt: on 249