本文主要是介绍mtd-utils编译过程,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
http://blog.csdn.net/jackyard/article/details/46453055
一.mtd-utils编译过程
下载:
sun@ubuntu:/work/6410/tools$ git clone git://git.infradead.org/mtd-utils.git
修改Makefile
sun@ubuntu:/work/6410/tools/mtd-utils$ vi common.mk
1 CROSS=arm-none-linux-gnueabi- ;指定交叉编译器
25 PREFIX=/tmp/mtd
1.第一次编译
- sun@ubuntu:/work/6410/tools/mtd-utils$ make
- CHK include/version.h
- LD ftl_format
- CC flash_erase.o
- LD flash_erase
- CC nanddump.o
- LD nanddump
- CC doc_loadbios.o
- LD doc_loadbios
- CC ftl_check.o
- LD ftl_check
- CC mkfs.jffs2.o
- mkfs.jffs2.c:70:21:error: sys/acl.h: No such file or directory
- mkfs.jffs2.c:Infunction'formalize_posix_acl':
- mkfs.jffs2.c:1024:error:'ACL_USER_OBJ' undeclared (first use in this function)
- mkfs.jffs2.c:1024:error:(Each undeclared identifier is reported only once
- mkfs.jffs2.c:1024:error:foreachfunction it appears in.)
- mkfs.jffs2.c:1025:error:'ACL_GROUP_OBJ' undeclared (first use in this function)
- mkfs.jffs2.c:1026:error:'ACL_MASK' undeclared (first use in this function)
- mkfs.jffs2.c:1027:error:'ACL_OTHER' undeclared (first use in this function)
- mkfs.jffs2.c:1033:error:'ACL_USER' undeclared (first use in this function)
- mkfs.jffs2.c:1034:error:'ACL_GROUP' undeclared (first use in this function)
- make:***[/work/6410/tools/mtd-utils/arm-none-linux-gnueabi/mkfs.jffs2.o]Error 1
解决方法:指定WITHOUT_XATTR=1 指定编译时要调用zlib库
2.第二次编译
- sun@ubuntu:/work/6410/tools/mtd-utils$ make WITHOUT_XATTR=1
- CHK include/version.h
- CC mkfs.jffs2.o
- CC compr_rtime.o
- CC compr_zlib.o
- CC compr_lzo.o
- compr_lzo.c:31:23:error: lzo/lzo1x.h: No such file or directory
- compr_lzo.c:Infunction'jffs2_lzo_cmpr':
- compr_lzo.c:53:error:'lzo_uint' undeclared (first use in this function)
- compr_lzo.c:53:error:(Each undeclared identifier is reported only once
- compr_lzo.c:53:error:foreachfunction it appears in.)
- compr_lzo.c:53:error: expected ';' before 'compress_size'
- compr_lzo.c:56: warning: implicit declaration of function'lzo1x_999_compress'
- compr_lzo.c:56:error:'compress_size' undeclared (first use in this function)
- compr_lzo.c:58:error:'LZO_E_OK' undeclared (first use in this function)
- compr_lzo.c:Infunction'jffs2_lzo_decompress':
- compr_lzo.c:74:error:'lzo_uint' undeclared (first use in this function)
- compr_lzo.c:74:error: expected ';' before 'dl'
- compr_lzo.c:76: warning: implicit declaration of function'lzo1x_decompress_safe'
- compr_lzo.c:76:error:'dl' undeclared (first use in this function)
- compr_lzo.c:78:error:'LZO_E_OK' undeclared (first use in this function)
- compr_lzo.c:Infunction'jffs2_lzo_init':
- compr_lzo.c:97:error:'LZO1X_999_MEM_COMPRESS' undeclared (first use in this function)
- make:***[/work/6410/tools/mtd-utils/arm-none-linux-gnueabi/compr_lzo.o]Error 1
解决方法:编译lzo库,并添加到交叉编译工具链中
- sun@ubuntu:/work/6410/tools/mtd-utils$ cd ..
- sun@ubuntu:/work/6410/tools$ wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.06.tar.gz //下载lzo库
- sun@ubuntu:/work/6410/tools$ ls
- lzo-2.06.tar.gz mtd-utils
- //下面的config指定交叉编译器
- sun@ubuntu:/work/6410/tools/lzo-2.06$ CC=arm-none-linux-gnueabi-gcc ./configure --host=arm-linux --prefix=/opt/6410/4.3.2/arm-none-linux-gnueabi/
- //编译
- sun@ubuntu:/work/6410/tools/lzo-2.06$ make && make install
- //确认在工具链目录中是否己经有头文件了
- sun@ubuntu:/work/6410/tools/lzo-2.06$ find /opt/6410/4.3.2/-name "lzo1x.h"
- /opt/6410/4.3.2/arm-none-linux-gnueabi/include/lzo/lzo1x.h
- sun@ubuntu:/work/6410/tools/mtd-utils$ make WITHOUT_XATTR=1
- CHK include/version.h
- LD mkfs.jffs2
- /opt/6410/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lz
- collect2: ld returned 1 exit status
- make:***[/work/6410/tools/mtd-utils/arm-none-linux-gnueabi/mkfs.jffs2]Error 1
解决方法:编译libz库,并添加到交叉编译工具链中
- sun@ubuntu:/work/6410/tools$ wget http://zlib.net/zlib-1.2.8.tar.gz //下载lzo库
- sun@ubuntu:/work/6410/tools$ ls
- lzo-2.06 lzo-2.06.tar.gz lzo-2.06.tar.gz.1 mtd-utils zlib-1.2.8.tar.gz
- sun@ubuntu:/work/6410/tools$ tar xf zlib-1.2.8.tar.gz
- sun@ubuntu:/work/6410/tools$ cd zlib-1.2.8/
- //下面的config指定交叉编译器
- sun@ubuntu:/work/6410/tools/zlib-1.2.8$ CC=arm-none-linux-gnueabi-gcc ./configure --shared --prefix=/opt/6410/4.3.2/arm-none-linux-gnueabi/
- //编译并安装到工具链目录中
- sun@ubuntu:/work/6410/tools/zlib-1.2.8$ make && make install
- //确认在工具链目录中是否己经有库了
- sun@ubuntu:/work/6410/tools/zlib-1.2.8$ find /opt/6410/4.3.2/arm-none-linux-gnueabi/-name "libz*"
- /opt/6410/4.3.2/arm-none-linux-gnueabi/lib/libz.a
- /opt/6410/4.3.2/arm-none-linux-gnueabi/lib/libz.so.1
- /opt/6410/4.3.2/arm-none-linux-gnueabi/lib/libz.so.1.2.8
- /opt/6410/4.3.2/arm-none-linux-gnueabi/lib/libz.so
- /opt/6410/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/libz.a
- sun@ubuntu:/work/6410/tools/mtd-utils$ make WITHOUT_XATTR=1
- In file included from mkfs.ubifs/mkfs.ubifs.c:26:
- mkfs.ubifs/mkfs.ubifs.h:46:23:error: uuid/uuid.h: No such file or directory
- mkfs.ubifs/mkfs.ubifs.c:Infunction'write_data':
- mkfs.ubifs/mkfs.ubifs.c:1621: warning: implicit declaration of function'time'
- mkfs.ubifs/mkfs.ubifs.c:Infunction'write_super':
- mkfs.ubifs/mkfs.ubifs.c:1934: warning: implicit declaration of function'uuid_generate_random'
- mkfs.ubifs/mkfs.ubifs.c:1938: warning: implicit declaration of function'uuid_unparse_upper'
- make:***[/work/6410/tools/mtd-utils/arm-none-linux-gnueabi/mkfs.ubifs/mkfs.ubifs.o]Error 1
解决方法:
- sun@ubuntu:/opt/6410/4.3.2$ grep "uuid_generate_random"*-R
- arm-none-linux-gnueabi/libc/usr/include/uuid.h:void uuid_generate_random(uuid_t out);
- //搜索发现uuid.h是在include目录下而不是在uuid这个目录下,所以只需要改一下路径就可以了
- sun@ubuntu:/work/6410/tools/mtd-utils$ vi mkfs.ubifs/mkfs.ubifs.h
- 46 //#include <uuid/uuid.h>
- 47 #include <uuid.h>
- sun@ubuntu:/work/6410/tools/mtd-utils$ make WITHOUT_XATTR=1
- CHK include/version.h
- CC mkfs.ubifs/mkfs.ubifs.o
- CC mkfs.ubifs/crc16.o
- CC mkfs.ubifs/lpt.o
- CC mkfs.ubifs/compr.o
- CC mkfs.ubifs/devtable.o
- CC mkfs.ubifs/hashtable/hashtable.o
- CC mkfs.ubifs/hashtable/hashtable_itr.o
- CC ubi-utils/libubi.o
- AR ubi-utils/libubi.a
- LD mkfs.ubifs/mkfs.ubifs
- /opt/6410/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -luuid
- collect2: ld returned 1 exit status
解决方法:
- sun@ubuntu:/opt/6410/4.3.2$ find .-name "libuuid*"
- ./arm-none-linux-gnueabi/libc/armv4t/usr/lib/libuuid.so.1
- ./arm-none-linux-gnueabi/libc/armv4t/usr/lib/libuuid.so
- ./arm-none-linux-gnueabi/libc/armv4t/usr/lib/libuuid.so.1.2
- //搜索发现libuuid是在libc/armv4t/usr/lib目录下,arm-none-linux-gnueabi-ld找不到,所以加个软链接
- sun@ubuntu:/opt/6410/4.3.2/arm-none-linux-gnueabi/lib$ ln -s ../libc/armv4t/usr/lib/libuuid.so ./libuuid.so
OK,可以了,这样就有了一大串命令
- sun@ubuntu:/work/6410/tools/mtd-utils$ ls /tmp/mtd/sbin/
- docfdisk flash_eraseall flash_otp_lock ftl_format mkfs.ubifs nandtest recv_image sumtool ubiformat ubirename
- doc_loadbios flash_lock flash_otp_write jffs2dump mtd_debug nandwrite rfddump ubiattach ubimkvol ubirmvol
- flashcp flash_otp_dump flash_unlock jffs2reader mtdinfo nftldump rfdformat ubicrc32 ubinfo ubirsvol
- flash_erase flash_otp_info ftl_check mkfs.jffs2 nanddump nftl_format serve_image ubidetach ubinize ubiupdatevol
这篇关于mtd-utils编译过程的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!