目录
4.1 /usr/include/unistd.h:203: error: conflicting types for 'gid_t'
4.2 miscutils/seedrng.c:45:24: fatal error: sys/random.h: No such file or directory
4.3 Makefile:405: *** mixed implicit and normal rules: deprecated syntax
4.4 linux/netfilter.h:44: error: field 'in' has incomplete type
1 下载busybox
去网址:https://busybox.net/downloads/
下载busybox源码,这里下载的1.36版本,然后解压
tar xvf busybox-1.36.0.tar.bz2
cd busybox-1.36.0/
2 修改Makefile
164行 CROSS_COMPILE ?= 改为:CROSS_COMPILE ?= arm-linux-
190行 ARCH ?= $(SUBARCH) 改为:ARCH ?= arm
3 配置busybox
make defconfig
make menuconfig
4 编译安装
make -j8
make CONFIG_PREFIX=../fs install
4.1 /usr/include/unistd.h:203: error: conflicting types for 'gid_t'
然后编译报下面的错误
CC libbb/capability.o
In file included from include/platform.h:333,
from include/libbb.h:13,
from libbb/capability.c:18:
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/unistd.h:203: error: conflicting types for 'gid_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:27: error: previous declaration of 'gid_t' was here
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/unistd.h:208: error: conflicting types for 'uid_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:26: error: previous declaration of 'uid_t' was here
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/unistd.h:216: error: conflicting types for 'off_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:17: error: previous declaration of 'off_t' was here
In file included from include/libbb.h:16,
from libbb/capability.c:18:
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/dirent.h:37: error: conflicting types for 'ino_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:14: error: previous declaration of 'ino_t' was here
In file included from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/bits/fcntl.h:25,
from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/fcntl.h:34,
from include/libbb.h:18,
from libbb/capability.c:18:
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/sys/types.h:62: error: conflicting types for 'dev_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:13: error: previous declaration of 'dev_t' was here
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/sys/types.h:72: error: conflicting types for 'mode_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:15: error: previous declaration of 'mode_t' was here
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/sys/types.h:77: error: conflicting types for 'nlink_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:16: error: previous declaration of 'nlink_t' was here
In file included from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/sys/types.h:133,
from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/bits/fcntl.h:25,
from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/fcntl.h:34,
from include/libbb.h:18,
from libbb/capability.c:18:
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/time.h:105: error: conflicting types for 'timer_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:22: error: previous declaration of 'timer_t' was here
In file included from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/sys/types.h:220,
from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/bits/fcntl.h:25,
from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/fcntl.h:34,
from include/libbb.h:18,
from libbb/capability.c:18:
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/sys/select.h:78: error: conflicting types for 'fd_set'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:12: error: previous declaration of 'fd_set' was here
In file included from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/bits/fcntl.h:25,
from /usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/fcntl.h:34,
from include/libbb.h:18,
from libbb/capability.c:18:
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/sys/types.h:248: error: conflicting types for 'blkcnt_t'
/usr/local/arm/4.3.2/bin/../arm-none-linux-gnueabi/libc/usr/include/linux/types.h:124: error: previous declaration of 'blkcnt_t' was here
scripts/Makefile.build:197: recipe for target 'libbb/capability.o' failed
make[1]: *** [libbb/capability.o] Error 1
Makefile:744: recipe for target 'libbb' failed
make: *** [libbb] Error 2
conflicting types for 'dev_t'的原因_小饼仙子的博客-CSDN博客
我看了下这篇博客,然后我这样修改
没用还是有错误。继续搜,看到
那更换成4.9.4的交叉编译工具链吧
4.2 miscutils/seedrng.c:45:24: fatal error: sys/random.h: No such file or directory
换成4.9.4的交叉编译工具后,编译报下面的错误
miscutils/seedrng.c:45:24: fatal error: sys/random.h: No such file or directory
#include <sys/random.h>
^
compilation terminated.
scripts/Makefile.build:197: recipe for target 'miscutils/seedrng.o' failed
make[1]: *** [miscutils/seedrng.o] Error 1
Makefile:746: recipe for target 'miscutils' failed
make: *** [miscutils] Error 2
网上继续搜,看到
上面说
进入make menuconfig:
在 Miscellaneous Utilities --->
[ ] taskset
将其前的星号去掉即可。
但是我在 Miscellaneous Utilities中没找到tasknet,于是搜索了下,发现它在Linux System Utilities中。
但是发现问题未解决,于是继续找,搜到了类似的
那应该还是交叉编译工具链的版本太低,我去看了下我交叉编译工具链里面的libc库,是2.19版本的。
这时候我不再更换交叉编译工具链版本了,因为我用的开发板芯片太老,用新的交叉编译工具链可能还会有其他稀奇古怪的错误,所以这里我反向操作,不升级交叉编译工具链的版本而是降低busybox的版本,这里用busy1.7.0版本,并且交叉编译工具链用回4.3.2。
4.3 Makefile:405: *** mixed implicit and normal rules: deprecated syntax
编译报下面的错误
Makefile:405: *** mixed implicit and normal rules: deprecated syntax
Makefile:1242: *** mixed implicit and normal rules: deprecated syntax
make: *** No rule to make target 'defconfig'. Stop.
解决方法在下面的博客
4.4 linux/netfilter.h:44: error: field 'in' has incomplete type
继续编译又报下面的错误
linux/netfilter.h:44: error: field 'in' has incomplete type
解决方法
在 .../arm-none-linux-gnueabi/libc/usr/include/linux/netfilter.h 的开头
添加缺少的头文件:
#include <netinet/in.h>
然后编译不再报错,然后安装安装
make CONFIG_PREFIX=../fs/ install
可以在fs下面看到生成的文件和目录
5 创建必要的文件夹
到fs目录下,执行下面的命令
mkdir dev etc lib mnt proc sys tmp var
6 安装glibc库
这里直接把交叉编译工具链路径下的库拷贝到上面创建的lib文件夹中。
在交叉编译工具链的位置里面用下面的命令搜索
由于ARM9属于ARMv4T架构,所以拷贝上面第三个第四个lib到fs文件夹里面
mkdir lib
mkdir usr/lib
cp -drf /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/lib/*.so* ./lib/
cp -drf /usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib/*.so* ./usr/lib/
上面拷贝的时候要注意,后面是*.so*,有两个星号,不是*.so。
7 构建etc目录
etc目录下的内容取决于要运行的程序,本节只需要创建3个文件:etc/inittab, etc/init.d/rcS, etc/fstab。
7.1 创建etc/inittab文件
我们在etc目录下创建inittab文件,文件内容如下
7.2 创建etc/init.d/rcS文件
这是一个脚本文件,可以在里面添加想自动执行的命令,以下命令配置IP地址、挂接/etc/fstab指定的文件系统。
- 第一行表示这是一个脚本文件,运行时使用/bin/sh解析。
- 第二行用来配置IP地址。
- 第三行挂接/etc/fstab文件指定的所有文件系统。
创建完成后改变它的属性,
chmod +x rcS
7.3 创建etc/fstab文件
内容如下,表示执行mount -a命令后将挂载proc、tmpfs文件系统。
8 构建dev目录
cd dev
sudo mknod console c 5 1
sudo mknod null c 1 3
sudo mknod ttySAC0 c 204 64
sudo mknod mtdblock0 b 31 0
sudo mknod mtdblock1 b 31 1
sudo mknod mtdblock2 b 31 2
执行完之后
9 制作yaff2镜像
这里不自己编译makeyaffe工具了,直接用韦老师的工具mkyaffs2image。
./mkyaffs2image fs/ fs_chw.yaffs
10 文件系统验证
把制作完成的文件系统下载到开发板中,发现报下面的错误
可能是rcS脚本写错了,去看一下
但是我看上面的笔记,当初是有i的,不知怎么成了fconfig了,
改完重新制作镜像文件,然后下载到板子上,这时候可以看到文件系统了。
参考文献
使用 busyBox 构建 linux 根文件系统_busybox制作linux_砌墙师傅的博客-CSDN博客
【ARM】使用Busybox构建根文件系统_busybox 制作根文件系统_凉开水白菜的博客-CSDN博客
Part6: 构建根文件系统(在s3c2440开发板演示)_韦东山 s3c2440 文件系统_ZMK_02的博客-CSDN博客
conflicting types for 'dev_t'的原因_小饼仙子的博客-CSDN博客
https://www.cnblogs.com/electronic/p/11146614.html
S3C2440移植linux3.4.2内核之修改分区以及制作根文件系统_busybox构建s3c2440根文件系统_嵌入式与Linux那些事的博客-CSDN博客