Merge pull request #1734 from meshtastic/Build-Image

Build image
This commit is contained in:
Thomas Göttgens 2022-10-01 15:17:41 +02:00 committed by GitHub
commit 28384df702
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 64 additions and 17 deletions

View File

@ -29,14 +29,11 @@ SRCELF=.pio/build/$1/firmware.elf
cp $SRCELF $OUTDIR/$basename.elf cp $SRCELF $OUTDIR/$basename.elf
echo "Copying ESP32 bin file" echo "Copying ESP32 bin file"
SRCBIN=.pio/build/$1/firmware.bin SRCBIN=.pio/build/$1/firmware.factory.bin
cp $SRCBIN $OUTDIR/$basename.bin cp $SRCBIN $OUTDIR/$basename.bin
echo "Building Filesystem for ESP32 targets" echo "Building Filesystem for ESP32 targets"
pio run --environment tbeam -t buildfs pio run --environment tbeam -t buildfs
cp .pio/build/tbeam/littlefs.bin $OUTDIR/littlefs-$VERSION.bin cp .pio/build/tbeam/littlefs.bin $OUTDIR/littlefs-$VERSION.bin
cp images/system-info.bin $OUTDIR/system-info.bin
cp .pio/build/$1/partitions.bin $OUTDIR/partitions.bin
cp bin/device-install.* $OUTDIR cp bin/device-install.* $OUTDIR
cp bin/device-update.* $OUTDIR cp bin/device-update.* $OUTDIR

View File

