MCPcopy Create free account
hub / github.com/ExpressLRS/ExpressLRS / findFirmwareEnd

Function findFirmwareEnd

src/python/UnifiedConfiguration.py:12–35  ·  view source on GitHub ↗
(f)

Source from the content-addressed store, hash-verified

10
11
12def findFirmwareEnd(f):
13 f.seek(0, 0)
14 (magic, segments, _, _, _) = struct.unpack('<BBBBI', f.read(8))
15 if magic != 0xe9:
16 sys.stderr.write('The file provided does not the right magic for a firmware file!\n')
17 exit(1)
18
19 is8285 = False
20 if segments == 2: # we have to assume it's an ESP8266/85
21 f.seek(0x1000, 0)
22 (magic, segments, _, _, _) = struct.unpack('<BBBBI', f.read(8))
23 is8285 = True
24 else:
25 f.seek(24, 0)
26
27 for _ in range(segments):
28 (_, size) = struct.unpack('<II', f.read(8))
29 f.seek(size, 1)
30
31 pos = f.tell()
32 pos = (pos + 16) & ~15
33 if not is8285:
34 pos = pos + 32
35 return pos
36
37def appendToFirmware(firmware_file, product_name, lua_name, defines, config, layout_file, rx_as_tx):
38 product = (product_name.encode() + (b'\0' * 128))[0:128]

Callers 1

appendToFirmwareFunction · 0.85

Calls 2

readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected