Crate flashkit_mtd
Expand description
Raw access to MTD partitions on NAND flash.
use std::io::Read as _;
use flashkit_mtd::{Flash as _, Partition, Reader};
let device = Partition::find("boot")?.open_read_only()?;
let mut block = vec![0; device.geometry().block_size() as usize];
let mut image = Vec::new();
Reader::new(&device, &mut block)?.read_to_end(&mut image)?;NAND flash is erased and written in blocks, and some blocks are bad. A bad
block has a marker in its first page. Reader and Writer skip marked
blocks. The n-th block of a partition is then its n-th good block. This is
the layout that bootloaders such as LK read.
When a block fails to erase, write or verify, Writer marks it bad and
writes the data to the next good block. Readers and the bootloader then skip
the failed block as well. Both see the same layout. If the next block fails
too, the writer stops with an error. Write protection makes every block
fail, and this keeps it from marking the whole chip bad.
Flash gives access to single physical blocks without any of this.
Some platforms protect partitions that another processor, such as a modem, owns. Accessing them can reset the system without an error in Linux. Only open the partitions you need.
Modulesยง
- device ๐
- device_
error ๐ - flash ๐
- geometry ๐
- good_
blocks ๐ - partition ๐
- reader ๐
- sys ๐
- ioctl interface of the MTD driver.
- wear ๐
- writer ๐
Structsยง
- Device
- Open MTD character device.
- Geometry
- Size, erase block size and page size of an MTD device.
- Good
Blocks - Iterator over the physical indexes of the good blocks of a
Flash. - Partition
- MTD partition listed in
/proc/mtd. - Reader
- Reader over the good blocks of an MTD device.
- Writer
- Writer over the good blocks of an MTD device.
Enumsยง
- Device
Error - Failure of an MTD operation.
Traitsยง
- Flash
- Operations on physical blocks of NAND flash.