Miscellaneous scripts for LF/FlexPRET.
Make sure you have spike
and riscv64-unknown-elf-gcc
on your PATH.
You can get the toolchains below:
https://static.dev.sifive.com/dev-tools/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz https://github.com/edwardcwang/riscv-toolchains/releases/download/toolchains/riscv64-unknown-elf-gcc-8.3.0-2019.08.0-x86_64-linux-ubuntu14.tar.gz
- Write the LF program
- Generate C code using
lfc -n <prog>.lf
- Swap out
<lf_prog_dir>/src-gen/core
withlib/core_spike_gdb
- Also copy
lib/start.S
intosrc-gen
- Compile
src-gen/<prog>.c
usingscripts/compile.sh
- Start 3 different screen/tmux windows
- In window 1,
cd <lf_prog_dir>/src-gen
and usespike.sh
to launch the RISC-V binary<prog_bin>
- In window 2,
cd gdb/
and doopenocd -f spike.cfg
- In window 3 (and subsequent actions will happen in this window),
cd <lf_prog_dir>/src-gen
and useriscv32-unknown-elf-gdb <prog_bin>
- After
gdb
prompt shows up, type intarget remote localhost:3333
- Then, change the source dir to the project directory in
gdb
usingdir <lf_prog_dir>
(e.g.$(gdb) dir ../../timer
). This is used to prevent certain "file not found" errors ingdb
- There will be a spin wait at the beginning. Disable it to continue program execution by doing
print wait = 0
- Now feel free to use all of your favorite
gdb
commands to debug the program!