移植 BusyBox-1.31.1 到 iTOP-4412(一)下载 & 编译 & rootfs

1. Download BusyBox

   看起来最新的稳定版是 1.31.1 了,那就下载它。

在这里插入图片描述

2. Download Cross Compile

   因为根文件系统跑在应用层,不能使用之前下载的编译器,因为应用层需要满足 EABI 的协议。之前的编译器只能编译 u-boot 和 kernel,所以这里需要下载支持 EABI 的编译器。

3. Read INSTALL

   首先看看 INSTALL 文档,如何编译安装。

The BusyBox build process is similar to the Linux kernel build:

  make menuconfig     # This creates a file called ".config"
  make                # This creates the "busybox" executable
  make install        # or make CONFIG_PREFIX=/path/from/root install

The full list of configuration and install options is available by typing:

  make help

Installation:
  install               - install busybox into CONFIG_PREFIX

Building out-of-tree:
=====================

By default, the BusyBox build puts its temporary files in the source tree.
Building from a read-only source tree, or building multiple configurations from
the same source directory, requires the ability to put the temporary files
somewhere else.

To build out of tree, cd to an empty directory and configure busybox from there:

  make KBUILD_SRC=/path/to/source -f /path/to/source/Makefile defconfig
  make
  make install

Alternately, use the O=$BUILDPATH option (with an absolute path) during the
configuration step, as in:

  make O=/some/empty/directory allyesconfig
  cd /some/empty/directory
  make
  make CONFIG_PREFIX=. install

4. make rootfs

4.1 build

初始化环境变量路径:

export CROSS_COMPILE=arm-none-linux-gnueabihf-
export PATH=$PATH:/home/xhr/iTop4412/crossCompiler/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/bin/
export ARCH=arm

根据文档,编译和安装就写个脚本一步到位吧。

  • 编译后临时文件:out/
  • 安装路径:out/install/
#! /bin/bash
mkdir out
make O=$(pwd)/out defconfig
cd out
make  -j$(nproc)
mkdir install
make CONFIG_PREFIX=install  install -j$(nproc)

4.2 rootfs

   编译完成后,还需要制作一些基本文件。

  1. mkdir dev etc home lib mnt proc root sys tmp var
  2. vim etc/inittab
#this is run first except when booting in single-user mode.
::sysinit:/etc/init.d/rcS
# /bin/sh invocations on selected ttys
::respawn:-/bin/sh
# Start an "askfirst" shell on the console (whatever that may be)
::askfirst:-/bin/sh
# Stuff to do when restarting the init process
::restart:/sbin/init
# Stuff to do before rebooting
::ctrlaltdel:/sbin/reboot
::shutdown:/sbin/swapoff -a
  1. mkdir etc/init.d/
  2. vim etc/init.d/rcS && chmod 777 …/rcS
#!/bin/sh
#This is the first script called by init process
/bin/mount -a
echo /sbin/mdev>/proc/sys/kernel/hotplug
mdev -s
  1. vim etc/fstab
#device mount-point     type    options         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
  1. vim etc/profile
#!/bin/sh
export HOSTNAME=xhr4412
export USER=root
export HOME=root
export PS1="[$USER@$HOSTNAME \W]\# "
#export PS1="[\[\033[01;32m\]$USER@\[\033[00m\]\[\033[01;34m\]$HOSTNAME\[\033[00m\ \W]\$ "
PATH=/bin:/sbin:/usr/bin:/usr/sbin
LD_LIBRARY_PATH=/lib:/usr/lib:$LD_LIBRARY_PATH
export PATH LD_LIBRARY_PATH
  1. copy shared lib
cd ~/iTop4412/crossCompiler/gcc-arm-9.2-2019.12-x86_64-arm-none-linux-gnueabihf/arm-none-linux-gnueabihf/libc/lib
cp -d * ~/iTop4412/xhr4412/busybox/busybox-1.31.1/out/install/lib/

查看依赖的库文件:

  • arm-none-linux-gnueabihf-readelf -d out/busybox

剥离动态库的调试信息,符号表等等 du -h 查看文件大小;瘦身_install/lib $ arm-linux-strip * 注意操作的目录;如果没有权限把所有的文件权限修改 chmod 777 *

  1. make_ext4fs
    ./make_ext4fs -s -l 314572800 -a root -L linux xhr4412_sys.img busybox-1.31.1/out/install

   到这里 rootfs 就制作完成了。

5. test rootfs

   根文件系统确实是启动成功了,不过一看就能发现还有很多问题,ls 都不能显示完整,使用 vi 更是满屏 crash。暂时先到这吧。。。

在这里插入图片描述

参考

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值