Skip to content

Commit a48db7b

Browse files
committed
Meshtastic build manifest
1 parent fe2e275 commit a48db7b

File tree

12 files changed

+276
-70
lines changed

12 files changed

+276
-70
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: 2 additions & 7 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,10 +220,11 @@ 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
232-
./firmware-*-ota.zip
227+
./firmware-*.zip
233228
./device-*.sh
234229
./device-*.bat
235230
./littlefs-*.bin

bin/build-esp32.sh

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -e
55
VERSION=`bin/buildinfo.py long`
66
SHORT_VERSION=`bin/buildinfo.py short`
77

8-
OUTDIR=release/
8+
BUILDDIR=.pio/build/$1
9+
OUTDIR=release
910

1011
rm -f $OUTDIR/firmware*
1112
rm -r $OUTDIR/* || true
@@ -14,24 +15,22 @@ rm -r $OUTDIR/* || true
1415
platformio pkg install -e $1
1516

1617
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
17-
rm -f .pio/build/$1/firmware.*
18+
rm -f $BUILDDIR/firmware*
1819

1920
# The shell vars the build tool expects to find
2021
export APP_VERSION=$VERSION
2122

2223
basename=firmware-$1-$VERSION
2324

2425
pio run --environment $1 # -v
25-
SRCELF=.pio/build/$1/firmware.elf
26-
cp $SRCELF $OUTDIR/$basename.elf
26+
27+
cp $BUILDDIR/$basename.elf $OUTDIR/$basename.elf
2728

2829
echo "Copying ESP32 bin file"
29-
SRCBIN=.pio/build/$1/firmware.factory.bin
30-
cp $SRCBIN $OUTDIR/$basename.bin
30+
cp $BUILDDIR/$basename.factory.bin $OUTDIR/$basename.factory.bin
3131

3232
echo "Copying ESP32 update bin file"
33-
SRCBIN=.pio/build/$1/firmware.bin
34-
cp $SRCBIN $OUTDIR/$basename-update.bin
33+
cp $BUILDDIR/$basename.bin $OUTDIR/$basename.bin
3534

3635
echo "Building Filesystem for ESP32 targets"
3736
# If you want to build the webui, uncomment the following lines
@@ -41,6 +40,10 @@ echo "Building Filesystem for ESP32 targets"
4140
# ls -l data/static # Diagnostic list of files
4241
# rm -rf data/static
4342
pio run --environment $1 -t buildfs
44-
cp .pio/build/$1/littlefs.bin $OUTDIR/littlefs-$1-$VERSION.bin
45-
cp bin/device-install.* $OUTDIR
46-
cp bin/device-update.* $OUTDIR
43+
cp $BUILDDIR/littlefs-$1-$VERSION.bin $OUTDIR/littlefs-$1-$VERSION.bin
44+
cp bin/device-install.* $OUTDIR/
45+
cp bin/device-update.* $OUTDIR/
46+
47+
# Generate the manifest file
48+
pio run --environment $1 -t mtjson
49+
cp $BUILDDIR/$basename.mt.json $OUTDIR/$basename.mt.json

bin/build-native.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ VERSION=$(bin/buildinfo.py long)
1717
SHORT_VERSION=$(bin/buildinfo.py short)
1818
PIO_ENV=${1:-native}
1919

20-
OUTDIR=release/
20+
BUILDDIR=.pio/build/$PIO_ENV
21+
OUTDIR=release
2122

22-
rm -f $OUTDIR/firmware*
23+
rm -f $OUTDIR/meshtasticd*
2324

2425
mkdir -p $OUTDIR/
2526
rm -r $OUTDIR/* || true
2627

28+
basename=meshtasticd-$1-$VERSION
29+
2730
# Important to pull latest version of libs into all device flavors, otherwise some devices might be stale
2831
pio pkg install --environment "$PIO_ENV" || platformioFailed
2932
pio run --environment "$PIO_ENV" || platformioFailed
30-
cp ".pio/build/$PIO_ENV/program" "$OUTDIR/meshtasticd_linux_$(uname -m)"
31-
cp bin/native-install.* $OUTDIR
33+
34+
cp "$BUILDDIR/$basename" "$OUTDIR/meshtasticd_linux_$(uname -m)"
35+
cp bin/native-install.* $OUTDIR/

bin/build-nrf52.sh

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -e
55
VERSION=$(bin/buildinfo.py long)
66
SHORT_VERSION=$(bin/buildinfo.py short)
77

8-
OUTDIR=release/
8+
BUILDDIR=.pio/build/$1
9+
OUTDIR=release
910

1011
rm -f $OUTDIR/firmware*
1112
rm -r $OUTDIR/* || true
@@ -14,40 +15,44 @@ rm -r $OUTDIR/* || true
1415
platformio pkg install -e $1
1516

1617
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
17-
rm -f .pio/build/$1/firmware.*
18+
rm -f $BUILDDIR/firmware.*
1819

1920
# The shell vars the build tool expects to find
2021
export APP_VERSION=$VERSION
2122

2223
basename=firmware-$1-$VERSION
2324

2425
pio run --environment $1 # -v
25-
SRCELF=.pio/build/$1/firmware.elf
26-
cp $SRCELF $OUTDIR/$basename.elf
2726

28-
echo "Generating NRF52 dfu file"
29-
DFUPKG=.pio/build/$1/firmware.zip
30-
cp $DFUPKG $OUTDIR/$basename-ota.zip
27+
cp $BUILDDIR/$basename.elf $OUTDIR/$basename.elf
3128

32-
echo "Generating NRF52 uf2 file"
33-
SRCHEX=.pio/build/$1/firmware.hex
29+
echo "Copying NRF52 dfu (OTA) file"
30+
cp $BUILDDIR/$basename.zip $OUTDIR/$basename.zip
31+
32+
SRCHEX=$BUILDDIR/$basename.hex
3433

3534
# if WM1110 target, merge hex with softdevice 7.3.0
35+
# TODO move this logic into platformio-custom.py
3636
if (echo $1 | grep -q "wio-sdk-wm1110"); then
3737
echo "Merging with softdevice"
38-
bin/mergehex -m bin/s140_nrf52_7.3.0_softdevice.hex $SRCHEX -o .pio/build/$1/$basename.hex
39-
SRCHEX=.pio/build/$1/$basename.hex
38+
bin/mergehex -m bin/s140_nrf52_7.3.0_softdevice.hex $SRCHEX -o $BUILDDIR/$basename.merged.hex
39+
SRCHEX=$BUILDDIR/$basename.merged.hex
4040
bin/uf2conv.py $SRCHEX -c -o $OUTDIR/$basename.uf2 -f 0xADA52840
41-
cp $SRCHEX $OUTDIR
42-
cp bin/*.uf2 $OUTDIR
41+
cp $SRCHEX $OUTDIR/
42+
cp bin/*.uf2 $OUTDIR/
4343
else
44-
bin/uf2conv.py $SRCHEX -c -o $OUTDIR/$basename.uf2 -f 0xADA52840
45-
cp bin/device-install.* $OUTDIR
46-
cp bin/device-update.* $OUTDIR
47-
cp bin/*.uf2 $OUTDIR
44+
# UF2 generated by default as part of platformio-custom.py
45+
cp $BUILDDIR/$basename.uf2 $OUTDIR/$basename.uf2
46+
cp bin/device-install.* $OUTDIR/
47+
cp bin/device-update.* $OUTDIR/
48+
cp bin/*.uf2 $OUTDIR/
4849
fi
4950

5051
if (echo $1 | grep -q "rak4631"); then
5152
echo "Copying hex file"
52-
cp .pio/build/$1/firmware.hex $OUTDIR/$basename.hex
53-
fi
53+
cp $SRCHEX $OUTDIR/$basename.hex
54+
fi
55+
56+
# Generate the manifest file
57+
pio run --environment $1 -t mtjson
58+
cp $BUILDDIR/$basename.mt.json $OUTDIR/$basename.mt.json

bin/build-rp2xx0.sh

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -e
55
VERSION=`bin/buildinfo.py long`
66
SHORT_VERSION=`bin/buildinfo.py short`
77

8-
OUTDIR=release/
8+
BUILDDIR=.pio/build/$1
9+
OUTDIR=release
910

1011
rm -f $OUTDIR/firmware*
1112
rm -r $OUTDIR/* || true
@@ -14,20 +15,23 @@ rm -r $OUTDIR/* || true
1415
platformio pkg install -e $1
1516

1617
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
17-
rm -f .pio/build/$1/firmware.*
18+
rm -f $BUILDDIR/firmware*
1819

1920
# The shell vars the build tool expects to find
2021
export APP_VERSION=$VERSION
2122

2223
basename=firmware-$1-$VERSION
2324

2425
pio run --environment $1 # -v
25-
SRCELF=.pio/build/$1/firmware.elf
26-
cp $SRCELF $OUTDIR/$basename.elf
26+
27+
cp $BUILDDIR/$basename.elf $OUTDIR/$basename.elf
2728

2829
echo "Copying uf2 file"
29-
SRCBIN=.pio/build/$1/firmware.uf2
30-
cp $SRCBIN $OUTDIR/$basename.uf2
30+
cp $BUILDDIR/$basename.uf2 $OUTDIR/$basename.uf2
31+
32+
cp bin/device-install.* $OUTDIR/
33+
cp bin/device-update.* $OUTDIR/
3134

32-
cp bin/device-install.* $OUTDIR
33-
cp bin/device-update.* $OUTDIR
35+
# Generate the manifest file
36+
pio run --environment $1 -t mtjson
37+
cp $BUILDDIR/$basename.mt.json $OUTDIR/$basename.mt.json

bin/build-stm32wl.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ set -e
55
VERSION=$(bin/buildinfo.py long)
66
SHORT_VERSION=$(bin/buildinfo.py short)
77

8-
OUTDIR=release/
8+
BUILDDIR=.pio/build/$1
9+
OUTDIR=release
910

1011
rm -f $OUTDIR/firmware*
1112
rm -r $OUTDIR/* || true
@@ -14,16 +15,20 @@ rm -r $OUTDIR/* || true
1415
platformio pkg install -e $1
1516

1617
echo "Building for $1 with $PLATFORMIO_BUILD_FLAGS"
17-
rm -f .pio/build/$1/firmware.*
18+
rm -f $BUILDDIR/firmware*
1819

1920
# The shell vars the build tool expects to find
2021
export APP_VERSION=$VERSION
2122

2223
basename=firmware-$1-$VERSION
2324

2425
pio run --environment $1 # -v
25-
SRCELF=.pio/build/$1/firmware.elf
26-
cp $SRCELF $OUTDIR/$basename.elf
2726

28-
SRCBIN=.pio/build/$1/firmware.bin
29-
cp $SRCBIN $OUTDIR/$basename.bin
27+
cp $BUILDDIR/$basename.elf $OUTDIR/$basename.elf
28+
29+
echo "Copying STM32 bin file"
30+
cp $BUILDDIR/$basename.bin $OUTDIR/$basename.bin
31+
32+
# Generate the manifest file
33+
pio run --environment $1 -t mtjson
34+
cp $BUILDDIR/$basename.mt.json $OUTDIR/$basename.mt.json

bin/device-install.bat

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,27 @@ 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).mcu"`) DO SET "MCU=%%A"
107+
FOR /f "usebackq" %%A IN (`powershell -NoProfile -Command ^
108+
"(Get-Content '!METAFILE!' | ConvertFrom-Json).part | Where-Object { $_.subtype -eq 'ota_1' } | Select-Object -ExpandProperty offset"`
109+
) DO SET "OTA_OFFSET=%%A"
110+
FOR /f "usebackq" %%A IN (`powershell -NoProfile -Command ^
111+
"(Get-Content '!METAFILE!' | ConvertFrom-Json).part | Where-Object { $_.subtype -eq 'spiffs' } | Select-Object -ExpandProperty offset"`
112+
) DO SET "SPIFFS_OFFSET=%%A"
113+
) ELSE (
114+
CALL :LOG_MESSAGE WARN "No metadata file found: !METAFILE!"
115+
)
116+
96117
IF NOT "!FILENAME:update=!"=="!FILENAME!" (
97118
CALL :LOG_MESSAGE DEBUG "We are working with a *update* file. !FILENAME!"
98119
CALL :LOG_MESSAGE INFO "Use script device-update.bat to flash update !FILENAME!."

bin/device-install.sh

Lines changed: 28 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,31 @@ 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+
if [[ $(jq -r '.part' "$METAFILE") != "null" ]]; then
164+
OTA_OFFSET=$(jq -r '.part[] | select(.subtype == "ota_1") | .offset' "$METAFILE")
165+
SPIFFS_OFFSET=$(jq -r '.part[] | select(.subtype == "spiffs") | .offset' "$METAFILE")
166+
fi
167+
MCU=$(jq -r '.mcu' "$METAFILE")
168+
else
169+
echo "WARNING: No metadata file found: ${METAFILE}"
170+
fi
171+
144172
# Check if FILENAME contains "-tft-" and set target partitionScheme accordingly.
145173
if [[ "${FILENAME//-tft-/}" != "$FILENAME" ]]; then
146174
TFT_BUILD=true
147175
fi
148176

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

0 commit comments

Comments
 (0)