diff options
Diffstat (limited to 'src/baremetal/run.sh')
| -rwxr-xr-x | src/baremetal/run.sh | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/baremetal/run.sh b/src/baremetal/run.sh index 467e86e..43f8a4c 100755 --- a/src/baremetal/run.sh +++ b/src/baremetal/run.sh @@ -6,11 +6,12 @@ # src/baremetal/run.sh riscv|aarch64 compile examples/hello.zc # run: the program is compiled into the image. nothing is read. # io: the same image, but stdin is the program's input and 0x04 ends it. -# compile: the default 1,048,576-word genome. the source, a backtick, and +# compile: the default compiler genome (build/core/genome.bin, from make genome). the source, a backtick, and # 0x04 are written to the UART. the backtick ends the unit; the # 0x04 is what eof() waits for after that. # Prints the program's UART output and nothing else. Exits 0 on a clean -# power-off. A missing toolchain exits 0 from `ready` and 1 otherwise. +# power-off. A missing toolchain exits 0 from `ready` and 1 otherwise. the cross +# compilers need c23 #embed (gcc 15 or later) to take in the genome. set -euo pipefail case "${1:-}" in --help|-h) printf '%s\n' 'usage: src/baremetal/run.sh ready riscv|aarch64' ' src/baremetal/run.sh riscv|aarch64 run|io|compile FILE.zc' 'builds a freestanding microcore and boots it in qemu-system.' 'run compiles the program into the image; io also forwards program input.' 'compile sends source to the resident compiler over the uart.' 'ready checks for the cross compiler and emulator.'; exit 0 ;; @@ -66,9 +67,9 @@ common="$cflags -ffreestanding -fno-pic -fno-pie -fno-builtin -fno-unwind-tables if [ "$mode" = run ] || [ "$mode" = io ]; then # the map is sized to the program, so a bigger runtime or program just gets a bigger board - gcc -O2 -w src/tools/genmap.c -o "$D/genmap" + ${CC:-$(sh src/tools/findcc.sh)} -O2 -w src/tools/genmap.c -o "$D/genmap" GENMAP="$D/genmap" bash src/tools/automap.sh run "$D/img" src/runtime/run.zc "$src" >"$D/genmap.log" 2>&1 || { cat "$D/genmap.log" >&2; exit 1; } - cp src/micro/micro.c src/micro/micro_port.h src/core/fops.h src/core/bops.h src/core/stack.h "$D/img/" + cp src/micro/micro.c src/micro/micro_port.h src/core/fops.h src/core/bops.h src/core/stack.h src/core/genome.h "$D/img/" "$cc" $common $def -I"$D/img" -c "$D/img/micro.c" -o "$D/micro.o" if [ "$mode" = io ]; then "$cc" $common $def -DBARE_INPUT=1 -I"$D/img" -c src/baremetal/port.c -o "$D/port.o" @@ -78,7 +79,8 @@ if [ "$mode" = run ] || [ "$mode" = io ]; then timeout=120 fi elif [ "$mode" = compile ]; then - cp src/micro/micro.c src/micro/micro_port.h src/core/memmap.h build/core/genome.h src/core/fops.h src/core/bops.h src/core/stack.h "$D/" + [ -f build/core/genome.bin ] || { echo "baremetal: no build/core/genome.bin; run make genome first" >&2; exit 1; } + cp src/micro/micro.c src/micro/micro_port.h build/core/map/memmap.h build/core/genome.bin src/core/genome.h src/core/fops.h src/core/bops.h src/core/stack.h "$D/" "$cc" $common $def -I"$D" -c "$D/micro.c" -o "$D/micro.o" "$cc" $common $def -DBARE_INPUT=1 -I"$D" -c src/baremetal/port.c -o "$D/port.o" timeout=90 |
