@@ -382,7 +382,7 @@ def gen_raw_ec_keypair_from_der(key_file, pubkey_raw_file, privkey_raw_file):
382
382
f .write (public_number_y .to_bytes (32 , byteorder = 'big' ))
383
383
384
384
385
- def generate_nvs_csv (out_csv_filename ):
385
+ def generate_nvs_csv (output_dir , out_csv_filename ):
386
386
csv_content = 'key,type,encoding,value\n '
387
387
csv_content += 'chip-factory,namespace,,\n '
388
388
@@ -391,10 +391,11 @@ def generate_nvs_csv(out_csv_filename):
391
391
continue
392
392
csv_content += f"{ k } ,{ v ['type' ]} ,{ v ['encoding' ]} ,{ v ['value' ]} \n "
393
393
394
- with open (out_csv_filename , 'w' ) as f :
394
+ with open (os . path . join ( output_dir , out_csv_filename ) , 'w' ) as f :
395
395
f .write (csv_content )
396
396
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 ))))
398
399
399
400
400
401
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):
412
413
nvs_partition_gen .generate (nvs_args )
413
414
414
415
415
- def print_flashing_help (encrypt , bin_filename ):
416
+ def print_flashing_help (encrypt , output_dir , bin_filename ):
416
417
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 )))
418
419
if (encrypt ):
419
420
logging .info ('Run below command to flash {}' .format (NVS_KEY_PARTITION_BIN ))
420
421
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 )))
422
423
423
424
424
425
def clean_up ():
@@ -478,7 +479,7 @@ def any_base_int(s): return int(s, 0)
478
479
help = 'Encrypt the factory parititon NVS binary' )
479
480
parser .add_argument ('--no-bin' , action = 'store_false' , dest = 'generate_bin' ,
480
481
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' )
482
483
483
484
parser .add_argument ('-cf' , '--commissioning-flow' , type = any_base_int , default = 0 ,
484
485
help = 'Device commissioning flow, 0:Standard, 1:User-Intent, 2:Custom. \
@@ -506,10 +507,10 @@ def set_up_factory_data(args):
506
507
507
508
508
509
def generate_factory_partiton_binary (args ):
509
- generate_nvs_csv (FACTORY_PARTITION_CSV )
510
+ generate_nvs_csv (args . output_dir , FACTORY_PARTITION_CSV )
510
511
if args .generate_bin :
511
512
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 )
513
514
clean_up ()
514
515
515
516
0 commit comments