|
2 | 2 | //!
|
3 | 3 | //! This is an implementation of the [`embedded-hal`] traits for the E310x
|
4 | 4 | //! family of microcontrollers.
|
| 5 | +//! |
| 6 | +//! # Building an application for the E310x chips |
| 7 | +//! |
| 8 | +//! The E310x chips implement the [Zaamo](https://github.com/riscv/riscv-zaamo-zalrsc/blob/main/zaamo-zalrsc.adoc) |
| 9 | +//! extension for atomic instructions. This means that it *partially* supports the `A` |
| 10 | +//! extension for atomic. Specifically, it supports the `amo*` instructions, but not the |
| 11 | +//! `lr*` and `sc*` instructions. |
| 12 | +//! |
| 13 | +//! It is discouraged to use the `riscv32imac-unknown-none-elf` target for E310x chips, as it |
| 14 | +//! will potentially generate code that uses the `lr*` and `sc*` instructions, which are not |
| 15 | +//! supported by the E310x chips. Thus, it is recommended to use `riscv32imc-unknown-none-elf`. |
| 16 | +//! |
| 17 | +//! # Working with atomic operations |
| 18 | +//! |
| 19 | +//! If you are using the `riscv32imc-unknown-none-elf` target, you will notice that |
| 20 | +//! `core::sync::atomic` is not available. To work around this, you can use the |
| 21 | +//! [`portable-atomic`](https://docs.rs/portable-atomic/1.8.0/portable_atomic/) crate. |
| 22 | +//! This crate allows us to use native `amo*` instructions on the E310x chips without requiring |
| 23 | +//! the `A` extension. Furthermore, you can emulate the `lr*` and `sc*` instructions if needed. |
| 24 | +//! |
| 25 | +//! Thus, the recommended way to work with E310x chips is: |
| 26 | +//! |
| 27 | +//! 1. Compile your code against the `riscv32imc-unknown-none-elf` target. |
| 28 | +//! 2. Add the following configuration to your `.cargo/config.toml`: |
| 29 | +//! |
| 30 | +//! ```toml |
| 31 | +//! [target.'cfg(all(target_arch = "riscv32", target_os = "none"))'] |
| 32 | +//! rustflags = [ |
| 33 | +//! "--cfg", "portable_atomic_target_feature=\"zaamo\"", |
| 34 | +//! ] |
| 35 | +//! |
| 36 | +//! [build] |
| 37 | +//! target = "riscv32imc-unknown-none-elf" |
| 38 | +//! ``` |
| 39 | +//! |
| 40 | +//! This will ensure that the `portable-atomic` crate is correctly configured to work with the E310x chips. |
5 | 41 |
|
6 | 42 | #![deny(missing_docs)]
|
7 | 43 | #![no_std]
|
|
0 commit comments