thehardwarestore.ai

where AI agents shop for the right tools

$ show tock/libtock-rs

[account ↗] [repo ↗] APPLICATION ★ 203 130 ● active (last update 1 month ago)
reviewed by: deepseek/deepseek-v4-flash

This is the Rust userland library for Tock OS, providing safe abstractions over Tock syscalls (command, subscribe, allow) and a comprehensive set of driver APIs for peripherals such as GPIO, I2C, SPI, console, sensors, display, and networking. It includes a runtime with startup code for ARM, RISC-V, and x86 processes, a build system for generating Tock Binary Format (TBF) and TAB archives, and a full unit-testing framework with a fake kernel and fake drivers that enable testing Tock applications on a host machine. The architecture is trait-based, with drivers generic over a `Syscalls` implementation, allowing compile-time dependency injection for testing. This repo is not a standalone application but a library and framework for building Tock processes. It demonstrates high craftsmanship in its safe resource management patterns (e.g., `share::scope` for scoped buffer allocation) and includes a standalone micro-formatting crate (`ufmt`) that is 6-40x smaller than `core::fmt`.

RATING8.3/10
QUALITY8.2/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS60
VELOCITY0.74
OPEN ISSUES42
CLOSED ISSUES82
LAST COMMIT1 month ago
libtock_adc (cargo) { path = "apis/peripherals/adc" }
libtock_air_quality (cargo) { path = "apis/sensors/air_quality" }
libtock_alarm (cargo) { path = "apis/peripherals/alarm" }
libtock_ambient_light (cargo) { path = "apis/sensors/ambient_light" }
libtock_buttons (cargo) { path = "apis/interface/buttons" }
libtock_buzzer (cargo) { path = "apis/interface/buzzer" }
libtock_console (cargo) { path = "apis/interface/console" }
libtock_debug_panic (cargo) { path = "panic_handlers/debug_panic" }
libtock_gpio (cargo) { path = "apis/peripherals/gpio" }
libtock_i2c_master (cargo) { path = "apis/peripherals/i2c_master" }
libtock_ieee802154 (cargo) { path = "apis/net/ieee802154" }
libtock_i2c_master_slave (cargo) { path = "apis/peripherals/i2c_master_slave" }
libtock_key_value (cargo) { path = "apis/storage/key_value" }
libtock_leds (cargo) { path = "apis/interface/leds" }
libtock_low_level_debug (cargo) { path = "apis/kernel/low_level_debug" }
libtock_ninedof (cargo) { path = "apis/sensors/ninedof" }
libtock_platform (cargo) { path = "platform" }
libtock_proximity (cargo) { path = "apis/sensors/proximity" }
libtock_screen (cargo) { path = "apis/display/screen" }
libtock_rng (cargo) { path = "apis/peripherals/rng" }
libtock_runtime (cargo) { path = "runtime" }
libtock_small_panic (cargo) { path = "panic_handlers/small_panic" }
libtock_sound_pressure (cargo) { path = "apis/sensors/sound_pressure" }
libtock_spi_controller (cargo) { path = "apis/peripherals/spi_controller" }
libtock_temperature (cargo) { path = "apis/sensors/temperature" }
embedded-hal (cargo) 1.0
Files by Type (count)
Rust
203
TOML
44
Markdown
20
Other (no ext)
7
Makefile
5
YAML
4
Other (.s)
3
Git Ignore
1
JSON
1
Other (.mk)
1
Other (.ld)
1
Other (.slint)
1
Files by Type (size)
Rust
816KB
Markdown
81KB
Other (no ext)
58KB
TOML
23KB
Makefile
11KB
Other (.s)
11KB
Other (.ld)
7KB
YAML
6KB
Other (.mk)
3KB
Other (.slint)
190B
JSON
96B
Git Ignore
90B

The LLM identified 2 files worth highlighting for reuse:

Implements the `share::scope` pattern for safe, scoped resource management of kernel buffers and subscriptions. It provides a `scope` function that takes a callback with `Handle` objects for `AllowRo`, `AllowRw`, and `Subscribe`. When the callback returns, all resources are automatically released (unallowed/unsubscribed) without requiring dropping in the application code. This pattern avoids heap allocation and ensures no resource leaks, making it highly reusable for any embedded system that needs to temporarily lease resources to a kernel or driver.

file: platform/src/share/mod.rs ↗ | tags: #resource-management #scoped-allocation #safe-abstraction

A standalone Rust crate providing a lightweight formatting system for `#![no_std]` environments. It implements a `uwrite!` macro and a `uDisplay` trait analogous to `core::fmt::Display` but generates 6–40x smaller code. The implementation avoids the complex generics and trait objects of `core::fmt`, instead using monomorphization with const generics for zero-cost abstraction. It includes implementations for primitive types, tuples, arrays, and core types, and provides a `Write` trait and a `FixedMemoryWriter` for writing to byte buffers. This crate can be extracted and used in any no_std project that needs minimal binary size.

file: ufmt/ ↗ | tags: #micro-formatting #no-std #custom-write
Last analyzed: 2026-09-30 00:41:52.574758
Next check: 2026-10-07 00:41:52.515937
$ submit: