55VERSION=$( bin/buildinfo.py long)
66SHORT_VERSION=$( bin/buildinfo.py short)
77
8- OUTDIR=release/
8+ BUILDDIR=.pio/build/$1
9+ OUTDIR=release
910
1011rm -f $OUTDIR /firmware*
1112rm -r $OUTDIR /* || true
@@ -14,40 +15,44 @@ rm -r $OUTDIR/* || true
1415platformio pkg install -e $1
1516
1617echo " 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
2021export APP_VERSION=$VERSION
2122
2223basename=firmware-$1 -$VERSION
2324
2425pio 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
3636if (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 /
4343else
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 /
4849fi
4950
5051if (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
0 commit comments