All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog and this project adheres to Semantic Versioning.
NVIC::request()no longer requires&mut self.
- Updated
SCB.ICSR.VECTACTIVE/SCB::vect_active()to be 9 bits instead of 8. Also fixesVectActive::fromto take au16and subtract16forVectActive::Interrupts to matchSBC::vect_active()(#373). - DWT: add
configureAPI for address, cycle count comparison (#342, #367). - ITM: add
configureAPI (#342). - TPIU: add API for Formatter and Flush Control (FFCR) and Selected Pin Control (SPPR) registers (#342).
- TPIU: add
swo_supportsfor checking what SWO configurations the target supports. (#381) - Add
stdandserdecrate features for improved host-side ITM decode functionality when working with the downstreamitm,cargo-rtic-scopecrates (#363, #366). - Added the ability to name the statics generated by
singleton!()for better debuggability (#364, #380). - Added
critical-section-single-corefeature which provides an implementation for thecritical_sectioncrate for single-core systems, based on disabling all interrupts. (#447)
- Fixed
singleton!()statics sometimes ending up in.datainstead of.bss(#364, #380). interrupt::freeno longer hands out aCriticalSectiontoken because it is unsound on multi-core. Usecritical_section::withinstead. (#447)
- Inline assembly is now always used, requiring Rust 1.59.
- removed all peripherals
ptr()functions in favor of the associated constantPTR(#385). - removed
inline-asmfeature which is now always enabled
v0.7.4 - 2021-12-31
- Added support for additional DWT counters (#349)
- CPI counter
- Exception overhead counter
- LSU counter
- Folded-instruction counter
- Added
DWT.set_cycle_count(#347). - Added support for the Cortex-M7 TCM and cache access control registers.
There is a feature
cm7to enable access to these (#352). - Add derives for serde, Hash, and PartialOrd to VectActive behind feature gates for host-platform use (#363).
- Support host platforms besides x86_64 (#369).
- Added
delay::Delay::with_source, a constructor that lets you specify the SysTick clock source (#374).
- Fix incorrect AIRCR PRIGROUP mask (#338, #339).
- Fix nightly users of inline-asm breaking now that the asm macro is removed from the prelude (#372).
DWT::get_cycle_counthas been deprecated in favor ofDWT::cycle_count. This change was made for consistency with the C-GETTER convention. (#349)
v0.7.3 - 2021-07-03
- Fixed compilation for native targets on non-x86 host systems (#336, #337).
- The
Delaystruct now offers directdelay_us()anddelay_ms()methods without having to go through the embedded-hal traits (#344).
v0.7.2 - 2021-03-07
- Fixed a bug where calling
asm::delay()with an argument of 0 or 1 would underflow, leading to a very long delay.
v0.7.1 - 2021-01-25
- New assembly methods
asm::semihosting_syscall,asm::bootstrap, andasm::bootload.
msp::writehas been deprecated in favor ofasm::bootstrap. It was not possible to usemsp::writewithout causing Undefined Behavior, so all existing users are encouraged to migrate.
- Fixed a bug in
asm::delaywhich could lead to incorrect codegen and infinite loops. - Improved timing guarantees of
asm::delayon multiple-issue CPU cores. - Additional compiler fences added to inline assembly where necessary.
- Fixed DWARF debug information in pre-built assembly binaries.
v0.7.0 - 2020-11-09
- New
InterruptNumbertrait is now required on interrupt arguments to the various NVIC functions, replacing the previous use ofNrfrom bare-metal. For backwards compatibility,InterruptNumberis implemented for types which areNr + Copy, but this will be removed in a future version. - Associated const
PTRis introduced to Core Peripherals to eventually replace the existingptr()API. - A delay driver based on SysTick.
- You can now use LTO to inline assembly calls, even on stable Rust.
See the
asm/lib.rsdocumentation for more details. - Initial ARMv8-M MPU support
- ICTR and ACTLR registers added
- Support for the Security Attribution Unit on ARMv8-M
- Previously, asm calls without the
inline-asmfeature enabled used pre-built objects which were built by a GCC compiler, whileinline-asmenabled the use ofllvm_asm!calls. The asm system has been replaced with a new technique which generates Rust static libs for stable calling, and uses the newasm!macro withinline-asm. See theasm/lib.rsdocumentation for more details. - Cache enabling now uses an assembly sequence to ensure correctness.
ptr()methods are nowconst.
SCB::invalidate_dcacheand related methods are now unsafe, see #188Peripheralsstruct is now non-exhaustive, so fields may be added in future non-breaking changes- Removed
aligneddependency - Removed const-fn feature
- Removed previously deprecated APIs
NVIC::clear_pendingNVIC::disableNVIC::enableNVIC::set_pendingSCB::system_reset
- Removed
basepri,basepri_max, andfaultmaskregisters from thumbv8m.base
v0.6.7 - 2021-01-26
- Fixed missing
peripheral::itmreexport.
v0.6.6 - 2021-01-26
- Fixed missing ITM reexport on
thumbv8m.basetargets.
v0.6.5 - 2021-01-24
- This release is forwards-compatible with cortex-m 0.7, and depends on and re-exports many types from that version. Both 0.6.5 and 0.7 may co-exist in a build.
v0.6.4 - 2020-10-26
- MSRV bumped to 1.36.0 due to
aligneddependency.
- Drop AT&T syntax from inline asm, which was causing miscompilations with newer versions of the compiler.
v0.6.3 - 2020-07-20
- Initial Cortex-M Security Extension support for armv8m
UDFintrinsic- Methods to enable/disable exceptions in SCB
- Fix bug in
asm::delaynot updating status clobber flags - Swapped to
llvm_asm!to support inline assembly on new nightlies - Our precompiled assembly routines have additional debug information
- ITM
is_fifo_readyimproved to support armv8 - Cache enabling moved to pre-built assembly routines to prevent possible undefined behaviour
v0.6.2 - 2020-01-12
- Allow writing to the
CONTROLregister viaregister::control::write - Add
DWT::unlock()for a safe way to unlock the DWT
- Deprecated incorrectly included registers (
BASPRI,BASEPRI_MAX,FAULTMASK) onthumbv8.base
v0.6.1 - 2019-08-21
- Better
Debug,PartialEqandEqfor more types - The
delayfunction is fixed for Cortex-M0 MCUs
- Static version of
system_resetassystem_reset2 - Now uses
links = "cortex-m"to not link multiple versions of the crate - Masking of the NVIC is added
NVIC::{mask,unmask} - Now Rust 2018 edition
{M,P}SPLIMaccess is now possible on ARMv8-M
system_resetis deprecated in favor ofsys_reset
v0.6.0 - 2019-03-12
- Fix numerous registers which were incorrectly included for thumbv6
SHCRSrenamed toSHCSRinSCB
-
Support for ARMv8-M (
thumbv8.baseandthumbv8.main) -
SCBgained methods to set and clearSLEEPONEXITbit -
NVICgainedSTIRregister and methods to request an interrupt -
DCBgained methods to check if debugger is attached
v0.5.8 - 2018-10-27
-
SCBgained methods to set, clear and check the pending state of the PendSV exception. -
SCBgained methods to set, clear and check the pending state of the SysTick exception. -
SCBgained methods to set and get the priority of system handlers like SVCall and SysTick. -
NVICgained static methods,pendandunpend, to set and clear the pending state of interrupts.
- The
NVIC.{clear,set}_pendingmethods have been deprecated in favor ofNVIC::{unpend,pend}.
v0.5.7 - 2018-09-06
DCB::enable_trace()andDCB::disable_trace()
iprintln!no longer depends oniprint!.cortex_m::iprintln!will work even ifcortex_m::iprinthas not been imported.
v0.5.6 - 2018-08-27
-
Removed duplicated symbols from binary blobs
-
The check-blobs.sh script
v0.5.5 - 2018-08-27 - YANKED
- This crate no longer depends on
arm-none-eabi-gcc.
v0.5.4 - 2018-08-11
- A method to trigger a system reset. See
SCB.system_reset.
-
Made the VTOR register (see peripheral::SCB) available on
thumbv6m-none-eabi. This register is present on Cortex-M0+, but not on Cortex-M0. -
Linking with LLD by marking all external assembly functions as
.thumb_func. See https://bugs.llvm.org/show_bug.cgi?id=38435 for details.
v0.5.3 - 2018-08-02
- Don't assemble basepri*.s and faultmask.s for ARMv6-M. This fix the build when using
clangas the assembler.
v0.5.2 - 2018-05-18
-
SCBgained a pair of safe methods to set / clear the DEEPSLEEP bit. -
asm::delay, delay loops whose execution time doesn't depend on the optimization level.
v0.5.1 - 2018-05-13
- An opt-in
"const-fn"feature that makesMutex.newconstructor into aconst fn. This feature requires a nightly toolchain.
v0.5.0 - 2018-05-11
-
DebugMonitorandSecureFaultvariants to theExceptionenumeration. -
An optional
"inline-asm"feature
-
[breaking-change] This crate now requires
arm-none-eabi-gccto be installed and available in$PATHwhen built with the"inline-asm"feature disabled (which is disabled by default). -
[breaking-change] The
register::{apsr,lr,pc}modules are now behind the"inline-asm"feature. -
[breaking-change] Some variants of the
Exceptionenumeration are no longer available onthumbv6m-none-eabi. See API docs for details. -
[breaking-change] Several of the variants of the
Exceptionenumeration have been renamed to match the CMSIS specification. -
[breaking-change] fixed typo in
shcrsfield ofscb::RegisterBlock; it was previously namedshpcrs. -
[breaking-change] removed several fields from
scb::RegisterBlockon ARMv6-M. These registers are not available on that sub-architecture. -
[breaking-change] changed the type of
scb::RegisterBlock.shprfromRW<u8>toRW<u32>on ARMv6-M. These registers are word accessible only on that sub-architecture. -
[breaking-change] renamed the
mmarfield ofscb::RegisterBlocktommfarto match the CMSIS name. -
[breaking-change] removed the
iabrfield fromscb::RegisterBlockon ARMv6-M. This register is not available on that sub-architecture. -
[breaking-change] removed several fields from
cpuid::RegisterBlockon ARMv6-M. These registers are not available on that sub-architecture. -
[breaking-change] The
Mutex.newconstructor is not aconst fnby default. To make it aconst fnyou have to opt into the"const-fn"feature, which was added in v0.5.1, and switch to a nightly compiler.
- [breaking-change] The
exceptionmodule has been removed. A replacement forException::activecan be found inSCB::vect_active. A modified versionexception::Exceptioncan be found in theperipheral::scbmodule.
v0.4.3 - 2018-01-25
- The initial value of a
singleton!no longer needs to be evaluable in const context; it can now be a value computed at runtime, or even a capture of some other local variable.
v0.4.2 - 2018-01-17
- Added a missing
Sendimplementation to all the peripherals.
v0.4.1 - 2018-01-16
peripheral::Peripheralsis now re-exported at the root of the crate.
v0.4.0 - 2018-01-15
-
Formatter and Flush Control register (FFCR) accessor to the TPIU register block.
-
A
singleton!macro that creates mutable reference to a statically allocated variable. -
A Cargo feature,
cm7-r0p1, to work around a silicon erratum that affects writes to BASEPRI on Cortex-M7 r0p1 devices.
-
[breaking-change] All peripherals are now exposed as scoped singletons and they need to be
taken into scope to become accessible. -
[breaking-change] The signatures of methods exposed by peripheral proxies have changed to better match the new scoped singletons semantics.
-
All the thin wrappers around assembly instructions now panic when executed on non-ARM devices.
- [breaking-change] APIs specific to ARMv7-M (
peripheral::{cbp, fpb, fpu, itm, tpiu},itm) when compiling forthumb6m-none-eabi.
v0.3.1 - 2017-07-20
{basepri,basepri_max}::writeare now compiler barriers for the same reason thatinterrupt::{disable,enable}are: they are used to create critical sections.
v0.3.0 - 2017-07-07
-
[breaking-change] Renamed
StackedRergisterstoExceptionFrameto better reflect the ARM documentation. -
[breaking-change] Renamed the variants of
Exceptionto better match the ARM documentation. -
[breaking-change] Renamed
Exception::currenttoException::activeand changed the signature to returnNonewhen no exception is being serviced. -
Moved bits non specific to the Cortex-M architecture into the
bare-metalcrate with the goal of sharing code between this crate and crates tailored for other (microcontroller) architectures.
-
[breaking-change] The
ctxtmodule along with the exception "tokens" in theexceptionmodule. Thecortex-m-rtcrate v0.3.0 provides a more ergonomic mechanism to add state to interrupts / exceptions; replace your uses ofLocalwith that. -
[breaking-change]
default_handler,DEFAULT_HANDLERSandHandlersfrom theexceptionmodule as well asReservedfrom the root of the crate.cortex-m-rtv0.3.0 provides a mechanism to override exceptions and the default exception handler. Change your use of theseHandlersand others to that.
interrupt::{enable,disable}are now compiler barriers. The compiler should not reorder code around these function calls for memory safety; that is the case now.
v0.2.11 - 2017-06-16
- An API to maintain the different caches (DCache, ICache) on Cortex M7 devices.
- the definition of the
ehprint!macro. - the implementation of the FPU API.
v0.2.10 - 2017-06-05
- Functions for the instructions DMB, ISB and DSB
- All the functions in the
asmmodule are nowinline(always)
v0.2.9 - 2017-05-30
- A bug in
itm::write_allwhere it would ignore the length of the buffer and serialize contents that come after the buffer.
v0.2.8 - 2017-05-30 - YANKED
- An
itm::write_alignedfunction to write 4 byte aligned buffers to an ITM port. This function is faster thanitm::write_allfor small buffers but requires the buffer to be aligned.
v0.2.7 - 2017-05-23
Dwt.enable_cycle_counter
v0.2.6 - 2017-05-08
- [breaking-change]. MEMORY UNSAFETY.
Mutexcould be used as a channel to send interrupt tokens from one interrupt to other thus breaking the contextLocalabstraction. See reproduction case below. This has been fixed by makingMutexSynconly if the protected data isSend.
#![feature(const_fn)]
#![feature(used)]
#![no_std]
use core::cell::RefCell;
use cortex_m::ctxt::Local;
use cortex_m::interrupt::Mutex;
use stm32f30x::interrupt::{self, Exti0, Exti1};
fn main() {
// ..
// trigger exti0
// then trigger exti0 again
}
static CHANNEL: Mutex<RefCell<Option<Exti0>>> = Mutex::new(RefCell::new(None));
// Supposedly task *local* data
static LOCAL: Local<i32, Exti0> = Local::new(0);
extern "C" fn exti0(mut ctxt: Exti0) {
static FIRST: Local<bool, Exti0> = Local::new(true);
let first = *FIRST.borrow(&ctxt);
// toggle
if first {
*FIRST.borrow_mut(&mut ctxt) = false;
}
if first {
cortex_m::interrupt::free(
|cs| {
let channel = CHANNEL.borrow(cs);
// BAD: transfer interrupt token to another interrupt
*channel.borrow_mut() = Some(ctxt);
},
);
return;
}
let _local = LOCAL.borrow_mut(&mut ctxt);
// ..
// trigger exti1 here
// ..
// `LOCAL` mutably borrowed up to this point
}
extern "C" fn exti1(_ctxt: Exti1) {
cortex_m::interrupt::free(|cs| {
let channel = CHANNEL.borrow(cs);
let mut channel = channel.borrow_mut();
if let Some(mut other_task) = channel.take() {
// BAD: `exti1` has access to `exti0`'s interrupt token
// so it can now mutably access local while `exti0` is also using it
let _local = LOCAL.borrow_mut(&mut other_task);
}
});
}
#[allow(dead_code)]
#[used]
#[link_section = ".rodata.interrupts"]
static INTERRUPTS: interrupt::Handlers = interrupt::Handlers {
Exti0: exti0,
Exti1: exti1,
..interrupt::DEFAULT_HANDLERS
};v0.2.5 - 2017-05-07 - YANKED
- Higher level API for the SysTick and FPU peripherals
- [breaking-change]. MEMORY UNSAFETY.
interrupt::enablewas safe to call inside aninterrupt::freecritical section thus breaking the preemption protection. Theinterrupt::enablemethod is nowunsafe.
v0.2.4 - 2017-04-20 - YANKED
- [breaking-change]. MEMORY UNSAFETY.
interrupt::freeleaked the critical section making it possible to access aMutexwhen interrupts are enabled (see below). This has been fixed by changing the signature ofinterrupt::free.
static FOO: Mutex<bool> = Mutex::new(false);
fn main() {
let cs = cortex_m::interrupt::free(|cs| cs);
// interrupts are enabled at this point
let foo = FOO.borrow(&cs);
}v0.2.3 - 2017-04-11 - YANKED
- [breaking-change]. MEMORY UNSAFETY. Some concurrency models that use "partial"
critical sections (cf. BASEPRI) can be broken by changing the priority of
interrupts or by changing BASEPRI in some scenarios. For this reason
NVIC.set_priorityandregister::basepri::writeare nowunsafe.
v0.2.2 - 2017-04-08 - YANKED
- [breaking-change]. MEMORY UNSAFETY. The
Mutex.borrow_mutmethod has been removed as it can be used to bypass Rust's borrow checker and get, for example, two mutable references to the same data.
static FOO: Mutex<bool> = Mutex::new(false);
fn main() {
cortex_m::interrupt::free(|mut cs1| {
cortex_m::interrupt::free(|mut cs2| {
let foo: &mut bool = FOO.borrow_mut(&mut cs1);
let and_foo: &mut bool = FOO.borrow_mut(&mut cs2);
});
});
}v0.2.1 - 2017-03-12 - YANKED
- The default exception handler now identifies the exception that's being serviced.
v0.2.0 - 2017-03-11 - YANKED
-
Semihosting functionality in the
semihostingmodule. -
exception::Handlersstruct that represent the section of the vector table that contains the exception handlers. -
A default exception handler
-
A high level API for the NVIC peripheral.
-
Context local data.
-
borrow/borrow_mutmethods toMutexthat replacelock. -
API and macros to send bytes / (formatted) strings through ITM
-
[breaking-change]
StackFramehas been renamed toStackedRegistersand moved into theexceptionsmodule. -
[breaking-change] Core peripherals can now be modified via a
&-reference and are no longerSync. -
[breaking-change]
interrupt::free's closure now includes a critical section token,CriticalSection. -
[breaking-change] the core register API has been revamped for type safety.
-
The safety of assembly wrappers like
wfiandinterrupt::freehas been reviewed. In many cases, the functions are no longer unsafe. -
[breaking-change]
bkpt!has been turned into a function. It no longer accepts an immediate value.
-
vector_tableand its associatedstruct,VectorTable. It's not a good idea to give people a simple way to call the exception handlers. -
Mutex'slockmethod as it's unsound. You could use it to get multiple&mut -references to the wrapped data.
v0.1.6 - 2017-01-22
Exceptiona enumeration of the kind of exceptions the processor can service. There's also aException::currentconstructor that returns theExceptionthat's currently being serviced.
interrupt::Mutex, a "mutex" based on critical sections.
- The closure that
interrupt::freetakes can now return a value.
asm::nop, a wrapper over the NOP instruction
- a StackFrame data structure
v0.1.2 - 2016-10-04
- Read/write Operations on registers (lr, cr, msp, etc.) which were reversed.
v0.1.1 - 2016-10-03 - YANKED
- Small, non user visible change to make this crate compile further for $HOST (e.g. x86_64) with the goal of making it possible to test, on the HOST, downstream crates that depend on this one.
- Functions to access core peripherals like NVIC, SCB and SysTick.
- Functions to access core registers like CONTROL, MSP and PSR.
- Functions to enable/disable interrupts
- Functions to get the vector table
- Wrappers over miscellaneous instructions like
bkpt