• 编译busybox1.24.1 制作文件系统


    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 编译时错误少很多。

  • 相关阅读:
    swift 一些公共的宏重新定义
    iOS中正则表达式的使用
    失败的尝试,使用继承扩展数组,以及ES6的必要性
    用travis-ci编译android版nodejs
    用es6写一个分数库
    快速平方根算法的javascript实现
    windows中vim以及cmder的使用
    nodejs的交叉(跨平台)编译(to android)
    用链表实现nodejs的内存对象管理
    给socks-proxy-agent增加认证
  • 原文地址:https://www.cnblogs.com/ningci/p/5261567.html
Copyright © 2020-2023  润新知