mtd-utils编译过程

一.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.第一次编译
  1. sun@ubuntu:/work/6410/tools/mtd-utils$ make
  2.   CHK include/version.h
  3.   LD ftl_format
  4.   CC flash_erase.o
  5.   LD flash_erase
  6.   CC nanddump.o
  7.   LD nanddump
  8.   CC doc_loadbios.o
  9.   LD doc_loadbios
  10.   CC ftl_check.o
  11.   LD ftl_check
  12.   CC mkfs.jffs2.o
  13. mkfs.jffs2.c:70:21:error: sys/acl.h: No such file or directory
  14. mkfs.jffs2.c:Infunction'formalize_posix_acl':
  15. mkfs.jffs2.c:1024:error:'ACL_USER_OBJ' undeclared (first use in this function)
  16. mkfs.jffs2.c:1024:error:(Each undeclared identifier is reported only once
  17. mkfs.jffs2.c:1024:error:foreachfunction it appears in.)
  18. mkfs.jffs2.c:1025:error:'ACL_GROUP_OBJ' undeclared (first use in this function)
  19. mkfs.jffs2.c:1026:error:'ACL_MASK' undeclared (first use in this function)
  20. mkfs.jffs2.c:1027:error:'ACL_OTHER' undeclared (first use in this function)
  21. mkfs.jffs2.c:1033:error:'ACL_USER' undeclared (first use in this function)
  22. mkfs.jffs2.c:1034:error:'ACL_GROUP' undeclared (first use in this function)
  23. make:***[/work/6410/tools/mtd-utils/arm-none-linux-gnueabi/mkfs.jffs2.o]Error 1
原因:  编译时调用acl.h了而没有调用zlib库
解决方法:指定WITHOUT_XATTR=1 指定编译时要调用zlib库

2.第二次编译
  1. sun@ubuntu:/work/6410/tools/mtd-utils$ make WITHOUT_XATTR=1
  2.   CHK include/version.h
  3.   CC mkfs.jffs2.o
  4.   CC compr_rtime.o
  5.   CC compr_zlib.o
  6.   CC compr_lzo.o
  7. compr_lzo.c:31:23:error: lzo/lzo1x.h: No such file or directory
  8. compr_lzo.c:Infunction'jffs2_lzo_cmpr':
  9. compr_lzo.c:53:error:'lzo_uint' undeclared (first use in this function)
  10. compr_lzo.c:53:error:(Each undeclared identifier is reported only once
  11. compr_lzo.c:53:error:foreachfunction it appears in.)
  12. compr_lzo.c:53:error: expected ';' before 'compress_size'
  13. compr_lzo.c:56: warning: implicit declaration of function'lzo1x_999_compress'
  14. compr_lzo.c:56:error:'compress_size' undeclared (first use in this function)
  15. compr_lzo.c:58:error:'LZO_E_OK' undeclared (first use in this function)
  16. compr_lzo.c:Infunction'jffs2_lzo_decompress':
  17. compr_lzo.c:74:error:'lzo_uint' undeclared (first use in this function)
  18. compr_lzo.c:74:error: expected ';' before 'dl'
  19. compr_lzo.c:76: warning: implicit declaration of function'lzo1x_decompress_safe'
  20. compr_lzo.c:76:error:'dl' undeclared (first use in this function)
  21. compr_lzo.c:78:error:'LZO_E_OK' undeclared (first use in this function)
  22. compr_lzo.c:Infunction'jffs2_lzo_init':
  23. compr_lzo.c:97:error:'LZO1X_999_MEM_COMPRESS' undeclared (first use in this function)
  24. make:***[/work/6410/tools/mtd-utils/arm-none-linux-gnueabi/compr_lzo.o]Error 1
原因: 没有lzo库
解决方法:编译lzo库,并添加到交叉编译工具链中
  1. sun@ubuntu:/work/6410/tools/mtd-utils$ cd ..
  2. sun@ubuntu:/work/6410/tools$ wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.06.tar.gz   //下载lzo库
  3. sun@ubuntu:/work/6410/tools$ ls
  4. lzo-2.06.tar.gz mtd-utils
  5. //下面的config指定交叉编译器
  6. 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/
  7. //编译
  8. sun@ubuntu:/work/6410/tools/lzo-2.06$ make && make install
  9. //确认在工具链目录中是否己经有头文件了
  10. sun@ubuntu:/work/6410/tools/lzo-2.06$ find /opt/6410/4.3.2/-name "lzo1x.h"
  11. /opt/6410/4.3.2/arm-none-linux-gnueabi/include/lzo/lzo1x.h
3.第三次编译
  1. sun@ubuntu:/work/6410/tools/mtd-utils$ make WITHOUT_XATTR=1
  2.   CHK include/version.h
  3.   LD mkfs.jffs2
  4. /opt/6410/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -lz
  5. collect2: ld returned 1 exit status
  6. make:***[/work/6410/tools/mtd-utils/arm-none-linux-gnueabi/mkfs.jffs2]Error 1
