buildroot构建根文件系统

相关介绍

底层开发中,有其中一块是构建文件系统,而构建文件系统常见的有三种方式:yocto,buildroot,busybox;
其中,yocto是常见的构建文件系统的工具,过于复杂,uboot和kernel也可以构建,编译出相应的二进制,还有各种库的文件系统,编译时间十几个小时都是有可能的;
buildroot用于构建完整的根文件系统,也可以构建bootloader和kernel,包括busybox的功能和各种集成软件,很少需要再去移植,相对于busybox更成熟,配置和编译过程相对简单;
busybox仅仅用于构建简单的根文件系统,包含一些常用的命令和文件,系统下的目录和库都需要自己手动创建,还需要自己去移植一些第三方软件和库,并且系统默认没有用会名和密码;

buildroot资源获取

buildroot官网(用于源码下载):
https://buildroot.org/

适用架构,mips,loongarch

buildroot软件相关

1.源码目录文件:

root@jdm:/home/jdm/institude/2k1000/la/buildroot/buildroot# ls
arch   boot     Config.in         config.old  COPYING     diff  docs  linux     Makefile.legacy  package  support  toolchain
board  CHANGES  Config.in.legacy  configs     DEVELOPERS  dl    fs    Makefile  output           README   system   utils

其中busybox压缩包和本地源码所在目录:

root@jdm:/home/jdm/institude/2k1000/la/buildroot/buildroot# ls dl/busybox/
busybox-1.35.0.tar.bz2
root@jdm:/home/jdm/institude/2k1000/la/buildroot/buildroot# ls output/build/busybox-1.35.0/
applets     busybox                 Config.in      docs       include      libpwdgrp   Makefile.custom         modutils           procps                  selinux                 TODO
applets_sh  busybox.links           configs        e2fsprogs  init         LICENSE     Makefile.flags          networking         qemu_multiarch_testing  shell                   TODO_unicode
arch        busybox_unstripped      console-tools  editors    INSTALL      loginutils  Makefile.help           NOFORK_NOEXEC.lst  README                  size_single_applets.sh  util-linux
archival    busybox_unstripped.map  coreutils      examples   klibc-utils  mailutils   make_single_applets.sh  NOFORK_NOEXEC.sh   runit                   sysklogd
AUTHORS     busybox_unstripped.out  debianutils    findutils  libbb        Makefile    miscutils               printutils         scripts                 testsuite

menuconfig配置目录结构:

 Target options  --->  
Build options  --→
Toolchain  --->                                                                                                                 
System configuration  --->   
Kernel  --->                  
Target packages  --->            
Filesystem images  --->                            
Bootloaders  --->                              
Host utilities  --->                         
Legacy config options  ---> 

编译执行流程:
1.make menuconfig图形配置当前所用cpu架构,编译器目录,二进制格式,库和系统工具,文件系统格式等等;
注意:配置完成后,可以通过sudo make show-targets命令查看已经配置的软件包;
2.sudo make busybox-menuconfig 图形配置busybox,此步若无特殊需求,可以采用默认配置;
注意:通过sudo make busybox命令可以单独编译busybox;
3.sudo make;

编译完成后的最终压缩包

root@jdm:/home/jdm/institude/2k1000/la/buildroot/buildroot# ls output/images/
rootfs.ext2  rootfs.tar(最终包)

buildroot常见错误记录

1.编译错误:

/usr/bin/make -j1 O=/home/jdm/institude/2k1000/la/buildroot/buildroot/output HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" syncconfig
make[1]: Entering directory '/home/jdm/institude/2k1000/la/buildroot/buildroot'
arch/Config.in.arc:65:warning: config symbol defined without type
make[1]: Leaving directory '/home/jdm/institude/2k1000/la/buildroot/buildroot'

You seem to have the current working directory in your
LD_LIBRARY_PATH environment variable. This doesn't work.
support/dependencies/dependencies.mk:27: recipe for target 'dependencies' failed
make: *** [dependencies] Error 1
解决办法:
sudo make;

2.编译错误:

root@jdm:/home/jdm/institude/2k1000/la/buildroot/buildroot# sudo make


>>> toolchain-external-custom  Installing to staging directory
/usr/bin/install -D -m 0755 /home/jdm/institude/2k1000/la/buildroot/buildroot/output/build/toolchain-external-custom/toolchain-wrapper /home/jdm/institude/2k1000/la/buildroot/buildroot/output/host/bin/toolchain-wrapper
loongarch64-linux-gnu-gcc: error: unrecognized argument in option '-mabi=n32'
loongarch64-linux-gnu-gcc: note: valid arguments to '-mabi=' are: lp32 lp64 lpx32; did you mean 'lp32'?
ln: failed to create symbolic link '/home/jdm/institude/2k1000/la/buildroot/buildroot/output/host/loongarch-buildroot-linux-gnu/sysroot/usr/lib64': No such file or directory
package/pkg-generic.mk:329: recipe for target '/home/jdm/institude/2k1000/la/buildroot/buildroot/output/build/toolchain-external-custom/.stamp_staging_installed' failed
make: *** [/home/jdm/institude/2k1000/la/buildroot/buildroot/output/build/toolchain-external-custom/.stamp_staging_installed] Error 1

解决办法:Target ABI (n64) ,编译器是64位的,图形配置的时候,要选择64位编译配置;

3.编译错误:

buildroot/output/build/buildroot-fs/cpio/fakeroot
fakeroot: preload library `libfakeroot.so' not found, aborting.
fs/cpio/cpio.mk:56: recipe for target '/home/jdm/institude/2k1000/la/buildroot/lj/buildroot/output/images/rootfs.cpio' failed
解决办法:
make clean;sudo make;
因为拷贝源码的时候,有一些已经编译的配置中有上一个环境中的路径,导致此编译错误;

注意:如果遇到一个编译错误,修改配置后,仍然报同样的编译错误,就执行make clean;sudo make;

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

打工人1379号

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值