Skip to content

Commit

Permalink
[doc, rust] Document the rust stack
Browse files Browse the repository at this point in the history
Signed-off-by: Douglas Reis <[email protected]>
  • Loading branch information
engdoreis committed Jul 7, 2023
1 parent 18d1c5b commit 7ac9850
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
27 changes: 18 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,19 +388,28 @@ You may need to run the last command twice if you get the following error:



## Building Software
## Building Software
### C stack

First the software must be built.
This can be loaded into an FPGA to run on a synthesized Ibex processor, or passed
to a verilator simulation model to be simulated on a PC.

```
mkdir sw/build
pushd sw/build
mkdir sw/c/build
pushd sw/c/build
cmake ..
make
popd
```
### Rust stack

```sh
pushd sw/rust
cargo build --bin led
popd
```
For more details, please refer to [Ibex Rust stack](sw/rust/README.md).

Note the FPGA build relies on a fixed path to the initial binary (blank.vmem) so
if you want to create your build directory elsewhere you need to adjust the path
Expand All @@ -418,14 +427,14 @@ fusesoc --cores-root=. run --target=sim --tool=verilator --setup --build lowrisc

Having built the simulator and software, to simulate using Verilator we can use the following commands.
`<sw_elf_file>` should be a path to an ELF file (or alternatively a vmem file)
built as described above. Use `./sw/build/demo/hello_world/demo` to run the `demo`
built as described above. Use `./sw/c/build/demo/hello_world/demo` to run the `demo`
binary.

Run from the repository root run:
```
# For example :
./build/lowrisc_ibex_demo_system_0/sim-verilator/Vibex_demo_system [-t] \
--meminit=ram,./sw/build/demo/hello_world/demo
--meminit=ram,./sw/c/build/demo/hello_world/demo
# You need to substitute the <sw_elf_file> for a binary we have build above.
./build/lowrisc_ibex_demo_system_0/sim-verilator/Vibex_demo_system [-t] --meminit=ram,<sw_elf_file>
Expand Down Expand Up @@ -486,11 +495,11 @@ debugger.

```bash
# Run demo
./util/load_demo_system.sh run ./sw/build/demo/hello_world/demo
./util/load_demo_system.sh run ./sw/build/demo/lcd_st7735/lcd_st7735
./util/load_demo_system.sh run ./sw/c/build/demo/hello_world/demo
./util/load_demo_system.sh run ./sw/c/build/demo/lcd_st7735/lcd_st7735

# Load demo and start halted awaiting a debugger
./util/load_demo_system.sh halt ./sw/build/demo/hello_world/demo
./util/load_demo_system.sh halt ./sw/c/build/demo/hello_world/demo
```

To view terminal output use screen:
Expand All @@ -517,7 +526,7 @@ Then run GDB against the running binary and connect to localhost:3333 as a
remote target

```
riscv32-unknown-elf-gdb ./sw/build/demo/hello_world/demo
riscv32-unknown-elf-gdb ./sw/c/build/demo/hello_world/demo
(gdb) target extended-remote localhost:3333
```
15 changes: 15 additions & 0 deletions sw/rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Ibex Rust stack
This a embedded Rust software stack for whom is enthusiast about Rust, embedded systems, RISC-V and open source.

## Installation
Install Rust:<https://www.rust-lang.org/tools/install>.

## Demos application
- [Hello world](demo/hello_world/README.md)
- [LED](demo/led/README.md)

## Running on the ARTY A7 FPGA
Before running, you need to build and load the bitstream to the board as described [here](../../README.md#building-fpga-bitstream).
```
cargo run --bin led
```
14 changes: 14 additions & 0 deletions sw/rust/demo/led/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# LED

This is a interactive demo application that light the LEDs based on the the buttons pressed on the ARTY A7 board while outputs the logs via UART.

## How to build and load
1. Build and Load the bistream as described [here](../../../../README.md#building-fpga-bitstream).
2. Connect to UART to see the console.
```sh
screen /dev/ttyUSB1 115200
```
3. Build and load the application
```
cargo run
```
2 changes: 1 addition & 1 deletion sw/rust/ibex-demo-system-pac/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Ibex demo system PAC (Peripheral Access Crate)
A Peripheral Access Crate (PAC) for the IBex Demo System from lowRISC. See the [svd2rust](https://docs.rs/svd2rust/0.29.0/svd2rust/) documentation for more information on how to use this crate.
A Peripheral Access Crate (PAC) for the Ibex Demo System from lowRISC. See the [svd2rust](https://docs.rs/svd2rust/0.29.0/svd2rust/) documentation for more information on how to use this crate.

The Ibex demo system pac is automatically generated when imported by cargo and it is based on the ibex.svd file.
## How to generate manually (Optional)
Expand Down

0 comments on commit 7ac9850

Please sign in to comment.