MTD Utilities
From Texas Instruments Embedded Processors Wiki
Contents |
What are the MTD Utilities?
The MTD Utilities are a collection of tools that allow the user to interact with the MTD subsystem in the kernel to perform operations on Flash devices. The most commonly used utilities are:
- flash_erase - Erases an erase block of flash
- flash_eraseall - Erases the entire flash device
- flashcp - Copies data into NOR flash
- flash_info - Displays information about Flash devices
- flash_lock - Lock flash pages to prevent writing
- flash_unlock - Unlock flash pages to allow writing
- mkfs.jffs2 - Create a JFFS2 file system image from an existing file system
- nandwrite - Write an input file (i.e. JFFS2 or YAFFS2 image) to the NAND Flash device
These utilities are often used to write file system images to the Flash device
on an embedded system.
Where to Obtain the MTD Utilities
The MTD utilities can be obtained from the mtd-utils.git project at http://git.infradead.org/. Here you can download the latest sources for compilation as well individual version releases. If you cannot use git you can obtain a snapshot of the latest sources using the git web interface on this site.
Host
This section describes how to compile the MTD utilities for the Linux development host. Versions of these utilities have already been compiled for the target and can be found on the MontaVista target file system. i.e. /opt/mv_pro_4.0.1/montavista/pro/devkit/arm/v5t_le/target
Prerequisites
The MTD utilities require the liblzo package to be installed on you Linux development host in order to compile. This package is usually installed in the /usr/local/lib directory as liblzo2.la and liblzo2.a
If you do not have liblzo installed you can download the sources from http://www.oberhumer.com/opensource/lzo/download/ and perform the following actions to build it for your Linux development host.
host$ tar xzf lzo-#.##.tar.gz host$ cd lzo-#.## host$ ./configure host$ make host$ make install
NOTE: In the above command replace #.## with the version downloaded from http://www.oberhumer.com/opensource/lzo/download/
Compilation
- Obtain the MTD utils tree from http://git.infradead.org/ and extract them into a working directory.
- Compile the MTD utilities with 'make'
- host$ make clean
- host$ make
Installing the MTD Utilities
After the MTD utilities have been compiled they can be installed with the command:
host$ make install
This will place the utilities in you /usr/sbin directory. If you do not have /usr/sbin in your PATH variable you can add it by editing your ~/.bash_profile file and adding /usr/sbin to your PATH variable.
Target
Using MontaVista toolchain, there is a version of the MTD utilities compiled for the ARM target provided in the MontaVista tool chain. The target file system from MontaVista, located at <MontaVista install dir>/pro/devkit/arm/v5t_le/target, contains these tools for the target.
Leave a Comment
