feat(run): initial run script
This commit is contained in:
31
run.sh
Executable file
31
run.sh
Executable file
@@ -0,0 +1,31 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# -x -> trace: print every command
|
||||||
|
# -u -> exit if undefined variables are used
|
||||||
|
# -e -> exit if an error occurs
|
||||||
|
set -xue
|
||||||
|
|
||||||
|
QEMU=qemu-system-riscv32
|
||||||
|
|
||||||
|
# Compile
|
||||||
|
CC=clang
|
||||||
|
# -ffreestanding: do not use stdlib of the host environment
|
||||||
|
# -fuse-ld=lld: LLVM linker
|
||||||
|
# -fno-stack-protector: disable stack protection
|
||||||
|
# -Wl,-Tkernel.ld: linker script
|
||||||
|
# -Wl,-Map=kernel.map: output a map file (linker allocationr result)
|
||||||
|
CFLAGS="-std=c11 -O2 -g3 -Wall -Wextra --target=riscv32-unknown-elf -fuse-ld=lld -fno-stack-protector -ffreestanding -nostdlib"
|
||||||
|
|
||||||
|
$CC $CFLAGS -Wl,-Tkernel.ld -Wl,-Map=kernel.map -o kernel.elf \
|
||||||
|
src/kernel.c
|
||||||
|
|
||||||
|
# Run QEMU
|
||||||
|
# -machine virt: generic riscv platform
|
||||||
|
# -bios default: load the default firmware (OpenSBI)
|
||||||
|
# -nographic: disable VGA, everything on console
|
||||||
|
# -serial mon:stdio: serial port is connected to terminal's stdin/stdout
|
||||||
|
# --no-reboot: do not reboot if there's panic/shutdown/crash
|
||||||
|
$QEMU -machine virt -bios default -nographic -serial mon:stdio --no-reboot \
|
||||||
|
-kernel kernel.elf
|
||||||
|
|
||||||
|
# Press Ctrl+A and then C to enter QEMU debug console and quit with `q`
|
||||||
Reference in New Issue
Block a user