From dc01b4da4b3c8b1539135bd181263f0aec074c13 Mon Sep 17 00:00:00 2001 From: Howard Mao Date: Mon, 13 Apr 2020 16:31:14 -0700 Subject: [PATCH] add documentation on baremetal tool flow --- docs/Software/Baremetal.rst | 25 +++++++++++++++++++++++++ docs/Software/index.rst | 1 + 2 files changed, 26 insertions(+) create mode 100644 docs/Software/Baremetal.rst diff --git a/docs/Software/Baremetal.rst b/docs/Software/Baremetal.rst new file mode 100644 index 00000000..2f0961e9 --- /dev/null +++ b/docs/Software/Baremetal.rst @@ -0,0 +1,25 @@ +.. _baremetal-programs: + +Baremetal RISC-V Programs +========================== + +To build baremetal RISC-V programs to run in simulation, we use the riscv64-unknown-elf cross-compiler and a fork of the libgloss board support package. To build such a program yourself, simply invoke the cross-compiler with the flags "-fno-common -fno-builtin-printf -specs=htif_nano.specs" and the link with the arguments "-static -specs=htif_nano.specs". For instance, if we want to run a "Hello, World" program in baremetal, we could do the following. + +.. code:: c + + #include + + int main(void) + { + printf("Hello, World!\n"); + return 0; + } + +.. code:: bash + + $ riscv64-unknown-elf-gcc -fno-common -fno-builtin-printf -specs=htif_nano.specs -c hello.c + $ riscv64-unknown-elf-gcc -static -specs=htif_nano.specs hello.o -o hello.riscv + $ spike hello.riscv + Hello, World! + +For more examples, look at the `tests/ directory `_ in the chipyard repository. diff --git a/docs/Software/index.rst b/docs/Software/index.rst index e7fe9925..04b5a5fd 100644 --- a/docs/Software/index.rst +++ b/docs/Software/index.rst @@ -19,3 +19,4 @@ challenging to modify. FireMarshal Spike + Baremetal