diff --git a/scripts/tools/telink/merge_factorydata_dac.py b/scripts/tools/telink/merge_factorydata_dac.py index f38aac93366a46..c4ebf186832bdc 100644 --- a/scripts/tools/telink/merge_factorydata_dac.py +++ b/scripts/tools/telink/merge_factorydata_dac.py @@ -32,7 +32,9 @@ import argparse -def merge_factorydata_dac(factory_data_ext_path, dac_cert_key_path, dac_cert_start_address, output_path): + +def merge_factorydata_dac(factory_data_ext_path, dac_cert_key_path, + dac_cert_start_address, output_path): # Read the content of the factory_data_ext.bin with open(factory_data_ext_path, 'rb') as f: factory_data_ext = f.read() @@ -59,19 +61,26 @@ def merge_factorydata_dac(factory_data_ext_path, dac_cert_key_path, dac_cert_sta print(f"Firmware merged successfully into {output_path}") + def main(): # Setup argument parser parser = argparse.ArgumentParser(description='Merge firmware files.') - parser.add_argument('factory_data_ext_path', type=str, help='Path to the factory_data_ext.bin file') - parser.add_argument('dac_cert_key_path', type=str, help='Path to the dac_cert_key.bin file') - parser.add_argument('dac_cert_start_address', type=lambda x: int(x, 0), help='Start address for dac_cert_key.bin (e.g., 0x800)') - parser.add_argument('output_path', default="merged_factorydata_dac.bin", type=str, help='Path to the output merged firmware file') + parser.add_argument('factory_data_ext_path', type=str, + help='Path to the factory_data_ext.bin file') + parser.add_argument('dac_cert_key_path', type=str, + help='Path to the dac_cert_key.bin file') + parser.add_argument('dac_cert_start_address', type=lambda x: int(x, 0), + help='Start address for dac_cert_key.bin (e.g., 0x800)') + parser.add_argument('output_path', default="merged_factorydata_dac.bin", + type=str, help='Path to the output merged firmware file') # Parse the arguments args = parser.parse_args() # Call the merge function with the provided arguments - merge_factorydata_dac(args.factory_data_ext_path, args.dac_cert_key_path, args.dac_cert_start_address, args.output_path) + merge_factorydata_dac(args.factory_data_ext_path, args.dac_cert_key_path, + args.dac_cert_start_address, args.output_path) + if __name__ == '__main__': - main() \ No newline at end of file + main() diff --git a/scripts/tools/telink/mfg_tool.py b/scripts/tools/telink/mfg_tool.py index 0760a8c9b3c12d..990dc0e75c5bfa 100644 --- a/scripts/tools/telink/mfg_tool.py +++ b/scripts/tools/telink/mfg_tool.py @@ -31,9 +31,9 @@ import cryptography.hazmat.backends import cryptography.x509 import pyqrcode -from intelhex import IntelHex -from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.backends import default_backend +from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes +from intelhex import IntelHex TOOLS = { 'spake2p': None, @@ -457,7 +457,7 @@ def write_device_unique_data(args, out_dirs, pai_cert): dacs = use_dac_cert_from_args(args, out_dirs) else: dacs = generate_dac_cert(int(row['Index']), args, out_dirs, int(row['Discriminator']), - int(row['PIN Code']), pai_cert['key_pem'], pai_cert['cert_pem']) + int(row['PIN Code']), pai_cert['key_pem'], pai_cert['cert_pem']) dac_cert_storage = read_der_file(dacs[0]) dac_key_storage = read_key_bin_file(dacs[1]) if not args.secure_programming_verification: @@ -744,10 +744,10 @@ def base64_str(s): return base64.b64decode(s) secure_args = parser.add_argument_group('Secure programming verification options') secure_args.add_argument("--secure-programming-verification", action="store_true", - help="Enable secure programming mode. When set, the script will perform additional steps for secure programming verification.") + help="Enable secure programming mode. When set, the script will perform additional steps for secure programming verification.") secure_args.add_argument("--chip-id", required=False, type=str, help="Chip ID in hex format (32 hex characters).") secure_args.add_argument("--disable_serial_num_storage", action="store_true", - help="Disable storage of serial-num in factorydata.") + help="Disable storage of serial-num in factorydata.") args = parser.parse_args()