Revision as of 02:12, 30 March 2014 by Craig Peacock (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Cross Compiling MTD Utils for ARM

At some stage you may need to run MTD utilities like flash_erase, mtdinfo, ubiformat, ubinfo on your ARM target system. The following includes details on how to build/cross compile the MTD utilities for ARM processors.

The MTD Utils require zlib and LZO compression libraries, and uuid from e2fsprogs as dependencies.

zlib Data Compression Library

Download, cross compile and install the zlib compression libraries. Configure doesn't accept the --host parameter (reports unknown option), so you need to hack the makefile.

wget http://zlib.net/zlib-1.2.8.tar.gz
tar -xzf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure --prefix=/home/temp/mtdutils

Edit the makefile and prefix the build tools with arm-none-linux-gnueabi-.

CC=arm-linux-gnueabi-gcc
LDSHARED=arm-linux-gnueabi-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
CPP=arm-linux-gnueabi-gcc -E
AR=arm-linux-gnueabi-ar
RANLIB=arm-linux-gnueabi-ranlib

Make and install:

make
make install

LZO Data Compression Library

Download, cross compile and install the LZO data compression library:

wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.06.tar.gz
tar -xzf lzo-2.06.tar.gz 
cd lzo-2.06/
./configure --host=arm-linux-gnueabi --prefix=/home/temp/mtdutils
make
make install

e2fsprogs

The mtd-util uses uuid from the e2fsprogs source. Download, cross compile and install:

wget http://sourceforge.net/projects/e2fsprogs/files/e2fsprogs/v1.42.9/e2fsprogs-1.42.9.tar.gz
tar -xzf e2fsprogs-1.42.9.tar.gz 
cd e2fsprogs-1.42.9
./configure --host=arm-linux-gnueabi --prefix=/home/temp/mtdutils
make
make install
cd lib/uuid/
make install

mtd-utils

With the dependencies above cross compiled for ARM and installed, we can now focus on MTD-Utils. Download the mtd-utils from GIT:

git clone git://git.infradead.org/mtd-utils.git
cd mtd-utils

mtd-utils does not include a configure script, so we must hack the makefile to cross compile it. Add the following to the makefile :

PREFIX = /home/temp/mtdutils
CROSS=arm-linux-gnueabi-

ZLIBCPPFLAGS = -I$(PREFIX)/include
ZLIBLDFLAGS = -L$(PREFIX)/lib

LZOCPPFLAGS = -I$(PREFIX)/include
LZOLDFLAGS = -L$(PREFIX)/lib

LDFLAGS += $(ZLIBLDFLAGS) $(LZOLDFLAGS)
CFLAGS ?= -O2 -g $(ZLIBCPPFLAGS) $(LZOCPPFLAGS)

Edit the common.mk file and comment out the PREFIX=/usr line. Then make and install:

WITHOUT_XATTR=1 make
make install

Download Pre-built Binaries

The link below contains a bzip2 tarball of the MTD-utils binaries compiled for ARM :

  • Built using:
    • zlib 1.2.6
    • lzo 2.06
    • e2fsprogs 1.42
    • mtd-utils 1.4.9
    • arm-none-linux-gnueabi-gcc version 4.6.1 (Sourcery CodeBench Lite 2011.09-70)
  • Built using:
    • zlib 1.2.8
    • lzo 2.06
    • e2fsprogs 1.42.9
    • mtd-utils 1.5.0
    • arm-linux-gnueabi-gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)