Skip to content

Commit cfb9404

Browse files
[ESP32] Fixed the output file name in log output for ESP32 factory partition script. (#33162)
* Fixed the output file name in log output for ESP32 factory partition script * Restyled by autopep8 --------- Co-authored-by: Restyled.io <[email protected]>
1 parent 8b1fd13 commit cfb9404

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

scripts/tools/generate_esp32_chip_factory_bin.py

+10-9
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ def gen_raw_ec_keypair_from_der(key_file, pubkey_raw_file, privkey_raw_file):
382382
f.write(public_number_y.to_bytes(32, byteorder='big'))
383383

384384

385-
def generate_nvs_csv(out_csv_filename):
385+
def generate_nvs_csv(output_dir, out_csv_filename):
386386
csv_content = 'key,type,encoding,value\n'
387387
csv_content += 'chip-factory,namespace,,\n'
388388

@@ -391,10 +391,11 @@ def generate_nvs_csv(out_csv_filename):
391391
continue
392392
csv_content += f"{k},{v['type']},{v['encoding']},{v['value']}\n"
393393

394-
with open(out_csv_filename, 'w') as f:
394+
with open(os.path.join(output_dir, out_csv_filename), 'w') as f:
395395
f.write(csv_content)
396396

397-
logging.info('Generated the factory partition csv file : {}'.format(os.path.abspath(out_csv_filename)))
397+
logging.info('Generated the factory partition csv file : {}'.format(
398+
os.path.abspath(os.path.join(output_dir, out_csv_filename))))
398399

399400

400401
def generate_nvs_bin(encrypt, size, csv_filename, bin_filename, output_dir):
@@ -412,13 +413,13 @@ def generate_nvs_bin(encrypt, size, csv_filename, bin_filename, output_dir):
412413
nvs_partition_gen.generate(nvs_args)
413414

414415

415-
def print_flashing_help(encrypt, bin_filename):
416+
def print_flashing_help(encrypt, output_dir, bin_filename):
416417
logging.info('Run below command to flash {}'.format(bin_filename))
417-
logging.info('esptool.py -p (PORT) write_flash (FACTORY_PARTITION_ADDR) {}'.format(os.path.join(os.getcwd(), bin_filename)))
418+
logging.info('esptool.py -p (PORT) write_flash (FACTORY_PARTITION_ADDR) {}'.format(os.path.join(os.getcwd(), output_dir, bin_filename)))
418419
if (encrypt):
419420
logging.info('Run below command to flash {}'.format(NVS_KEY_PARTITION_BIN))
420421
logging.info('esptool.py -p (PORT) write_flash --encrypt (NVS_KEY_PARTITION_ADDR) {}'.format(
421-
os.path.join(os.getcwd(), 'keys', NVS_KEY_PARTITION_BIN)))
422+
os.path.join(os.getcwd(), output_dir, 'keys', NVS_KEY_PARTITION_BIN)))
422423

423424

424425
def clean_up():
@@ -478,7 +479,7 @@ def any_base_int(s): return int(s, 0)
478479
help='Encrypt the factory parititon NVS binary')
479480
parser.add_argument('--no-bin', action='store_false', dest='generate_bin',
480481
help='Do not generate the factory partition binary')
481-
parser.add_argument('--output_dir', type=str, default='bin', help='Created image output file path')
482+
parser.add_argument('--output_dir', type=str, default='out', help='Created image output file path')
482483

483484
parser.add_argument('-cf', '--commissioning-flow', type=any_base_int, default=0,
484485
help='Device commissioning flow, 0:Standard, 1:User-Intent, 2:Custom. \
@@ -506,10 +507,10 @@ def set_up_factory_data(args):
506507

507508

508509
def generate_factory_partiton_binary(args):
509-
generate_nvs_csv(FACTORY_PARTITION_CSV)
510+
generate_nvs_csv(args.output_dir, FACTORY_PARTITION_CSV)
510511
if args.generate_bin:
511512
generate_nvs_bin(args.encrypt, args.size, FACTORY_PARTITION_CSV, FACTORY_PARTITION_BIN, args.output_dir)
512-
print_flashing_help(args.encrypt, FACTORY_PARTITION_BIN)
513+
print_flashing_help(args.encrypt, args.output_dir, FACTORY_PARTITION_BIN)
513514
clean_up()
514515

515516

0 commit comments

Comments
 (0)