Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Cargo.lock

*.hex
*.elf
*.bin
RIOT_App/app/bin

# Added by cargo

Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "rv"
name = "triops"
version = "0.1.0"
edition = "2021"

Expand Down
69 changes: 69 additions & 0 deletions RIOT_App/README.md
Original file line number Diff line number Diff line change
@@ -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
```
1 change: 1 addition & 0 deletions RIOT_App/RIOT
Submodule RIOT added at 7ba922
27 changes: 27 additions & 0 deletions RIOT_App/app/Makefile
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions RIOT_App/app/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include <stdio.h>
#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;
}