Skip to content

firmware: make build-schedules.sh portable to Linux - #175

Merged
geonnave merged 1 commit into
DotBots:mainfrom
geonnave:portable-build-scripts
Sep 18, 2026
Merged

geonnave merged 1 commit into
DotBots:mainfrom
geonnave:portable-build-scripts

Conversation

@geonnave

Copy link
Copy Markdown
Contributor

build-schedules.sh cannot work on Linux today, and it fails in the worst way
available: silently, with plausible-looking output.

Line 78 used sed -i '' -E. BSD sed reads the empty string as the backup
suffix; GNU sed reads it as the sed script and then treats the real expression
as a filename. It prints "can't read ..." to stderr, edits nothing, and exits
0. Under set -euo pipefail that is not caught, so the run continues, builds
the image with whatever schedule_app already pointed at, and files it under
the requested name. Asking for tiny gets you a file called
03app_gateway_net-tiny.hex containing the huge schedule.

That is worse than a crash because nothing downstream can detect it. Every
image links all four schedules in and only the compile-time pointer differs,
so once the hex exists there is no way to inspect which schedule it holds. The
error surfaces as a gateway quietly running the wrong slotframe.

The in-place edit now goes through a scratch file and is written back with
cat, which both seds accept and which preserves the inode and permissions of
main.c - that matters because the script's EXIT trap restores the file
byte-for-byte so local uncommitted edits survive a build. shasum is likewise
replaced by a helper that prefers sha256sum when it exists, since that is
coreutils and shasum is the perl tool macOS ships; neither is present
everywhere.

Verified on Ubuntu 22.04 with GNU sed 4.8: the helper flips &schedule_huge
to &schedule_tiny correctly, the checksum helper takes the sha256sum
branch, the script reaches the compiler invocation, and the EXIT trap leaves
main.c unmodified afterwards. Not verified on macOS, where the previous
behaviour was already correct and the scratch-file form is the portable
spelling of the same edit.

One related rough edge left alone deliberately: SEGGER_DIR still defaults to
/opt/segger, which is a common Linux location but not a universal one, and
is not where the SES packages install by default. That is a configurable
default with an env override rather than a correctness bug, and changing it
would affect macOS users who rely on the current value, so it seemed worth
raising separately rather than bundling here.

@geonnave
geonnave merged commit c7eda96 into DotBots:main Sep 18, 2026
2 checks passed
@geonnave
geonnave deleted the portable-build-scripts branch September 18, 2026 13:27
@geonnave geonnave mentioned this pull request Sep 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant