Build: report per-region memory usage after each build
Pass --print-memory-usage to the linker and re-print its FLASH/RAM/CCMRAM table in the build-script summary with a computed Free column, so the headroom for further features is visible at the end of every build. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
c614ba8096
commit
975661689a
2 changed files with 26 additions and 1 deletions
|
|
@ -22,14 +22,38 @@ echo "==> Building toolchain image ($IMAGE)"
|
||||||
docker build --platform linux/amd64 -t "$IMAGE" "$REPO_DIR/docker"
|
docker build --platform linux/amd64 -t "$IMAGE" "$REPO_DIR/docker"
|
||||||
|
|
||||||
echo "==> Running build in container ($PLATFORM)"
|
echo "==> Running build in container ($PLATFORM)"
|
||||||
|
BUILD_LOG="$(mktemp)"
|
||||||
|
trap 'rm -f "$BUILD_LOG"' EXIT
|
||||||
|
# Stream to the terminal and capture a copy so we can re-show the linker's
|
||||||
|
# memory-usage table at the end (pipefail makes a build failure still abort).
|
||||||
docker run --rm --platform linux/amd64 \
|
docker run --rm --platform linux/amd64 \
|
||||||
-v "$REPO_DIR":/work \
|
-v "$REPO_DIR":/work \
|
||||||
"$IMAGE" \
|
"$IMAGE" \
|
||||||
bash /work/docker/build.sh "$PLATFORM"
|
bash /work/docker/build.sh "$PLATFORM" 2>&1 | tee "$BUILD_LOG"
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "==> Firmware ready:"
|
echo "==> Firmware ready:"
|
||||||
echo " $REPO_DIR/MDUV380_firmware/build/${OUT}.bin"
|
echo " $REPO_DIR/MDUV380_firmware/build/${OUT}.bin"
|
||||||
|
|
||||||
|
# Re-print the linker's per-region memory usage (emitted by --print-memory-usage
|
||||||
|
# during the link) with the free bytes worked out for each region.
|
||||||
|
if grep -q "Memory region" "$BUILD_LOG"; then
|
||||||
|
echo
|
||||||
|
echo "==> Memory usage (FLASH = code budget, RAM/CCMRAM = data budget):"
|
||||||
|
grep -A3 "Memory region" "$BUILD_LOG" | awk '
|
||||||
|
function toBytes(n, unit) {
|
||||||
|
if (unit == "KB") return n * 1024
|
||||||
|
if (unit == "MB") return n * 1024 * 1024
|
||||||
|
if (unit == "GB") return n * 1024 * 1024 * 1024
|
||||||
|
return n # already bytes
|
||||||
|
}
|
||||||
|
NR == 1 { printf " %-9s %11s %12s %8s %11s\n", "Region", "Used", "Size", "Used%", "Free"; next }
|
||||||
|
/:/ {
|
||||||
|
gsub(":", "", $1)
|
||||||
|
used = toBytes($2, $3); size = toBytes($4, $5); free = size - used
|
||||||
|
printf " %-9s %9d B %10d B %7s %9d B\n", $1, used, size, $6, free
|
||||||
|
}'
|
||||||
|
fi
|
||||||
echo
|
echo
|
||||||
echo "Flash it (with the radio in firmware-update mode) using:"
|
echo "Flash it (with the radio in firmware-update mode) using:"
|
||||||
echo " ./MDUV380_firmware/tools/opengd77_stm32_firmware_loader.py \\"
|
echo " ./MDUV380_firmware/tools/opengd77_stm32_firmware_loader.py \\"
|
||||||
|
|
|
||||||
|
|
@ -63,6 +63,7 @@ ASFLAGS := $(CPU) -x assembler-with-cpp -DDEBUG -g3 -MMD -MP
|
||||||
LDSCRIPT := ../STM32F405VGTX_FLASH.ld
|
LDSCRIPT := ../STM32F405VGTX_FLASH.ld
|
||||||
LDFLAGS := $(CPU) -T$(LDSCRIPT) --specs=nano.specs \
|
LDFLAGS := $(CPU) -T$(LDSCRIPT) --specs=nano.specs \
|
||||||
-Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -static \
|
-Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -static \
|
||||||
|
-Wl,--print-memory-usage \
|
||||||
-Wl,--start-group -lc -lm -Wl,--end-group
|
-Wl,--start-group -lc -lm -Wl,--end-group
|
||||||
|
|
||||||
# ---- Sources --------------------------------------------------------------
|
# ---- Sources --------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue