stm32-lisp (1134 bytes)
1 #!/bin/sh 2 # stm32-lisp -- boot the Forth kernel for the STM32F446 in QEMU (netduinoplus2; 128 KiB RAM and 3 # 512 KiB flash used), load the Scheme through the host, then attach its REPL. 4 # Quit with ctrl-c; (forth) returns to the Forth prompt. PORT picks the TCP port (default 4444). 5 # Tools come from PATH unless set: QEMU (qemu-system-arm), SBCL (sbcl), NC (nc), STTY (stty). 6 set -e 7 HERE=$(cd "$(dirname "$0")" && pwd) 8 CORE=${FORTHLISP_CORE:-$HERE}; [ -f "$CORE/host.lisp" ] || CORE=$HERE/../forthlisp # core repo checkout 9 IMG=$HERE/kernel-f446.bin 10 PORT=${PORT:-4444} 11 [ -f "$IMG" ] || "$HERE/build-firmware.sh" >/dev/null 12 "${QEMU:-qemu-system-arm}" -M netduinoplus2 -kernel "$IMG" -display none -monitor none \ 13 -serial null -serial tcp:127.0.0.1:$PORT,server,nowait 2>/dev/null & 14 QPID=$! 15 trap 'kill $QPID 2>/dev/null; ${STTY:-stty} sane 2>/dev/null' EXIT HUP INT TERM 16 PORT=$PORT "${SBCL:-sbcl}" --script "$CORE/host.lisp" load 17 echo 18 echo "target Lisp ready: type an expression, (forth) returns to Forth, ctrl-c quits" 19 ${STTY:-stty} -echo -icanon 2>/dev/null || true # the chip echoes; no tty when piped 20 ${NC:-nc} 127.0.0.1 $PORT