目录
1、Build Zlib: zlib-1.2.11.tar.gz
(1)tar -xvf ~/download/zlib-1.2.11.tar.gz
(2)cd zlib-1.2.11/
(3)./configure --prefix=`pwd`/../__install/
(4)Change Makefile:修改Makefile -:删除 +:增加
(5)make
(6)make install
二、Build LZO: lzo-2.10.tar.gz
(1)tar -xvf ~/download/lzo-2.10.tar.gz
(2)cd lzo-2.10/
(3)./configure --host=mips-linux-gnu --prefix=`pwd`/../__install/
(4)vi Makefile(添加 -muclibc):
(5)make
(6)make install
三、Build e2fsprogs: e2fsprogs-1.45.2.tar.gz
(1)tar -xvf e2fsprogs-1.45.2.tar.gz
(2)cd e2fsprogs-1.45.2/
(3)./configure --host=mips-linux-gnu --prefix=`pwd`/../__install
(4)vi Makefile:
(5)vi lib/uuid/gen_uuid.c
(6)make
(7)make install-libs
四、Build mtd-utils: mtd-utils-2.1.0.tar.bz2
(1)tar -xvf mtd-utils-2.1.0.tar.bz2
(2)cd mtd-utils-2.1.0/
(3)export PKG_CONFIG_PATH=`pwd`/../__install/lib/pkgconfig/
(4)export PREFIX=`pwd`/../__install
(5)执行
(6)vi Makefile:
(7)vi ubifs-utils/mkfs.ubifs/mkfs.ubifs.h
(8)vi include/config.h
(9)vi tests/fs-tests/integrity/integck.c
(10) vi tests/mtd-tests/flash_speed.c
(11)make
(12)make install
编译结束!!
所需文件:
从720工具链中mips-gcc720-glibc229-r5.1.4/mips-linux-gnu/libc/uclibc/lib复制两个库文件(ld-uClibc-mipsn8.so.0、libc.so.0)到库文件系统的/lib下(mtd-utils-2.1.0/lib/)
mtd-utils的交叉编译,压缩包中是已经使用720工具链交叉编译好的,可直接使用,也可自己编译,方法参考如下:
./configure --prefix=`pwd`/../__install/
--- a/Makefile
+++ b/Makefile
@@ -16,7 +16,7 @@
# To install in $HOME instead of /usr/local, use:
# make install prefix=$HOME
-CC=gcc
+CC=mips-linux-gnu-gcc
-CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
+CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -muclibc
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
CFLAGS=-O3 -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
SFLAGS=-O3 -fPIC -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN
-LDFLAGS=
+LDFLAGS=-muclibc
TEST_LDFLAGS=-L. libz.a
-LDSHARED=gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
-CPP=gcc -E
+LDSHARED=mips-linux-gnu-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map
+CPP=mips-linux-gnu-gcc -E
STATICLIB=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.2.11
SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIBV)
-AR=ar
+AR=mips-linux-gnu-ar
ARFLAGS=rc
-RANLIB=ranlib
+RANLIB=mips-linux-gnu-ranlib
LDCONFIG=ldconfig
LDSHAREDLIBC=-lc
TAR=tar
./configure --host=mips-linux-gnu --prefix=`pwd`/../__install/
371: +CFLAGS = -g -O2 -muclibc
373:+CPPFLAGS = -muclibc
393:+LDFLAGS = -muclibc
./configure --host=mips-linux-gnu --prefix=`pwd`/../__install
96: +CFLAGS = -g -O2 -muclibc
99:+CPPFLAGS = -I. -I$(top_builddir)/lib -I$(top_srcdir)/lib -muclibc
103:+LDFLAGS = $(SANITIZER_LDFLAGS) -muclibc
356 if (state_fd >= 0) {
357 unsigned int cl;
358 unsigned long tv1, tv2;
359 int a;
360
361 /* if (fscanf(state_f, "clock: %04x tv: %lu %lu adj: %d\n",
362 &cl, &tv1, &tv2, &a) == 4) {
363 clock_seq = cl & 0x3FFF;
364 last.tv_sec = tv1;
365 last.tv_usec = tv2;
366 adjustment = a;
367 }*/ /**注释if**/
368 }
export PKG_CONFIG_PATH=`pwd`/../__install/lib/pkgconfig/
export PREFIX=`pwd`/../__install
./configure --host=mips-linux-gnu CC=mips-linux-gnu-gcc --prefix=${PREFIX} WITHOUT_XATTR=1 LDFLAGS=-L${PREFIX}/lib CFLAGS='-I${PREFIX}/include -I${PREFIX}/include/lzo -I${PREFIX}/include/uuid/ -g -O2' UUID_CFLAGS='-I${PREFIX}/include/uuid/' LZO_CFLAGS='-I${PREFIX}/include/' ZLIB_CFLAGS='-I${PREFIX}/include' --without-crypto
1205: +CFLAGS = -I${PREFIX}/include -I${PREFIX}/include/lzo -I${PREFIX}/include/uuid/ -g -O2 -muclibc
1209:+CPPFLAGS = -muclibc
1229:+LDFLAGS = -L/home/user/yqhuang/QS/1.1.4/mtd-utils-2.1.0/../__install//lib -muclibc
#include
#include
#include
+#ifdef WITH_CRYPTO
#include
+#endif
#include
4 /* Define to 1 if you have the `clock_gettime' function. */
5 #define HAVE_CLOCK_GETTIME 1
6
7 /* Define to 1 if you have the header file. */
8 #define HAVE_DLFCN_H 1
9
10 /* Define to 1 if you have the header file. */
11 //#define HAVE_EXECINFO_H 1 /***改动(注释掉)****/
12
13 /* Define to 1 if you have the header file. */
14 #define HAVE_INTTYPES_H 1
15
16 /* Define to 1 if you have the header file. */
17 #define HAVE_MEMORY_H 1
2877 else if (!strcmp(opt, "ro"))
2878 fsinfo.mount_flags |= MS_RDONLY;
2879 // else if (!strcmp(opt, "dirsync")) /***注释掉***/
2880 // fsinfo.mount_flags |= MS_DIRSYNC; /***注释掉***/
2881 else if (!strcmp(opt, "noatime"))
2882 fsinfo.mount_flags |= MS_NOATIME;
2883 else if (!strcmp(opt, "nodiratime"))
2884 fsinfo.mount_flags |= MS_NODIRATIME;
2885 else if (!strcmp(opt, "noexec"))
2886 fsinfo.mount_flags |= MS_NOEXEC;
2887 else if (!strcmp(opt, "nosuid"))
2888 fsinfo.mount_flags |= MS_NOSUID;
2889 // else if (!strcmp(opt, "relatime")) /***注释掉***/
2890 // fsinfo.mount_flags |= MS_RELATIME; /***注释掉***/
2891 else if (!strcmp(opt, "sync"))
2892 fsinfo.mount_flags |= MS_SYNCHRONOUS;
261 static void start_timing(void)
262 {
263 clock_gettime(CLOCK_MONOTONIC, &start); /***改动***/
264 }
265
266 static void stop_timing(void)
267 {
268 clock_gettime(CLOCK_MONOTONIC, &finish); /***改动***/
269 }
查看分区:cat /proc/mtd
查看挂接主次设备号:cat /proc/partitions
擦除要烧写的分区:
flash_eraseall /dev/mtd5
nandwrite烧写(先擦除烧写的分区):
./nandwrite -a /dev/mtd5 data.img
flashcp烧写到分区:
./flashcp -v data.img /dev/mtd5
(PS:nandwrite、flash_eraseall等执行文件位于__install/sbin文件夹下)
flash_eraseall擦除之后flashcp烧写失败解决办法:https://blog.csdn.net/weixin_43615992/article/details/126721414