1. 简介
在使用 flash_eraseall 命令时可能没有,如果你是用的busybox自己定制文件系统,只需要在配置busybox中时按自己需要将nandflash相关工具选择上,重新编译制作。
Miscellaneous Utilities --->
[*] nandwrite
[*] nanddump
[*] flash_eraseall
但还是有一些情况需要我们自己移植 flash 相关的操作命令,即 mtd_util
2. 正文
此次移植的版本是:2.0.0
本文的介绍顺序是记录的整个移植过程。
下载 mtd-utils-2.0.0,解压,进入目录,在目录下新建一个文件夹 install
然后回到mtd-utils的解压目录下
> ./configure --prefix=/home/zyl/wor_lip/porting/mtd-utils-2.0.0/install --host=arm-linux CC="arm-none-linux-gnueabi-gcc -march=armv4t"
出现错误
configure: error: lzo missing
安装 lzo,
先下载lzo:http://www.oberhumer.com/opensource/lzo/#download
解压文件,在文件夹下创建 install 文件夹
> mkdir install
> ./configure --prefix=/home/zyl/wor_lip/porting/lzo-2.10/install --host=arm-linux CC="arm-none-linux-gnueabi-gcc -march=armv4t"
> make
> make install
在install下就有有我们需要的库,文件结构如下
关键的数据大小
216K include/
664K lib/liblzo2.a
我们查找源码中有关lzo的变量,发现在configure中有如下的变量
./configure:1497: LZO_CFLAGS C compiler flags for lzo
./configure:1498: LZO_LIBS linker flags for lzo
则之前的配置命令变成:
./configure --prefix=/home/zyl/wor_lip/porting/mtd-utils-2.0.0/install --host=arm-linux CC="arm-none-linux-gnueabi-gcc -march=armv4t" LDFLAGS=-L/home/zyl/wor_lip/porting/lzo-2.10/install/lib CPPFLAGS=-I/home/zyl/wor_lip/porting/lzo-2.10/install/include/lzo
其中上面的 LDFLAGS 变量决定了 configure 脚本能不能找到lzo。
出现错误
ubifs-utils/mkfs.ubifs/mkfs.ubifs.h:46:23: fatal error: uuid/uuid.h: No such file or directory
#include <uuid/uuid.h>
搜索路径发现系统中文件在include下,因此改动这里变成
#include <uuid.h>
ubifs-utils/mkfs.ubifs/compr.c:28:23: fatal error: lzo/lzo1x.h: No such file or directory
#include <lzo/lzo1x.h>
我们知道lzo头文件搜索路径我们设置的是 CPPFLAGS=-I/home/zyl/wor_lip/porting/lzo-2.10/install/include/lzo,因此,我们重新配置下,将搜索路径变成lzo的上一层
> ./configure --prefix=/home/zyl/wor_lip/porting/mtd-utils-2.0.0/install --host=arm-linux CC="arm-none-linux-gnueabi-gcc -march=armv4t" LDFLAGS=-L/home/zyl/wor_lip/porting/lzo-2.10/install/lib CPPFLAGS=-I/home/zyl/wor_lip/porting/lzo-2.10/install/include
出现错误
ubifs-utils/mkfs.ubifs/compr.c:33:18: fatal error: zlib.h: No such file or directory
#include <zlib.h>
缺少 zlib,
下载zlib,
在解压出来的文件中创建文件夹 install
配置
> ./configure --prefix=/home/zyl/wor_lip/porting/zlib-1.2.11/install --shared
更改Makefile
CC=arm-none-linux-gnueabi-gcc -march=armv4t
LDSHARED=$(CC) -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
CPP=$(CC) -E
AR=arm-none-linux-gnueabi-ar
RANLIB=arm-none-linux-gnueabi-ranlib
> make
> make install
回到mtd文件夹下
> ./configure --prefix=/home/zyl/wor_lip/porting/mtd-utils-2.0.0/install --host=arm-linux CC="arm-none-linux-gnueabi-gcc -march=armv4t" LDFLAGS="-L/home/zyl/wor_lip/porting/lzo-2.10/install/lib -L/home/zyl/wor_lip/porting/zlib-1.2.11/install/lib" CPPFLAGS="-I/home/zyl/wor_lip/porting/lzo-2.10/install/include -I/home/zyl/wor_lip/porting/zlib-1.2.11/install/include"
出现错误
/home/zyl/arm-2014.05/bin/../lib/gcc/arm-none-linux-gnueabi/4.8.3/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -luuid
看来是系统中没有uuid的库,下载移植
下载:https://sourceforge.net/projects/libuuid/files/latest/download
在解压的文件夹下创建 install 文件夹
> ./configure --prefix=/home/zyl/wor_lip/porting/libuuid-1.0.3/install --host=arm-linux CC="arm-none-linux-gnueabi-gcc -march=armv4t"
> make
> make install
重新回到mtd文件夹下,添加libuuid相关
> ./configure --prefix=/home/zyl/wor_lip/porting/mtd-utils-2.0.0/install --host=arm-linux CC="arm-none-linux-gnueabi-gcc -march=armv4t" LDFLAGS="-L/home/zyl/wor_lip/porting/lzo-2.10/install/lib -L/home/zyl/wor_lip/porting/zlib-1.2.11/install/lib -L/home/zyl/wor_lip/porting/lzo-2.10/install/lib -L/home/zyl/wor_lip/porting/libuuid-1.0.3/install/lib" CPPFLAGS="-I/home/zyl/wor_lip/porting/lzo-2.10/install/include -I/home/zyl/wor_lip/porting/zlib-1.2.11/install/include -I/home/zyl/wor_lip/porting/libuuid-1.0.3/install/include"
> make
hmmm,顺利通过,
> make install
将 install/sbin中的可执行程序拷贝到开发板中相应位置就能使用了。