Crates.io | peekpoke |
lib.rs | peekpoke |
version | 0.3.0 |
source | src |
created_at | 2023-02-23 17:56:27.108716 |
updated_at | 2023-09-25 07:38:04.533437 |
description | peekpoke - a lightweight Rust library for accessing physical addresses using /dev/mem in Linux |
homepage | https://github.com/erickrenz/peekpoke |
repository | https://github.com/erickrenz/peekpoke |
max_upload_size | |
id | 792961 |
size | 10,718 |
A lightweight Rust library used for reading and writing from physical memory address using /dev/mem
.
In Linux, /dev/mem
is a character device file containing access to the physical memory in a system. This file can be used to read and write to physical addresses on the bare metal (or virtualized) hardware. This functionality for user-space applications is similar to the devmem
cli utility in busybox.
For more information, refer to the linux kernel manual.
Linux (WSL, Debian, Fedora, Arch)
Sudo permissions
Add this to your Cargo.toml
:
[dependencies]
peekpoke = "0.3"
let address: u32 = 0x4000_0000;
let value: u32 = 0xDEAD_BEEF;
peekpoke::write(address, value);
let result: u32 = peekpoke::read(address);
println!("{:#010X}", result); // 0xDEAD_BEEF
CONFIG_STRICT_DEVMEM=n
(RECCOMENDED). The default kernel configuration denies access to RAM using /dev/mem
(default: CONFIG_STRICT_DEVMEM=y
) for non root users.The default behavior for /dev/mem
is to return errors if the address you enter is invalid. Refer to your hardware's manual for further troubleshooting steps.
For embedded systems development, it may be useful to cross compile your app to run on a different architecture. For more information on this process, check out this example GitHub repo for Rust cross-compiling.
Peekpoke is distributed under the terms of the MIT license. See terms and conditions here.