1
0
Fork 0

Did stuff

This commit is contained in:
jenra-uwu 2021-07-25 16:26:52 -04:00
parent 3c9c33df23
commit 8be90bba34
3 changed files with 9 additions and 7 deletions

View File

@ -1,5 +1,7 @@
CODE=src/
CC=riscv64-unknown-elf-gcc
CROSS_COMPILE=riscv64-unknown-elf-
CC=$(CROSS_COMPILE)gcc
GDB=$(CROSS_COMPILE)gdb
CFLAGS=-march=rv64gc -mabi=lp64d -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -Tkernel.ld -g -Wall -Wextra
EMU=qemu-system-riscv64
EFLAGS=-machine virt -cpu rv64 -bios opensbi-riscv64-generic-fw_dynamic.bin -m 256m -nographic -global virtio-mmio.force-legacy=false -s #-S
@ -11,3 +13,6 @@ all: $(CODE)*.s $(CODE)*.c
run:
$(EMU) $(EFLAGS) -kernel kernel
gdb:
$(GDB) -x kernel.gdb

View File

@ -8,15 +8,10 @@ Install [the Newlib GNU RISC V toolchain](https://github.com/riscv/riscv-gnu-too
This is the new "how to exit Vi" I guess. To exit, press control+x, unpress those keys, and then press a.
## Debugging
Execute `riscv64-unknown-elf-gdb` and run the following commands:
```
(gdb) symbol-file kernel
(gdb) target remote localhost:1234
```
Execute `make gdb` and then `make run`.
If you'd like to trace the execution since the beginning, uncomment the `# -S` at the end of the line in the makefile and run. This halts the emulator until a gdb connection is established.
## Resources
- [OpenSBI docs](https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc)
- [RISC V specs](https://riscv.org/technical/specifications/)

2
kernel.gdb Normal file
View File

@ -0,0 +1,2 @@
symbol-file kernel
target remote localhost:1234