mtd_utils 移植

  1、设置编释器

       export PATH=/usr/local/arm/3.3.2/bin/:$PATH

     2、解压压缩包:

       tar zxvf zlib-1.2.3.tar.gz

       tar jxvf mtd-utils-1.2.0.tar.bz2 

        点击此处下载以上两个资源

     3、编译zlib-1.2.3.tar.gz

       修改Makefile  CC=arm-linux-gcc./configure --prefix=/usr/local/arm/3.3.2/arm-linux

       make install

       说明:这里的--prefix是要使zlib编释完后安装到/usr/local/arm/3.3.2/arm-linux,是为了下面

       编译mtd要用zlib和zlib.h头文件。

     4、到编译mtd了:

       先vi Makefile,把“#CROSS=arm-linux-”中的"#"号去掉。

       make

       这就生成flashcp、flash_erase等,这就是想要的了。

使用:

      把flash_erase、flashcp考到开发板上.


常用命令:


flash_erase  MTD-device  [start]  [cnt (# erase blocks  64K/block)]
flash_eraseall  MTD-device 
flashcp  -v filename  MTD-device 



移植mtd_utils常见错误(转自http://blog.chinaunix.net/uid-26009923-id-3862627.html)

1.第一次编译

1. sun@ubuntu:/work/6410/tools/mtd-utils$ make

2.   CHK include/version.h

3.   LDftl_format

4.   CCflash_erase.o

5.   LDflash_erase

6.   CC nanddump.o

7.   LD nanddump

8.   CCdoc_loadbios.o

9.   LDdoc_loadbios

10.  CCftl_check.o

11.  LDftl_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: In function '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: for each function 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.   CCcompr_rtime.o

5.   CCcompr_zlib.o

6.   CCcompr_lzo.o

7. compr_lzo.c:31:23: error: lzo/lzo1x.h: No such file or directory

8. compr_lzo.c: In function 'jffs2_lzo_cmpr':

9. compr_lzo.c:53: error: 'lzo_uint' undeclared (first use in this function)

10.compr_lzo.c:53: error: (Each undeclaredidentifier is reported only once

11.compr_lzo.c:53: error: for each function itappears 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: In function '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: In function '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: In function 'write_data':

5. mkfs.ubifs/mkfs.ubifs.c:1621: warning: implicit declaration of function 'time'

6. mkfs.ubifs/mkfs.ubifs.c: In function '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:voiduuid_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_eraseallflash_otp_lock ftl_format mkfs.ubifs nandtest recv_image sumtool ubiformatubirename

3. doc_loadbios flash_lockflash_otp_write jffs2dump mtd_debug nandwrite rfddump ubiattach ubimkvol ubirmvol

4. flashcp flash_otp_dumpflash_unlock jffs2reader mtdinfo nftldump rfdformat ubicrc32 ubinfo ubirsvol

5. flash_eraseflash_otp_info ftl_check mkfs.jffs2 nanddump nftl_format serve_image ubidetachubinize ubiupdatevol

 


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值