CompilingMTDUtils

From eLinux.org
Revision as of 08:50, 6 October 2008 by Dirk (talk | contribs) (Add zlib and lzo build instructions)
Jump to: navigation, search

This article is about (cross-) compiling MTD-Utils. MTD-Utils(MTD == memory technology device) are user space tools to work with MTD kernel subsystem. As these tools are often necessary to write embedded file system to MTD (NOR/NAND) devices and there are some dependencies, we briefly describe here how to cross compile them.

Source and dependencies

MTD utils are available from MTD utils git. You can get them by

  • using gitweb "snapshot" feature (use "snapshot" link at latest commit at the right side)
  • using git
git pull git://git.infradead.org/mtd-utils.git mtd-utils

Compiling MTD utils depend on zlib and LZO. Download latest archives using the given links. For this example we use

  • zlib-1.2.3.tar.bz2
  • lzo-2.03.tar.gz
  • mtd-utils.git-snapshot-20081004.tar.gz

Cross compile

As example for cross compilation, we use CodeSourcery ARM tool chain as popular for BeagleBoard.

Note: If you use other cross compiler, replace tool chain prefix arm-none-linux-gnueabi- below by prefix of your (cross-) toolchain.

Preparation

In this example, we use

/home/user/mtd

as base directory. This example assumes you are in this directory and the above three source .tar.gz files are located here, too.

To not pollute the host file system, we install build results in local subdirectory:

> mkdir install

should result in /home/user/mtd/install (replace this with your real path below)

zlib

> tar xfj zlib-1.2.3.tar.bz2
> cd zlib-1.2.3/
zlib-1.2.3> ./configure --prefix=/home/user/mtd/install

Edit resulting Makefile, e.g.

zlib-1.2.3> emacs Makefile

and add toolchain prefix arm-none-linux-gnueabi- to gcc, ar and ranlib. Then you should be ready to compile:

zlib-1.2.3> make
zlib-1.2.3> make install
zlib-1.2.3> cd ..

Result should be zlib.a in install/lib directory and zlib's headers in install/include. If this was successful, remove build directory:

> rm -rf zlib-1.2.3

lzo

> tar xfz lzo-2.03.tar.gz
> cd lzo-2.03/
lzo-2.03 > ./configure --host=arm-none-linux-gnueabi --prefix=/home/user/mtd/install
lzo-2.03 > make
lzo-2.03 > make install
lzo-2.03 > cd ..
> rm -rf lzo-2.03

Result should be liblzo2.a in install/lib directory and lzo's headers in install/include/lzo.

mtd-utils

tbd.