Skip to content

NAND support - #130

Draft
mschwan-phytec wants to merge 12 commits into
mainfrom
wip-nand-support
Draft

mschwan-phytec wants to merge 12 commits into
mainfrom
wip-nand-support

Conversation

@mschwan-phytec

Copy link
Copy Markdown
Collaborator

No description provided.

Add a dedicated error code for failures while parsing the UBI section of
a layout configuration file. This follows the existing codes for eMMC
and MTD parsing errors and is needed by the new UBI module.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Introduce a new module for UBI (Unsorted Block Images), the volume
management layer used on raw NAND flash. NANDs do not have a partition
table, but UBI volumes, which in turn usually hold a UBIFS filesystem
for a rootfs or raw data for bootloader related files.

This module parses the volumes out of a layout configuration. A volume
is described by a name, a size in bytes, its type (dynamic or static),
an optional filesystem (UBIFS by default, none for raw volumes), extra
arguments for mkfs.ubifs, and a sequence of input files.

The sizes given in the layout configuration are not yet checked against
the logical erase blocks of a real device. This requires an attached UBI
device and is done in a later step.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Allow specifying a nested 'ubi' mapping in an MTD partition. The UBI
device is then created on top of that partition and holds the volumes
specified in its 'volumes' sequence.

A partition holding UBI volumes must not have its own input, because
writing raw data to the partition and formatting it with UBI are
mutually exclusive.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Test a layout configuration with UBI volumes nested into an MTD
partition, including a static raw volume and an expanding volume with
UBIFS as filesystem.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Add a new user suite test for the MTD module. It only parses layout
configurations and never calls any of the flash functions, so no MTD
device is ever accessed.

Next to a valid configuration, test several invalid ones: a volume
without a name or size, a partition with an 'ubi' mapping without
volumes, an expanding volume which is not the last one, an unknown
volume type, an unsupported filesystem, an input bigger than its
volume, and a partition with both an input and UBI volumes.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Add error codes for failures while setting up UBI on an MTD and while
writing and verifying UBI volumes. They are used by the UBI module the
same way the MTD codes are used by the MTD module.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Add the runtime part of the UBI module: detach an already attached UBI
device, format an MTD with UBI, attach it again, and create the volumes
specified in a layout configuration.

MTDs holding UBI volumes must be detached before their partitions can
be removed, otherwise the kernel refuses to remove a partition that is
still in use. Formatting with ubiformat instead of only erasing the
partition ensures fresh erase counters and an empty volume table, so
that the layout is fully reproducible.

The UBI device number of an attached MTD is looked up in sysfs, because
it is assigned by the kernel and thus not known in advance. The same is
done for the volume nodes: they are found by their name, which UBI
guarantees to be unique per UBI device.

Volumes with a filesystem are formatted with mkfs.ubifs, which obtains
the LEB size and the volume size from the volume itself. Data is either
written as a UBIFS image with ubiupdatevol, extracted from a tar
archive, or copied into the mounted filesystem. Raw volumes are written
with ubiupdatevol and verified by reading the volume back, similar to
how raw MTD partitions are verified with flashcp.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Handle partitions with a 'ubi' section while initializing, formatting,
and writing an MTD.

Such partitions are formatted with UBI instead of being erased, and
their volumes are created right afterwards. Writing data then goes to
the volumes instead of copying an image onto the partition with
flashcp.

UBI devices attached to the master device or to one of its old
partitions are detached before the partitions are removed, as the
kernel refuses to remove partitions which are still in use.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Static volumes have no filesystem by default, so leave the filesystem
out of the volume in the valid configuration and add configurations for
a static volume with an explicit filesystem and for an expanding static
volume, both of which must be rejected.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Describe the 'ubi' mapping of an MTD partition and all options of its
volumes, including the difference between dynamic and static volumes and
the automatic UBIFS filesystem default for dynamic volumes.

Also describe how input files of volumes are treated and which writes
are verified by reading the data back.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
The note stating that devices without a flash translation layer, such as
MTDs, are unsupported is outdated since MTD support was added in
partup 3.0.0. Replace it with a note explaining that an MTD must be
given as its master device and that the kernel needs to expose it.

Add MTDs, including NAND flash with UBI volumes, to the list of
supported output devices and to the list of writes that are verified by
reading the data back.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>
Add an example layout configuration for a raw NAND flash. It shows a raw
partition written with flashcp next to a partition formatted with UBI,
holding static volumes for the bootloader and a dynamic UBIFS rootfs.

Signed-off-by: Martin Schwan <m.schwan@phytec.de>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant