Skip to content
Back to skills

Riscv Embedded Knowledge Patch

ASecurity

RISC-V embedded (Rust)

  • 25 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added December 1, 2026
developmentrustgoapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 7 files and shows the line behind each finding

Scanned December 1, 2026

npx -y skills add Nevaberry/nevaberry-plugins --skill riscv-embedded-knowledge-patch --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Riscv Embedded Knowledge Patch?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Riscv Embedded Knowledge Patch
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nevaberry-riscv-embedded-knowledge-patch-nevaberry-plugins/badge)](https://www.skillsdirectory.com/skills/nevaberry-riscv-embedded-knowledge-patch-nevaberry-plugins)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: riscv-embedded-knowledge-patch
description: RISC-V embedded (Rust)
version: "0.16.1"
license: MIT
metadata:
  author: Nevaberry
---


# RISC-V embedded Rust compatibility

Use this skill when updating `riscv`, `riscv-rt`, or `riscv-peripheral`
code, configuring startup and trap handling, or maintaining custom linker scripts.
The references give the crate-specific conditions and version attributions.

## Reference index

| Reference | Topics |
| --- | --- |
| [CSR access and interrupts](references/csr-and-interrupts.md) | CSR safety, proxies, status bits, typed interrupts, registers, imports, target configuration |
| [Runtime startup](references/runtime-startup.md) | Startup arguments, missing CSRs, initialization hooks, early assembly, HAL entry, toolchain |
| [Trap handling](references/trap-handling.md) | Trap generation, dispatch features, handler ABI, interrupt setup, trap-table placement |
| [Linking and memory](references/linking-and-memory.md) | Boundary symbols, heap, RAM initialization, linker inputs, fallbacks, stacks, code placement |
| [Standard peripherals](references/peripherals.md) | ACLINT, CLINT, PLIC, trait contracts, instance methods, generated types, dependencies |

## CSR writes and removed APIs

From `riscv` 0.13.0, CSR write APIs are `unsafe` by default.
Review the register and value at existing write call sites before wrapping
the call in an `unsafe` block.

When upgrading through `riscv` 0.11.0, remove calls to user-mode trap registers,
user-level interrupt fields and cause variants, and machine environment-call
delegation in `medeleg`. FCSR register operations are also removed.

In `riscv` 0.16.1, XS and SD become read-only summaries; remove writes to them.
See [CSR access and interrupts](references/csr-and-interrupts.md).

## Pending interrupts and in-memory edits

In `riscv` 0.15.0, `Mip` and `Sip` fields are read-only to prevent
read-modify-write updates from clearing interrupts that arrive between the
read and write. Use the `unsafe` atomic `mip::clear_pending` or
`sip::clear_pending` only when both the chip and interrupt source support it.

Use `Mstatus::update_*` and the `Mcounteren` update helpers for in-memory
edits before a separate CSR write. Panicking CSR APIs gain fallible
counterparts from `riscv` 0.12.0.

## Trait imports and generated traps

The migration from `riscv-pac` to `riscv-types`, introduced in the yanked
`riscv` 0.16.0 release, requires updated trait imports and Rust 1.81 or later.
In `riscv` 0.16.1, only `pac_enum` is re-exported from `riscv-macros`.

Enable `rt` or `rt-v-trap` when relying on trap code generated by
`riscv::pac_enum`; this requirement began in the yanked 0.16.0 release.

```toml
[dependencies]
riscv = { version = "0.16.1", features = ["rt"] }
```

## Built-in target configuration

`riscv` 0.15.0 removes the build script that supplied `cfg(riscv)`.
Replace that flag with the built-in architecture check:

```rust
#[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))]
use riscv::register;
```

## Custom trap dispatch and vector placement

For `riscv-rt` 0.13.0 through 0.17.x, `no-exceptions` and `no-interrupts`
omit the default `_dispatch_exception` and `_dispatch_core_interrupt`,
respectively. From 0.15.0, the corresponding standard handler references
are also omitted from the linker script.
In 0.18.0, those feature names are deprecated in favor of
`custom-exceptions` and `custom-interrupts`.

From `riscv` 0.15.0, custom linker scripts need to place `.trap.vector`
for tables generated by `riscv::pac_enum(unsafe CoreInterrupt)`;
these tables previously used `.trap`.
See [trap handling](references/trap-handling.md) for generation and alignment.

## Initialization hook migration

Enable `riscv-rt`'s `pre-init` and define `__pre_init` in assembly with
`core::arch::global_asm!` for a hook before RAM initialization.
The Rust `pre_init` attribute was deprecated in 0.15.0 because Rust code
at this stage is unsound; its re-export was removed in 0.18.0.

From `riscv-rt` 0.16.0, custom `_mp_hook` and `__pre_init` assembly must
preserve startup arguments in `s0`–`s2`, with `a2` saved in `a5` on RVE.
The runtime no longer zeroes general-purpose registers and avoids stack
access before `_start_rust`. Early hooks must operate without a stack
while RAM is uninitialized.

For a Rust hook before `main`, enable `post-init` and apply
`#[riscv_rt::post_init]` to define `__post_init` from 0.16.0.

## Custom linker migration

For `riscv-rt` 0.14.0, add a second leading underscore to `_sdata`,
`_edata`, `_idata`, `_sbss`, `_ebss`, `_sheap`, `_eheap`, `_estack`, and `_sstack`.
Keep `_stext` as the configurable text start, with `__stext` at the same
address. Use `__etext`, `__srodata`, and `__erodata` for the text end
and read-only data bounds.

Use `riscv_rt::heap_start()` to initialize an allocator because `__sheap`
is private. The linker aligns `.heap` to four bytes.

The default linker template removes `.init.rust` and references to
`eh_frame` in 0.14.0; `.init.trap` is removed in 0.15.0.
Use linker `PROVIDE` definitions for runtime fallbacks when maintaining
a custom `link.x`; see [linking and memory](references/linking-and-memory.md).

## Peripheral API migration

For `riscv-peripheral` 0.3.0, change CLINT and PLIC associated-function
calls to methods on a peripheral instance. Types generated by
`clint_codegen!` and `plic_codegen!` expose these methods through `Deref`.

That release drops `embedded-hal-async` support. Use a chip-specific
async HAL crate that accounts for the chip's hart topology.

From 0.4.0, `riscv-peripheral` removes its `riscv` re-export. If you used
it, add `riscv` as a direct dependency and import from it.
From 0.5.0, `riscv-peripheral` requires Rust 1.81 or later because of
its `riscv` dependency.

## Nested and typed interrupts

Both `riscv::interrupt::machine` and `riscv::interrupt::supervisor`
expose `nested` for handlers that need nested interrupts from 0.11.0.
`riscv::interrupt` re-exports the machine API by default and the
supervisor API when the `s-mode` Cargo feature is enabled.

In `riscv` 0.15.0, `mie`/`sie` enable operations and `mip`/`sip`
pending operations gain APIs based on `riscv_pac::CoreInterruptNumber`.
The interrupt module exposes `is_interrupt_enabled`, `enable_interrupt`,
`disable_interrupt`, and `is_interrupt_pending`.

## Startup configuration

Enable `s-mode` on `riscv-rt` for supervisor-mode startup from 0.10.0.
Custom `_mp_hook` hooks must accept the hart ID passed as a `usize`.

For targets with missing CSRs, `single-hart` assumes hart zero and skips
reading `mhartid` from 0.12.0. In 0.16.0, `no-xie-xip` supports chips
without XIE and XIP CSRs. In 0.17.0, `no-mhartid` loads zero into `a0`,
and `no-xtvec` omits interrupt-related runtime code.

An application's `#[entry]` can receive startup `a0`–`a2` values from
0.9.0. Machine-mode startup puts the hart ID in `a0` at the beginning
of the runtime from 0.16.0.

## Vectored traps and interrupt setup

Enable `riscv-rt`'s `v-trap` for vectored interrupt handling and for
`#[riscv_rt::core_interrupt]` and `#[riscv_rt::exception]` to generate
their corresponding traps from 0.13.0.
`RISCV_RT_BASE_ISA` configures macro generation for a base ISA such as
RV32I or RV32E from 0.14.0; 0.17.0 requires it for vectored core-interrupt
trap generation.

From 0.18.0, enable `custom-setup-interrupts` to omit the default
`_setup_interrupts` and make `#[riscv_rt::setup_interrupts]` available.
The replacement can take one `usize` argument containing the running hart's ID.

## Linker inputs and uninitialized storage

From `riscv-rt` 0.15.0, enable `device` or `memory` to have `link.x`
include `device.x` or `memory.x`, respectively. Enable both when supplying
both scripts for inclusion.

From 0.16.0, place data that should survive RAM initialization in `.uninit`,
which the runtime linker script places in `REGION_BSS`.
See [linking and memory](references/linking-and-memory.md) for RAM bounds,
per-hart stacks, application placement, and linker architecture width.

Files in this skill

  • SKILL.md7.9 KB
  • coverage.json610 B
  • references/csr-and-interrupts.md3.4 KB
  • references/linking-and-memory.md2.5 KB
  • references/peripherals.md1.4 KB
  • references/runtime-startup.md2.1 KB
  • references/trap-handling.md2.1 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.