diff --git a/components/efuse/CMakeLists.txt b/components/efuse/CMakeLists.txt index e11e1e74f3..6077f39269 100644 --- a/components/efuse/CMakeLists.txt +++ b/components/efuse/CMakeLists.txt @@ -16,39 +16,47 @@ set(COMPONENT_REQUIRES) set(COMPONENT_PRIV_REQUIRES bootloader_support) register_component() +set(GEN_EFUSE_TABLE_ARG --coding_scheme ${CONFIG_EFUSE_CODE_SCHEME}) + +if(CONFIG_EFUSE_CUSTOM_TABLE_USE_BLK1) + list(APPEND GEN_EFUSE_TABLE_ARG --custom_table_use_BLK1) +endif() + +if(CONFIG_EFUSE_CUSTOM_TABLE_USE_BLK2) + list(APPEND GEN_EFUSE_TABLE_ARG --custom_table_use_BLK2) +endif() + +if(CONFIG_EFUSE_COMMON_TABLE_FIX_SIZE_BLK1_BLK2_DEP_ON_CODE_SCHEME) + list(APPEND GEN_EFUSE_TABLE_ARG --common_table_fix_size_secure_key_and_encrypt_key) +endif() ################### # Make common files esp_efuse_table.c and include/esp_efuse_table.h files. -# The generated files are used in the bootloader and application space. -# To generate new *.c/*.h files run the command manually "make efuse_common_table". set(EFUSE_COMMON_TABLE_CSV_PATH "${COMPONENT_PATH}/${SOC_NAME}/esp_efuse_table.csv") -add_custom_target(efuse_common_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_COMMON_TABLE_CSV_PATH}) +set(EFUSE_COMMON_TABLE_OUT_PATH "${COMPONENT_PATH}/${SOC_NAME}/esp_efuse_table.c") - -# custom gen header files +################### +# Make custom files project/main/esp_efuse_custom_table.c and project/main/include/esp_efuse_custom_table.h files. +# Path to CSV file is relative to project path for custom CSV files. if(${CONFIG_EFUSE_CUSTOM_TABLE}) # Custom filename expands any path relative to the project get_filename_component(EFUSE_CUSTOM_TABLE_CSV_PATH "${CONFIG_EFUSE_CUSTOM_TABLE_FILENAME}" ABSOLUTE BASE_DIR "${PROJECT_PATH}") - - add_custom_target(efuse_custom_table ALL - COMMAND ${CMAKE_COMMAND} -E echo "Efuse CSV ${EFUSE_CUSTOM_TABLE_CSV_PATH} does not exist. Either change efuse table file in menuconfig or create this input file." - COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_BINARY_DIR}/CMakeCache.txt" - COMMAND ${CMAKE_COMMAND} -P ${IDF_PATH}/tools/cmake/scripts/fail.cmake) - -string(REPLACE ".csv" ".c" HEADER_CUSTOM ${EFUSE_CUSTOM_TABLE_CSV_PATH}) -add_custom_command(OUTPUT ${HEADER_CUSTOM} - COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" - ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} - DEPENDS ${EFUSE_CUSTOM_TABLE_CSV_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" - VERBATIM) - -if(EXISTS ${EFUSE_CUSTOM_TABLE_CSV_PATH}) - add_custom_target(efuse_custom_table ALL DEPENDS ${HEADER_CUSTOM} ${EFUSE_CUSTOM_TABLE_CSV_PATH}) -endif() + string(REPLACE ".csv" ".c" EFUSE_CUSTOM_TABLE_OUT_PATH ${EFUSE_CUSTOM_TABLE_CSV_PATH}) endif()#if(${CONFIG_EFUSE_CUSTOM_TABLE}) +set(GENERATED_SRC ${EFUSE_COMMON_TABLE_OUT_PATH} ${EFUSE_CUSTOM_TABLE_OUT_PATH}) +set_source_files_properties(GENERATED_SRC PROPERTIES SYMBOLIC true) +add_custom_command( + OUTPUT GENERATED_OUTPUT + BYPRODUCTS ${GENERATED_SRC} + COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" + ${EFUSE_COMMON_TABLE_CSV_PATH} ${EFUSE_CUSTOM_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG} + DEPENDS "${EFUSE_COMMON_TABLE_CSV_PATH}" "${EFUSE_CUSTOM_TABLE_CSV_PATH}" "${SDKCONFIG_CMAKE}" + VERBATIM) +add_custom_target(GENERATED_SRC DEPENDS GENERATED_OUTPUT ${GENERATED_SRC}) + ################### # Generates files for unit test. This command is run manually. set(EFUSE_TEST_TABLE_CSV_PATH "${COMPONENT_PATH}/test/esp_efuse_test_table.csv") -add_custom_target(efuse_test_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_TEST_TABLE_CSV_PATH}) +add_custom_target(efuse_test_table COMMAND "${PYTHON}" "${CMAKE_CURRENT_SOURCE_DIR}/efuse_table_gen.py" ${EFUSE_TEST_TABLE_CSV_PATH} ${GEN_EFUSE_TABLE_ARG}) diff --git a/components/efuse/Kconfig b/components/efuse/Kconfig index d07ae851fd..69697c219c 100644 --- a/components/efuse/Kconfig +++ b/components/efuse/Kconfig @@ -20,18 +20,44 @@ config EFUSE_VIRTUAL If this option is set, all permanent changes (via eFuse) are disabled. Log output will state changes which would be applied, but they will not be. -choice EFUSE_CODE_SCHEME - prompt "eFuse Code Scheme" - default EFUSE_CODE_SCHEME_NONE +choice EFUSE_CODE_SCHEME_SELECTOR + prompt "Coding scheme" + default EFUSE_CODE_SCHEME_STATE_NONE help Selector eFuse code scheme. -config EFUSE_CODE_SCHEME_NONE - bool "None" -config EFUSE_CODE_SCHEME_3_4 +config EFUSE_CODE_SCHEME_STATE_NONE + bool "NONE" +config EFUSE_CODE_SCHEME_STATE_3_4 bool "3/4" -config EFUSE_CODE_SCHEME_REPEAT - bool "Repeat" +config EFUSE_CODE_SCHEME_STATE_REPEAT + bool "REPEAT" endchoice +config EFUSE_CODE_SCHEME + int + default 0 if EFUSE_CODE_SCHEME_STATE_NONE + default 1 if EFUSE_CODE_SCHEME_STATE_3_4 + default 2 if EFUSE_CODE_SCHEME_STATE_REPEAT + +config EFUSE_CUSTOM_TABLE_USE_BLK1 + bool "Use EFUSE_BLK1 for custom purpose" + default n + help + If this option is set then ENCRYPT_FLASH_KEY field from EFUSE_BLK1 [0..192/255] can not be used anymore. + ENCRYPT_FLASH_KEY field will contain 0 bits. + +config EFUSE_CUSTOM_TABLE_USE_BLK2 + bool "Use EFUSE_BLK2 for custom purpose" + default n + help + If this option is set then SECURE_BOOT_KEY field from EFUSE_BLK2 [0..192/255] can not be used anymore. + SECURE_BOOT_KEY field will contain 0 bits. + +config EFUSE_COMMON_TABLE_FIX_SIZE_BLK1_BLK2_DEP_ON_CODE_SCHEME + bool "Limit size BLK1 and BLK2 if coding scheme is changed" + default y + help + efuse_table_gen.py tool will change size two fields: SECURE_BOOT_KEY and ENCRYPT_FLASH_KEY if they have not much coding scheme with a description in csv file. + endmenu diff --git a/components/efuse/Makefile.projbuild b/components/efuse/Makefile.projbuild index 35e0355a92..beebe72ce8 100644 --- a/components/efuse/Makefile.projbuild +++ b/components/efuse/Makefile.projbuild @@ -1,48 +1,59 @@ # # eFuse Manager ganeretes header file. # -# .PHONY: efuse_table efuse_custom_table efuse_common_table efuse_test_table show_efuse_table +# .PHONY: efuse_table efuse_test_table show_efuse_table -GEN_EFUSE_TABLE := $(PYTHON) $(COMPONENT_PATH)/efuse_table_gen.py +GEN_TOOL := $(COMPONENT_PATH)/efuse_table_gen.py +GEN_EFUSE_TABLE := $(PYTHON) $(GEN_TOOL) -efuse_table: efuse_custom_table +GEN_EFUSE_TABLE_ARG := --coding_scheme $(CONFIG_EFUSE_CODE_SCHEME) + +ifdef CONFIG_EFUSE_CUSTOM_TABLE_USE_BLK1 +GEN_EFUSE_TABLE_ARG += --custom_table_use_BLK1 +endif + +ifdef CONFIG_EFUSE_CUSTOM_TABLE_USE_BLK2 +GEN_EFUSE_TABLE_ARG += --custom_table_use_BLK2 +endif + +ifdef CONFIG_EFUSE_COMMON_TABLE_FIX_SIZE_BLK1_BLK2_DEP_ON_CODE_SCHEME +GEN_EFUSE_TABLE_ARG += --common_table_fix_size_secure_key_and_encrypt_key +endif ################### # Make common files esp_efuse_table.c and include/esp_efuse_table.h files. -# The generated files are used in the bootloader and application space. -# To generate new *.c/*.h files run the command manually "make efuse_common_table". SOC_NAME := $(IDF_TARGET) EFUSE_COMMON_TABLE_CSV_PATH := $(COMPONENT_PATH)/$(SOC_NAME)/esp_efuse_table.csv -efuse_common_table: - $(GEN_EFUSE_TABLE) $(EFUSE_COMMON_TABLE_CSV_PATH) +EFUSE_COMMON_TABLE_OUT_PATH := $(COMPONENT_PATH)/$(SOC_NAME)/esp_efuse_table.c ################### -# Make custom files -# Changes in esp_efuse_custom_table.csv file lead to regeneration of esp_efuse_custom_table.c and include/esp_efuse_custom_table.h files. -# The generated files are used only in the application. -ifdef IS_BOOTLOADER_BUILD -efuse_custom_table: -else - +# Make custom files project/main/esp_efuse_custom_table.c and project/main/include/esp_efuse_custom_table.h files. ifdef CONFIG_EFUSE_CUSTOM_TABLE # Path to CSV file is relative to project path for custom CSV files. EFUSE_CUSTOM_TABLE_CSV_PATH := $(call dequote,$(abspath $(call dequote, $(PROJECT_PATH))/$(call dequote,$(CONFIG_EFUSE_CUSTOM_TABLE_FILENAME)))) -EFUSE_CUSTOM_TABLE_OUT_PATH := $(call dequote,$(abspath $(call dequote, $(BUILD_DIR_BASE))/$(call dequote,$(CONFIG_EFUSE_CUSTOM_TABLE_FILENAME)))) -efuse_custom_table: $(EFUSE_CUSTOM_TABLE_OUT_PATH:.csv=.o) - -$(EFUSE_CUSTOM_TABLE_OUT_PATH:.csv=.o): $(EFUSE_CUSTOM_TABLE_CSV_PATH) - @echo "$(EFUSE_CUSTOM_TABLE_OUT_PATH)" - @echo "$(EFUSE_CUSTOM_TABLE_CSV_PATH)" - $(GEN_EFUSE_TABLE) $(EFUSE_COMMON_TABLE_CSV_PATH) $(EFUSE_CUSTOM_TABLE_CSV_PATH) - +EFUSE_CUSTOM_TABLE_OUT_PATH_CSV := $(call dequote,$(abspath $(call dequote, $(PROJECT_PATH))/$(call dequote,$(CONFIG_EFUSE_CUSTOM_TABLE_FILENAME)))) +EFUSE_CUSTOM_TABLE_OUT_PATH := $(EFUSE_CUSTOM_TABLE_OUT_PATH_CSV:.csv=.c) else -efuse_custom_table: -endif +EFUSE_CUSTOM_TABLE_CSV_PATH := +EFUSE_CUSTOM_TABLE_OUT_PATH := +endif # ifdef CONFIG_EFUSE_CUSTOM_TABLE -endif +efuse_table: $(EFUSE_COMMON_TABLE_OUT_PATH) $(EFUSE_CUSTOM_TABLE_OUT_PATH) + +$(EFUSE_COMMON_TABLE_OUT_PATH): $(EFUSE_COMMON_TABLE_CSV_PATH) $(SDKCONFIG_MAKEFILE) + @echo "COMMON_TABLE_CSV: $(EFUSE_COMMON_TABLE_CSV_PATH)" + $(GEN_EFUSE_TABLE) $(EFUSE_COMMON_TABLE_CSV_PATH) $(GEN_EFUSE_TABLE_ARG) + +$(EFUSE_CUSTOM_TABLE_OUT_PATH): $(EFUSE_CUSTOM_TABLE_CSV_PATH) $(SDKCONFIG_MAKEFILE) + @echo "CUSTOM_TABLE_CSV: $(EFUSE_CUSTOM_TABLE_CSV_PATH)" + $(GEN_EFUSE_TABLE) $(EFUSE_COMMON_TABLE_CSV_PATH) $(EFUSE_CUSTOM_TABLE_CSV_PATH) $(GEN_EFUSE_TABLE_ARG) + +# print to console efuse table +show_efuse_table: + $(GEN_EFUSE_TABLE) $(EFUSE_COMMON_TABLE_CSV_PATH) $(EFUSE_CUSTOM_TABLE_CSV_PATH) $(GEN_EFUSE_TABLE_ARG) --info ################### # Generates files for unit test. This command is run manually. EFUSE_TEST_TABLE_CSV_PATH := $(COMPONENT_PATH)/test/esp_efuse_test_table.csv efuse_test_table: - $(GEN_EFUSE_TABLE) $(EFUSE_TEST_TABLE_CSV_PATH) + $(GEN_EFUSE_TABLE) $(EFUSE_TEST_TABLE_CSV_PATH) $(GEN_EFUSE_TABLE_ARG) diff --git a/components/efuse/efuse_table_gen.py b/components/efuse/efuse_table_gen.py index a64f2f9495..98be7a6017 100644 --- a/components/efuse/efuse_table_gen.py +++ b/components/efuse/efuse_table_gen.py @@ -30,6 +30,16 @@ import ntpath __version__ = '1.0' quiet = False +coding_scheme = 0 +custom_table_use_BLK1 = False +custom_table_use_BLK2 = False +common_table_fix_size = False + +CODE_SCHEME = { + "NONE" : 0, + "3/4" : 1, + "REPEAT" : 2, +} copyright = '''// Copyright 2017-2018 Espressif Systems (Shanghai) PTE LTD // @@ -59,12 +69,11 @@ def critical(msg): class FuseTable(list): def __init__(self): super(FuseTable, self).__init__(self) - self.md5_digest = "" + self.md5_digest_table = "" @classmethod - def from_csv(cls, csv_contents): + def from_csv(cls, csv_contents, type_table): res = FuseTable() - res.md5_digest = res.calc_md5(csv_contents) lines = csv_contents.splitlines() def expand_vars(f): f = os.path.expandvars(f) @@ -120,6 +129,16 @@ class FuseTable(list): i_count = 0 res.verify_duplicate_name() + # fix size due to coding scheme + if type_table == "common_table": + if common_table_fix_size == True and (custom_table_use_BLK1 == False or custom_table_use_BLK2 == False): + res.fix_size_fields_from_blk1_blk2(); + if custom_table_use_BLK1 == True or custom_table_use_BLK2 == True: + res.keys_from_blk1_blk2_make_empty(); + + # clac md5 for table + res.calc_md5() + return res def verify_duplicate_name(self): @@ -139,11 +158,9 @@ class FuseTable(list): if fl_error == True: raise InputError("Field names must be unique") - def verify(self): - - '''list_field_names = []''' + def verify(self, type_table = None): for p in self: - p.verify() + p.verify(type_table) self.verify_duplicate_name() @@ -156,8 +173,25 @@ class FuseTable(list): last.field_name, last.efuse_block, last.bit_start, last.bit_count)) last = p - def calc_md5(self, csv_contents): - return hashlib.md5(csv_contents).hexdigest() + def fix_size_fields_from_blk1_blk2(self): + for p in self: + if (p.efuse_block == "EFUSE_BLK1" and custom_table_use_BLK1 == False) or (p.efuse_block == "EFUSE_BLK2" and custom_table_use_BLK2 == False): + max_bits = p.get_max_bits_of_block() + if p.bit_start == 0 and p.bit_count > max_bits: + print("Fix size `%s` field from %d to %d" %(p.field_name, p.bit_count, max_bits)) + p.bit_count = max_bits + + def keys_from_blk1_blk2_make_empty(self): + for p in self: + if (p.efuse_block == "EFUSE_BLK1" and custom_table_use_BLK1 == True) or (p.efuse_block == "EFUSE_BLK2" and custom_table_use_BLK2 == True): + p.bit_count = 0 + print("efuse: `%s` field was changed from %d to 0" %(p.field_name, p.bit_count)) + + def calc_md5(self): + txt_table = '' + for p in self: + txt_table += "%s %s %d %d %s" % (p.field_name, p.efuse_block, p.bit_start, p.bit_count, p.comment) + "\n" + self.md5_digest_table = hashlib.md5(txt_table).hexdigest() def show_range_used_bits(self): # print used and free bits @@ -190,7 +224,7 @@ class FuseTable(list): "#endif", "", "", - "// md5_digest " + self.md5_digest, + "// md5_digest_table " + self.md5_digest_table, "// This file was generated automatically from the file " + file_name + ".csv. DO NOT CHANGE THIS FILE MANUALLY.", "// If you want to change some fields, you need to change " + file_name + ".csv file then build system will generate this header file", "// To show efuse_table run the command 'make show_efuse_table'.", @@ -215,7 +249,7 @@ class FuseTable(list): rows += [ '#include "esp_efuse.h"', '#include "' + file_name + '.h"', "", - "// md5_digest " + self.md5_digest, + "// md5_digest_table " + self.md5_digest_table, "// This file was generated automatically from the file " + file_name + ".csv. DO NOT CHANGE THIS FILE MANUALLY.", "// If you want to change some fields, you need to change " + file_name + ".csv file then build system will generate this header file", "// To show efuse_table run the command 'make show_efuse_table'.", @@ -293,18 +327,36 @@ class FuseDefinition(object): raise InputError("Field 'efuse_block' should consist from EFUSE_BLK0..EFUSE_BLK3") return strval - def verify(self): - '''if self.field_name is None: - raise ValidationError(self, "field_name field is not set")''' + def get_max_bits_of_block(self): + '''common_table: EFUSE_BLK0, EFUSE_BLK1, EFUSE_BLK2, EFUSE_BLK3 + custom_table: ----------, ----------, ----------, EFUSE_BLK3(some reserved in common_table) + ''' + max_bits = 0 + if coding_scheme == CODE_SCHEME["NONE"] or self.efuse_block == "EFUSE_BLK0": + max_bits = 256 + elif coding_scheme == CODE_SCHEME["3/4"]: + max_bits = 192 + elif coding_scheme == CODE_SCHEME["REPEAT"]: + max_bits = 128 + else: + ValidationError(self, "Unknown coding scheme") + return max_bits + + def verify(self, type_table): if self.efuse_block is None: raise ValidationError(self, "efuse_block field is not set") if self.bit_count is None: raise ValidationError(self, "bit_count field is not set") - max_bits = 256 - if self.efuse_block == "EFUSE_BLK0": - max_bits = 224 + if type_table is not None: + if type_table == "custom_table": + if self.efuse_block != "EFUSE_BLK3": + ValidationError(self, "custom_table should use only EFUSE_BLK3") + + max_bits = self.get_max_bits_of_block() + if self.bit_start + self.bit_count > max_bits: + print("(%d + %d) > %d" % (self.bit_start, self.bit_count, max_bits)) raise ValidationError(self, "The field is outside the boundaries of the %s block" % (self.efuse_block)) def get_full_name(self): @@ -324,15 +376,26 @@ class FuseDefinition(object): str(self.bit_start), str(self.bit_count) + "}, \t // " + self.comment]) -def process_input_file(file): +def process_input_file(file, type_table): status("Parsing efuse CSV input file " + file.name + " ...") input = file.read() - table = FuseTable.from_csv(input) - + table = FuseTable.from_csv(input, type_table) status("Verifying efuse table...") - table.verify() + table.verify(type_table) return table +def ckeck_md5_in_file(md5, filename): + if os.path.exists(filename): + with open(filename,'r') as f: + for line in f: + if md5 in line: + return True + return False + +def touch(fname, times=None): + with open(fname, 'a'): + os.utime(fname, times) + def create_output_files(name, output_table, debug): file_name = os.path.splitext(os.path.basename(name))[0] gen_dir = os.path.dirname(name) @@ -346,55 +409,74 @@ def create_output_files(name, output_table, debug): file_h_path = os.path.join(dir_for_file_h, file_name + ".h") file_c_path = os.path.join(gen_dir, file_name + ".c") - status("Creating efuse *.h file " + file_h_path + " ...") - output = output_table.to_header(file_name) - with open(file_h_path, 'w') as f: - f.write(output) - f.close() - - status("Creating efuse *.c file " + file_c_path + " ...") - output = output_table.to_c_file(file_name, debug) - with open(file_c_path, 'w') as f: - f.write(output) - f.close() - + # src files are the same + if ckeck_md5_in_file(output_table.md5_digest_table, file_c_path) == False: + status("Creating efuse *.h file " + file_h_path + " ...") + output = output_table.to_header(file_name) + with open(file_h_path, 'w') as f: + f.write(output) + f.close() + + status("Creating efuse *.c file " + file_c_path + " ...") + output = output_table.to_c_file(file_name, debug) + with open(file_c_path, 'w') as f: + f.write(output) + f.close() + else: + print("touch: %s.c" % (file_name)) + touch(file_c_path) + def main(): global quiet + global coding_scheme + global custom_table_use_BLK1 + global custom_table_use_BLK2 + global common_table_fix_size parser = argparse.ArgumentParser(description='ESP32 eFuse Manager') parser.add_argument('--quiet', '-q', help="Don't print non-critical status messages to stderr", action='store_true') parser.add_argument('--debug', help='Create header file with debug info', default=False, action="store_false") parser.add_argument('--info', help='Print info about range of used bits', default=False, action="store_true") + parser.add_argument('--custom_table_use_BLK1', help='BLK1 is used for custom purpose', default=False, action="store_true") + parser.add_argument('--custom_table_use_BLK2', help='BLK2 is used for custom purpose', default=False, action="store_true") + parser.add_argument('--common_table_fix_size_secure_key_and_encrypt_key', help='Size of secure_key and encrypt_key will limit to coding scheme', default=False, action="store_true") + parser.add_argument('--coding_scheme', help='Coding scheme', type=int, default=None) parser.add_argument('common_input', help='Path to common CSV file to parse.', type=argparse.FileType('rb')) parser.add_argument('custom_input', help='Path to custom CSV file to parse.', type=argparse.FileType('rb'), nargs='?', default=None) args = parser.parse_args() + coding_scheme = args.coding_scheme + if CODE_SCHEME["NONE"] == coding_scheme: + print("eFuse coding scheme: NONE") + elif CODE_SCHEME["3/4"] == coding_scheme: + print("eFuse coding scheme: 3/4") + elif CODE_SCHEME["REPEAT"] == coding_scheme: + print("eFuse coding scheme: REPEAT") + + custom_table_use_BLK1 = args.custom_table_use_BLK1 + custom_table_use_BLK2 = args.custom_table_use_BLK2 + common_table_fix_size = args.common_table_fix_size_secure_key_and_encrypt_key quiet = args.quiet debug = args.debug info = args.info - common_table = process_input_file(args.common_input) + common_table = process_input_file(args.common_input, "common_table") + two_table = common_table if args.custom_input is not None: - custom_table = process_input_file(args.custom_input) - common_table += custom_table - common_table.verify() - if info == True: - output_table = common_table - else: - output_table = custom_table - name = args.custom_input.name - else: - output_table = common_table - name = args.common_input.name - output_table.verify() + custom_table = process_input_file(args.custom_input, "custom_table") + two_table += custom_table + two_table.verify() # save files. if info == False: - create_output_files(name, output_table, debug) + if args.custom_input is None: + create_output_files(args.common_input.name, common_table, debug) + else: + create_output_files(args.custom_input.name, custom_table, debug) else: - print(output_table.show_range_used_bits()) + print(two_table.show_range_used_bits()) return 0 diff --git a/components/efuse/esp32/esp_efuse_table.c b/components/efuse/esp32/esp_efuse_table.c index 69685c0e89..d4bfeb2854 100644 --- a/components/efuse/esp32/esp_efuse_table.c +++ b/components/efuse/esp32/esp_efuse_table.c @@ -15,8 +15,7 @@ #include "esp_efuse.h" #include "esp_efuse_table.h" - -// md5_digest 963d6d14dc4bd997fd5d4b9de351745d +// md5_digest_table 20db0282fe17fec59ea46716026f5fce // This file was generated automatically from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file then build system will generate this header file // To show efuse_table run the command 'make show_efuse_table'. @@ -171,6 +170,10 @@ static const esp_efuse_desc_t ADC2_TP_HIGH[] = { {EFUSE_BLK3, 119, 9}, // TP_REG EFUSE_RD_ADC2_TP_HIGH, }; +static const esp_efuse_desc_t SECURE_VERSION[] = { + {EFUSE_BLK3, 128, 32}, // Secure version for anti-rollback, +}; + @@ -360,3 +363,8 @@ const esp_efuse_desc_t* ESP_EFUSE_ADC2_TP_HIGH[] = { NULL }; +const esp_efuse_desc_t* ESP_EFUSE_SECURE_VERSION[] = { + &SECURE_VERSION[0], // Secure version for anti-rollback + NULL +}; + diff --git a/components/efuse/esp32/esp_efuse_table.csv b/components/efuse/esp32/esp_efuse_table.csv index 8c6db79dd4..0c85664f66 100644 --- a/components/efuse/esp32/esp_efuse_table.csv +++ b/components/efuse/esp32/esp_efuse_table.csv @@ -78,3 +78,7 @@ ADC1_TP_LOW, EFUSE_BLK3, 96, 7, TP_REG EFUSE_RD_ADC1_TP_LOW ADC2_TP_LOW, EFUSE_BLK3, 112, 7, TP_REG EFUSE_RD_ADC2_TP_LOW ADC1_TP_HIGH, EFUSE_BLK3, 103, 9, TP_REG EFUSE_RD_ADC1_TP_HIGH ADC2_TP_HIGH, EFUSE_BLK3, 119, 9, TP_REG EFUSE_RD_ADC2_TP_HIGH + +# anti-rollback # +################# +SECURE_VERSION, EFUSE_BLK3, 128, 32, Secure version for anti-rollback diff --git a/components/efuse/esp32/include/esp_efuse_table.h b/components/efuse/esp32/include/esp_efuse_table.h index c7e7c44481..c06e776a0a 100644 --- a/components/efuse/esp32/include/esp_efuse_table.h +++ b/components/efuse/esp32/include/esp_efuse_table.h @@ -17,7 +17,7 @@ extern "C" { #endif -// md5_digest 963d6d14dc4bd997fd5d4b9de351745d +// md5_digest_table 20db0282fe17fec59ea46716026f5fce // This file was generated automatically from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file then build system will generate this header file // To show efuse_table run the command 'make show_efuse_table'. @@ -59,6 +59,7 @@ extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_TP_LOW[]; extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_TP_LOW[]; extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_TP_HIGH[]; extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_TP_HIGH[]; +extern const esp_efuse_desc_t* ESP_EFUSE_SECURE_VERSION[]; #ifdef __cplusplus } diff --git a/components/soc/CMakeLists.txt b/components/soc/CMakeLists.txt index 551063b39c..f377386a42 100644 --- a/components/soc/CMakeLists.txt +++ b/components/soc/CMakeLists.txt @@ -13,6 +13,4 @@ list(APPEND COMPONENT_SRCS "src/memory_layout_utils.c") set(COMPONENT_ADD_LDFRAGMENTS linker.lf) -set(COMPONENT_REQUIRES efuse) - register_component() diff --git a/make/project.mk b/make/project.mk index 6f86cbef07..a0d411496f 100644 --- a/make/project.mk +++ b/make/project.mk @@ -13,7 +13,7 @@ .PHONY: build-components menuconfig defconfig all build clean all_binaries check-submodules size size-components size-files size-symbols list-components MAKECMDGOALS ?= all -all: all_binaries | check_python_dependencies +all: efuse_table all_binaries | check_python_dependencies # see below for recipe of 'all' target # # # other components will add dependencies to 'all_binaries'. The @@ -481,7 +481,7 @@ $(APP_ELF): $(foreach libcomp,$(COMPONENT_LIBRARIES),$(BUILD_DIR_BASE)/$(libcomp $(summary) LD $(patsubst $(PWD)/%,%,$@) $(CC) $(LDFLAGS) -o $@ -Wl,-Map=$(APP_MAP) -app: $(APP_BIN) partition_table_get_info +app: efuse_table $(APP_BIN) partition_table_get_info ifeq ("$(CONFIG_SECURE_BOOT_ENABLED)$(CONFIG_SECURE_BOOT_BUILD_SIGNED_BINARIES)","y") # secure boot enabled, but remote sign app image @echo "App built but not signed. Signing step via espsecure.py:" @echo "espsecure.py sign_data --keyfile KEYFILE $(APP_BIN)" @@ -521,7 +521,7 @@ endef define GenerateComponentTargets .PHONY: component-$(2)-build component-$(2)-clean -component-$(2)-build: check-submodules efuse_table $(call prereq_if_explicit, component-$(2)-clean) | $(BUILD_DIR_BASE)/$(2) +component-$(2)-build: check-submodules $(call prereq_if_explicit, component-$(2)-clean) | $(BUILD_DIR_BASE)/$(2) $(call ComponentMake,$(1),$(2)) build component-$(2)-clean: | $(BUILD_DIR_BASE)/$(2) $(BUILD_DIR_BASE)/$(2)/component_project_vars.mk