一. Buildroot 简介
buildroot是Linux平台上一个构建嵌入式Linux系统的框架。
整个Buildroot是由Makefile脚本和Kconfig配置文件构成的。
可以和编译Linux内核一样,通过buildroot配置,menuconfig修改,编译出一个完整的可以直接烧写到机器上运行的Linux系统软件(包含boot、kernel、rootfs以及rootfs中的各种库和应用程序)。
buildboot也可以单独通过配置和使用交叉编译链工具来实现制作一个Linux文件系统。
下载
下载地址: https://buildroot.org/downloads/
-
选择好相应的目录,将下载的压缩包放置在其下
-
解压:
tar -xzvf buildroot-2021.05.3.tar.gz
buildroot目录介绍
解压之后,我们可以看到以下的目录情况:
├── arch: 存放CPU架构相关的配置脚本,如arm/mips/x86,这些CPU相关的配置,在制作工具链时,编译uboot和kernel时很关键.
├── board 存放了一些默认开发板的配置补丁之类的
├── boot
├── CHANGES
├── Config.in
├── Config.in.legacy
├── configs: 放置开发板的一些配置参数.
├── COPYING
├── DEVELOPERS
├── dl: 存放下载的源代码及应用软件的压缩包.
├── docs: 存放相关的参考文档.
├── fs: 放各种文件系统的源代码.
├── linux: 存放着Linux kernel的自动构建脚本.
├── Makefile
├── Makefile.legacy
├── output: 是编译出来的输出文件夹.
│ ├── build: 存放解压后的各种软件包编译完成后的现场.
│ ├── host: 存放着制作好的编译工具链,如gcc、arm-linux-gcc等工具.
│ ├── images: 存放着编译好的uboot.bin, zImage, rootfs等镜像文件,可烧写到板子里, 让linux系统跑起来.
│ ├── staging
│ └── target: 用来制作rootfs文件系统,里面放着Linux系统基本的目录结构,以及编译好的应用库和bin可执行文件. (buildroot根据用户配置把.ko .so .bin文件安装到对应的目录下去,根据用户的配置安装指定位置)
├── package:下面放着应用软件的配置文件,每个应用软件的配置文件有Config.in和soft_name.mk,其中soft_name.mk(这种其实就Makefile脚本的自动构建脚本)文件可以去下载应用软件的包。
├── README
├── support
├── system
└── toolchain
buildroot配置
然后通过make menuconfig进行配置:
Target options --->选择目标板架构特性。
Build options --->配置编译选项。
Toolchain ---> 配置交叉工具链,使用buildroot工具链还是外部提供。
System configuration ---> 系统配置
Kernel ---> 配置内核
Target packages --->
Filesystem images --->配置文件系统
Bootloaders --->硬件启动程序
Host utilities --->
Legacy config options --->
① 主页
② Target options
② Build options
③ Toolchain
③ System configuration
④ Kernel
⑤ Filesystem images
make命令解析
通过make help可以看到buildroot下make的使用细节,包括对package、uclibc、busybox、linux以及文档生成等配置:
Cleaning:
clean - delete all files created by build----------------------------------------清理
distclean - delete all non-source files (including .config)Build:
all - make world----------------------------------------------编译整个系统
toolchain - build toolchain------------------------------------------编译工具链Configuration:
menuconfig - interactive curses-based configurator--------------------------------对整个buildroot进行配置
savedefconfig - Save current config to BR2_DEFCONFIG (minimal config)----------------保存menuconfig的配置Package-specific:-------------------------------------------------------------------------------对package配置
<pkg> - Build and install <pkg> and all its dependencies---------------------单独编译对应APP
<pkg>-source - Only download the source files for <pkg>
<pkg>-extract - Extract <pkg> sources
<pkg>-patch - Apply patches to <pkg>
<pkg>-depends - Build <pkg>'s dependencies
<pkg>-configure - Build <pkg> up to the configure step
<pkg>-build - Build <pkg> up to the build step
<pkg>-show-depends - List packages on which <pkg> depends
<pkg>-show-rdepends - List packages which have <pkg> as a dependency
<pkg>-graph-depends - Generate a graph of <pkg>'s dependencies
<pkg>-graph-rdepends - Generate a graph of <pkg>'s reverse dependencies
<pkg>-dirclean - Remove <pkg> build directory-----------------------------------------清除对应APP的编译目录
<pkg>-reconfigure - Restart the build from the configure step
<pkg>-rebuild - Restart the build from the build step--------------------------------单独重新编译对应APPbusybox:
busybox-menuconfig - Run BusyBox menuconfiguclibc:
uclibc-menuconfig - Run uClibc menuconfiglinux:
linux-menuconfig - Run Linux kernel menuconfig-----------------------------------------配置Linux并保存设置
linux-savedefconfig - Run Linux kernel savedefconfig
linux-update-defconfig - Save the Linux configuration to the path specified
by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILEDocumentation:
manual - build manual in all formats
manual-pdf - build manual in PDF
graph-build - generate graphs of the build times----------------------------------对编译时间、编译依赖、文件系统大小生成图标
graph-depends - generate graph of the dependency tree
graph-size - generate stats of the filesystem size
查看Qt 的默认版本
cd ./package/qt5/qt5.mk
二. ·编译
Buildroot--如何配置安装Qt5_海歌也疯狂的博客-CSDN博客
最后执行make指令,会将uboot、linux、文件系统及Qt全部编译完成。
- images/ — 存放编译后产生的所有镜像文件( 内核镜像 , 加载引导镜像 和 根文件系统镜像)
- build/ — 存放所有的组件除了构建交叉编译工具链的组件 , 在这个目录里面每一个功能对应一个子目录存放他们各自的组件.
- staging/ — 包含一个类似于根文件系统等级层次的层级 . 这个目录包含了 安装的交叉编译工具链 和 所有被选择用于目标板的所有用户空间包.
- target/ — 包含了根文件系统
- host/ — 包含了我们需要的交叉编译工具集
另外,./dl 包含了所有下载的软件包。有时候在线下载太慢的话,需要手动添加,再重新开始编译,就可以跨过去。
三. 安装一些必要库
解决 Solution for “make menuconfig” Error in Linux PC
# 无效
#$ sudo apt-get install build-essentials
$ sudo apt-get install libncurses5 libncurses5-dev