acl_2.2.47.orig.tar.gzlzo-2.03.tar.gzmtd-utils_20080508.orig.tar.gzzlib-1.2.3.tar.gzmkfs.jffs2.for.arm-linux-gcc.3.4.1平台.tar.bz2mkfs.jffs2.for.arm-linux-gcc.4.3.2平台.tar.bz2mkfs.jffs2.for.pc平台.tar.bz2如果只需要mkfs.jffs2工具,那么ubuntu 8.10下直接安装jffnms软件包即可,
luther@gliethttp:~$ sudo apt-get install jffnms
如果需要将jffs2移植到arm开发板上,那么就需要下载源码进行交叉编译了,这就是本文的内容.
1.下载工具软件源码包
luther@gliethttp:~$ wget
luther@gliethttp:~$ wget
luther@gliethttp:~$ wget
luther@gliethttp:~$ mkdir libs 用来存放下面生成的lib库.
2.编译zlib库
luther@gliethttp:~/zlib-1.2.3$ ./configure --prefix=~/libs --shared
对于交叉编译输入如下指令
luther@gliethttp:~/zlib-1.2.3$ CC=arm-linux-gcc ./configure --prefix=~/libs --shared
luther@gliethttp:~/zlib-1.2.3$ make -j4
luther@gliethttp:~/zlib-1.2.3$ make install
luther@gliethttp:~$ tree ~/libs
/home/ubuntu/libs
|-- include
| |-- zconf.h
| `-- zlib.h
|-- lib
| |-- libz.so -> libz.so.1.2.3
| |-- libz.so.1 -> libz.so.1.2.3
| `-- libz.so.1.2.3
`-- share
`-- man
`-- man3
`-- zlib.3
5 directories, 6 files
这就表示完成了.
3.编译lzo库
luther@gliethttp:~/lzo-2.03$ ./configure --prefix=/home/ubuntu/libs --enable-shared
对于交叉编译输入如下指令
luther@gliethttp:~/lzo-2.03$ CC=arm-linux-gcc ./configure --host=arm-linux --prefix=/home/ubuntu/libs --enable-shared --disable-static
这个还必须要绝对路径才行.
luther@gliethttp:~/lzo-2.03$ make
luther@gliethttp:~/lzo-2.03$ make install
luther@gliethttp:~$ tree ~/libs
.
|-- include
| |-- lzo
| | |-- lzo1.h
| | |-- lzo1a.h
| | |-- lzo1b.h
| | |-- lzo1c.h
| | |-- lzo1f.h
| | |-- lzo1x.h
| | |-- lzo1y.h
| | |-- lzo1z.h
| | |-- lzo2a.h
| | |-- lzo_asm.h
| | |-- lzoconf.h
| | |-- lzodefs.h
| | `-- lzoutil.h
| |-- zconf.h
| `-- zlib.h
|-- lib
| |-- liblzo2.a
| |-- liblzo2.la
| |-- liblzo2.so -> liblzo2.so.2.0.0
| |-- liblzo2.so.2 -> liblzo2.so.2.0.0
| |-- liblzo2.so.2.0.0
| `-- libz.a
`-- share
`-- man
`-- man3
`-- zlib.3
6 directories, 22 files
手工将静态库删掉就行了,
如果是arm平台还需要strip优化.
4.编译mtd-utils-20080508前的准备工作.
编译之前的代码工作
luther@gliethttp:~$ wget
luther@gliethttp:~$ mkdir libs/include/sys -p
luther@gliethttp:~$ cp acl-2.2.47/include/acl.h libs/include/sys
luther@gliethttp:~/mtd-utils-20080508$ export LD_LIBRARY_PATH=~/libs/lib:$LD_LIBRARY_PATH
如果还找不到-llzo2,那么把他拷到/usr/lib下,对于交叉编译器,就是拷贝到
比如
luther@gliethttp:~/libs/lib$ sudo cp -a * /vobs/tools/arm-tools/arm-linux-gcc-3.4.1/arm-linux/lib/
luther@gliethttp:~/mtd-utils-20080508$ vim Makefile
修改安装路径
DESTDIR=.
SBINDIR=gliethttp/sbin
MANDIR=gliethttp/share/man
INCLUDEDIR=gliethttp/include
修改CFLAGS变量
CFLAGS := -I./include -I/home/ubuntu/libs/include $(OPTFLAGS)
如果是arm-linux-gcc定义为
CFLAGS := -I./include -I/home/ubuntu/libs/include -DAI_ADDRCONFIG=0x0020 $(OPTFLAGS)
来自/usr/include/netdb.h
luther@gliethttp:~/mtd-utils-20080508$ vim ubi-utils/Makefile
DESTDIR := ~/mtd-utils-20080508
SBINDIR=gliethttp/sbin
MANDIR=gliethttp/share/man
INCLUDEDIR=gliethttp/include
luther@gliethttp:~/mtd-utils-20080508$ vim recv_image.c
拷贝/usr/include/netinet/in.h文件中
arm-linux-gcc中不需要拷贝它.
struct ip_mreq
{
/* IP multicast address of group. */
struct in_addr imr_multiaddr;
/* Local IP address of interface. */
struct in_addr imr_interface;
};
结构体数据到头部,否则在u盘版的ubuntu 8.10上老是提示没有ip_mreq定义,虽然上面明明写了#define _USE_MISC
arm-linux-gcc中还需要创建如3下个目录
luther@gliethttp:~/mtd-utils-20080508$ mkdir arm-linux
luther@gliethttp:~/mtd-utils-20080508$ cp -r ubi-utils arm-linux/
luther@gliethttp:~/mtd-utils-20080508$ cp -r include arm-linux/
luther@gliethttp:~/mtd-utils-20080508$ vim ubi-utils/src/libpfiflash.c
将所有EBUF(PFIFLASH_ERRSTR[-rc]);全部替换为EBUF("%s", PFIFLASH_ERRSTR[-rc]);
vim下替换脚本为
:%s/EBUF(PFIFLASH_ERRSTR\[-rc\]);/EBUF("\%s", PFIFLASH_ERRSTR\[-rc\]);/g
luther@gliethttp:~/mtd-utils-20080508$ vim ubi-utils/src/ubimirror.c
将第206行的
fprintf(stderr, err_buf);
改为
fprintf(stderr, "%s", err_buf); // 想法是好的,因为err_buf中含有%d等format信息,这样接口更加统一,但是编译器似乎还并不支持这样的操作.[luther.gliethttp]
luther@gliethttp:~/mtd-utils-20080508$ vim ubi-utils/src/unubi.c
将第898行
char fname[PATH_MAX];
改为
char fname[PATH_MAX+1];
luther@gliethttp:~/mtd-utils-20080508$ cd ubi-utils/new-utils
因为-O2优化的原因,会导致如下log信息
error: ignoring return value of ‘scanf’, declared with attribute warn_unused_result
所有手工先编译.o
luther@gliethttp:~/mtd-utils-20080508/ubi-utils/new-utils$ gcc -Iinclude -Isrc -I../../include -Wall -Werror -Wall src/ubiformat.c -c -o ubiformat.o
对于交叉编译执行如下1条语句
luther@gliethttp:~/mtd-utils-20080508/ubi-utils/new-utils$ arm-linux-gcc -Iinclude -Isrc -I../../include -Wall -Werror -Wall src/ubiformat.c -c -o ubiformat.o
luther@gliethttp:~/mtd-utils-20080508/ubi-utils/new-utils$ cd -
好了,上面的所有修改完成之后,就可以执行make成功编译了[luther.gliethttp].
luther@gliethttp:~/mtd-utils-20080508$ make
如果是交叉编译,执行
luther@gliethttp:~/mtd-utils-20080508$ make CROSS=arm-linux-
luther@gliethttp:~/mtd-utils-20080508$ make install
对于交叉编译,执行
luther@gliethttp:~/mtd-utils-20080508$ make CROSS=arm-linux- install
luther@gliethttp:~/mtd-utils-20080508$ tree gliethttp/
gliethttp/
|-- sbin
| |-- bin2nand
| |-- doc_loadbios
| |-- docfdisk
| |-- flash_erase
| |-- flash_eraseall
| |-- flash_info
| |-- flash_lock
| |-- flash_otp_dump
| |-- flash_otp_info
| |-- flash_unlock
| |-- flashcp
| |-- ftl_check
| |-- ftl_format
| |-- jffs2dump
| |-- mkbootenv
| |-- mkfs.jffs2
| |-- mkpfi
| |-- mtd_debug
| |-- nand2bin
| |-- nanddump
| |-- nandtest
| |-- nandwrite
| |-- nftl_format
| |-- nftldump
| |-- pddcustomize
| |-- pfi2bin
| |-- pfiflash
| |-- recv_image
| |-- rfddump
| |-- rfdformat
| |-- serve_image
| |-- sumtool
| |-- ubiattach
| |-- ubicrc32
| |-- ubicrc32.pl
| |-- ubidetach
| |-- ubigen
| |-- ubimirror
| |-- ubimkvol
| |-- ubinfo
| |-- ubinize
| |-- ubirmvol
| |-- ubiupdatevol
| `-- unubi
`-- share
`-- man
`-- man1
`-- mkfs.jffs2.1.gz
4 directories, 45 files
ep9312开发板上没有任何文件系统flash数据读取
# ./mtd_debug read /dev/mtd0 0 100 gliethttp.bin
Copied 100 bytes from address 0x00000000 in flash to gliethttp.bin
# hexdump gliethttp.bin
0000000 03ff ea00 350c e59f 001c e583 410e e3a0
0000010 4004 e583 4a03 e3a0 4001 e254 fffd 1aff
0000020 4106 e3a0 4004 e583 420f e202 5000 e594
0000030 4001 e084 5000 e594 4001 e084 5000 e594
0000040 4001 e084 5000 e594 4010 e3a0 4008 e583
0000050 4050 e3a0 4001 e254 fffd 1aff 4e1e e3a0
0000060 4008 e583
0000064
#
# ./mtd_debug read /dev/mtd2 0 100 gliethttp.bin;hexdump gliethttp.bin -Cv
Copied 100 bytes from address 0x00000000 in flash to gliethttp.bin
00000000 1f 8b 08 00 ca 14 7d 4a 02 03 e4 5a 0f 70 93 e7 |......}J...Z.p..|
00000010 79 7f 3f 49 36 b2 31 41 80 a0 0e 38 cd 57 70 16 |y.?I6.1A...8.Wp.|
00000020 93 18 f3 19 3b 60 12 9a d9 60 08 09 4e 22 c0 a4 |....;`...`..N"..|
00000030 b4 81 ca 42 92 6d 0d 59 d2 49 72 02 2b 4d dd 60 |...B.m.Y.Ir.+M.`|
00000040 72 84 e1 86 03 a7 21 01 8a d2 b2 4b 2e f3 56 76 |r.....!....K..Vv|
00000050 63 b7 34 0b 1d cd b1 1d 6b b3 95 36 dc 95 db d1 |c.4.....k..6....|
00000060 8b 90 d1 ea |....|
00000064
#!/bin/bash
lpath=`pwd`
if [ ! -x zlib-1.2.5 ]; then
[ ! -f zlib-1.2.5.tar.gz ] && wget http://www.zlib.net/zlib-1.2.5.tar.gz
tar zxvf zlib-1.2.5.tar.gz
cd zlib-1.2.5
CC=arm-linux-gcc ./configure --prefix=${lpath}/libs --shared
cd -;
fi
cd zlib-1.2.5
make; make install;
cd -;
if [ ! -x lzo-2.03 ]; then
[ ! -f lzo-2.03.tar.gz ] && wget http://www.oberhumer.com/opensource/lzo/download/lzo-2.03.tar.gz
tar zxvf lzo-2.03.tar.gz
cd lzo-2.03
CC=arm-linux-gcc ./configure --host=arm-linux --prefix=${lpath}/libs --enable-shared
cd -;
fi
cd lzo-2.03
make; make install;
cd -;
if [ ! -x acl-2.2.47 ]; then
[ ! -f acl_2.2.47.orig.tar.gz ] && wget http://ftp.de.debian.org/debian/pool/main/a/acl/acl_2.2.47.orig.tar.gz
tar zxvf acl_2.2.47.orig.tar.gz
mkdir -p libs/include/sys
cp acl-2.2.47/include/acl.h libs/include/sys
fi
export LD_LIBRARY_PATH=${lpath}/libs/lib:$LD_LIBRARY_PATH
export LIBRARY_PATH=${lpath}/libs/lib:$LIBRARY_PATH
export C_INCLUDE_PATH=${lpath}/libs/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=${lpath}/libs/include:$CPLUS_INCLUDE_PATH
if [ ! -x mtd-utils-1.3.1 ]; then
[ ! -f mtd-utils-1.3.1.tar.bz2 ] && wget ftp://ftp.infradead.org/pub/mtd-utils/mtd-utils-1.3.1.tar.bz2
tar jxvf mtd-utils-1.3.1.tar.bz2
fi
cd mtd-utils-1.3.1
make CROSS=arm-linux- LDFLAGS='-static'
# 最后文件生成到arm-linux目录下
# ls arm-linux/虽然编译中途有失败的地方,但是一些基本的bin工具还是生成出来了[luther.gliethttp]
# 如果找不掉lzo库,那么将libs/lib目录下的库拷贝到arm-linux-gcc所在lib库
# which arm-linux-gcc
|