34 lines
1.8 KiB
Shell
Executable file
34 lines
1.8 KiB
Shell
Executable file
#!/bin/bash
|
|
# Builds two of FwLib_STC8's own demos with SDCC, untouched, for the STC8H1K08 at 24 MHz: firmware
|
|
# someone else wrote, against a library that sets every register its own way. FwLib_STC8 is
|
|
# Apache-2.0 (https://github.com/IOsetting/FwLib_STC8, commit 992a4e0); only the built images are kept
|
|
# here, in crates/flowrs-sim/data/mcs51/fixtures/, with this script and the licence named in NOTICE.md.
|
|
#
|
|
# embedded/twin-fixtures-mcs51/build-fwlib.sh <sdcc prefix> <FwLib_STC8 checkout>
|
|
set -euo pipefail
|
|
PREFIX=${1:?usage: build-fwlib.sh <sdcc prefix> <FwLib_STC8 checkout>}
|
|
LIB=${2:?usage: build-fwlib.sh <sdcc prefix> <FwLib_STC8 checkout>}
|
|
HERE=$(cd "$(dirname "$0")" && pwd)
|
|
OUT=$HERE/../../crates/flowrs-sim/data/mcs51/fixtures
|
|
BUILD=$(mktemp -d "${TMPDIR:-/tmp}/mcs51-fwlib.XXXX")
|
|
SDCC=$PREFIX/bin/sdcc
|
|
FLAGS="-mmcs51 --model-large --opt-code-size --iram-size 256 --xram-size 1024 --code-size 8192 \
|
|
-D__CONF_FOSC=24000000UL -D__CONF_MCU_MODEL=MCU_MODEL_STC8H1K08 -D__CONF_IRCBAND=0x00 \
|
|
-D__CONF_VRTRIM=0x00 -D__CONF_IRTRIM=0x00 -D__CONF_LIRTRIM=0x00 -D__CONF_CLKDIV=0x00 -I$LIB/include"
|
|
cd "$BUILD"
|
|
for s in fw_sys fw_uart fw_tim fw_util; do
|
|
"$SDCC" $FLAGS -c "$LIB/src/$s.c" -o "$s.rel"
|
|
done
|
|
build() { # output, demo source
|
|
"$SDCC" $FLAGS -c "$LIB/demo/$2" -o main.rel
|
|
"$SDCC" $FLAGS -o "$1.ihx" main.rel fw_sys.rel fw_uart.rel fw_tim.rel fw_util.rel
|
|
"$PREFIX/bin/packihx" "$1.ihx" > "$OUT/$1.ihx" 2>/dev/null
|
|
shasum -a 256 "$LIB/demo/$2" "$OUT/$1.ihx" | sed "s#$OUT/#out: #; s#$LIB/##"
|
|
}
|
|
{
|
|
echo "FwLib_STC8 $(git -C "$LIB" rev-parse --short HEAD) (Apache-2.0), SDCC $("$SDCC" --version | head -1)"
|
|
build fwlib_timer0_1t tim/timer0_timer_1t.c
|
|
build fwlib_uart1_t2 uart/uart1_timer2_tx.c
|
|
} > "$OUT/BUILD-fwlib.txt"
|
|
rm -rf "$BUILD"
|
|
cat "$OUT/BUILD-fwlib.txt"
|