diff --git a/.gitignore b/.gitignore index 0413640..4b5d081 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,8 @@ Cargo.lock *.hex *.elf +*.bin +RIOT_App/app/bin # Added by cargo diff --git a/.gitmodules b/.gitmodules index a2163b2..d15880c 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,7 @@ [submodule "tests/src"] path = tests/src url = git@github.com:riscv-software-src/riscv-tests.git +[submodule "RIOT_App/RIOT"] + path = RIOT_App/RIOT + url = https://github.com/RIOT-OS/RIOT.git + shallow = true diff --git a/Cargo.toml b/Cargo.toml index 87d5ee2..e7919ef 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rv" +name = "triops" version = "0.1.0" edition = "2021" diff --git a/RIOT_App/README.md b/RIOT_App/README.md new file mode 100644 index 0000000..28982ae --- /dev/null +++ b/RIOT_App/README.md @@ -0,0 +1,69 @@ +# RIOT for TRIOPS + +The [RIOT](https://github.com/RIOT-OS/RIOT) OS supports the Hifive1b board, which is emulated by TRIOPS. +All you need to do is building a RIOT app for that board and load the resulting binary file into TRIOPS. +To setup your system for RIOT development, please refer to the [Getting Started](https://guide.riot-os.org/getting-started/installing/) guide of RIOT. +The tl;dr is that you will need GCC (`riscv64-unknown-elf`), binutils, and newlib. + +Because it is easy to use RIOT with external apps, TRIOPS comes with an example app provided in the `app/` folder. +The `Makefile` in the example configures RIOT to: + +* target the Hifive1b board +* set the app name to `triops_app` +* use the emulator for running the app +* which RIOT modules to include + +While the `main.c` prints a hello-world and starts the RIOT shell. + +## Building the RIOT example app + +1. Clone RIOT. Because it is a git submodule, you can fetch it right here: +```sh +git submodule update +``` + +2. Enter the `app/` directory and run gnu `make` +```sh +cd app/ && make +``` + +3. You will see RIOTs build process and the result binary `triops_app.elf`. It should look something like this: +```txt +Building application "triops_app" for "hifive1b" with CPU "fe310". + +make -C /foo/triops/RIOT_App/RIOT/pkg/mpaland-printf/ +make -C /foo/triops/RIOT_App/RIOT/build/pkg/mpaland-printf -f /foo/triops/RIOT_App/RIOT/pkg/mpaland-printf/mpaland-printf.mk +make -C /foo/triops/RIOT_App/RIOT/boards +make -C /foo/triops/RIOT_App/RIOT/boards/common/init +make -C /foo/triops/RIOT_App/RIOT/boards/hifive1b +make -C /foo/triops/RIOT_App/RIOT/core +make -C /foo/triops/RIOT_App/RIOT/core/lib +make -C /foo/triops/RIOT_App/RIOT/cpu/fe310 +make -C /foo/triops/RIOT_App/RIOT/cpu/fe310/periph +make -C /foo/triops/RIOT_App/RIOT/cpu/fe310/vendor +make -C /foo/triops/RIOT_App/RIOT/cpu/riscv_common +make -C /foo/triops/RIOT_App/RIOT/cpu/riscv_common/periph +make -C /foo/triops/RIOT_App/RIOT/drivers +make -C /foo/triops/RIOT_App/RIOT/drivers/periph_common +make -C /foo/triops/RIOT_App/RIOT/sys +make -C /foo/triops/RIOT_App/RIOT/sys/auto_init +make -C /foo/triops/RIOT_App/RIOT/sys/div +make -C /foo/triops/RIOT_App/RIOT/sys/isrpipe +make -C /foo/triops/RIOT_App/RIOT/sys/libc +make -C /foo/triops/RIOT_App/RIOT/sys/malloc_thread_safe +make -C /foo/triops/RIOT_App/RIOT/sys/newlib_syscalls_default +make -C /foo/triops/RIOT_App/RIOT/sys/preprocessor +make -C /foo/triops/RIOT_App/RIOT/sys/ps +make -C /foo/triops/RIOT_App/RIOT/sys/shell +make -C /foo/triops/RIOT_App/RIOT/sys/shell/cmds +make -C /foo/triops/RIOT_App/RIOT/sys/stdio +make -C /foo/triops/RIOT_App/RIOT/sys/stdio_uart +make -C /foo/triops/RIOT_App/RIOT/sys/tsrb + text data bss dec hex filename + 8850 1193 2628 12671 317f /foo/triops/RIOT_App/app/bin/hifive1b/triops_app.elf +``` + +4. Run RIOT within TRIOPS. This assumes that you already built TRIOPS using `cargo build`! +```sh +make term +``` diff --git a/RIOT_App/RIOT b/RIOT_App/RIOT new file mode 160000 index 0000000..7ba922f --- /dev/null +++ b/RIOT_App/RIOT @@ -0,0 +1 @@ +Subproject commit 7ba922f6658daa956539aa30af6cbbad4492ebf0 diff --git a/RIOT_App/app/Makefile b/RIOT_App/app/Makefile new file mode 100644 index 0000000..9edff15 --- /dev/null +++ b/RIOT_App/app/Makefile @@ -0,0 +1,27 @@ +# name of your application +APPLICATION = triops_app + +# If no BOARD is found in the environment, use this default: +BOARD = hifive1b + +# Comment this out to disable code in RIOT that does safety checking +# which is not needed in a production environment but helps in the +# development process: +DEVELHELP ?= 1 + +# Change this to 0 show compiler invocation lines by default: +QUIET ?= 1 + +# Modules to include: +USEMODULE += shell +USEMODULE += shell_cmds_default +USEMODULE += ps + +TERMPROG = ../../target/debug/triops +TERMFLAGS = $(ELFFILE) + +PROJECT_BASE ?= $(CURDIR)/../ +# This has to be the absolute path to the RIOT base directory: +RIOTBASE ?= $(PROJECT_BASE)/RIOT + +include $(RIOTBASE)/Makefile.include diff --git a/RIOT_App/app/main.c b/RIOT_App/app/main.c new file mode 100644 index 0000000..674c18d --- /dev/null +++ b/RIOT_App/app/main.c @@ -0,0 +1,17 @@ +#include +#include "shell.h" + +int main(void) +{ + puts("Hello TRIOPS!"); + + printf("You are running RIOT on a(n) %s (emulated) board.\n", RIOT_BOARD); + printf("This board features a(n) %s CPU.\n", RIOT_CPU); + + printf("You are in the RIOT shell now, type 'help' for...help.\n"); + + char line_buf[SHELL_DEFAULT_BUFSIZE]; + shell_run(NULL, line_buf, SHELL_DEFAULT_BUFSIZE); + + return 0; +}