22import sys
33
44
5- def gen_multi_bin (source , target , env ):
6- target_bin = target [0 ]
7- bin_path = os .path .dirname (target_bin .rstr ())
8- bin_target = os .path .join (bin_path , 'elrs.opentx.bin' )
9- with open (bin_target , "wb+" ) as _out :
10- _out .write (target_bin .get_contents ())
11- # append version information (24bytes) to end of the bin file
12- _out .write ("multi-x00000b81-01030073" .encode ('utf-8' ))
13- _out .close ()
14- sys .stdout .write ("Copy %s to SD card and choose flash external multi" % bin_target )
15- sys .stdout .flush ()
16-
17-
185def gen_elrs (source , target , env ):
19- #if not "_stock" in env['PIOENV']:
20- # return
216 source_bin = source [0 ]
227 sys .stdout .write ("Source bin: %s \n " % source_bin )
238 bin_path = os .path .dirname (source_bin .rstr ())
@@ -31,48 +16,3 @@ def gen_elrs(source, target, env):
3116 sys .stdout .write ("=====================================================================================================================================\n " )
3217 sys .stdout .write ("\n " )
3318 sys .stdout .flush ()
34-
35-
36- def gen_frsky (source , target , env ):
37- if "_stock" in env ['PIOENV' ]:
38- return
39- sys .stdout .write ("\n " )
40- sys .stdout .write ("\n " )
41- sys .stdout .write ("Building flashable .frk file...\n " )
42- target_bin = source [0 ] # target[0]
43- sys .stdout .write ("Source bin: %s \n " % target_bin )
44- bin_path = os .path .dirname (target_bin .rstr ())
45- bin_target = os .path .join (bin_path , 'elrs.frk' )
46- with open (bin_target , "wb+" ) as _out :
47- bin_content = target_bin .get_contents ()
48- # append FrSky header (16bytes)
49- '''
50- struct FrSkyFirmwareInformation_no_pack {
51- uint32_t fourcc; = 0x4B535246
52- uint8_t headerVersion; = 1
53- uint8_t firmwareVersionMajor;
54- uint8_t firmwareVersionMinor;
55- uint8_t firmwareVersionRevision;
56- uint32_t size; == len(bin_content)
57- uint8_t productFamily;
58- uint8_t productId;
59- uint16_t crc;
60- };
61- '''
62- sys .stdout .write ("Bin size: %u \n " % len (bin_content ))
63- _out .write (b"\x46 \x52 \x53 \x4B " ) # fourcc
64- _out .write (b"\x01 " ) # header version
65- _out .write (b"\x00 \x00 \x00 " ) # fw versions
66- size = len (bin_content ) + 16
67- _out .write (bytearray (
68- [size & 0xFF , size >> 8 & 0xFF , size >> 16 & 0xFF , size >> 24 & 0xFF ]))
69- _out .write (b"\x00 \x00 " ) # productFamily, productId
70- _out .write (b"\x00 \x00 " ) # crc
71- _out .write (bin_content )
72- _out .close ()
73- sys .stdout .write ("\n " )
74- sys .stdout .write ("=====================================================================================================================================\n " )
75- sys .stdout .write ("|| !!! Copy %s to SD card and choose flash external in order to flash via OpenTX !!! ||\n " % bin_target )
76- sys .stdout .write ("=====================================================================================================================================\n " )
77- sys .stdout .write ("\n " )
78- sys .stdout .flush ()
0 commit comments