编译busybox-1.24.1 制作文件系统

发布时间:2023-09-04  

arm-linux-gcc  3.4.5

busybox-1.24.1.tar.bz2
1, 修改 Makefile
找到以下2处修改为
ARCH ?= arm
CROSS_COMPILE ?= arm-linux-

2, 打开配置菜单
make menuconfig
这里进行一些配置,打开 TAB 补全功能,选中 ifconfig , 打开驱动加载功能等
可以按 / 后输入字符进行搜索

错误1
miscutils/i2c_tools.c: At top level:
miscutils/i2c_tools.c:1046: error: `I2C_FUNC_SMBUS_PEC' undeclared here (not in a function)
miscutils/i2c_tools.c:1046: error: initializer element is not constant
miscutils/i2c_tools.c:1046: error: (near initialization for `i2c_funcs_tab[12].value')
miscutils/i2c_tools.c:1047: error: initializer element is not constant
miscutils/i2c_tools.c:1047: error: (near initialization for `i2c_funcs_tab[12]')
miscutils/i2c_tools.c:1049: error: initializer element is not constant
miscutils/i2c_tools.c:1049: error: (near initialization for `i2c_funcs_tab[13]')
miscutils/i2c_tools.c:1051: error: initializer element is not constant
miscutils/i2c_tools.c:1051: error: (near initialization for `i2c_funcs_tab[14]')
miscutils/i2c_tools.c:1052: error: initializer element is not constant
miscutils/i2c_tools.c:1052: error: (near initialization for `i2c_funcs_tab[15]')
make[1]: *** [miscutils/i2c_tools.o] Error 1
make: *** [miscutils] Error 2

方法:
make menuconfig 去掉 i2c 相关模块


错误2
miscutils/ionice.c: In function `ioprio_set':
miscutils/ionice.c:23: error: `SYS_ioprio_set' undeclared (first use in this function)
miscutils/ionice.c:23: error: (Each undeclared identifier is reported only once
miscutils/ionice.c:23: error: for each function it appears in.)
miscutils/ionice.c: In function `ioprio_get':
miscutils/ionice.c:28: error: `SYS_ioprio_get' undeclared (first use in this function)
make[1]: *** [miscutils/ionice.o] Error 1
make: *** [miscutils] Error 2
方法:
make menuconfig 去掉 ionice 相关模块

错误3
miscutils/nandwrite.c:91: error: dereferencing pointer to incomplete type
miscutils/nandwrite.c:97: error: `MEMGETBADBLOCK' undeclared (first use in this function)
miscutils/nandwrite.c:97: error: (Each undeclared identifier is reported only once
miscutils/nandwrite.c:97: error: for each function it appears in.)
miscutils/nandwrite.c:102: error: dereferencing pointer to incomplete type
miscutils/nandwrite.c: In function `nandwrite_main':
miscutils/nandwrite.c:117: error: storage size of 'meminfo' isn't known
miscutils/nandwrite.c:118: error: storage size of 'oob' isn't known
miscutils/nandwrite.c:145: error: `MEMGETINFO' undeclared (first use in this function)
miscutils/nandwrite.c:252: error: `MEMREADOOB' undeclared (first use in this function)
miscutils/nandwrite.c:117: warning: unused variable `meminfo'
miscutils/nandwrite.c:118: warning: unused variable `oob'
make[1]: *** [miscutils/nandwrite.o] Error 1
方法:
make menuconfig 去掉 nandwrite,nanddump模块


错误4
miscutils/ubi_tools.c:67:26: mtd/ubi-user.h: No such file or directory
miscutils/ubi_tools.c: In function `ubi_tools_main':
miscutils/ubi_tools.c:106: error: `UBI_DEV_NUM_AUTO' undeclared (first use in this function)
miscutils/ubi_tools.c:106: error: (Each undeclared identifier is reported only once
miscutils/ubi_tools.c:106: error: for each function it appears in.)
miscutils/ubi_tools.c:107: error: `UBI_VOL_NUM_AUTO' undeclared (first use in this function)
miscutils/ubi_tools.c:115: error: field `attach_req' has incomplete type
miscutils/ubi_tools.c:116: error: field `mkvol_req' has incomplete type
miscutils/ubi_tools.c:117: error: field `rsvol_req' has incomplete type
miscutils/ubi_tools.c:181: error: `UBI_IOCATT' undeclared (first use in this function)
miscutils/ubi_tools.c:194: error: `UBI_IOCDET' undeclared (first use in this function)
miscutils/ubi_tools.c:237: error: `UBI_DYNAMIC_VOLUME' undeclared (first use in this function)
miscutils/ubi_tools.c:239: error: `UBI_STATIC_VOLUME' undeclared (first use in this function)
方法:
make menuconfig 去掉 ubi 相关模块

错误5
util-linux/umount.c: In function `umount_main':
util-linux/umount.c:87: error: `MNT_DETACH' undeclared (first use in this function)
util-linux/umount.c:87: error: (Each undeclared identifier is reported only once
util-linux/umount.c:87: error: for each function it appears in.)
make[1]: *** [util-linux/umount.o] Error 1
make: *** [util-linux] Error 2
方法:
umount 这里不能去掉了,因为这个功能是需要的 打开源码看看

83 // MNT_FORCE and MNT_DETACH (from linux/fs.h) must match
84 // OPT_FORCE and OPT_LAZY.
85 {
86 typedef char bug[
87 (OPT_FORCE != MNT_FORCE || OPT_LAZY != MNT_DETACH) ? -1 : 1
88 ];

打开 ARM GCC 的 include/linux/fs.h 确实没有发现这2个定义
从 linux 内核源码里面找到这个 include/linux/fs.h
找到里面的这个
#define MNT_FORCE 0x00000001 /* Attempt to forcibily umount */
#define MNT_DETACH 0x00000002 /* Just detach from the tree */

把这里直接写为2 在次 make


错误6
coreutils/lib.a(sync.o)(.text.sync_main+0x80): In function `sync_main':
: undefined reference to `syncfs'
collect2: ld returned 1 exit status
make: *** [busybox_unstripped] Error 1

解决:
vi ./coreutils/sync.c
/*
* syncfs is documented to only fail with EBADF,
* which can't happen here. So, no error checks.
*/
86行 syncfs(fd);

18 行 //config: bool "Enable -d and -f flags (requres syncfs(2) in libc)"

找了一个 arm-libc 中并没有这个函数

下载了 busybox-1.23.0.tar.bz2 找到同名文件,发现这个内容明显要简单很多。用 1.23 的版本替换 1.24 的。
#include "libbb.h"

/* This is a NOFORK applet. Be very careful! */

int sync_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int sync_main(int argc UNUSED_PARAM, char **argv IF_NOT_DESKTOP(UNUSED_PARAM))
{
/* coreutils-6.9 compat */
bb_warn_ignoring_args(argv[1]);

sync();

return EXIT_SUCCESS;
}


在次编译通过了
Your linker does not support --sort-section,alignment
Trying libraries: crypt m
Library crypt is not needed, excluding it
Library m is needed, can't exclude it (yet)
Final link with: m

安装
make CONFIG_PREFIX=/opt/fs_1.24 install

制作 /dev/ 设备节点
cd /opt/fs_1.24
mkdir dev

cd dev
mknod console c 5 1
mknod null c 1 3

创建 etc 和 启动目录
cd ..
mkdir etc/init.d -p

创建启动脚本
vi etc/inittab
console::askfirst:-/bin/sh
::sysinit:/etc/init.d/rcS

编辑启动脚本启动 fstab 挂载设备节点等
vi etc/init.d/rcS
#!/bin/sh
mount -a
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s

创建自动挂载文件
mkdir tmp
mkdir sys

mkdir proc

vi etc/fstab
#device mount-point type optionos dump fsck order
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
sysfs /sys sysfs defaults 0 0
tmpfs /dev tmpfs defaults 0 0

复制 C 库
mkdir lib
cd /opt/gcc/arm-linux/lib
cp *.so* /opt/fs_1.24/lib/ -d

制作好了, 用 NFS 启动吧。
# busybox --help
BusyBox v1.24.1 (2016-03-10 09:37:27 CST) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.

配置成功。

rmmod 时出现错误 , 按提示创建 目录即可。

rmmod: can't change directory to '/lib/modules': No such file or directory
mkdir /lib/modules

rmmod: can't change directory to '2.6.22.6': No such file or directory
mkdir /lib/modules/2.6.22.6

 ps: gcc-4.3.2 编译时错误少很多。


文章来源于:电子工程世界    原文链接
本站所有转载文章系出于传递更多信息之目的,且明确注明来源,不希望被转载的媒体或个人可与我们联系,我们将立即进行删除处理。

我们与500+贴片厂合作,完美满足客户的定制需求。为品牌提供定制化的推广方案、专属产品特色页,多渠道推广,SEM/SEO精准营销以及与公众号的联合推广...详细>>

利用葫芦芯平台的卓越技术服务和新产品推广能力,原厂代理能轻松打入消费物联网(IOT)、信息与通信(ICT)、汽车及新能源汽车、工业自动化及工业物联网、装备及功率电子...详细>>

充分利用其强大的电子元器件采购流量,创新性地为这些物料提供了一个全新的窗口。我们的高效数字营销技术,不仅可以助你轻松识别与连接到需求方,更能够极大地提高“闲置物料”的处理能力,通过葫芦芯平台...详细>>

我们的目标很明确:构建一个全方位的半导体产业生态系统。成为一家全球领先的半导体互联网生态公司。目前,我们已成功打造了智能汽车、智能家居、大健康医疗、机器人和材料等五大生态领域。更为重要的是...详细>>

我们深知加工与定制类服务商的价值和重要性,因此,我们倾力为您提供最顶尖的营销资源。在我们的平台上,您可以直接接触到100万的研发工程师和采购工程师,以及10万的活跃客户群体...详细>>

凭借我们强大的专业流量和尖端的互联网数字营销技术,我们承诺为原厂提供免费的产品资料推广服务。无论是最新的资讯、技术动态还是创新产品,都可以通过我们的平台迅速传达给目标客户...详细>>

我们不止于将线索转化为潜在客户。葫芦芯平台致力于形成业务闭环,从引流、宣传到最终销售,全程跟进,确保每一个potential lead都得到妥善处理,从而大幅提高转化率。不仅如此...详细>>