Files
MeshCore/local_build.sh
T
rich f36852812e
Build and deploy Docs site to GitHub Pages / github-pages (push) Canceled after 0s
Run Unit Tests / nrf52-companion-smoke (push) Canceled after 0s
Run Unit Tests / nrf52-sensor-smoke (push) Canceled after 0s
Run Unit Tests / optional-display-smoke (push) Canceled after 0s
Run Unit Tests / esp32-sensor-smoke (push) Canceled after 0s
Run Unit Tests / esp32-ethernet-companion-smoke (push) Canceled after 0s
Run Unit Tests / esp32-classic-companion-smoke (push) Canceled after 0s
Run Unit Tests / esp32-constrained-companion-smoke (push) Canceled after 0s
Run Unit Tests / cross-platform-smoke (push) Canceled after 0s
Run Unit Tests / cardputer-smoke (push) Canceled after 0s
Run Unit Tests / management-reports (push) Canceled after 0s
Run Unit Tests / stm32-companion-smoke (push) Canceled after 0s
Run Unit Tests / stm32-mini-repeater-smoke (push) Canceled after 0s
Run Unit Tests / bootloader-version (push) Canceled after 0s
Run Unit Tests / test (push) Canceled after 0s
Run Unit Tests / hosted-doc-links (push) Canceled after 0s
Trim unused features from the Hazelwood RAK4631 repeater build
Drop display, GPS, INA, RS232, KISS host and every sensor driver except
SHTC3 (RAK1901) from RAK_4631_repeater_unified_lora_ota, keeping the env
name and therefore OTA target id 05F5FFAE. The Full image shrinks by about
125 KB, leaving more in-place room for LoRa OTA deltas.

check_firmware_capabilities.py accepts capabilities listed in
MESHCORE_LOCAL_OMIT_CAPABILITIES as deliberately omitted, and fails if a
listed one is still present.
2026-10-28 16:39:31 -04:00

121 lines
6.0 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.N N of your own commits that change firmware code relative to the
# maintainer's fork (upstream/keymindCascade; origin is the personal
# Gitea copy, so @{upstream} would hide them)
# .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)
if [ "$local_commits" -gt 0 ]; then
local_id="-hz.${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