forked from arduino/ArduinoCore-renesas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcombine.py
executable file
·40 lines (27 loc) · 1.08 KB
/
combine.py
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/python3
import sys;
basePath = "esp-hosted/esp_hosted_fg/esp/esp_driver/network_adapter/"
booloaderData = open(basePath + "build/bootloader/bootloader.bin", "rb").read()
partitionData = open(basePath + "build/partition_table/partition-table.bin", "rb").read()
networkData = open(basePath + "build/network_adapter.bin", "rb").read()
# 0x0 bootloader.bin 0x8000 partition-table.bin 0x10000 network_adapter.bin
# calculate the output binary size, app offset
outputSize = 0x10000 + len(networkData)
if (outputSize % 1024):
outputSize += 1024 - (outputSize % 1024)
# allocate and init to 0xff
outputData = bytearray(b'\xff') * outputSize
# copy data: bootloader, partitions, app
for i in range(0, len(booloaderData)):
outputData[0x0000 + i] = booloaderData[i]
for i in range(0, len(partitionData)):
outputData[0x8000 + i] = partitionData[i]
for i in range(0, len(networkData)):
outputData[0x10000 + i] = networkData[i]
outputFilename = "ESP32-C3.bin"
if (len(sys.argv) > 1):
outputFilename = sys.argv[1]
# write out
with open(outputFilename,"w+b") as f:
f.seek(0)
f.write(outputData)