فهرست منبع

add:添加量产脚本以及说明

Dozingfiretruck 1 سال پیش
والد
کامیت
1bd1e75cac
2فایلهای تغییر یافته به همراه83 افزوده شده و 0 حذف شده
  1. 68 0
      tools/main.py
  2. 15 0
      tools/量产脚本工具.md

+ 68 - 0
tools/main.py

@@ -0,0 +1,68 @@
+
+import os
+import subprocess
+import sys
+import serial
+import serial.tools.list_ports
+import time
+import traceback
+import _thread
+
+SPOOL = {}
+
+
+def burn_dev(device):
+    ser = None
+    linelen = len("I/main auth ok 680845463968338A185E air101")+1
+    try:
+        ser = serial.Serial(device, 115200, timeout=1)
+        ser.rts = False
+        data = ser.read(linelen)
+        ser.close()
+        #print(data)
+        if data and  b'CCC' in data :
+            # {} -ds {} -ws 115200 -c {} -rs rts -dl {}
+            print("***********刷机开始**************", device)
+            subprocess.check_call(["air101_flash.exe", "-ds", "2M", "-c", str(device), "-ws", "115200", "-rs", "rts", "-dl", "air10x.fls"])
+            print("***********刷机完成**************", device)
+
+        # TODO 读取授权信息,联网授权
+        ser = serial.Serial(device, 921600, timeout=1)
+        ser.rts = False
+        data = ser.read(linelen)
+        #ser.close()
+        
+        if data and b'auth ok' in data:
+            print("============设备已刷机且已激活===", device)
+            time.sleep(3)
+        else :
+            ser.close()
+            ser = None
+            print("===非刷机模式的COM===========", device)
+            time.sleep(3)
+        SPOOL.pop(str(device))
+    except Exception:
+        traceback.print_exc()
+        if ser :
+            ser.close()
+        time.sleep(1)
+
+def serial_lpop():
+    for item in serial.tools.list_ports.comports():
+        if "CH340" in str(item.description) :
+            if str(item.device) in SPOOL :
+                continue
+            SPOOL[str(item.device)] = True
+            _thread.start_new_thread(burn_dev, (item.device,))
+    print("===等待新的设备==========================")
+
+def main():
+    while 1:
+        try :
+            serial_lpop()
+        except Exception:
+            traceback.print_exc()
+        time.sleep(1)
+
+if __name__ == "__main__" :
+    main()

+ 15 - 0
tools/量产脚本工具.md

@@ -0,0 +1,15 @@
+# 量产脚本工具说明
+
+此目录下main.py即为简单的自动刷机脚本,**使用前先详细阅读说明与脚本**
+
+[LuatOS-SoC通用固件格式soc - LuatOS 文档](https://wiki.luatos.com/develop/contribute/soc_format.html)
+
+[命令行刷机指南 - LuatOS 文档](https://wiki.luatos.com/develop/soc_download.html)
+
+脚本本质就是调用命令行刷机,首先下载7z解压量产的soc文件,得到
+
+xxx.fls文件 
+
+air101_flash.exe文件
+
+air101_flash.exe即为刷机程序,xxx.fls为需要烧录的固件,确认main.py中调用命令行代码处`subprocess.check_call(["air101_flash.exe"` 后面的命令行参数与你实际使用芯片参数匹配后,执行即可