fix combine.py to handle different bootloader offstes
This commit is contained in:
parent
74339a4809
commit
4d89dd36c2
2 changed files with 28 additions and 10 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -3,5 +3,6 @@ build/
|
||||||
# Regenerate sdkconfig from the sdkconfig.defaults* files.
|
# Regenerate sdkconfig from the sdkconfig.defaults* files.
|
||||||
sdkconfig.esp32
|
sdkconfig.esp32
|
||||||
sdkconfig.esp32c6
|
sdkconfig.esp32c6
|
||||||
|
sdkconfig.*.old
|
||||||
sdkconfig.old
|
sdkconfig.old
|
||||||
managed_components/
|
managed_components/
|
||||||
|
|
|
||||||
37
combine.py
37
combine.py
|
|
@ -1,20 +1,26 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import json
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def extract_firmware_version():
|
def extract_firmware_version():
|
||||||
with open('main/CommandHandler.cpp', 'r') as file:
|
with open('main/CommandHandler.cpp', 'r') as file:
|
||||||
for line in file:
|
for line in file:
|
||||||
if 'const char FIRMWARE_VERSION[] = ' in line:
|
if 'const char FIRMWARE_VERSION[] = ' in line:
|
||||||
# The line format is `const char FIRMWARE_VERSION[] = "2.0.0-adafruit";`
|
# The line format is `const char FIRMWARE_VERSION[] = "2.0.0-adafruit";`
|
||||||
# Split by double quote and get the second element
|
# Split by double quote and get the second element
|
||||||
version = line.split('"')[1]
|
version = line.split('"')[1]
|
||||||
return version
|
return version
|
||||||
|
raise RuntimeError("FIRMWARE_VERSION not found in CommandHandler.cpp")
|
||||||
|
|
||||||
|
def get_idf_target():
|
||||||
|
with open("build/config.env") as file:
|
||||||
|
config = json.load(file)
|
||||||
|
return config["IDF_TARGET"]
|
||||||
|
|
||||||
booloaderData = open("build/bootloader/bootloader.bin", "rb").read()
|
bootloaderData = open("build/bootloader/bootloader.bin", "rb").read()
|
||||||
partitionData = open("build/partition_table/partition-table.bin", "rb").read()
|
partitionData = open("build/partition_table/partition-table.bin", "rb").read()
|
||||||
#phyData = open("data/phy.bin", "rb").read()
|
#phyData = open("data/phy.bin", "rb").read()
|
||||||
appData = open("build/nina-fw.bin", "rb").read()
|
appData = open("build/nina-fw.bin", "rb").read()
|
||||||
|
|
@ -40,8 +46,19 @@ if outputSize % 1024:
|
||||||
outputData = bytearray(b"\xff") * outputSize
|
outputData = bytearray(b"\xff") * outputSize
|
||||||
|
|
||||||
# copy data: bootloader, partitions, app
|
# copy data: bootloader, partitions, app
|
||||||
for i in range(0, len(booloaderData)):
|
BOOTLOADER_OFFSET = {
|
||||||
outputData[0x1000 + i] = booloaderData[i]
|
"esp32" : 0x1000,
|
||||||
|
"esp32c6" : 0x0000,
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
target = get_idf_target()
|
||||||
|
bootloader_offset = BOOTLOADER_OFFSET[get_idf_target()]
|
||||||
|
except KeyError:
|
||||||
|
raise RuntimeError(f"unsupported IDF_TARGET: {target}")
|
||||||
|
|
||||||
|
for i in range(0, len(bootloaderData)):
|
||||||
|
outputData[bootloader_offset + i] = bootloaderData[i]
|
||||||
|
|
||||||
for i in range(0, len(partitionData)):
|
for i in range(0, len(partitionData)):
|
||||||
outputData[0x8000 + i] = partitionData[i]
|
outputData[0x8000 + i] = partitionData[i]
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue