Przeglądaj źródła

add: 串口固件和usb固件一次性生成好

Wendal Chen 3 lat temu
rodzic
commit
41f8b3e72c
1 zmienionych plików z 21 dodań i 1 usunięć
  1. 21 1
      luatos/makesoc.py

+ 21 - 1
luatos/makesoc.py

@@ -4,6 +4,7 @@
 import os
 import shutil
 import re
+import json
 
 bootloader_bin = './build/bootloader/bootloader.bin'
 partition_table_bin = './build/partition_table/partition-table.bin'
@@ -25,16 +26,35 @@ if __name__=='__main__':
     fo.close()# 关闭文件
     out_file="LuatOS-SoC_{}_{}".format(bsp_version, bsp)
 
-    print(cwd_path)
+    #print(cwd_path)
 
     if os.path.exists(out_path+out_file+'.soc'):
         os.remove(out_path+out_file+'.soc')
+    if os.path.exists(out_path+out_file+'_USB.soc'):
+        os.remove(out_path+out_file+'_USB.soc')
 
+    with open(pack_path + "/info.json", "rb") as f :
+        fdata = f.read()
+    with open(pack_path + "/info.json") as f :
+        info_json = json.load(f)
+
+    # 首先, 生成不带USB后缀的soc文件
     shutil.copy(bootloader_bin, pack_path+'/')
     shutil.copy(partition_table_bin, pack_path+'/')
     shutil.copy(luatos_bin, pack_path+'/')
 
     shutil.make_archive(out_path+out_file, 'zip', root_dir=pack_path)
     os.rename(out_path+out_file+'.zip',out_file+'.soc')
+
+    # 然后生成USB版本的soc文件
+    with open(pack_path + "/info.json", "w") as f :
+        info_json["download"]["force_br"] = "0"
+        json.dump(info_json, f)
+    shutil.make_archive(out_path+out_file, 'zip', root_dir=pack_path)
+    os.rename(out_path+out_file+'.zip',out_file+'_USB.soc')
+
+    # 还原info.json
+    with open(pack_path + "/info.json", "wb") as f :
+        f.write(fdata)
     
     print('done', out_file)