Builds on newer upstream code kept the same -hz.N label because N counted only local commits, so KM-Test's v1.18.0.2-hz.1 and the CI release of a later upstream were indistinguishable. The identifier is now -hz.U.L: U upstream commits past the version tag, L local firmware-code commits.
129 lines
6.7 KiB
Bash
Executable File
129 lines
6.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Local firmware build wrapper: bakes this checkout's preferred defaults into
|
|
# every build, then hands off to build.sh with the same arguments.
|
|
#
|
|
# Usage:
|
|
# ./local_build.sh build-firmware <TARGET> [build.sh options]
|
|
#
|
|
# Defaults baked in (edit the list below to change them):
|
|
# Radio 919.5 MHz / BW500 / SF10 / CR5 (matches the local mesh;
|
|
# Hazelwood KM-Test repeater)
|
|
# BLE PIN code macro 123456, companion targets only (on display boards such as Heltec V3 the
|
|
# firmware treats 123456 as "show a random PIN on screen each
|
|
# session"; set a fixed PIN at runtime from the app/CLI instead)
|
|
# Settings profile: target defaults (--profile default), not Cascade
|
|
# Version label: see local_version.py
|
|
#
|
|
# How it works: build.sh normally injects the USA Cascadia radio preset after
|
|
# any caller flags, which would win. `--radio-preset target` disables that
|
|
# injection, so the LORA_* flags exported here take effect. build.sh keeps an
|
|
# existing PLATFORMIO_BUILD_FLAGS and appends its own recipe flags after it.
|
|
#
|
|
# Firmware defaults only apply to a node without saved preferences (fresh
|
|
# flash or erase). A node that already has saved settings keeps them.
|
|
#
|
|
# macOS: build.sh needs bash >= 4, flock and GNU date/sed:
|
|
# brew install bash flock coreutils gnu-sed
|
|
#
|
|
# Lives on the personal Gitea branch, not in the upstream fork.
|
|
|
|
set -e
|
|
|
|
LOCAL_BUILD_FLAGS="-DLORA_FREQ=919.5 -DLORA_BW=500 -DLORA_SF=10 -DLORA_CR=5"
|
|
# BLE_PIN_CODE only matters to companions. scripts/check_firmware_ram.py
|
|
# reserves 5,920 bytes of Bluetooth worker stacks on nRF52 whenever it is
|
|
# defined, which pushes the RAK4631 repeater over its runtime RAM budget.
|
|
case "${2:-}" in
|
|
*companion*) LOCAL_BUILD_FLAGS="${LOCAL_BUILD_FLAGS} -DBLE_PIN_CODE=123456" ;;
|
|
esac
|
|
|
|
# Hazelwood RAK4631 repeaters (KM-Test, Treebeard): no display, GPS, INA, RS232
|
|
# or KISS host; Treebeard's only sensor is a RAK1901 (SHTC3). Dropping the rest
|
|
# shrinks the image by ~100 KB, which leaves more in-place room for LoRa OTA
|
|
# deltas. The env name must stay as is: it is the OTA target id (05F5FFAE).
|
|
# Upstream qualification still expects these features from the env name, so
|
|
# list them for scripts/check_firmware_capabilities.py to accept as omitted.
|
|
case "${2:-}" in
|
|
RAK_4631_repeater_unified_lora_ota)
|
|
LOCAL_BUILD_FLAGS="${LOCAL_BUILD_FLAGS} -UDISPLAY_CLASS -UENV_INCLUDE_GPS -UWITH_RS232_BRIDGE -UMESH_ENABLE_HOST_KISS"
|
|
for sensor in AHTX0 BME280 BME680 BME680_BSEC BMP085 BMP280 INA219 INA226 INA260 INA3221 LPS22HB MLX90614 RAK12035 SHT4X VL53L0X; do
|
|
LOCAL_BUILD_FLAGS="${LOCAL_BUILD_FLAGS} -UENV_INCLUDE_${sensor}"
|
|
done
|
|
MESHCORE_LOCAL_OMIT_CAPABILITIES="bridge.rs232,bridge.rs232.merged,sensor.gps,sensor.ina219,sensor.ina226,sensor.ina260,sensor.ina3221,radio2.kiss.host,radio2.kiss.usb"
|
|
export MESHCORE_LOCAL_OMIT_CAPABILITIES
|
|
;;
|
|
esac
|
|
|
|
export PLATFORMIO_BUILD_FLAGS="${PLATFORMIO_BUILD_FLAGS:+${PLATFORMIO_BUILD_FLAGS} }${LOCAL_BUILD_FLAGS}"
|
|
|
|
if [ -d /opt/homebrew/bin ]; then
|
|
PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:/opt/homebrew/opt/gnu-sed/libexec/gnubin:/opt/homebrew/bin:${PATH}"
|
|
export PATH
|
|
fi
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
# Firmware version label (applied by local_version.py, see that file):
|
|
# hazelwood_repeater v<VERSION> (core v<CORE>) / companion: v<VERSION> hazelwood (core v<CORE>)
|
|
# VERSION follows the fork's own numbering: the highest vX.Y.Z.W tag reachable
|
|
# from HEAD (e.g. v1.17.1.10 from rak4631-full-companion-v1.17.1.10-preview3).
|
|
# Local code changes add an identifier; build settings (untracked files) don't:
|
|
# -hz.U.L U upstream commits past the vX.Y.Z.W tag(s) in the maintainer's fork
|
|
# (upstream/keymindCascade; origin is the personal Gitea copy, so
|
|
# @{upstream} would hide them) and L of your own commits that change
|
|
# firmware code. U grows with every upstream pull, so builds on newer
|
|
# upstream code sort higher even when the tag and L are unchanged.
|
|
# LoRa OTA sees only vX.Y.Z.W; compare U.L to decide an upgrade.
|
|
# .dirty uncommitted edits to tracked firmware code
|
|
# Merge commits and the build-setup files below don't count: they change
|
|
# settings, not code. Edit LOCAL_FW_SETUP_PATHS if you add more setup files.
|
|
# CORE is the upstream MeshCore version from examples/simple_repeater/MyMesh.h.
|
|
LOCAL_FW_NAME=hazelwood
|
|
|
|
fork_version=$(git tag --merged HEAD \
|
|
| sed -nE 's/.*v([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+).*/\1/p' \
|
|
| sort -t. -k1,1n -k2,2n -k3,3n -k4,4n | tail -n 1)
|
|
if [ -z "$fork_version" ]; then
|
|
echo "local_build.sh: no vX.Y.Z.W tag reachable from HEAD; run git fetch --tags" >&2
|
|
exit 1
|
|
fi
|
|
local_id=""
|
|
LOCAL_FW_UPSTREAM_REF=${LOCAL_FW_UPSTREAM_REF:-upstream/keymindCascade}
|
|
LOCAL_FW_SETUP_PATHS=":(exclude)local_build.sh :(exclude)local_version.py :(exclude)platformio.local.ini"
|
|
# shellcheck disable=SC2086 # intentional word-splitting of the pathspec list
|
|
local_commits=$(git rev-list --count --no-merges "${LOCAL_FW_UPSTREAM_REF}..HEAD" \
|
|
-- . $LOCAL_FW_SETUP_PATHS 2>/dev/null || echo 0)
|
|
# Every tag carrying this version is excluded, so U counts from the newest of them.
|
|
upstream_base=$(git merge-base HEAD "${LOCAL_FW_UPSTREAM_REF}" 2>/dev/null || git rev-parse HEAD)
|
|
# shellcheck disable=SC2046 # one ^tag argument per tag
|
|
upstream_commits=$(git rev-list --count "$upstream_base" \
|
|
$(git tag --merged "$upstream_base" | grep -F "v${fork_version}" | sed 's/^/^/') 2>/dev/null || echo 0)
|
|
if [ "$upstream_commits" -gt 0 ] || [ "$local_commits" -gt 0 ]; then
|
|
local_id="-hz.${upstream_commits}.${local_commits}"
|
|
fi
|
|
# shellcheck disable=SC2086
|
|
if [ -n "$(git status --porcelain --untracked-files=no -- . $LOCAL_FW_SETUP_PATHS)" ]; then
|
|
local_id="${local_id:--hz}.dirty"
|
|
fi
|
|
LOCAL_FW_VERSION="v${fork_version}${local_id}"
|
|
LOCAL_FW_CORE_VERSION=$(sed -n 's/^ *#define FIRMWARE_VERSION *"v\([0-9.]*\)".*/\1/p' examples/simple_repeater/MyMesh.h | head -n 1)
|
|
export LOCAL_FW_NAME LOCAL_FW_VERSION LOCAL_FW_CORE_VERSION
|
|
|
|
# build.sh deletes and recreates its output directory on every run (unless
|
|
# RESUME_BUILD_OUTPUT=1), so give each run its own folder under out/ instead of
|
|
# letting it wipe out/ itself. Never keep anything else in an output folder.
|
|
if [ -z "${OUTPUT_DIR:-}" ]; then
|
|
OUTPUT_DIR="out/$(date +%Y%m%d-%H%M%S)"
|
|
export OUTPUT_DIR
|
|
fi
|
|
echo "Build output: ${OUTPUT_DIR}"
|
|
|
|
# FIRMWARE_VERSION also names the output files (build.sh appends -<commit8>).
|
|
export FIRMWARE_VERSION="${LOCAL_FW_VERSION}"
|
|
export PLATFORMIO_EXTRA_SCRIPTS="${PLATFORMIO_EXTRA_SCRIPTS:+${PLATFORMIO_EXTRA_SCRIPTS}
|
|
}pre:local_version.py"
|
|
|
|
echo "Local build defaults: ${LOCAL_BUILD_FLAGS} (--radio-preset target --profile default)"
|
|
echo "Local firmware version: ${FIRMWARE_VERSION} (core v${LOCAL_FW_CORE_VERSION})"
|
|
exec bash build.sh "$@" --radio-preset target --profile default
|