forked from ExpressLRS/ExpressLRS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirmware.py
More file actions
40 lines (32 loc) · 758 Bytes
/
firmware.py
File metadata and controls
40 lines (32 loc) · 758 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python
from enum import Enum
from typing import NamedTuple
class MCUType(Enum):
STM32 = 0
ESP32 = 1
ESP8266 = 2
class DeviceType(Enum):
TX = 0
RX = 1
TX_Backpack = 2
VRx_Backpack = 3
class RadioType(Enum):
SX127X = 0
SX1280 = 1
class FirmwareOptions(NamedTuple):
hasWiFi: bool
hasBuzzer: bool
mcuType: MCUType
deviceType: DeviceType
radioChip: RadioType
luaName: str
bootloader: str
offset: int
firmware: str
def find_patch_location(mm):
return mm.find(b'\xBE\xEF\xBA\xBE\xCA\xFE\xF0\x0D')
def get_hardware(mm):
pos = mm.find(b'\xBE\xEF\xBA\xBE\xCA\xFE\xF0\x0D')
if pos != -1:
pos += 8 + 2 # Skip magic & version
return pos