Skip to content

Commit

Permalink
telink update mfg_tool and merge_factorydata_dac
Browse files Browse the repository at this point in the history
to fix code style issues.

Signed-off-by: Damien Ji <[email protected]>
  • Loading branch information
damien0x0023 committed Jan 10, 2025
1 parent 8ca9ce4 commit 1724e4c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
5 changes: 4 additions & 1 deletion scripts/tools/telink/merge_factorydata_dac.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

import argparse


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:
Expand Down Expand Up @@ -59,6 +60,7 @@ 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.')
Expand All @@ -73,5 +75,6 @@ def main():
# 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)


if __name__ == '__main__':
main()
main()
10 changes: 5 additions & 5 deletions scripts/tools/telink/mfg_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 1724e4c

Please sign in to comment.