mmreg
A Rust library and CLI tool for safe, concurrent access to 32-bit memory-mapped IO registers.
Features
- Safe mapping/unmapping of physical memory (e.g., via
/dev/mem) - Register abstraction with offset and bitfield helpers
- Grouped register interfaces (e.g., AXI)
- Safe concurrent read/write operations (multi-process)
- Usable as both a library and a command-line tool
Usage
mmreg CLI Usage
Commands
read <address>: Read a 32-bit value from the given physical address.write <address> <value>: Write a 32-bit value to the given physical address.
Examples
Options
- Addresses and values can be specified in hex (with or without
0x). - Output is formatted as
0xXXXXXXXXfor reads.
Library Usage
See Documentation for API documentation and examples.
use ;
use ;
// Read a 32-bit value from a physical address
let value = read_register_at?;
// Write a 32-bit value to a physical address
write_register_at?;
// ...
Project Structure
src/register.rs: Single register and subregister abstractionsrc/interface.rs: Group of registers (interface)src/memregs.rs: Unsafe Memory read Write (unix only)src/lib.rs: Library APIsrc/main.rs: Command-line interface
Cross-Compilation Targets
The list of supported cross-compilation targets is maintained in a single file: targets.txt.
- Requires WSL/Ubuntu with buildtools for compilation.
sudo apt update ; sudo apt install -y build-essential - Do not edit the Makefile or config files to add/remove targets; always update
targets.txt. - The Makefile and build automation read from
targets.txtto ensure consistency. - Example contents of
targets.txt:
x86_64-unknown-linux-gnu
i686-unknown-linux-gnu
armv7-unknown-linux-gnueabihf
aarch64-unknown-linux-gnu
To add or remove a target, simply edit targets.txt and rerun your build commands.
License
MIT
mmreg Roadmap
Planned Features (Not in sequence)
- Support for 8, 16, 64, and larger register widths
- Batch/group register operations
- Improved error handling and diagnostics
- More flexible bitfield/subregister API
- Integration tests and example scripts
- Documentation improvements
- Support Windows machine build
- Setup Tests
- Setup release
- Add/Verify Targets
- mips-unknown-linux-gnu
- powerpc-unknown-linux-gnu
- riscv64gc-unknown-linux-gnu
Future Directions
- Optional async API for high-performance use