36 lines
1.4 KiB
Shell
Executable file
36 lines
1.4 KiB
Shell
Executable file
#!/bin/bash
|
|
# Builds the 8051 firmware fixtures with SDCC, on the build host, into
|
|
# crates/flowrs-sim/data/mcs51/fixtures/. The fixtures' sources are this repository's (see
|
|
# NOTICE.md); SDCC's runtime is GPL with the linking exception, so the built images can be kept.
|
|
#
|
|
# embedded/twin-fixtures-mcs51/build.sh <sdcc prefix> # $R/tmp/mcs51/sdcc
|
|
set -euo pipefail
|
|
PREFIX=${1:?usage: build.sh <sdcc prefix>}
|
|
cd "$(dirname "$0")"
|
|
OUT=../../crates/flowrs-sim/data/mcs51/fixtures
|
|
mkdir -p "$OUT"
|
|
BUILD=$(mktemp -d "${TMPDIR:-/tmp}/mcs51-fixtures.XXXX")
|
|
SDCC=$PREFIX/bin/sdcc
|
|
PACK=$PREFIX/bin/packihx
|
|
"$SDCC" --version | head -1 > "$BUILD/version"
|
|
build() { # name code-size xram-size
|
|
local name=$1 code=$2 xram=$3
|
|
"$SDCC" -mmcs51 --std-c11 --code-size "$code" --iram-size 256 --xram-size "$xram" \
|
|
-Isrc -o "$BUILD/$name.ihx" "src/$name.c"
|
|
"$PACK" "$BUILD/$name.ihx" > "$OUT/$name.ihx" 2>/dev/null
|
|
}
|
|
build uart_hello 8192 0
|
|
build timer_blink 8192 0
|
|
build serial_echo 8192 0
|
|
build stc15_blink 61440 2048
|
|
build stc15_uart_adc 61440 2048
|
|
build stc8h_blink 65536 1024
|
|
build n76e_uart_blink 18432 768
|
|
build ch552_uart_blink 14336 1024
|
|
{
|
|
echo "SDCC: $(cat "$BUILD/version")"
|
|
for f in src/*.c src/*.h; do shasum -a 256 "$f"; done
|
|
for f in "$OUT"/*.ihx; do shasum -a 256 "$f" | sed "s#$OUT/#out: #"; done
|
|
} > "$OUT/BUILD.txt"
|
|
rm -rf "$BUILD"
|
|
cat "$OUT/BUILD.txt" | head -3
|