Skip to content

Commit 8d09c2e

Browse files
committed
Meshtastic build manifest
1 parent 9c5513d commit 8d09c2e

File tree

9 files changed

+87
-10
lines changed

9 files changed

+87
-10
lines changed

.github/workflows/build_firmware.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
name: firmware-${{ inputs.platform }}-${{ inputs.pio_env }}-${{ inputs.version }}.zip
6363
overwrite: true
6464
path: |
65+
release/*.mt.json
6566
release/*.bin
6667
release/*.elf
6768
release/*.uf2

.github/workflows/main_matrix.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ on:
2727

2828
jobs:
2929
setup:
30-
if: github.repository == 'meshtastic/firmware'
3130
strategy:
3231
fail-fast: true
3332
matrix:
@@ -42,10 +41,6 @@ jobs:
4241
python-version: 3.x
4342
cache: pip
4443
- run: pip install -U platformio
45-
- name: Uncomment build epoch
46-
shell: bash
47-
run: |
48-
sed -i 's/#-DBUILD_EPOCH=$UNIX_TIME/-DBUILD_EPOCH=$UNIX_TIME/' platformio.ini
4944
- name: Generate matrix
5045
id: jsonStep
5146
run: |
@@ -62,7 +57,6 @@ jobs:
6257
check: ${{ steps.jsonStep.outputs.check }}
6358

6459
version:
65-
if: github.repository == 'meshtastic/firmware'
6660
runs-on: ubuntu-latest
6761
steps:
6862
- uses: actions/checkout@v5
@@ -226,6 +220,7 @@ jobs:
226220
name: firmware-${{matrix.arch}}-${{ needs.version.outputs.long }}
227221
overwrite: true
228222
path: |
223+
./firmware-*.mt.json
229224
./firmware-*.bin
230225
./firmware-*.uf2
231226
./firmware-*.hex

bin/build-esp32.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export APP_VERSION=$VERSION
2222
basename=firmware-$1-$VERSION
2323

2424
pio run --environment $1 # -v
25+
26+
SRCMANIFEST=.pio/build/$1/meshtastic.json
27+
cp $SRCMANIFEST $OUTDIR/$basename.mt.json
28+
2529
SRCELF=.pio/build/$1/firmware.elf
2630
cp $SRCELF $OUTDIR/$basename.elf
2731

bin/build-nrf52.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export APP_VERSION=$VERSION
2222
basename=firmware-$1-$VERSION
2323

2424
pio run --environment $1 # -v
25+
26+
SRCMANIFEST=.pio/build/$1/meshtastic.json
27+
cp $SRCMANIFEST $OUTDIR/$basename.mt.json
28+
2529
SRCELF=.pio/build/$1/firmware.elf
2630
cp $SRCELF $OUTDIR/$basename.elf
2731

bin/build-rp2xx0.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export APP_VERSION=$VERSION
2222
basename=firmware-$1-$VERSION
2323

2424
pio run --environment $1 # -v
25+
26+
SRCMANIFEST=.pio/build/$1/meshtastic.json
27+
cp $SRCMANIFEST $OUTDIR/$basename.mt.json
28+
2529
SRCELF=.pio/build/$1/firmware.elf
2630
cp $SRCELF $OUTDIR/$basename.elf
2731

bin/build-stm32wl.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ export APP_VERSION=$VERSION
2222
basename=firmware-$1-$VERSION
2323

2424
pio run --environment $1 # -v
25+
26+
SRCMANIFEST=.pio/build/$1/meshtastic.json
27+
cp $SRCMANIFEST $OUTDIR/$basename.mt.json
28+
2529
SRCELF=.pio/build/$1/firmware.elf
2630
cp $SRCELF $OUTDIR/$basename.elf
2731

bin/device-install.bat

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,25 @@ IF NOT EXIST !FILENAME! (
9393
GOTO eof
9494
)
9595

96+
CALL :LOG_MESSAGE DEBUG "Checking for metadata..."
97+
@REM Derive metadata filename from firmware filename.
98+
SET "METAFILE=!FILENAME:.bin=!.mt.json"
99+
IF EXIST !METAFILE! (
100+
@REM Print parsed json with powershell
101+
CALL :LOG_MESSAGE INFO "Firmware metadata: !METAFILE!"
102+
powershell -NoProfile -Command "(Get-Content '!METAFILE!' | ConvertFrom-Json | Out-String).Trim()"
103+
104+
@REM Save metadata values to variables for later use.
105+
FOR /f "usebackq" %%A IN (`powershell -NoProfile -Command ^
106+
"(Get-Content '!METAFILE!' | ConvertFrom-Json).part_csv"`) DO SET "PART_CSV=%%A"
107+
FOR /f "usebackq" %%A IN (`powershell -NoProfile -Command ^
108+
"(Get-Content '!METAFILE!' | ConvertFrom-Json).has_mui"`) DO SET "HAS_MUI=%%A"
109+
FOR /f "usebackq" %%A IN (`powershell -NoProfile -Command ^
110+
"(Get-Content '!METAFILE!' | ConvertFrom-Json).mcu"`) DO SET "MCU=%%A"
111+
) ELSE (
112+
CALL :LOG_MESSAGE WARN "No metadata file found: !METAFILE!"
113+
)
114+
96115
IF NOT "!FILENAME:update=!"=="!FILENAME!" (
97116
CALL :LOG_MESSAGE DEBUG "We are working with a *update* file. !FILENAME!"
98117
CALL :LOG_MESSAGE INFO "Use script device-update.bat to flash update !FILENAME!."

bin/device-install.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ else
7676
exit 1
7777
fi
7878

79+
# Check for jq
80+
if ! command -v jq >/dev/null 2>&1; then
81+
echo "Error: jq not found" >&2
82+
echo "Install jq with your package manager." >&2
83+
echo "e.g. 'apt install jq', 'dnf install jq', 'brew install jq', etc." >&2
84+
exit 1
85+
fi
86+
7987
set -e
8088

8189
# Usage info
@@ -141,14 +149,29 @@ if [[ "$FILENAME" != firmware-* ]]; then
141149
exit 1
142150
fi
143151

152+
# Extract BASENAME from %FILENAME% for later use.
153+
BASENAME="${FILENAME/firmware-/}"
154+
155+
# Derive metadata filename from firmware filename.
156+
METAFILE="${FILENAME%.bin}.mt.json"
157+
158+
# Display metadata if it exists
159+
if [[ -f "$METAFILE" ]]; then
160+
echo "Firmware metadata: ${METAFILE}"
161+
jq . "$METAFILE"
162+
# Extract relevant fields from metadata
163+
PART_CSV=$(jq -r '.part_csv' "$METAFILE")
164+
HAS_MUI=$(jq -r '.has_mui' "$METAFILE")
165+
MCU=$(jq -r '.mcu' "$METAFILE")
166+
else
167+
echo "WARNING: No metadata file found: ${METAFILE}"
168+
fi
169+
144170
# Check if FILENAME contains "-tft-" and set target partitionScheme accordingly.
145171
if [[ "${FILENAME//-tft-/}" != "$FILENAME" ]]; then
146172
TFT_BUILD=true
147173
fi
148174

149-
# Extract BASENAME from %FILENAME% for later use.
150-
BASENAME="${FILENAME/firmware-/}"
151-
152175
if [ -f "${FILENAME}" ] && [ -n "${FILENAME##*"update"*}" ]; then
153176
# Default littlefs* offset.
154177
OFFSET=0x300000

bin/platformio-custom.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# trunk-ignore-all(ruff/F821)
33
# trunk-ignore-all(flake8/F821): For SConstruct imports
44
import sys
5-
from os.path import join
5+
from os.path import join, basename
66
import subprocess
77
import json
88
import re
@@ -181,3 +181,26 @@ def load_boot_logo(source, target, env):
181181
# Load the boot logo on TFT builds
182182
if ("HAS_TFT", 1) in env.get("CPPDEFINES", []):
183183
env.AddPreAction('$BUILD_DIR/littlefs.bin', load_boot_logo)
184+
185+
def write_manifest(source, target, env):
186+
manifest = {
187+
"version": verObj["long"],
188+
"build_epoch": build_epoch,
189+
"board": env.get("PIOENV"),
190+
"mcu": env.get("BOARD_MCU"),
191+
"repo": repo_owner,
192+
"part_csv": None,
193+
"has_mui": False
194+
}
195+
# Include the partitions CSV filename if it is set
196+
if env.get("PARTITIONS_TABLE_CSV"):
197+
manifest["part_csv"] = basename(env.get("PARTITIONS_TABLE_CSV"))
198+
# Enable MUI flag for TFT builds
199+
if ("HAS_TFT", 1) in env.get("CPPDEFINES", []):
200+
manifest["has_mui"] = True
201+
202+
# Write the manifest to the build directory
203+
with open(f"{env['PROJECT_BUILD_DIR']}/{env.get('PIOENV')}/meshtastic.json", "w") as f:
204+
json.dump(manifest, f, indent=4)
205+
206+
env.AddPostAction("$PROGPATH", write_manifest)

0 commit comments

Comments
 (0)