原因: 没有libz库
解决方法:编译libz库,并添加到交叉编译工具链中
  1. sun@ubuntu:/work/6410/tools$ wget http://zlib.net/zlib-1.2.8.tar.gz   //下载lzo库
  2. sun@ubuntu:/work/6410/tools$ ls
  3. lzo-2.06 lzo-2.06.tar.gz lzo-2.06.tar.gz.1 mtd-utils zlib-1.2.8.tar.gz
  4. sun@ubuntu:/work/6410/tools$ tar xf zlib-1.2.8.tar.gz 
  5. sun@ubuntu:/work/6410/tools$ cd zlib-1.2.8/
  6. //下面的config指定交叉编译器
  7. 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/
  8. //编译并安装到工具链目录中
  9. sun@ubuntu:/work/6410/tools/zlib-1.2.8$ make && make install
  10. //确认在工具链目录中是否己经有库了
  11. sun@ubuntu:/work/6410/tools/zlib-1.2.8$ find /opt/6410/4.3.2/arm-none-linux-gnueabi/-name "libz*"
  12. /opt/6410/4.3.2/arm-none-linux-gnueabi/lib/libz.a
  13. /opt/6410/4.3.2/arm-none-linux-gnueabi/lib/libz.so.1
  14. /opt/6410/4.3.2/arm-none-linux-gnueabi/lib/libz.so.1.2.8
  15. /opt/6410/4.3.2/arm-none-linux-gnueabi/lib/libz.so
  16. /opt/6410/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/libz.a
4.第四次编译
  1. sun@ubuntu:/work/6410/tools/mtd-utils$ make WITHOUT_XATTR=1
  2. In file included from mkfs.ubifs/mkfs.ubifs.c:26:
  3. mkfs.ubifs/mkfs.ubifs.h:46:23:error: uuid/uuid.h: No such file or directory
  4. mkfs.ubifs/mkfs.ubifs.c:Infunction'write_data':
  5. mkfs.ubifs/mkfs.ubifs.c:1621: warning: implicit declaration of function'time'
  6. mkfs.ubifs/mkfs.ubifs.c:Infunction'write_super':
  7. mkfs.ubifs/mkfs.ubifs.c:1934: warning: implicit declaration of function'uuid_generate_random'
  8. mkfs.ubifs/mkfs.ubifs.c:1938: warning: implicit declaration of function'uuid_unparse_upper'
  9. make:***[/work/6410/tools/mtd-utils/arm-none-linux-gnueabi/mkfs.ubifs/mkfs.ubifs.o]Error 1
原因: 找不到头文件uuid
解决方法:
  1. sun@ubuntu:/opt/6410/4.3.2$ grep "uuid_generate_random"*-
  2.       arm-none-linux-gnueabi/libc/usr/include/uuid.h:void uuid_generate_random(uuid_t out);
  3. //搜索发现uuid.h是在include目录下而不是在uuid这个目录下,所以只需要改一下路径就可以了
  4. sun@ubuntu:/work/6410/tools/mtd-utils$ vi mkfs.ubifs/mkfs.ubifs.h
  5.  46 //#include <uuid/uuid.h>
  6.  47 #include <uuid.h>
5.第五次编译
  1. sun@ubuntu:/work/6410/tools/mtd-utils$ make WITHOUT_XATTR=1
  2.   CHK include/version.h
  3.   CC mkfs.ubifs/mkfs.ubifs.o
  4.   CC mkfs.ubifs/crc16.o
  5.   CC mkfs.ubifs/lpt.o
  6.   CC mkfs.ubifs/compr.o
  7.   CC mkfs.ubifs/devtable.o
  8.   CC mkfs.ubifs/hashtable/hashtable.o
  9.   CC mkfs.ubifs/hashtable/hashtable_itr.o
  10.   CC ubi-utils/libubi.o
  11.   AR ubi-utils/libubi.a
  12.   LD mkfs.ubifs/mkfs.ubifs
  13. /opt/6410/4.3.2/bin/../lib/gcc/arm-none-linux-gnueabi/4.3.2/../../../../arm-none-linux-gnueabi/bin/ld: cannot find -luuid
  14. collect2: ld returned 1 exit status
原因: 找不到库libuuid
解决方法:
  1. sun@ubuntu:/opt/6410/4.3.2$ find .-name "libuuid*"
  2. ./arm-none-linux-gnueabi/libc/armv4t/usr/lib/libuuid.so.1
  3. ./arm-none-linux-gnueabi/libc/armv4t/usr/lib/libuuid.so
  4. ./arm-none-linux-gnueabi/libc/armv4t/usr/lib/libuuid.so.1.2
  5. //搜索发现libuuid是在libc/armv4t/usr/lib目录下,arm-none-linux-gnueabi-ld找不到,所以加个软链接
  6. sun@ubuntu:/opt/6410/4.3.2/arm-none-linux-gnueabi/lib$ ln -../libc/armv4t/usr/lib/libuuid.so ./libuuid.so
6.第六次编译
OK,可以了,这样就有了一大串命令
  1. sun@ubuntu:/work/6410/tools/mtd-utils$ ls /tmp/mtd/sbin/
  2. docfdisk flash_eraseall flash_otp_lock ftl_format mkfs.ubifs nandtest recv_image sumtool ubiformat ubirename
  3. doc_loadbios flash_lock flash_otp_write jffs2dump mtd_debug nandwrite rfddump ubiattach ubimkvol ubirmvol
  4. flashcp flash_otp_dump flash_unlock jffs2reader mtdinfo nftldump rfdformat ubicrc32 ubinfo ubirsvol
  5. flash_erase flash_otp_info ftl_check mkfs.jffs2 nanddump nftl_format serve_image ubidetach ubinize ubiupdatevol

你可能感兴趣的:(linux,kernel,内核,linux内核,nand)