Crates.io | rucos-cortex-m |
lib.rs | rucos-cortex-m |
version | 0.1.1 |
source | src |
created_at | 2023-11-05 19:33:32.038394 |
updated_at | 2023-11-12 21:05:30.602942 |
description | A port of the RuCOS kernel to ARM Cortex-M |
homepage | |
repository | https://github.com/bbrown1867/rucos-rs |
max_upload_size | |
id | 1026143 |
size | 35,404 |
Rust Microcontroller Operating System (RuCOS, pronounced roo-cos) is a
real-time kernel for embedded Rust applications (no_std
).
async
/await
patternstable
The rucos
crate is a collection of no_std
data structures. It has
no platform specific or unsafe
code. The Kernel
struct is designed to be
used as a singleton in an embedded application.
The rucos
crate would be difficult to use alone, as the embedded application
needs a mutable reference to the Kernel
singleton in every task. This is
where the "port specific" crate comes in (e.g. rucos-cortex-m
).
The port specific crate creates wrappers around the Kernel
APIs, dealing with
platform specific details (e.g. stack initialization) and handling the Kernel
singleton in a safe way (e.g. disabling interrupts).
Using RuCOS is as simple as adding the port specific crate to Cargo.toml
and
calling a few APIs.
use rucos_cortex_m as rucos;
let my_task = |_: u32| -> ! {
loop {
info!("Hello from Task {}", rucos::get_current_task());
rucos::sleep(rucos::TICK_RATE_HZ);
}
};
let mut idle_stack: [u8; IDLE_STACK_SIZE] = [0; IDLE_STACK_SIZE];
let mut my_task_stack: [u8; TASK_STACK_SIZE] = [0; TASK_STACK_SIZE];
rucos::init(&mut idle_stack, None);
rucos::create(0, 10, &mut my_task_stack, my_task, None);
rucos::start(...);
rucos
, only the Rust toolchain is requiredrucos-cortex-m
, the nightly
Rust toolchain is requiredrucos-cortex-m
examples, probe-rs
is requiredrucos-cortex-m
examples, the probe-rs
VS Code extension is required./build_all
rucos
cd kernel && cargo test
rucos-cortex-m
Testing rucos-cortex-m
requires targeting a particular device. The STM32F767
microcontroller is used as the test platform, but note that the example code
should be easily portable to other devices.
Ideally cargo test
would be used to automate target testing via defmt-test
,
but the nature of RuCOS applications is that they do not terminate and or follow
a serial sequence of steps we can assert on. Instead examples
are used for testing and each one must be run manually:
cd cortex-m && cargo run --example <name>