详情请参考: http://www.buildroot.org/downloads/manual/manual.html


Buildroot是一个为嵌入式平台构建一个完整Linux系统的工具,它可以生成交叉编译工具、文件系统、Linux内核和bootloader。

   

目录结构

./buildroot$ tree -L 1 -d
.

├── arch

目录存放CPU架构相关的配置脚本,如arm/mips/x86 ,这些CPU相关的配置,在制作工具链,编译boot和内核时很关键。

   

├── board

存放了一些默认开发板的配置补丁之类的。

   

├── boot

├── configs

放置支持的开发板的默认配置文件。

   

├── dl

存放下载的源码包及应用软件的压缩包,第一次下载后,下次就不会再去从官网下载了,而是从dl/目录下拿开源包,以节约时间。本身下载通常都是很慢的,你可以手动找到相关包下载后放到这里就OK了,make时会自动检测这个目录。

   

├── docs

存放相关的参考文档。

   

├── fs

放各种文件系统的源代码;fs/skeleton:放生成文件系统镜像的地方,及板子里面的系统。

   

├── linux

存放着Linux kernel的自动构建脚本。

   

├── output

是编译出来的输出文件夹。

/buildroot/output$ tree -L 1 -d
.

├── build

所有源码包解压出来的文件存放地和编译的发生地。

   

├── host

是由各类源码编译后在你主机上运行的工具(build for host)的安装目录,如arm-linux-gcc就是安装在这里。

   

├── images

编译好的镜像。

   

├── staging -> /work/buildroot/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot

 
 
└── target

用来制作rootfs文件系统,里面放着Linux系统基本的目录结构,以及各种编译好的应用库和bin可执行文件。

├── package

下面放着应用软件的配置文件,每个应用软件的配置文件有Config.in和soft_name.mk。

   

├── support

├── system

这里就是根目录的主要骨架了和相关的启动初始化配置,当制作根目录时就是将此处的文件cp到output里去。然后再安装toolchain的动态库和你勾选的package的可执行文件之类的.

   

├── toolchain

└── utils

   

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--------------------------------单独重新编译对应APP

 
 
busybox:

  busybox-menuconfig      - Run BusyBox menuconfig

 
 
uclibc:

  uclibc-menuconfig          - Run uClibc menuconfig

 
 
linux:

  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_FILE

 
 
Documentation:

  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

   

buildroot框架

Buildroot提供了函数框架和变量命令框架(下一篇文章将介绍细节),采用它的框架编写的app_pkg.mk这种Makefile格式的自动构建脚本,将被package/pkg-generic.mk 这个核心脚本展开填充到buildroot主目录下的Makefile中去。

   

最后make all执行Buildroot主目录下的Makefile,生成你想要的image。 package/pkg-generic.mk中通过调用同目录下的pkg-download.mk、pkg-utils.mk文件,已经帮你自动实现了下载、解压、依赖包下载编译等一系列机械化的流程。

   

你只要需要按照格式写Makefile脚app_pkg.mk,填充下载地址,链接依赖库的名字等一些特有的构建细节即可。 总而言之,Buildroot本身提供构建流程的框架,开发者按照格式写脚本,提供必要的构建细节,配置整个系统,最后自动构建出你的系统。

buildroot包含docker buildroot 内核_文件系统

   

对buildroot的配置通过Config.in串联起来,起点在根目录Config.in中。

配置选项        

Config.in位置        

Target options        

arch/Config.in        

Build options        

Config.in        

Toolchain        

toolchain/Config.in        

System configuration        

system/Config.in        

Kernel        

linux/Config.in        

Target packages        

package/Config.in        

Target packages->Busybox

                 

Filesystem images        

fs/Config.in        

Bootloaders        

boot/Config.in        

Host utilities        

package/Config.in.host        

Legacy config options        

Config.in.legacy