@ -29,13 +29,11 @@ IF "__%FILENAME%__" == "____" (
IF EXIST %FILENAME% ( IF EXIST %FILENAME% (
echo Trying to flash update %FILENAME%, but first erasing and writing system information" echo Trying to flash update %FILENAME%, but first erasing and writing system information"
%PYTHON% -m esptool --baud 115200 erase_flash %PYTHON% -m esptool --baud 115200 erase_flash
%PYTHON% -m esptool --baud 115200 write_flash 0x1000 system-info.bin %PYTHON% -m esptool --baud 115200 write_flash 0x00 %FILENAME%
%PYTHON% -m esptool --baud 115200 write_flash 0x8000 partitions.bin %PYTHON% -m esptool --baud 115200 write_flash 0x260000 bleota.bin
for %%f in (littlefs-*.bin) do ( for %%f in (littlefs-*.bin) do (
%PYTHON% -m esptool --baud 115200 write_flash 0x300000 %%f %PYTHON% -m esptool --baud 115200 write_flash 0x300000 %%f
) )
%PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME%
%PYTHON% -m esptool --baud 115200 write_flash 0x260000 bleota.bin
) else ( ) else (
echo "Invalid file: %FILENAME%" echo "Invalid file: %FILENAME%"
goto HELP goto HELP

View File

@ -47,11 +47,10 @@ shift "$((OPTIND-1))"
if [ -f "${FILENAME}" ]; then if [ -f "${FILENAME}" ]; then
echo "Trying to flash ${FILENAME}, but first erasing and writing system information" echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
"$PYTHON" -m esptool erase_flash "$PYTHON" -m esptool erase_flash
"$PYTHON" -m esptool write_flash 0x1000 system-info.bin "$PYTHON" -m esptool write_flash 0x00 ${FILENAME}
"$PYTHON" -m esptool write_flash 0x8000 partitions.bin
"$PYTHON" -m esptool write_flash 0x300000 littlefs-*.bin
"$PYTHON" -m esptool write_flash 0x260000 bleota.bin "$PYTHON" -m esptool write_flash 0x260000 bleota.bin
"$PYTHON" -m esptool write_flash 0x10000 ${FILENAME} "$PYTHON" -m esptool write_flash 0x300000 littlefs-*.bin
else else
echo "Invalid file: ${FILENAME}" echo "Invalid file: ${FILENAME}"
show_help show_help

View File

@ -28,7 +28,7 @@ IF "__%FILENAME%__" == "____" (
) )
IF EXIST %FILENAME% ( IF EXIST %FILENAME% (
echo Trying to flash update %FILENAME% echo Trying to flash update %FILENAME%
%PYTHON% -m esptool --baud 115200 write_flash 0x10000 %FILENAME% %PYTHON% -m esptool --baud 115200 write_flash 0x00 %FILENAME%
) else ( ) else (
echo "Invalid file: %FILENAME%" echo "Invalid file: %FILENAME%"
goto HELP goto HELP

View File

@ -44,7 +44,7 @@ shift "$((OPTIND-1))"
if [ -f "${FILENAME}" ]; then if [ -f "${FILENAME}" ]; then
echo "Trying to flash update ${FILENAME}." echo "Trying to flash update ${FILENAME}."
$PYTHON -m esptool --baud 115200 write_flash 0x10000 ${FILENAME} $PYTHON -m esptool --baud 115200 write_flash 0x00 ${FILENAME}
else else
echo "Invalid file: ${FILENAME}" echo "Invalid file: ${FILENAME}"
show_help show_help

View File

@ -1,17 +1,70 @@
import subprocess import subprocess
import configparser import configparser
import traceback import traceback
import sys import sys
from os.path import join
from readprops import readProps from readprops import readProps
Import("env")
platform = env.PioPlatform()
def esp32_create_combined_bin(source, target, env):
# this sub is borrowed from ESPEasy build toolchain. It's licensed under GPL V3
# https://github.com/letscontrolit/ESPEasy/blob/mega/tools/pio/post_esp32.py
print("Generating combined binary for serial flashing")
app_offset = 0x10000
new_file_name = env.subst("$BUILD_DIR/${PROGNAME}.factory.bin")
sections = env.subst(env.get("FLASH_EXTRA_IMAGES"))
firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin")
chip = env.get("BOARD_MCU")
flash_size = env.BoardConfig().get("upload.flash_size")
flash_freq = env.BoardConfig().get("build.f_flash", '40m')
flash_freq = flash_freq.replace('000000L', 'm')
flash_mode = env.BoardConfig().get("build.flash_mode", "dio")
memory_type = env.BoardConfig().get("build.arduino.memory_type", "qio_qspi")
if flash_mode == "qio" or flash_mode == "qout":
flash_mode = "dio"
if memory_type == "opi_opi" or memory_type == "opi_qspi":
flash_mode = "dout"
cmd = [
"--chip",
chip,
"merge_bin",
"-o",
new_file_name,
"--flash_mode",
flash_mode,
"--flash_freq",
flash_freq,
"--flash_size",
flash_size,
]
print(" Offset | File")
for section in sections:
sect_adr, sect_file = section.split(" ", 1)
print(f" - {sect_adr} | {sect_file}")
cmd += [sect_adr, sect_file]
print(f" - {hex(app_offset)} | {firmware_name}")
cmd += [hex(app_offset), firmware_name]
print('Using esptool.py arguments: %s' % ' '.join(cmd))
esptool.main(cmd)
if (platform.name == "espressif32"):
sys.path.append(join(platform.get_package_dir("tool-esptoolpy")))
import esptool
env.AddPostAction("$BUILD_DIR/${PROGNAME}.bin", esp32_create_combined_bin)
Import("projenv") Import("projenv")
prefsLoc = projenv["PROJECT_DIR"] + "/version.properties" prefsLoc = projenv["PROJECT_DIR"] + "/version.properties"
verObj = readProps(prefsLoc) verObj = readProps(prefsLoc)
print("Using meshtastic platformio-custom.py, firmware version " + verObj['long']) print("Using meshtastic platformio-custom.py, firmware version " + verObj['long'])
# print("path is" + ','.join(sys.path))
# General options that are passed to the C and C++ compilers # General options that are passed to the C and C++ compilers
projenv.Append(CCFLAGS=[ projenv.Append(CCFLAGS=[

Binary file not shown.