MTD address mapper

Driver for address remap for flash devices. More...

Detailed Description

Driver for address remap for flash devices.

This MTD module allows for remapping multiple different regions on a single MTD device and present them as separate MTD devices. This is similar to partitions on a hard drive, although this system only allows hardcoded partitions and lacks a partition table.

The use case for this module is to be able to split a single MTD device, for example a SPI NOR flash chip into multiple separate regions which all can contain their own content or file systems.

Usage

To use this module include it in your makefile:

USEMODULE += mtd_mapper

To define new regions with an existing MTD device the following is required:

.mtd = {
.sector_count = SECTOR_COUNT / 2,
.pages_per_sector = PAGE_PER_SECTOR,
.page_size = PAGE_SIZE,
},
.parent = &parent,
.sector = SECTOR_COUNT / 2
};
mtd_dev_t *dev = &region.mtd;

The snippet here defines a region within an existing MTD_0 device of half the size of MTD_0 and starting in the middle of the device.

Warning
Please ensure that the different configured regions do not overlap.

Interface definitions for mtd mapper support

Author
Koen Zandberg koen@.nosp@m.berg.nosp@m.zand..nosp@m.net

Data Structures

struct  mtd_mapper_parent_t
 MTD mapper backing device context. More...
 
struct  mtd_mapper_region_t
 MTD mapped region. More...
 

Macros

#define MTD_PARENT_INIT(_parent)
 Shortcut macro for initializing the members of an mtd_mapper_parent_t struct. More...
 

Variables

const mtd_desc_t mtd_mapper_driver
 Mapper MTD device operations table.
 

Macro Definition Documentation

◆ MTD_PARENT_INIT

#define MTD_PARENT_INIT (   _parent)
Value:
{ \
.mtd = _parent, \
.lock = MUTEX_INIT, \
.init = false, \
}

Shortcut macro for initializing the members of an mtd_mapper_parent_t struct.

Definition at line 77 of file mtd_mapper.h.

mtd_dev_t
MTD device descriptor.
Definition: mtd.h:58
mtd_dev_t::driver
const mtd_desc_t * driver
MTD driver.
Definition: mtd.h:59
mtd_mapper_parent_t
MTD mapper backing device context.
Definition: mtd_mapper.h:87
mtd_mapper_region_t::mtd
mtd_dev_t mtd
MTD context
Definition: mtd_mapper.h:97
MTD_0
#define MTD_0
Default MTD drive definition.
Definition: board_common.h:127
MTD_PARENT_INIT
#define MTD_PARENT_INIT(_parent)
Shortcut macro for initializing the members of an mtd_mapper_parent_t struct.
Definition: mtd_mapper.h:77
MUTEX_INIT
#define MUTEX_INIT
Static initializer for mutex_t.
Definition: mutex.h:133
mtd_mapper_driver
const mtd_desc_t mtd_mapper_driver
Mapper MTD device operations table.
mtd_mapper_region_t
MTD mapped region.
Definition: mtd_mapper.h:96