mirror of
https://github.com/Ai-Thinker-Open/Ai-Thinker-Open_RTL8710BX_ALIOS_SDK.git
synced 2024-12-04 19:40:27 +00:00
18 lines
580 B
Python
18 lines
580 B
Python
import os
|
|
import sys
|
|
import struct
|
|
import shutil
|
|
|
|
workdir = os.path.dirname(os.path.abspath(sys.argv[0]))
|
|
if sys.platform == 'linux2':
|
|
xzpath = 'xz'
|
|
else:
|
|
xzpath = os.path.join(workdir, 'xz', 'osx/xz' if sys.platform == 'darwin' else 'win/xz.exe').replace('\\', '/')
|
|
|
|
rawfile = sys.argv[1]
|
|
rawsize = os.path.getsize(rawfile)
|
|
xzfile = rawfile.replace('.bin', '.bin.xz')
|
|
otafile = rawfile.replace('.bin', '.ota.bin')
|
|
os.system('%s --lzma2=dict=32KiB --check=crc32 -k %s' % (xzpath, rawfile))
|
|
open(xzfile, 'ab').write(struct.pack('<L', rawsize))
|
|
shutil.move(xzfile, otafile)
|