Skip to content

Commit 5d5ecb9

Browse files
romancardenasAfoHT
authored andcommitted
Adding docs about RISC-V
1 parent 4542367 commit 5d5ecb9

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ A concurrency framework for building real-time systems.
4141

4242
- **All Cortex-M devices are fully supported**.
4343

44+
- **Most RISC-V devices are supported**. Refer to the [RTIC book]((https://rtic.rs/))
45+
to learn more about RISC-V backends, their particularities, and their limitations.
46+
4447
- This task model is amenable to known WCET (Worst Case Execution Time) analysis
4548
and scheduling analysis techniques.
4649

book/en/src/internals/targets.md

+46-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Target Architecture
22

3+
## Cortex-M Devices
4+
35
While RTIC can currently target all Cortex-m devices there are some key architecture differences that
46
users should be aware of. Namely, the absence of Base Priority Mask Register (`BASEPRI`) which lends
57
itself exceptionally well to the hardware priority ceiling support used in RTIC, in the ARMv6-M and
@@ -27,11 +29,11 @@ Table 1 below shows a list of Cortex-m processors and which type of critical sec
2729
| Cortex-M23 | ARMv8-M-base | ||
2830
| Cortex-M33 | ARMv8-M-main || |
2931

30-
## Priority Ceiling
32+
### Priority Ceiling
3133

3234
This is covered by the [Resources](../by-example/resources.html) page of this book.
3335

34-
## Source Masking
36+
### Source Masking
3537

3638
Without a `BASEPRI` register which allows for directly setting a priority ceiling in the Nested
3739
Vectored Interrupt Controller (NVIC), RTIC must instead rely on disabling (masking) interrupts.
@@ -66,3 +68,45 @@ risk of data race conditions. At time *t4*, task A completes and returns the exe
6668

6769
Since source masking relies on use of the NVIC, core exception sources such as HardFault, SVCall,
6870
PendSV, and SysTick cannot share data with other tasks.
71+
72+
## RISC-V Devices
73+
74+
All the current RISC-V backends work in a similar way as Cortex-M devices with priority ceiling.
75+
Therefore, the [Resources](../by-example/resources.html) page of this book is a good reference.
76+
However, some of these backends are not full hardware implementations, but use software to emulate
77+
a physical interrupt controller. Therefore, these backends do not implement hardware tasks, and
78+
only software tasks are needed. Furthermore, the number of software tasks for these targets is
79+
not bounded by the number of available physical interrupt sources.
80+
81+
Table 2 below compares the available RISC-V backends.
82+
83+
#### *Table 2: Critical Section Implementation by Processor Architecture*
84+
85+
| Backend | Compatible targets | Backend-specific configuration | Hardware Tasks | Software Tasks | Number of tasks bounded by HW |
86+
| :---------------------: | :---------------------------: | :----------------------------: | :------------: | :------------: | :---------------------------: |
87+
| `riscv-esp32c3-backend` | ESP32-C3 only | ||||
88+
| `riscv-mecall-backend` | Any RISC-V device | | || |
89+
| `riscv-clint-backend` | Devices with CLINT peripheral || || |
90+
91+
92+
### `riscv-mecall-backend`
93+
94+
It is not necessary to provide a list of dispatchers in the `#[app]` attribute, as RTIC will generate them at compile time.
95+
Priority levels can go from 0 (for the `idle` task) to 255.
96+
97+
### `riscv-clint-backend`
98+
99+
It is not necessary to provide a list of `dispatchers` in the `#[app]` attribute, as RTIC will generate them at compile time.
100+
Priority levels can go from 0 (for the `idle` task) to 255.
101+
102+
You **must** include a `backend`-specific configuration in the `#[app]` attribute so RTIC knows the ID number used to identify the HART running your application.
103+
For example, for `e310x` chips, you would configure a minimal application as follows:
104+
105+
```rust
106+
#[rtic::app(device = e310x, backend = H0)]
107+
mod app {
108+
// your application here
109+
}
110+
```
111+
112+
In this way, RTIC will always refer to HART `H0`.

book/en/src/starting_a_project.md

+19
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ protection using [`flip-link`]. There is also a multitude of examples provided b
1212

1313
For inspiration, you may look at the [RTIC examples].
1414

15+
## RTIC on RISC-V devices
16+
17+
Even though RTIC was initially developed for ARM Cortex-M, it is possible to use RTIC on RISC-V devices.
18+
However, the RISC-V ecosystem is more heterogeneous.
19+
To tackle this issue, currently, RTIC implements three different backends:
20+
21+
- **`riscv-esp32c3-backend`**: This backend provides support for the ESP32-C3 SoC.
22+
In these devices, RTIC is very similar to its Cortex-M counterpart.
23+
24+
- **`riscv-mecall-backend`**: This backend provides support for **any** RISC-V device.
25+
In this backend, pending tasks trigger Machine Environment Call exceptions.
26+
The handler for this exception source dispatches pending tasks according to their priority.
27+
The behavior of this backend is equivalent to `riscv-clint-backend`.
28+
The main difference of this backend is that all the tasks **must be** [software tasks](./by-example/software_tasks.md).
29+
Additionally, it is not required to provide a list of dispatchers in the `#[app]` attribute, as RTIC will generate them at compile time.
30+
31+
- **`riscv-clint-backend`**: This backend supports devices with a CLINT peripheral.
32+
It is equivallent to `riscv-mecall-backend`, but instead of triggering exceptions, it triggers software interrupts via the `MSIP` register of the CLINT.
33+
1534
[`defmt`]: https://github.com/knurling-rs/defmt/
1635
[`flip-link`]: https://github.com/knurling-rs/flip-link/
1736
[RTIC examples]: https://github.com/rtic-rs/rtic/tree/master/examples

0 commit comments

Comments
 (0)