riscv
Low level access to RISC-V processors
0.16.1
9.2M downloads/mo
#3253 most downloaded on crates.io
rust-embedded/riscv
What this package is like to depend on
Last release 2 months ago
28 May 2026
Ships fairly regularly
a new release about every 4 months
Some releases are documented
notes for 14 of 27 stable releases
4 versions withdrawn
withdrawn after publishing
9 years old
31 releases · first in 2017
3 releases in the last 12 months
see the full history below
Release timeline
31 releases · Sep 2017 to May 2026Releases
latest 31-
0.16.128 May 2026Release notes
Open source →Added
- Add
mtopeiCSR - Add
mstatusandsstatusCSRs helpers for UBE, VS, UXL and SXL, and the corresponding tests - Add
pmpaddr16~pmpaddr63CSRs - Add
siselectCSR - Add
vsiselectCSR - Add
stopiCSR
Changed
- Fix the CSR masks to preserve all legal status bits
- Modify XS and SD bits to read-only summary fields instead of writable fields
- replaced
pastecrate withpasteyto fix RUSTSEC-2024-0436
- Add
-
0.16.024 Dec 2025Release notes
Open source →A new batch of RISC-V releases is now available at crates.io! Here we enumerate the most important changes, but please read the
CHANGELOG.mdfiles for further details.riscv-typesv0.1.0This crate substitutes
riscv-pac, which is now deprecatedriscvv0.16.0- Added new CSRs (@0xllx0 @KushalMeghani1644)
- New
rtandrt-v-trapfeatures to opt-inriscv-rt-related code inriscv::pac_enummacro (@romancardenas)
riscv-rtv0.17.0- New
no-mhartidandno-xtvecfeatures to support more targets (@Shatur) - Fix
v-trapcore interrupt soRISCV_RT_BASE_ISAmust be defined (@kurtjd) - Fix stack allocation algorithm for multi-core targets without M extension (@romancardenas )
Release notes
Open source →Added
- Add
vstopiCSR - Add
dcsratch0anddscratch1CSRs - Add new
read-write_csr_as_usizemacro for registers - Add
dpcCSR support for RISC-V - Add Mtopi
- Added DCSR (Debug Control and Status Register) CSR support for the RISC-V
- Add
miselectCSR - Improved assembly macro handling in asm.rs
- New
rtandrt-v-trapfeatures to opt-inriscv-rt-related code inriscv::pac_enummacro. - Add
mvien+mvienhCSR
Changed
- Bump MSRV to 1.81 due to
riscv-types - Use
riscv-typesinstead ofriscv-pac - Reexport only
pac_enummacro fromriscv-macros - Fix broken links in register macro doc string.
- Moved macros from
./macros/to../riscv-macros/ - Updated the license to
MIT or Apache-2.0 - Now,
riscv::pac_enummacro only includes trap-related code ifrtorrt-v-trapfeatures are enabled.
-
0.15.009 Sep 2025Release notes
Open source →A new batch of RISC-V releases is now available at
crates.io! Here we enumerate the most important changes, but please read theCHANGELOG.mdfiles for further details.riscvv0.15.0- @rmsyn added proxies to new CSRs.
- @romancardenas added new methods and associated functions that rely on
riscv-pacabstractions for interrupts. - @jsgf fixed a bug with the
mcausebit mask.
riscv-peripheralv0.4.0- @romancardenas added new constant methods to access registers for HART 0.
riscv-rtv0.16.0This release features numerous exciting changes. The most important are:
- @bjoernQ added the final necessary changes to allow
esp-riscv-rtto run on top ofriscv-rt. - @romancardenas added linker sections and adapted the boot process to resemble
cortex-m-rtandesp-riscv-rt. - @janderholm fixed a bug in the linker file. Also, the stack is now split into equal parts based on the number of hearts. In addition, the runtime now avoids some relative jumps to ease the linker placement of code.
- @jannic and @Dirbaio merged
global_asmmacro invocations to avoid potential undefined behavior in future Rust releases.
Other changes
- @Lumilesto fixed some links in the docs
- @gibbz00 improved the CI process with spelling checks and improved the docs of
riscv-rt
Thank you to all the people who contributed to these releases!
Release notes
Open source →Added
- New convenience
try_newandnewassociated functions forMtvecandStvec. - New methods and functions for enabling core interrupts in the
mieandsieregisters using theriscv_pac::CoreInterruptNumbertrait. - New
riscv::interrupt::{is_interrupt_enabled, disable_interrupt, enable_interrupt}functions. - New methods and functions for dealing with pending interrupts in
mipandsipregisters using theriscv_pac::CoreInterruptNumbertrait. - New
riscv::interrupt::is_interrupt_pendingfunction. - New
riscv::register::xip::clear_pendingatomic function formipandsipregisters. This function is marked asunsafe, as its availability depends both on the target chip and the target interrupt source. - Add
mseccfgCSR - Add
mseccfghCSR
Changed
- Use
cfg(any(target_arch = "riscv32", target_arch = "riscv64"))instead ofcfg(riscv). riscv::pac_enum(unsafe CoreInterrupt)now locates the vector table at the.trap.vectorsection instead of.trap.- Allow all bits to be set in Mcause::from_bits on 64-bit targets.
Removed
- Removed custom build script, as
cfg(riscv)is no longer necessary. - All the fields of
MipandSipCSR proxies are now read-only. This change is motivated to avoid clearing unwanted interrupts triggered between CSR reads and CSR writes.
-
0.14.010 Jun 2025Release notes
Open source →A new batch of RISC-V releases are now available at
crates.io! Here we enumerate the most important changes, but please read theCHANGELOG.mdfiles for further detailsriscvv0.14.0@rmsyn added new CSRs. Also, MSRV is now 1.67
riscv-peripheralv0.3.0This crate experienced a full rework, so the code corresponding to RISC-V peripherals is more natural for PACS generated with
svd2rustriscv-rtv0.15.0We added the
deviceandmemoryfeatures to allow PACs to simplify the linking process, similar tocortex-m-rt. If you enable these features, thelink.xfile will include thedevice.xand/ormemory.xfiles. In this way, just includinglink.xin your binary is enough.The
__pre_initsymbol has disappeared fromriscv-rtby default. If you need it, you must activate thepre_initfeature. Also, note that theriscv_rt::pre_inithas been deprecated, as it is unsound to execute Rust code before RAM initialization. Instead, use assembly.We removed weak symbols, as currently stable Rust does not support weak linkage and LTOs. Now, we use
_default_*symbols. Once weak linkage is available in stable Rust, we plan to go back to weak symbols. Thanks, @rslawson !Release notes
Open source →Added
- CSR helper macro
write_composite_csrfor writing 64-bit CSRs on 32-bit targets. - Write utilities for
mcycle,minstret - Add
senvcfgCSR - Add
scontextCSR - Add
mconfigptrCSR - Bump MSRV to 1.67.0 for
logtoilogname change - Add
mtval2CSR
Changed
- Simplify
riscv::interrupt::machine::nested
- CSR helper macro
-
0.13.018 Feb 2025Release notes
Open source →riscv0.12.0- CSR writes are now all
unsafe. Users can open an RFC to nominate certain CSRs to be safe (#209) - All CSR fields are now generated using macros (thanks, @rmsyn !)
- PACs can now use the
RISCV_MTVEC_ALIGNenvironment variable to set the vector table byte alignment ((thanks, @ia0 !)
riscv-rt0.13.0- Compatibility with RV32E and RV64E!
- Linker script is now more aligned with
cortex-m-rt
riscv-target-parser0.1.0New utility crate to assist in build scripts of the RISC-V ecosystem. It is useful for determining which extensions are available, the base ISA of the target, etc.
riscv-peripheral0.2.1 andriscv-semihosting0.1.3Update dependencies
Release notes
Open source →Added
- CSR helper macro to check for platform implementation
Changed
- Make all CSR writes
unsafeby default (#209) - Use
RISCV_MTVEC_ALIGNto control the alignment constraint of the vector table - Simplify register macros with
cfgfield - Align assembly functions with
cortex-m - Use CSR helper macros to define
marchidregister - Re-use
try_*functions inmcountinhibit - Use CSR helper macros to define
mcauseregister - Use CSR helper macros to define
medelegregister - Use CSR helper macros to define
midelegregister - Use CSR helper macros to define
mcounterenregister - Use CSR helper macros to define
mieregister - Use CSR helper macros to define
mimpidregister - Use CSR helper macros to define
misaregister - Use CSR helper macros to define
mipregister - Use CSR helper macros to define
mstatusregister - Use CSR helper macros to define
mstatushregister - Use CSR helper macros to define
mtvecregister - Use CSR helper macros to define
mtvendoridregister - Use CSR helper macros to define
satpregister - Use CSR helper macros to define
pmpcfgxfield types - Use CSR helper macros to define
scausefield types - Use CSR helper macros to define
sieregister - Use CSR helper macros to define
scounterenfield types - Use CSR helper macros to define
sipregister - Use CSR helper macros to define
sstatusfield types - Use CSR helper macros to define
stvecfield types - Add remaining
pmpcfgCSRs from RISC-V privileged spec
- CSR writes are now all
-
0.12.121 Oct 2024 -
0.12.020 Oct 2024 withdrawnRelease notes
Open source →New features
riscv0.12.0- Support for target-dependent external interrupt and exception numbers
riscv-macrosfor helping during the definition of custom interrupt and exception sources- Macros for automating the definition of new CSRs
riscv-pac0.2.0- Enumeration of common errors for RISC-V targets at the register level
- All PAC traits now work with
usizenumbers - New
ExceptionNumbertrait for custom exception numbers
riscv-peripheral0.2.0- Adapt to new changes in the RISC-V ecosystem
riscv-rt0.13.0- Now exceptions rely on the
_dispatch_exceptionfunction - Now interrupts rely on the
_dispatch_interruptfunction - While the crate provides a default implementation for the previously mentioned functions, you can skip these functions with the new
no-exceptionsandno-interruptsfeatures. This way, you can adaptriscv-rtto target-specific sources. - New
pre_init_trapto detect early errors during the boot process. - Vectored interrupts handling is now available under the
v-trapfeature! - New
core_interrupt,external_interrupt, andexceptionmacros for defining interrupt and exception handlers - New
u-bootfeature to execute U-boot binaries.
Release notes
Open source →Added
riscv-macroscrate forriscv-pacenums.- Bump MSRV to 1.61.
- Implementation of
riscv-pactraits forInterruptandExceptionenums. - Tests for the
riscv-pactrait implementations ofInterruptandExceptionenums. - Add
Mcause::from(usize)for use in unit tests - Add
Mstatus::from(usize)for use in unit tests - Add
Mstatus.bits() - Add
EqandPartialEqforpmpcfgx::{Range, Permission} - Add
Mstatus::update_*helpers to manipulate Mstatus values without touching the CSR - Export
riscv::register::macrosmodule macros for external use - Add
riscv::register::mcountinhibitmodule formcountinhibitCSR - Add
Mcounterenin-memory update functions - Add
Mstatusvector extension support - Add fallible counterparts to all functions that
panic - Add
riscv-pacas a dependency - Add CSR-defining macros to create in-memory types
Fixed
- Fixed
sip::set_ssoftandsip::clear_ssoftusing wrong address - Fixed assignment in
mstatusunit tests. - delay implementation does not use binary labels in inline assembly.
-
0.11.115 Feb 2024Release notes
Open source →Changed
- Made
asm::wfi,fence,fence_iandsfencesafe (ie, removedunsafefrom their definitions) - Made
cfgvariable selection more robust for custom targets
- Made
-
0.11.014 Jan 2024Release notes
Open source →Added
- Add
asm::ecall(), a wrapper for implementing anecallinstruction - Add
nestedfunction for nested ISRs ininterrupt::machineandinterrupt::supervisor s-modefeature for reexportinginterrupt::machineorinterrupt::supervisortointerrupt- Support for supervisor-level interrupts in
interrupt::supervisor - Add CI workflow to check that CHANGELOG.md file has been modified in PRs
- Add
read_csr_as_rv32,set_rv32, andclear_rv32macros - Add
mstatus::uxlandmstatus::sxl - Add
mstatus::ube,mstatus::sbe, andmstatus::mbeendianness bit fields - Add
mstatushregisters (RISCV-32 only) - Add
asm::fence(), a wrapper for implementing afenceinstruction - Add
asm::fence_i(), a wrapper for implementing afence.iinstruction - Add
TryFromimplementation formcause::{Interrupt, Exception}andscause::{Interrupt, Exception}
Changed
- Cargo workspace for riscv and riscv-rt
- Update
embedded-haldependency to v1.0.0 (bumps MSRV to 1.60) misa::MXLrenamed tomisa::XLEN- Removed
bit_fielddependency - CI actions updated. They now use
checkout@v3anddtolnay/rust-toolchain. mcause::{Interrupt, Exception}andscause::{Interrupt, Exception}now implementFromtrait forusize- Set safety of
asm::nopandasm::delayfunctions to safe.
Fixed
- Fix
scause::ExceptionmissingLoadMisaligned - Fix
scause::ExceptionmissingSupervisorEnvCall - Removed user-level interrupts from
mcause::Interruptandscause::Interrupt - Removed user-level interrupts from
mstatus - Removed machine environment call delegation from
medeleg - Removed user-level interrupts from machine and supervisor mode interrupt-related registers.
Removed
- User mode registers removed, as they are no longer supported in RISC-V
- FCSR register operations removed to avoid UB (#148)
- Add
-
0.10.118 Jan 2023 -
0.10.010 Nov 2022 withdrawnRelease notes
Open source →Release notes
Open source →Added
critical-section-single-hartfeature which provides an implementation for thecritical_sectioncrate for single-hart systems, based on disabling all interrupts.
-
0.9.007 Oct 2022 withdrawnRelease notes
Open source →Fixed
- Fix
asm::delay()to ensure count register is always reloaded - Fix reading marchid and mimpid (#107)
Removed
set_msoft,clear_msoft,set_mtimerandclear_mtimerremoved as part of fixing issue #62
- Fix
-
0.8.106 Oct 2022 withdrawnRelease notes
Open source →112: Propose to release a version
riscvv0.8.1 r=almindor a=luojia65The
riscvcrate includes an important fix (#107) where the RustSBI community would leverage the use of. However, the latest release v0.8.0 did not include this fix. In this pull request we want to propose to release a new version ofriscvcrate to include at least this fix, so that RustSBI community would write correct implemenations based on this crate.Notes to
CHANGELOG.md: the release date2022-10-06can always be changed.r?
@DisasmCo-authored-by: luojia65 [email protected]
-
0.8.020 Apr 2022Release notes
Open source →102: Prepare v0.8.0 release r=almindor a=Disasm
Co-authored-by: Vadim Kaushan [email protected]
Release notes
Open source →Added
- Add
#[cfg(riscv32)]topmpcfg1andpmpcfg3modules - Add enums
Range,Permissionfor PMP configuration - Add
set_pmp()andclear_pmp()functions to pmpcfg(x) modules - Add struct
Pmpcsrand is returned frompmpcfgx::read() - Add
singleton!macro - Add delay structure and methods using embedded-hal traits and
mcycleregister - Add
asm::delay()function for assembly-based busy-loops - Add
asm::nop(), a wrapper for implementing anopinstruction - Add missing
#[inline]attribute to register reads, type conversations andinterrupt::free
Changed
- Use new
asm!instead ofllvm_asm! - Change
pmpcfgx::read()macro toread_csr_as!()fromread_csr_as_usize!() - Inline assembly is now always used
- Update Minimum Supported Rust Version to 1.59
Fixed
- Fix
sfence.vmaoperand order
Removed
- Remove
inline-asmfeature which is now always enabled
- Add
-
0.7.030 Jul 2021Release notes
Open source →Added
- Add
medelegregister - Add
cycle[h],instret[h]andmcounteren - Add additional binaries for floating-point ABIs
- Add support for
mxr - Add support for
mprv
Changed
- Fix
scause::set - Various formatting and comment fixes
- Update
bare-metaltov1.0.0removingNrtrait - Build targets on
docs.rsare now RISC-V targets other than default ones
- Add
-
0.6.020 Jun 2020Release notes
Open source →Changed
Mtvec::trap_mode(),Stvec::trap_mode()andUtvec::trap_mode()functions now returnOption<TrapMode>(breaking change)- Updated Minimum Supported Rust Version to 1.42.0
- Use
llvm_asm!instead ofasm!
Removed
- vexriscv-specific registers were moved to the
vexriscvcrate
-
0.5.614 Mar 2020 -
0.5.507 Mar 2020Release notes
Open source →Added
- Added
riscv32i-unknown-none-elftarget support - Added user trap setup and handling registers
- Added write methods for the
mipandsatpregisters - Added
midelegregister - Added Changelog
Changed
- Fixed MSRV by restricting the upper bound of
bare-metalversion
- Added
-
0.5.423 Jul 2019Nothing published for this version
-
0.5.325 Jun 2019Nothing published for this version
-
0.5.202 Apr 2019Nothing published for this version
-
0.5.129 Mar 2019Nothing published for this version
-
0.5.001 Mar 2019Nothing published for this version
-
0.4.024 Jan 2019Nothing published for this version
-
0.3.012 Aug 2018Nothing published for this version
-
0.2.025 Apr 2018Nothing published for this version
-
0.1.420 Nov 2017Nothing published for this version
-
0.1.318 Nov 2017Nothing published for this version
-
0.1.218 Nov 2017Nothing published for this version
-
0.1.118 Nov 2017Nothing published for this version
-
0.1.019 Sep 2017Nothing published for this version