├── 1.bin ├── 1.rbl ├── README.md ├── gzipHeader.bin ├── my_1.rbl ├── ota_packager_python.py └── 对比图.png /1.bin: -------------------------------------------------------------------------------- 1 | 0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF0123456789ABCDEF -------------------------------------------------------------------------------- /1.rbl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunkr1995/RT_ota_packager_python/6c3010a07c5dbd20f187ac35e26cdf094f7bdbc3/1.rbl -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 9 | # RT-Thread OTA 固件打包器 python版本 10 | 11 | RT-Thread OTA 固件打包器原始的固件打包器操作不便,无法在linux上运行,不便于自动打包,自动更新版本。 12 | 于是研究了几天,写了一个python的版本,现仅支持gzip压缩,(对我来说足够了。。。quicklz实在太古老。。。) 13 | 14 | 随便搞了个二进制文件,与原固件打包器的对比如图: 15 | ![avatar](对比图.png) -------------------------------------------------------------------------------- /gzipHeader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunkr1995/RT_ota_packager_python/6c3010a07c5dbd20f187ac35e26cdf094f7bdbc3/gzipHeader.bin -------------------------------------------------------------------------------- /my_1.rbl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sunkr1995/RT_ota_packager_python/6c3010a07c5dbd20f187ac35e26cdf094f7bdbc3/my_1.rbl -------------------------------------------------------------------------------- /ota_packager_python.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Author: your name 3 | Date: 2021-07-15 10:05:16 4 | LastEditTime: 2021-07-20 14:25:35 5 | LastEditors: Please set LastEditors 6 | Description: In User Settings Edit 7 | FilePath: \pkg\3.py 8 | ''' 9 | import gzip 10 | import os 11 | import struct 12 | import zlib 13 | 14 | from Crypto import Random 15 | from Crypto.Cipher import AES 16 | 17 | """ 18 | aes加密算法 19 | padding : PKCS7 20 | """ 21 | 22 | class AESUtil: 23 | 24 | __BLOCK_SIZE_16 = BLOCK_SIZE_16 = AES.block_size 25 | 26 | @staticmethod 27 | def encryt(string, key, iv): 28 | """ 29 | 加密文本 30 | :param string: 文本 31 | :param key: 密钥 32 | :param iv: 偏移量/初始向量 33 | :return: 密文 34 | """ 35 | #print (string) 36 | 37 | cipher = AES.new(key, AES.MODE_CBC, iv) 38 | x = AESUtil.__BLOCK_SIZE_16 - (len(string) % AESUtil.__BLOCK_SIZE_16) 39 | # 如果最后一块不够16位需要用字符进行补全 40 | if x != 0: 41 | string = string + bytes(chr(x)*x,encoding="utf-8") 42 | 43 | msg = cipher.encrypt(string) 44 | 45 | # msg = base64.urlsafe_b64encode(msg).replace('=', '') 46 | # msg = base64.b64encode(msg) 47 | return msg 48 | 49 | @staticmethod 50 | def decrypt(en_str, key, iv): 51 | cipher = AES.new(key, AES.MODE_CBC, iv) 52 | # en_str += (len(en_str) % 4)*"=" 53 | # decryptByts = base64.urlsafe_b64decode(en_str) 54 | # decryptByts = base64.b64decode(en_str) 55 | # msg = cipher.decrypt(decryptByts) 56 | 57 | msg = cipher.decrypt(en_str) 58 | padding_len = msg[len(msg)-1] 59 | return msg[0:-padding_len] 60 | 61 | 62 | def crc32(bytes_obj): 63 | hashs = 0 64 | hashs = zlib.crc32(bytes_obj) 65 | return hashs 66 | 67 | def fnv1a_r(oneByte,has): 68 | return ((oneByte ^ has)*0x1000193) & 0xFFFFFFFF 69 | 70 | def getHashCode(data): 71 | has = 0x811c9dc5 72 | for i in range(len(data)): 73 | has = fnv1a_r(data[i],has) 74 | return has 75 | 76 | def gethead(filename,ori_obj,dst_obj): 77 | ### ("type_4") 78 | type_name = b'RBL' 79 | type_4 = struct.pack('4s',type_name) 80 | 81 | ### ("fota_algo") 82 | fota_algo = 258#int(statinfo.st_ctime) 83 | algo = struct.pack('