Table of Contents 目录
.mk
file 18.3. .mk
文件.hash
file 18.4. .hash
文件SNNfoo
start scriptSNNfoo
启动脚本List of Examples 例子清单
Buildroot ${BR2_VERSION%%-git*} manual generated on 2024-05-07
08:28:19 UTC from git revision 0155095c55
Buildroot ${BR2_VERSION%%-git*} 手册生成于 2024-05-07 08:28:19 UTC,来自 git 修订版本 0155095c55
The Buildroot manual is written by the Buildroot developers.
It is licensed under the GNU General Public License, version 2. Refer to the
COPYING
file in the Buildroot sources for the full text of this license.
Buildroot 手册是由 Buildroot 开发人员编写的。它在 GNU 通用公共许可证第 2 版下许可。有关此许可证的完整文本,请参阅 Buildroot 源代码中的 COPYING 文件。
Copyright © The Buildroot developers <buildroot@buildroot.org>
版权所有 © Buildroot 开发人员 <buildroot@buildroot.org>
Buildroot is a tool that simplifies and automates the process of
building a complete Linux system for an embedded system, using
cross-compilation.
Buildroot 是一个工具,它简化和自动化了为嵌入式系统构建完整 Linux 系统的过程,使用交叉编译。
In order to achieve this, Buildroot is able to generate a
cross-compilation toolchain, a root filesystem, a Linux kernel image
and a bootloader for your target. Buildroot can be used for any
combination of these options, independently (you can for example use
an existing cross-compilation toolchain, and build only your root
filesystem with Buildroot).
为
了实现这一目标,Buildroot 能够为您的目标生成一个交叉编译工具链、一个根文件系统、一个 Linux
内核映像和一个引导加载程序。Buildroot 可以独立地用于这些选项的任何组合(例如,您可以使用现有的交叉编译工具链,并且仅使用
Buildroot 构建您的根文件系统)。
Buildroot is useful mainly for people working with embedded systems.
Embedded systems often use processors that are not the regular x86
processors everyone is used to having in his PC. They can be PowerPC
processors, MIPS processors, ARM processors, etc.
Buildroot 主要用于与嵌入式系统工作的人。嵌入式系统通常使用不是每个人都习惯在个人电脑上拥有的常规 x86 处理器。它们可以是 PowerPC 处理器、MIPS 处理器、ARM 处理器等。
Buildroot supports numerous processors and their variants; it also
comes with default configurations for several boards available
off-the-shelf. Besides this, a number of third-party projects are based on,
or develop their BSP [1] or
SDK [2] on top of Buildroot.
Buildroot 支持众多处理器及其变种;它还配备了几个现成的板卡的默认配置。此外,许多第三方项目都基于 Buildroot,或在 Buildroot 之上开发他们的 BSP [1] 或 SDK [2] 。
Buildroot is designed to run on Linux systems.
Buildroot 设计用于在 Linux 系统上运行。
While Buildroot itself will build most host packages it needs for the
compilation, certain standard Linux utilities are expected to be
already installed on the host system. Below you will find an overview of
the mandatory and optional packages (note that package names may vary
between distributions).
虽然 Buildroot 本身将构建大多数编译所需的主机软件包,但是预期某些标准的 Linux 实用工具已经安装在主机系统上。下面您将找到强制和可选软件包的概述(请注意软件包名称在不同发行版之间可能会有所不同)。
Build tools: 构建工具:
which
sed
make
(version 3.81 or any later)
make
(版本 3.81 或更高版本)binutils
build-essential
(only for Debian based systems)
build-essential
(仅适用于基于 Debian 的系统)diffutils
gcc
(version 4.8 or any later)
gcc
(版本 4.8 或更高版本)g++
(version 4.8 or any later)
g++
(版本 4.8 或更高版本)bash
patch
gzip
bzip2
perl
(version 5.8.7 or any later)
perl
(版本 5.8.7 或更高版本)tar
cpio
unzip
rsync
file
(must be in /usr/bin/file
)
file
(必须在 /usr/bin/file
内)bc
findutils
Source fetching tools: 源获取工具:
wget
Recommended dependencies:
推荐依赖项:
Some features or utilities in Buildroot, like the legal-info, or the
graph generation tools, have additional dependencies. Although they
are not mandatory for a simple build, they are still highly recommended:
Buildroot 中的一些功能或实用工具,如 legal-info 或图形生成工具,具有额外的依赖关系。虽然它们对于简单构建来说并非强制性的,但仍然强烈建议:
python
(version 2.7 or any later)
python
(版本 2.7 或更新版本)
Configuration interface dependencies:
配置界面依赖项:
For these libraries, you need to install both runtime and development
data, which in many distributions are packaged separately. The
development packages typically have a -dev or -devel suffix.
对于这些库,您需要安装运行时和开发数据,这在许多发行版中通常是分开打包的。开发包通常具有-dev 或-devel 后缀。
ncurses5
to use the menuconfig interface
ncurses5
使用 menuconfig 界面qt5
to use the xconfig interface
qt5
使用 xconfig 界面glib2
, gtk2
and glade2
to use the gconfig interface
glib2
, gtk2
和 glade2
使用 gconfig 接口Source fetching tools: 源码获取工具:
In the official tree, most of the package sources are retrieved using
wget
from ftp, http or https locations. A few packages are only
available through a version control system. Moreover, Buildroot is
capable of downloading sources via other tools, like git
or scp
(refer to Chapter 20, Download infrastructure for more details). If you enable
packages using any of these methods, you will need to install the
corresponding tool on the host system:
在官方树中,大多数软件包源码是通过 ftp、http 或 https 位置使用 wget
检索的。少数软件包只能通过版本控制系统获得。此外,Buildroot 能够通过其他工具(如 git
或 scp
)下载源码(详细信息请参阅第 20 章“下载基础设施”)。如果您使用这些方法启用软件包,则需要在主机系统上安装相应的工具:
bazaar
cvs
git
mercurial
scp
sftp
subversion
Java-related packages, if the Java Classpath needs to be built for
the target system:
如果目标系统需要构建 Java Classpath,则与 Java 相关的软件包:
javac
compiler
javac
编译器jar
tool
jar
工具
Documentation generation tools:
文档生成工具:
asciidoc
, version 8.6.3 or higher
asciidoc
,版本 8.6.3 或更高版本w3m
python
with the argparse
module (automatically present in 2.7+ and 3.2+)
python
与 argparse
模块(自动包含在 2.7+和 3.2+中)dblatex
(required for the pdf manual only)
dblatex
(仅适用于 PDF 手册)Graph generation tools: 图形生成工具:
graphviz
to use graph-depends and <pkg>-graph-dependsgraphviz
用于使用图形依赖项和 -图形依赖项
python-matplotlib
to use graph-build python-matplotlib
使用图形构建
Buildroot releases are made every 3 months, in February, May, August and
November. Release numbers are in the format YYYY.MM, so for example
2013.02, 2014.08.
Buildroot 每 3 个月发布一次版本,分别在 2 月、5 月、8 月和 11 月。版本号的格式为 YYYY.MM,例如 2013.02,2014.08。
Release tarballs are available at http://buildroot.org/downloads/.
发行版 tar 包可在 http://buildroot.org/downloads/获取。
For your convenience, a Vagrantfile is
available in support/misc/Vagrantfile
in the Buildroot source tree
to quickly set up a virtual machine with the needed dependencies to
get started.
为方便起见,在 Buildroot 源代码树中提供了一个 Vagrantfile,可快速设置一个带有所需依赖项的虚拟机,以便快速开始。
If you want to setup an isolated buildroot environment on Linux or Mac
Os X, paste this line onto your terminal:
如果您想在 Linux 或 Mac Os X 上设置一个独立的 buildroot 环境,请将此行粘贴到您的终端上:
curl -O https://buildroot.org/downloads/Vagrantfile; vagrant up
If you are on Windows, paste this into your powershell:
如果您使用的是 Windows,请将此内容粘贴到您的 PowerShell 中:
(new-object System.Net.WebClient).DownloadFile( "https://buildroot.org/downloads/Vagrantfile","Vagrantfile"); vagrant up
If you want to follow development, you can use the daily snapshots or
make a clone of the Git repository. Refer to the
Download page of the Buildroot website
for more details.
如果您想要跟踪开发进展,您可以使用每日快照或克隆 Git 存储库。有关更多详细信息,请参阅 Buildroot 网站的下载页面。
Important: you can and should build everything as a normal user. There
is no need to be root to configure and use Buildroot. By running all
commands as a regular user, you protect your system against packages
behaving badly during compilation and installation.
重要提示:您可以并且应该以普通用户的身份构建所有内容。在配置和使用 Buildroot 时,无需使用 root 权限。通过以普通用户身份运行所有命令,可以保护系统免受在编译和安装过程中表现不佳的软件包的影响。
The first step when using Buildroot is to create a configuration.
Buildroot has a nice configuration tool similar to the one you can
find in the Linux kernel or in
BusyBox.
使用 Buildroot 的第一步是创建配置。Buildroot 有一个很好的配置工具,类似于 Linux 内核或 BusyBox 中的配置工具。
From the buildroot directory, run
从 buildroot 目录中运行
$ make menuconfig
for the original curses-based configurator, or
用于原始基于 curses 的配置器,或
$ make nconfig
for the new curses-based configurator, or
用于新的基于 curses 的配置器,或
$ make xconfig
for the Qt-based configurator, or
用于基于 Qt 的配置器,或
$ make gconfig
for the GTK-based configurator.
用于基于 GTK 的配置器。
All of these "make" commands will need to build a configuration
utility (including the interface), so you may need to install
"development" packages for relevant libraries used by the
configuration utilities. Refer to Chapter 2, System requirements for more details,
specifically the optional requirements
to get the dependencies of your favorite interface.
所有这些“make”命令都需要构建一个配置实用程序(包括界面),因此您可能需要安装与配置实用程序使用的相关库的“开发”软件包。有关更多详细信息,请参阅第 2 章“系统要求”,特别是有关获取您喜爱的界面的依赖项的可选要求。
For each menu entry in the configuration tool, you can find associated
help that describes the purpose of the entry. Refer to Chapter 6, Buildroot configuration
for details on some specific configuration aspects.
对于配置工具中的每个菜单条目,您可以找到描述条目目的的相关帮助。有关一些特定配置方面的详细信息,请参阅第 6 章“Buildroot 配置”。
Once everything is configured, the configuration tool generates a
.config
file that contains the entire configuration. This file will be
read by the top-level Makefile.
一旦一切都配置好了,配置工具将生成一个包含整个配置的 .config
文件。此文件将由顶层 Makefile 读取。
To start the build process, simply run:
要开始构建过程,只需运行:
$ make
By default, Buildroot does not support top-level parallel build, so
running make -jN
is not necessary. There is however experimental
support for top-level parallel build, see
Section 8.12, “Top-level parallel build”.
默认情况下,Buildroot 不支持顶层并行构建,因此运行 make -jN
是不必要的。但是,顶层并行构建有实验性支持,请参见第 8.12 节“顶层并行构建”。
The make
command will generally perform the following steps:
make
命令通常会执行以下步骤:
Buildroot output is stored in a single directory, output/
.
This directory contains several subdirectories:
Buildroot 输出存储在一个单独的目录中, output/
。该目录包含几个子目录:
images/
where all the images (kernel image, bootloader and root
filesystem images) are stored. These are the files you need to put
on your target system.
images/
,其中存储了所有的镜像(内核镜像、引导加载程序和根文件系统镜像)。这些是您需要放在目标系统上的文件。build/
where all the components are built (this includes tools
needed by Buildroot on the host and packages compiled for the
target). This directory contains one subdirectory for each of these
components.
build/
,其中构建了所有的组件(这包括 Buildroot 在主机上需要的工具和为目标编译的软件包)。该目录包含每个组件的一个子目录。host/
contains both the tools built for the host, and the sysroot
of the target toolchain. The former is an installation of tools
compiled for the host that are needed for the proper execution of
Buildroot, including the cross-compilation toolchain. The latter
is a hierarchy similar to a root filesystem hierarchy. It contains
the headers and libraries of all user-space packages that provide
and install libraries used by other packages. However, this
directory is not intended to be the root filesystem for the target:
it contains a lot of development files, unstripped binaries and
libraries that make it far too big for an embedded system. These
development files are used to compile libraries and applications for
the target that depend on other libraries.
host/
包含为主机构建的工具和目标工具链的 sysroot。前者是为主机编译的工具的安装,这些工具是 Buildroot
正确执行所需的,包括交叉编译工具链。后者是类似于根文件系统层次结构的层次结构。它包含所有用户空间软件包的头文件和库,这些软件包提供并安装其他软件
包使用的库。但是,此目录不打算成为目标的根文件系统:它包含大量开发文件、未剥离的二进制文件和库,使其对于嵌入式系统来说太大。这些开发文件用于为依
赖其他库的目标编译库和应用程序。staging/
is a symlink to the target toolchain sysroot inside
host/
, which exists for backwards compatibility.
staging/
是 host/
中目标工具链 sysroot 的符号链接,用于向后兼容。target/
which contains almost the complete root filesystem for
the target: everything needed is present except the device files in
/dev/
(Buildroot can’t create them because Buildroot doesn’t run
as root and doesn’t want to run as root). Also, it doesn’t have the correct
permissions (e.g. setuid for the busybox binary). Therefore, this directory
should not be used on your target. Instead, you should use one of
the images built in the images/
directory. If you need an
extracted image of the root filesystem for booting over NFS, then
use the tarball image generated in images/
and extract it as
root. Compared to staging/
, target/
contains only the files and
libraries needed to run the selected target applications: the
development files (headers, etc.) are not present, the binaries are
stripped.
target/
包含了目标设备几乎完整的根文件系统:除了 /dev/
中的设备文件之外,一切所需的文件都已经准备就绪(Buildroot 无法创建这些文件,因为 Buildroot 不以 root
用户身份运行,也不希望以 root 用户身份运行)。此外,它也没有正确的权限(例如,busybox 二进制文件的
setuid)。因此,这个目录不应该在您的目标设备上使用。相反,您应该使用在 images/
目录中构建的其中一个镜像。如果您需要一个用于通过 NFS 引导的根文件系统的提取镜像,那么请使用在 images/
中生成的 tarball 镜像,并以 root 用户身份进行提取。与 staging/
相比, target/
只包含了运行所选目标应用程序所需的文件和库:开发文件(头文件等)不包含在内,二进制文件已经剥离。These commands, make menuconfig|nconfig|gconfig|xconfig
and make
, are the
basic ones that allow to easily and quickly generate images fitting
your needs, with all the features and applications you enabled.
这些命令, make menuconfig|nconfig|gconfig|xconfig
和 make
,是基本命令,可以轻松快速地生成符合您需求的图像,具有您启用的所有功能和应用程序。
More details about the "make" command usage are given in
Section 8.1, “make tips”.
有关“make”命令用法的更多详细信息,请参阅第 8.1 节“make 技巧”。
Like any open source project, Buildroot has different ways to share
information in its community and outside.
与任何开源项目一样,Buildroot 在其社区内部和外部分享信息的方式各不相同。
Each of those ways may interest you if you are looking for some help,
want to understand Buildroot or contribute to the project.
如果您正在寻求帮助,想了解 Buildroot 或为项目做出贡献,那么这些方式可能会引起您的兴趣。
Buildroot has a mailing list for discussion and development. It is the
main method of interaction for Buildroot users and developers.
Buildroot 有一个用于讨论和开发的邮件列表。这是 Buildroot 用户和开发人员进行互动的主要方法。
Only subscribers to the Buildroot mailing list are allowed to post to
this list. You can subscribe via the
mailing list info
page.
只有订阅了 Buildroot 邮件列表的订阅者才可以在此列表上发布。您可以通过邮件列表信息页面订阅。
Mails that are sent to the mailing list are also available in the
mailing list archives, available through
Mailman or at
lore.kernel.org.
发送到邮件列表的邮件也可以在邮件列表归档中找到,可通过 Mailman 或 lore.kernel.org 访问。
The Buildroot IRC channel #buildroot is
hosted on OFTC. It is a useful place to
ask quick questions or discuss on certain topics.
Buildroot IRC 频道#buildroot 托管在 OFTC 上。这是一个提问快速问题或讨论特定主题的有用场所。
When asking for help on IRC, share relevant logs or pieces of code
using a code sharing website, such as https://paste.ack.tf/.
在 IRC 上寻求帮助时,请使用代码共享网站(例如 https://paste.ack.tf/)分享相关日志或代码片段。
Note that for certain questions, posting to the mailing list may be
better as it will reach more people, both developers and users.
请注意,对于某些问题,将问题发布到邮件列表可能更好,因为这样可以让更多的人看到,包括开发人员和用户。
Patchwork is a web-based patch tracking system designed to facilitate
the contribution and management of contributions to an open-source
project. Patches that have been sent to a mailing list are 'caught' by
the system, and appear on a web page. Any comments posted that
reference the patch are appended to the patch page too. For more
information on Patchwork see
http://jk.ozlabs.org/projects/patchwork/.
补
丁工作是一个基于网络的补丁跟踪系统,旨在促进对开源项目的贡献和管理。已发送到邮件列表的补丁会被系统“捕捉”,并显示在网页上。任何涉及该补丁的发布
的评论也会附加到补丁页面上。有关补丁工作的更多信息,请参阅 http://jk.ozlabs.org/projects/patchwork/。
Buildroot’s Patchwork website is mainly for use by Buildroot’s
maintainer to ensure patches aren’t missed. It is also used by Buildroot
patch reviewers (see also Section 22.3.1, “Applying Patches from Patchwork”).
However, since the website exposes patches and their corresponding
review comments in a clean and concise web interface, it can be useful
for all Buildroot developers.
Buildroot
的 Patchwork 网站主要供 Buildroot 的维护者使用,以确保不会错过补丁。它还被 Buildroot
补丁审阅者使用(另请参见第 22.3.1 节“从 Patchwork
应用补丁”)。然而,由于该网站以清晰简洁的网络界面展示补丁及其相应的审阅评论,因此对所有 Buildroot 开发人员都有用。
The Buildroot patch management interface is available at
https://patchwork.ozlabs.org/project/buildroot/list/.
Buildroot 补丁管理界面可在 https://patchwork.ozlabs.org/project/buildroot/list/找到。
All the configuration options in make *config
have a help text
providing details about the option.
make *config
中的所有配置选项都有帮助文本,提供有关该选项的详细信息。
The make *config
commands also offer a search tool. Read the help
message in the different frontend menus to know how to use it:
make *config
命令还提供搜索工具。阅读不同前端菜单中的帮助消息,了解如何使用它:
/
;
/
键调用搜索工具;Ctrl
+ f
.
Ctrl
+ f
可调用搜索工具。The result of the search shows the help message of the matching items.
In menuconfig, numbers in the left column provide a shortcut to the
corresponding entry. Just type this number to directly jump to the
entry, or to the containing menu in case the entry is not selectable due
to a missing dependency.
搜索结果显示匹配项目的帮助消息。在 menuconfig 中,左列的数字为对应条目提供了快捷方式。只需键入该数字即可直接跳转到该条目,或者跳转到包含菜单(如果由于缺少依赖项而无法选择该条目)。
Although the menu structure and the help text of the entries should be
sufficiently self-explanatory, a number of topics require additional
explanation that cannot easily be covered in the help text and are
therefore covered in the following sections.
尽管菜单结构和条目的帮助文本应该足够自解释,但有一些主题需要额外解释,这些内容不容易在帮助文本中涵盖,因此在以下部分进行了介绍。
A compilation toolchain is the set of tools that allows you to compile
code for your system. It consists of a compiler (in our case, gcc
),
binary utils like assembler and linker (in our case, binutils
) and a
C standard library (for example
GNU Libc,
uClibc-ng).
编译工具链是一组工具,允许您为您的系统编译代码。它包括编译器(在我们的情况下, gcc
),二进制工具如汇编器和链接器(在我们的情况下, binutils
)和 C 标准库(例如 GNU Libc,uClibc-ng)。
The system installed on your development station certainly already has
a compilation toolchain that you can use to compile an application
that runs on your system. If you’re using a PC, your compilation
toolchain runs on an x86 processor and generates code for an x86
processor. Under most Linux systems, the compilation toolchain uses
the GNU libc (glibc) as the C standard library. This compilation
toolchain is called the "host compilation toolchain". The machine on
which it is running, and on which you’re working, is called the "host
system" [3].
安
装在您的开发站点上的系统肯定已经有一个编译工具链,您可以使用它来编译在您的系统上运行的应用程序。如果您使用的是个人电脑,您的编译工具链在 x86
处理器上运行,并为 x86 处理器生成代码。在大多数 Linux 系统下,编译工具链使用 GNU libc(glibc)作为 C
标准库。这个编译工具链被称为“主机编译工具链”。它正在运行的机器,以及您正在工作的机器,被称为“主机系统” [3] 。
The compilation toolchain is provided by your distribution, and
Buildroot has nothing to do with it (other than using it to build a
cross-compilation toolchain and other tools that are run on the
development host).
编译工具链由您的发行版提供,Buildroot 与之无关(除了使用它来构建交叉编译工具链和在开发主机上运行的其他工具)。
As said above, the compilation toolchain that comes with your system
runs on and generates code for the processor in your host system. As
your embedded system has a different processor, you need a
cross-compilation toolchain - a compilation toolchain that runs on
your host system but generates code for your target system (and
target processor). For example, if your host system uses x86 and your
target system uses ARM, the regular compilation toolchain on your host
runs on x86 and generates code for x86, while the cross-compilation
toolchain runs on x86 and generates code for ARM.
如
上所述,系统自带的编译工具链在您的主机系统上运行,并为主机系统中的处理器生成代码。由于您的嵌入式系统使用不同的处理器,您需要一个交叉编译工具链 -
一个在您的主机系统上运行但为目标系统(和目标处理器)生成代码的编译工具链。例如,如果您的主机系统使用 x86,而目标系统使用
ARM,那么主机上的常规编译工具链在 x86 上运行并为 x86 生成代码,而交叉编译工具链在 x86 上运行并为 ARM 生成代码。
Buildroot provides two solutions for the cross-compilation toolchain:
Buildroot 为交叉编译工具链提供了两种解决方案:
Buildroot toolchain
in
the configuration interface.
Buildroot toolchain
。External toolchain
in
the configuration interface.
External toolchain
。The choice between these two solutions is done using the Toolchain
Type
option in the Toolchain
menu. Once one solution has been
chosen, a number of configuration options appear, they are detailed in
the following sections.
在 Toolchain
菜单中使用 Toolchain
Type
选项来选择这两个解决方案之间的选择。一旦选择了一个解决方案,将出现一些配置选项,这些选项在以下部分中详细说明。
The internal toolchain backend is the backend where Buildroot builds
by itself a cross-compilation toolchain, before building the userspace
applications and libraries for your target embedded system.
内部工具链后端是 Buildroot 在构建目标嵌入式系统的用户空间应用程序和库之前,通过自身构建交叉编译工具链的后端。
This backend supports several C libraries:
uClibc-ng,
glibc and
musl.
该后端支持几种 C 库:uClibc-ng、glibc 和 musl。
Once you have selected this backend, a number of options appear. The
most important ones allow to:
一旦选择了这个后端,将会出现许多选项。其中最重要的选项允许:
.h
files from the kernel), which
define the interface between userspace and the kernel (system
calls, data structures, etc.). Since this interface is backward
compatible, the version of the Linux kernel headers used to build
your toolchain do not need to match exactly the version of the
Linux kernel you intend to run on your embedded system. They only
need to have a version equal or older to the version of the Linux
kernel you intend to run. If you use kernel headers that are more
recent than the Linux kernel you run on your embedded system, then
the C library might be using interfaces that are not provided by
your Linux kernel.
.h
文件),这些文件定义了用户空间和内核之间的接口(系统调用、数据结构等)。由于这个接口是向后兼容的,用于构建工具链的 Linux
内核头文件的版本不需要完全匹配您打算在嵌入式系统上运行的 Linux 内核的版本。它们只需要具有与您打算运行的 Linux
内核版本相等或更旧的版本。如果您使用的内核头文件比您在嵌入式系统上运行的 Linux 内核更新,那么 C 库可能会使用您的 Linux
内核未提供的接口。make uclibc-menuconfig
. Note however that
all packages in Buildroot are tested against the default uClibc
configuration bundled in Buildroot: if you deviate from this
configuration by removing features from uClibc, some packages may no
longer build.
make uclibc-menuconfig
进一步调整 uClibc 配置。但请注意,Buildroot 中的所有软件包都针对 Buildroot 捆绑的默认 uClibc 配置进行测试:如果您通过从 uClibc 中删除功能而偏离此配置,则某些软件包可能无法构建。It is worth noting that whenever one of those options is modified,
then the entire toolchain and system must be rebuilt. See
Section 8.2, “Understanding when a full rebuild is necessary”.
值得注意的是,每当修改这些选项之一时,整个工具链和系统都必须重新构建。请参阅第 8.2 节“了解何时需要进行完全重建”。
Advantages of this backend:
此后端的优势:
Drawbacks of this backend:
这个后端的缺点:
make clean
, which
takes time. If you’re trying to reduce your build time, consider
using the External toolchain backend.
make clean
时,需要重新构建工具链,这需要时间。如果您想要减少构建时间,请考虑使用外部工具链后端。The external toolchain backend allows to use existing pre-built
cross-compilation toolchains. Buildroot knows about a number of
well-known cross-compilation toolchains (from
Linaro for ARM,
Sourcery
CodeBench for ARM, x86-64, PowerPC, and MIPS, and is capable of
downloading them automatically, or it can be pointed to a custom
toolchain, either available for download or installed locally.
外
部工具链后端允许使用现有的预构建交叉编译工具链。Buildroot 知道一些知名的交叉编译工具链(来自 Linaro 的
ARM,Sourcery CodeBench 的 ARM,x86-64,PowerPC 和
MIPS),并且能够自动下载它们,或者可以指向自定义工具链,无论是可供下载还是本地安装。
Then, you have three solutions to use an external toolchain:
然后,您有三种解决方案可以使用外部工具链:
Toolchain
from the available ones. This is
definitely the easiest solution.
Toolchain
through the available
ones, unselect Download toolchain automatically
, and fill the
Toolchain path
text entry with the path to your cross-compiling
toolchain.
Toolchain
中选择工具链配置文件,取消选择 Download toolchain automatically
,并在 Toolchain path
文本框中填入交叉编译工具链的路径。Custom toolchain
solution in the
Toolchain
list. You need to fill the Toolchain path
, Toolchain
prefix
and External toolchain C library
options. Then, you have
to tell Buildroot what your external toolchain supports. If your
external toolchain uses the glibc library, you only have to tell
whether your toolchain supports C++ or not and whether it has
built-in RPC support. If your external toolchain uses the uClibc
library, then you have to tell Buildroot if it supports RPC,
wide-char, locale, program invocation, threads and C++.
At the beginning of the execution, Buildroot will tell you if
the selected options do not match the toolchain configuration.
Toolchain
列表中选择 Custom toolchain
解决方案。您需要填写 Toolchain path
、 Toolchain
prefix
和 External toolchain C library
选项。然后,您需要告诉 Buildroot 您的外部工具链支持什么。如果您的外部工具链使用 glibc 库,您只需告诉工具链是否支持
C++,以及是否具有内置的 RPC 支持。如果您的外部工具链使用 uClibc 库,那么您需要告诉 Buildroot 它是否支持
RPC、宽字符、区域设置、程序调用、线程和 C++。在执行开始时,Buildroot 会告诉您所选选项是否与工具链配置不匹配。Our external toolchain support has been tested with toolchains from
CodeSourcery and Linaro, toolchains generated by
crosstool-NG, and toolchains generated by
Buildroot itself. In general, all toolchains that support the
sysroot feature should work. If not, do not hesitate to contact the
developers.
我
们的外部工具链支持已经与来自 CodeSourcery 和 Linaro 的工具链,由 crosstool-NG 生成的工具链以及由
Buildroot 本身生成的工具链进行了测试。一般来说,所有支持 sysroot
功能的工具链都应该可以工作。如果不能,请不要犹豫与开发人员联系。
We do not support toolchains or SDK generated by OpenEmbedded or
Yocto, because these toolchains are not pure toolchains (i.e. just the
compiler, binutils, the C and C++ libraries). Instead these toolchains
come with a very large set of pre-compiled libraries and
programs. Therefore, Buildroot cannot import the sysroot of the
toolchain, as it would contain hundreds of megabytes of pre-compiled
libraries that are normally built by Buildroot.
我
们不支持由 OpenEmbedded 或 Yocto 生成的工具链或
SDK,因为这些工具链不是纯粹的工具链(即仅包括编译器、binutils、C 和
C++库)。相反,这些工具链带有非常庞大的预编译库和程序集。因此,Buildroot 无法导入工具链的
sysroot,因为它将包含数百兆字节的通常由 Buildroot 构建的预编译库。
We also do not support using the distribution toolchain (i.e. the
gcc/binutils/C library installed by your distribution) as the
toolchain to build software for the target. This is because your
distribution toolchain is not a "pure" toolchain (i.e. only with the
C/C++ library), so we cannot import it properly into the Buildroot
build environment. So even if you are building a system for a x86 or
x86_64 target, you have to generate a cross-compilation toolchain with
Buildroot or crosstool-NG.
我
们也不支持使用发行版工具链(即由您的发行版安装的 gcc/binutils/C
库)作为构建目标软件的工具链。这是因为您的发行版工具链不是一个“纯粹”的工具链(即只有 C/C++库),所以我们无法将其正确地导入到
Buildroot 构建环境中。因此,即使您正在为 x86 或 x86_64 目标构建系统,您也必须使用 Buildroot 或
crosstool-NG 生成交叉编译工具链。
If you want to generate a custom toolchain for your project, that can
be used as an external toolchain in Buildroot, our recommendation is
to build it either with Buildroot itself (see
Section 6.1.3, “Build an external toolchain with Buildroot”) or with
crosstool-NG.
如果您想为您的项目生成自定义工具链,以便在 Buildroot 中用作外部工具链,我们建议使用 Buildroot 本身构建(请参阅第 6.1.3 节“使用 Buildroot 构建外部工具链”)或使用 crosstool-NG 构建。
Advantages of this backend:
此后端的优势:
Drawbacks of this backend:
该后端的缺点:
The Buildroot internal toolchain option can be used to create an
external toolchain. Here are a series of steps to build an internal
toolchain and package it up for reuse by Buildroot itself (or other
projects).
可以使用 Buildroot 内部工具链选项来创建外部工具链。以下是构建内部工具链并将其打包以供 Buildroot 本身(或其他项目)重复使用的一系列步骤。
Create a new Buildroot configuration, with the following details:
创建一个新的 Buildroot 配置,包括以下细节:
Then, we can trigger the build, and also ask Buildroot to generate a
SDK. This will conveniently generate for us a tarball which contains
our toolchain:
然后,我们可以触发构建,并要求 Buildroot 生成一个 SDK。这将方便地为我们生成一个包含我们的工具链的 tarball:
make sdk
This produces the SDK tarball in $(O)/images
, with a name similar to
arm-buildroot-linux-uclibcgnueabi_sdk-buildroot.tar.gz
. Save this
tarball, as it is now the toolchain that you can re-use as an external
toolchain in other Buildroot projects.
这将在 $(O)/images
中生成 SDK tarball,名称类似于 arm-buildroot-linux-uclibcgnueabi_sdk-buildroot.tar.gz
。保存这个 tarball,因为现在它是您可以在其他 Buildroot 项目中作为外部工具链重复使用的工具链。
In those other Buildroot projects, in the Toolchain menu:
在其他 Buildroot 项目中,在工具链菜单中:
file:///path/to/your/sdk/tarball.tar.gz
file:///path/to/your/sdk/tarball.tar.gz
When using an external toolchain, Buildroot generates a wrapper program,
that transparently passes the appropriate options (according to the
configuration) to the external toolchain programs. In case you need to
debug this wrapper to check exactly what arguments are passed, you can
set the environment variable BR2_DEBUG_WRAPPER
to either one of:
当使用外部工具链时,Buildroot 会生成一个包装程序,该程序会根据配置透明地将适当的选项传递给外部工具链程序。如果您需要调试此包装程序以检查传递的确切参数,您可以将环境变量 BR2_DEBUG_WRAPPER
设置为以下之一:
0
, empty or not set: no debug
0
,为空或未设置:无调试1
: trace all arguments on a single line
1
:在单行上跟踪所有参数2
: trace one argument per line
2
:每行跟踪一个参数On a Linux system, the /dev
directory contains special files, called
device files, that allow userspace applications to access the
hardware devices managed by the Linux kernel. Without these device
files, your userspace applications would not be able to use the
hardware devices, even if they are properly recognized by the Linux
kernel.
在 Linux 系统上, /dev
目录包含称为设备文件的特殊文件,允许用户空间应用程序访问由 Linux 内核管理的硬件设备。如果没有这些设备文件,即使 Linux 内核正确识别了硬件设备,您的用户空间应用程序也无法使用这些硬件设备。
Under System configuration
, /dev management
, Buildroot offers four
different solutions to handle the /dev
directory :
在 System configuration
, /dev management
下,Buildroot 提供了四种不同的解决方案来处理 /dev
目录:
system/device_table_dev.txt
in the
Buildroot source code. This file is processed when Buildroot
generates the final root filesystem image, and the device files
are therefore not visible in the output/target
directory. The
BR2_ROOTFS_STATIC_DEVICE_TABLE
option allows to change the
default device table used by Buildroot, or to add an additional
device table, so that additional device files are created by
Buildroot during the build. So, if you use this method, and a
device file is missing in your system, you can for example create
a board/<yourcompany>/<yourproject>/device_table_dev.txt
file
that contains the description of your additional device files,
and then you can set BR2_ROOTFS_STATIC_DEVICE_TABLE
to
system/device_table_dev.txt
board/<yourcompany>/<yourproject>/device_table_dev.txt
. For more
details about the format of the device table file, see
Chapter 25, Makedev syntax documentation.
system/device_table_dev.txt
中。当 Buildroot 生成最终的根文件系统映像时,将处理此文件,因此设备文件在 output/target
目录中不可见。 BR2_ROOTFS_STATIC_DEVICE_TABLE
选项允许更改 Buildroot 使用的默认设备表,或添加额外的设备表,以便 Buildroot 在构建过程中创建额外的设备文件。因此,如果您使用此方法,并且系统中缺少设备文件,您可以例如创建一个包含您额外设备文件描述的 board/<yourcompany>/<yourproject>/device_table_dev.txt
文件,然后您可以将 BR2_ROOTFS_STATIC_DEVICE_TABLE
设置为 system/device_table_dev.txt
board/<yourcompany>/<yourproject>/device_table_dev.txt
。有关设备表文件格式的更多详细信息,请参阅第 25 章《Makedev 语法文档》。/dev
, this virtual
filesystem will automatically make device files appear and
disappear as hardware devices are added and removed from the
system. This filesystem is not persistent across reboots: it is
filled dynamically by the kernel. Using devtmpfs requires the
following kernel configuration options to be enabled:
CONFIG_DEVTMPFS
and CONFIG_DEVTMPFS_MOUNT
. When Buildroot is in
charge of building the Linux kernel for your embedded device, it
makes sure that those two options are enabled. However, if you
build your Linux kernel outside of Buildroot, then it is your
responsibility to enable those two options (if you fail to do so,
your Buildroot system will not boot).
/dev
中挂载时,这个虚拟文件系统会自动使设备文件随着硬件设备被添加到系统中而出现和消失。这个文件系统在重新启动后不是持久的:它由内核动态填充。使用 devtmpfs 需要启用以下内核配置选项: CONFIG_DEVTMPFS
和 CONFIG_DEVTMPFS_MOUNT
。当 Buildroot 负责为您的嵌入式设备构建 Linux 内核时,它会确保这两个选项已启用。但是,如果您在 Buildroot 之外构建 Linux 内核,则您有责任启用这两个选项(如果未能这样做,您的 Buildroot 系统将无法启动)。CONFIG_DEVTMPFS
and
CONFIG_DEVTMPFS_MOUNT
enabled in the kernel configuration still
apply), but adds the mdev
userspace utility on top of it. mdev
is a program part of BusyBox that the kernel will call every time a
device is added or removed. Thanks to the /etc/mdev.conf
configuration file, mdev
can be configured to for example, set
specific permissions or ownership on a device file, call a script
or application whenever a device appears or disappear,
etc. Basically, it allows userspace to react on device addition
and removal events. mdev
can for example be used to automatically
load kernel modules when devices appear on the system. mdev
is
also important if you have devices that require a firmware, as it
will be responsible for pushing the firmware contents to the
kernel. mdev
is a lightweight implementation (with fewer
features) of udev
. For more details about mdev
and the syntax
of its configuration file, see
http://git.busybox.net/busybox/tree/docs/mdev.txt.
CONFIG_DEVTMPFS
和 CONFIG_DEVTMPFS_MOUNT
),但在其之上添加了 mdev
用户空间实用程序。 mdev
是 BusyBox 的一部分程序,内核会在每次添加或移除设备时调用它。通过 /etc/mdev.conf
配置文件, mdev
可以被配置为例如,在设备文件上设置特定权限或所有权,每当设备出现或消失时调用脚本或应用程序等。基本上,它允许用户空间对设备添加和移除事件做出反应。例如, mdev
可以用于在系统上出现设备时自动加载内核模块。如果您有需要固件的设备, mdev
也很重要,因为它将负责将固件内容推送到内核。 mdev
是 udev
的轻量级实现(功能较少)。有关 mdev
和其配置文件语法的更多详细信息,请参阅 http://git.busybox.net/busybox/tree/docs/mdev.txt。eudev
userspace daemon on top of it. eudev
is a daemon that runs in the background, and gets called by the
kernel when a device gets added or removed from the system. It is a
more heavyweight solution than mdev
, but provides higher
flexibility. eudev
is a standalone version of udev
, the
original userspace daemon used in most desktop Linux distributions,
which is now part of Systemd. For more details, see
http://en.wikipedia.org/wiki/Udev.
eudev
用户空间守护程序。 eudev
是一个在后台运行的守护程序,当系统中添加或移除设备时,会被内核调用。这是一个比 mdev
更加庞大的解决方案,但提供了更高的灵活性。 eudev
是 udev
的独立版本, udev
是大多数桌面 Linux 发行版中使用的原始用户空间守护程序,现在已成为 Systemd 的一部分。更多详情请参阅 http://en.wikipedia.org/wiki/Udev。The Buildroot developers recommendation is to start with the Dynamic
using devtmpfs only solution, until you have the need for userspace
to be notified when devices are added/removed, or if firmwares are
needed, in which case Dynamic using devtmpfs + mdev is usually a
good solution.
Buildroot 开发人员建议首先使用仅使用 devtmpfs 的动态解决方案,直到需要在添加/移除设备时通知用户空间,或者需要固件时,此时通常使用动态使用 devtmpfs + mdev 是一个不错的解决方案。
Note that if systemd
is chosen as init system, /dev management will
be performed by the udev
program provided by systemd
.
请注意,如果选择 systemd
作为初始化系统,则/dev 管理将由 systemd
提供的 udev
程序执行。
The init program is the first userspace program started by the
kernel (it carries the PID number 1), and is responsible for starting
the userspace services and programs (for example: web server,
graphical applications, other network servers, etc.).
初始化程序是内核启动的第一个用户空间程序(它携带 PID 编号 1),负责启动用户空间服务和程序(例如:Web 服务器、图形应用程序、其他网络服务器等)。
Buildroot allows to use three different types of init systems, which
can be chosen from System configuration
, Init system
:
Buildroot 允许使用三种不同类型的 init 系统,可以从 System configuration
, Init system
中选择:
init
program, which is sufficient
for most embedded systems. Enabling the BR2_INIT_BUSYBOX
will
ensure BusyBox will build and install its init
program. This is
the default solution in Buildroot. The BusyBox init
program will
read the /etc/inittab
file at boot to know what to do. The syntax
of this file can be found in
http://git.busybox.net/busybox/tree/examples/inittab (note that
BusyBox inittab
syntax is special: do not use a random inittab
documentation from the Internet to learn about BusyBox
inittab
). The default inittab
in Buildroot is stored in
system/skeleton/etc/inittab
. Apart from mounting a few important
filesystems, the main job the default inittab does is to start the
/etc/init.d/rcS
shell script, and start a getty
program (which
provides a login prompt).
init
程序的实现,这对大多数嵌入式系统来说已经足够了。启用 BR2_INIT_BUSYBOX
将确保 BusyBox 构建并安装其 init
程序。这是 Buildroot 中的默认解决方案。BusyBox 的 init
程序将在启动时读取 /etc/inittab
文件以了解要执行的操作。此文件的语法可以在 http://git.busybox.net/busybox/tree/examples/inittab 中找到(请注意,BusyBox 的 inittab
语法很特殊:不要使用来自互联网的随机 inittab
文档来了解 BusyBox 的 inittab
)。Buildroot 中的默认 inittab
存储在 system/skeleton/etc/inittab
中。除了挂载几个重要的文件系统外,默认的 inittab 的主要工作是启动 /etc/init.d/rcS
shell 脚本,并启动一个 getty
程序(提供登录提示)。package/sysvinit
. This was the solution used in most desktop
Linux distributions, until they switched to more recent
alternatives such as Upstart or Systemd. sysvinit
also works with
an inittab
file (which has a slightly different syntax than the
one from BusyBox). The default inittab
installed with this init
solution is located in package/sysvinit/inittab
.
package/sysvinit
。这是大多数桌面 Linux 发行版使用的解决方案,直到它们转向更近期的替代方案,如 Upstart 或 Systemd。 sysvinit
还可以使用 inittab
文件(其语法与 BusyBox 的语法略有不同)。使用此 init 解决方案安装的默认 inittab
位于 package/sysvinit/inittab
。systemd
is the new generation
init system for Linux. It does far more than traditional init
programs: aggressive parallelization capabilities, uses socket and
D-Bus activation for starting services, offers on-demand starting
of daemons, keeps track of processes using Linux control groups,
supports snapshotting and restoring of the system state,
etc. systemd
will be useful on relatively complex embedded
systems, for example the ones requiring D-Bus and services
communicating between each other. It is worth noting that systemd
brings a fairly big number of large dependencies: dbus
, udev
and more. For more details about systemd
, see
http://www.freedesktop.org/wiki/Software/systemd.
systemd
是 Linux 的新一代 init 系统。它比传统的 init 程序做得更多:具有激进的并行化能力,使用套接字和 D-Bus 激活启动服务,提供按需启动守护程序,使用 Linux 控制组跟踪进程,支持系统状态的快照和恢复等。 systemd
将在相对复杂的嵌入式系统上很有用,例如需要 D-Bus 和服务之间通信的系统。值得注意的是 systemd
带来了相当多的大型依赖项: dbus
, udev
等。有关 systemd
的更多详细信息,请参阅 http://www.freedesktop.org/wiki/Software/systemd。The solution recommended by Buildroot developers is to use the
BusyBox init as it is sufficient for most embedded
systems. systemd can be used for more complex situations.
Buildroot 开发人员推荐的解决方案是使用 BusyBox init,因为对于大多数嵌入式系统来说已经足够了。systemd 可用于更复杂的情况。
[3] This terminology differs from what is used by GNU
configure, where the host is the machine on which the application will
run (which is usually the same as target)
[3] 这个术语与 GNU 配置中使用的术语不同,在那里主机是应用程序将运行的机器(通常与目标相同)。
Before attempting to modify any of the components below, make sure you
have already configured Buildroot itself, and have enabled the
corresponding package.
在尝试修改以下任何组件之前,请确保您已经配置了 Buildroot 本身,并已启用相应的软件包。
If you already have a BusyBox configuration file, you can directly
specify this file in the Buildroot configuration, using
BR2_PACKAGE_BUSYBOX_CONFIG
. Otherwise, Buildroot will start from a
default BusyBox configuration file.
如果您已经有一个 BusyBox 配置文件,您可以直接在 Buildroot 配置中指定该文件,使用 BR2_PACKAGE_BUSYBOX_CONFIG
。否则,Buildroot 将从默认的 BusyBox 配置文件开始。
To make subsequent changes to the configuration, use make
busybox-menuconfig
to open the BusyBox configuration editor.
要对配置进行后续更改,请使用 make
busybox-menuconfig
打开 BusyBox 配置编辑器。
It is also possible to specify a BusyBox configuration file through an
environment variable, although this is not recommended. Refer to
Section 8.6, “Environment variables” for more details.
也可以通过环境变量指定 BusyBox 配置文件,尽管这不被推荐。有关更多详细信息,请参阅第 8.6 节“环境变量”。
BR2_UCLIBC_CONFIG
. The command to make subsequent changes is make
uclibc-menuconfig
.BR2_UCLIBC_CONFIG
。进行后续更改的命令为 make
uclibc-menuconfig
。If you already have a kernel configuration file, you can directly
specify this file in the Buildroot configuration, using
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG
.
如果您已经有内核配置文件,可以直接在 Buildroot 配置中指定该文件,使用 BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG
。
If you do not yet have a kernel configuration file, you can either start
by specifying a defconfig in the Buildroot configuration, using
BR2_LINUX_KERNEL_USE_DEFCONFIG
, or start by creating an empty file and
specifying it as custom configuration file, using
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG
.
如果您还没有内核配置文件,可以通过在 Buildroot 配置中指定一个 defconfig(使用 BR2_LINUX_KERNEL_USE_DEFCONFIG
)开始,或者通过创建一个空文件并将其指定为自定义配置文件(使用 BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG
)开始。
To make subsequent changes to the configuration, use make
linux-menuconfig
to open the Linux configuration editor.
要对配置进行后续更改,请使用 make
linux-menuconfig
打开 Linux 配置编辑器。
BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG
and
BR2_TARGET_BAREBOX_USE_DEFCONFIG
. To open the configuration editor,
use make barebox-menuconfig
.BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG
和 BR2_TARGET_BAREBOX_USE_DEFCONFIG
。要打开配置编辑器,请使用 make barebox-menuconfig
。BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG
and
BR2_TARGET_UBOOT_USE_DEFCONFIG
. To open the configuration editor,
use make uboot-menuconfig
.BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG
和 BR2_TARGET_UBOOT_USE_DEFCONFIG
。要打开配置编辑器,请使用 make uboot-menuconfig
。This is a collection of tips that help you make the most of Buildroot.
这是一些帮助您充分利用 Buildroot 的技巧的集合。
Display all commands executed by make:
显示由 make 执行的所有命令:
$ make V=1 <target>
Display the list of boards with a defconfig:
显示具有 defconfig 的板的列表:
$ make list-defconfigs
Display all available targets:
显示所有可用的目标:
$ make help
Not all targets are always available,
some settings in the .config
file may hide some targets:
并非所有目标始终可用, .config
文件中的一些设置可能会隐藏一些目标:
busybox-menuconfig
only works when busybox
is enabled;
busybox
时, busybox-menuconfig
才起作用;linux-menuconfig
and linux-savedefconfig
only work when
linux
is enabled;
linux
时, linux-menuconfig
和 linux-savedefconfig
才起作用;uclibc-menuconfig
is only available when the uClibc C library is
selected in the internal toolchain backend;
uclibc-menuconfig
可用;barebox-menuconfig
and barebox-savedefconfig
only work when the
barebox
bootloader is enabled.
barebox
bootloader 启用时,只有 barebox-menuconfig
和 barebox-savedefconfig
可用。uboot-menuconfig
and uboot-savedefconfig
only work when the
U-Boot
bootloader is enabled and the uboot
build system is set
to Kconfig
.
U-Boot
bootloader 启用且 uboot
构建系统设置为 Kconfig
时,只有 uboot-menuconfig
和 uboot-savedefconfig
可用。Cleaning: Explicit cleaning is required when any of the architecture or toolchain
configuration options are changed.
清理:当更改任何架构或工具链配置选项时,需要显式清理。
To delete all build products (including build directories, host, staging
and target trees, the images and the toolchain):
要删除所有构建产品(包括构建目录、主机、暂存和目标树、映像和工具链):
$ make clean
Generating the manual: The present manual sources are located in the docs/manual directory.
To generate the manual:
生成手册:当前手册源位于 docs/manual 目录中。要生成手册:
$ make manual-clean $ make manual
The manual outputs will be generated in output/docs/manual.
手册输出将生成在 output/docs/manual 中。
Notes 注意事项
Resetting Buildroot for a new target: To delete all build products as well as the configuration:
为新目标重置 Buildroot:要删除所有构建产品以及配置:
$ make distclean
Notes. If ccache
is enabled, running make clean
or distclean
does
not empty the compiler cache used by Buildroot. To delete it, refer
to Section 8.13.3, “Using ccache
in Buildroot”.
注意事项。如果启用了 ccache
,运行 make clean
或 distclean
不会清空 Buildroot 使用的编译器缓存。要删除它,请参阅第 8.13.3 节“在 Buildroot 中使用 ccache
”。
Dumping the internal make variables: One can dump the variables known to make, along with their values:
转储内部制作变量:可以转储已知于制作的变量及其值:
$ make -s printvars VARS='VARIABLE1 VARIABLE2' VARIABLE1=value_of_variable VARIABLE2=value_of_variable
It is possible to tweak the output using some variables:
可以使用一些变量来调整输出:
VARS
will limit the listing to variables which names match the
specified make-patterns - this must be set else nothing is printed
VARS
将限制列出与指定制作模式匹配的变量名称 - 必须设置,否则不会打印任何内容QUOTED_VARS
, if set to YES
, will single-quote the value
QUOTED_VARS
,如果设置为 YES
,将对值进行单引号处理RAW_VARS
, if set to YES
, will print the unexpanded value
RAW_VARS
,如果设置为 YES
,将打印未展开的值For example: 例如:
$ make -s printvars VARS=BUSYBOX_%DEPENDENCIES BUSYBOX_DEPENDENCIES=skeleton toolchain BUSYBOX_FINAL_ALL_DEPENDENCIES=skeleton toolchain BUSYBOX_FINAL_DEPENDENCIES=skeleton toolchain BUSYBOX_FINAL_PATCH_DEPENDENCIES= BUSYBOX_RDEPENDENCIES=ncurses util-linux
$ make -s printvars VARS=BUSYBOX_%DEPENDENCIES QUOTED_VARS=YES BUSYBOX_DEPENDENCIES='skeleton toolchain' BUSYBOX_FINAL_ALL_DEPENDENCIES='skeleton toolchain' BUSYBOX_FINAL_DEPENDENCIES='skeleton toolchain' BUSYBOX_FINAL_PATCH_DEPENDENCIES='' BUSYBOX_RDEPENDENCIES='ncurses util-linux'
$ make -s printvars VARS=BUSYBOX_%DEPENDENCIES RAW_VARS=YES BUSYBOX_DEPENDENCIES=skeleton toolchain BUSYBOX_FINAL_ALL_DEPENDENCIES=$(sort $(BUSYBOX_FINAL_DEPENDENCIES) $(BUSYBOX_FINAL_PATCH_DEPENDENCIES)) BUSYBOX_FINAL_DEPENDENCIES=$(sort $(BUSYBOX_DEPENDENCIES)) BUSYBOX_FINAL_PATCH_DEPENDENCIES=$(sort $(BUSYBOX_PATCH_DEPENDENCIES)) BUSYBOX_RDEPENDENCIES=ncurses util-linux
The output of quoted variables can be reused in shell scripts, for example:
引用变量的输出可以在 shell 脚本中重复使用,例如:
$ eval $(make -s printvars VARS=BUSYBOX_DEPENDENCIES QUOTED_VARS=YES) $ echo $BUSYBOX_DEPENDENCIES skeleton toolchain
Buildroot does not attempt to detect what parts of the system should
be rebuilt when the system configuration is changed through make
menuconfig
, make xconfig
or one of the other configuration
tools. In some cases, Buildroot should rebuild the entire system, in
some cases, only a specific subset of packages. But detecting this in
a completely reliable manner is very difficult, and therefore the
Buildroot developers have decided to simply not attempt to do this.
当系统配置通过 make
menuconfig
, make xconfig
或其他配置工具更改时,Buildroot 不会尝试检测应重新构建系统的哪些部分。在某些情况下,Buildroot
应重新构建整个系统,而在某些情况下,只需重新构建特定的软件包子集。但以完全可靠的方式检测这一点非常困难,因此 Buildroot
开发人员决定简单地不尝试这样做。
Instead, it is the responsibility of the user to know when a full
rebuild is necessary. As a hint, here are a few rules of thumb that
can help you understand how to work with Buildroot:
相反,用户有责任知道何时需要进行完全重建。以下是一些经验法则的提示,可以帮助您了解如何使用 Buildroot:
ctorrent
package, but without openssl
. Your system works, but you realize
you would like to have SSL support in ctorrent
, so you enable the
openssl
package in Buildroot configuration and restart the
build. Buildroot will detect that openssl
should be built and
will be build it, but it will not detect that ctorrent
should be
rebuilt to benefit from openssl
to add OpenSSL support. You will
either have to do a full rebuild, or rebuild ctorrent
itself.
ctorrent
软件包,但不包含 openssl
软件包。你的系统可以运行,但你意识到你想在 ctorrent
中添加 SSL 支持,因此你在 Buildroot 配置中启用了 openssl
软件包并重新启动构建。Buildroot 将检测到应该构建 openssl
并对其进行构建,但它不会检测到应该重建 ctorrent
以从 openssl
中获益以添加 OpenSSL 支持。你要么进行完全重建,要么重建 ctorrent
本身。make
invocation
will take the changes into account.
make
调用将考虑到更改。FOO_DEPENDENCIES
is rebuilt or removed,
the package foo
is not automatically rebuilt. For example, if a
package bar
is listed in FOO_DEPENDENCIES
with FOO_DEPENDENCIES
= bar
and the configuration of the bar
package is changed, the
configuration change would not result in a rebuild of package foo
automatically. In this scenario, you may need to either rebuild any
packages in your build which reference bar
in their DEPENDENCIES
,
or perform a full rebuild to ensure any bar
dependent packages are
up to date.
FOO_DEPENDENCIES
中列出的软件包被重新构建或移除时,软件包 foo
不会自动重新构建。例如,如果软件包 bar
在 FOO_DEPENDENCIES
中与 FOO_DEPENDENCIES
= bar
一起列出,并且 bar
软件包的配置发生更改,则配置更改不会自动导致软件包 foo
重新构建。在这种情况下,您可能需要重新构建任何在构建中引用 bar
的软件包,或者执行完整的重新构建以确保任何 bar
依赖软件包是最新的。Generally speaking, when you’re facing a build error and you’re unsure
of the potential consequences of the configuration changes you’ve
made, do a full rebuild. If you get the same build error, then you are
sure that the error is not related to partial rebuilds of packages,
and if this error occurs with packages from the official Buildroot, do
not hesitate to report the problem! As your experience with Buildroot
progresses, you will progressively learn when a full rebuild is really
necessary, and you will save more and more time.
一
般来说,当您面临构建错误并且不确定您所做配置更改的潜在后果时,请进行完整重建。如果您收到相同的构建错误,则可以确定该错误与软件包的部分重建无关,
如果此错误发生在官方 Buildroot 软件包中,请毫不犹豫地报告问题!随着您对 Buildroot
的经验不断积累,您将逐渐学会何时真正需要进行完整重建,并且将节省越来越多的时间。
For reference, a full rebuild is achieved by running:
供参考,通过运行以下命令来实现完整重建:
$ make clean all
One of the most common questions asked by Buildroot users is how to
rebuild a given package or how to remove a package without rebuilding
everything from scratch.
Buildroot 用户经常问的一个最常见的问题是如何重新构建给定的软件包或如何在不从头开始重新构建的情况下删除软件包。
Removing a package is unsupported by Buildroot without
rebuilding from scratch. This is because Buildroot doesn’t keep track
of which package installs what files in the output/staging
and
output/target
directories, or which package would be compiled differently
depending on the availability of another package.
在不从头开始重新构建的情况下,Buildroot 不支持删除软件包。这是因为 Buildroot 不跟踪哪个软件包在 output/staging
和 output/target
目录中安装了哪些文件,或者哪个软件包的编译方式会因为另一个软件包的可用性而有所不同。
The easiest way to rebuild a single package from scratch is to remove
its build directory in output/build
. Buildroot will then re-extract,
re-configure, re-compile and re-install this package from scratch. You
can ask buildroot to do this with the make <package>-dirclean
command.
从头开始重新构建单个软件包的最简单方法是删除其在 output/build
中的构建目录。然后 Buildroot 将重新提取、重新配置、重新编译和重新安装此软件包。您可以使用 make <package>-dirclean
命令要求 buildroot 这样做。
On the other hand, if you only want to restart the build process of a
package from its compilation step, you can run make <package>-rebuild
. It
will restart the compilation and installation of the package, but not from
scratch: it basically re-executes make
and make install
inside the package,
so it will only rebuild files that changed.
另一方面,如果您只想从编译步骤重新启动软件包的构建过程,可以运行 make <package>-rebuild
。它将重新启动软件包的编译和安装过程,但不是从头开始:它基本上重新执行软件包内的 make
和 make install
,因此只会重新构建已更改的文件。
If you want to restart the build process of a package from its configuration
step, you can run make <package>-reconfigure
. It will restart the
configuration, compilation and installation of the package.
如果您想从配置步骤重新启动软件包的构建过程,可以运行 make <package>-reconfigure
。它将重新启动软件包的配置、编译和安装。
While <package>-rebuild
implies <package>-reinstall
and
<package>-reconfigure
implies <package>-rebuild
, these targets as well
as <package>
only act on the said package, and do not trigger re-creating
the root filesystem image. If re-creating the root filesystem in necessary,
one should in addition run make
or make all
.
虽然 <package>-rebuild
意味着 <package>-reinstall
, <package>-reconfigure
意味着 <package>-rebuild
,这些目标以及 <package>
仅对所述软件包起作用,并不会触发重新创建根文件系统映像。如果需要重新创建根文件系统,则还应运行 make
或 make all
。
Internally, Buildroot creates so-called stamp files to keep track of
which build steps have been completed for each package. They are
stored in the package build directory,
output/build/<package>-<version>/
and are named
.stamp_<step-name>
. The commands detailed above simply manipulate
these stamp files to force Buildroot to restart a specific set of
steps of a package build process.
在内部,Buildroot 创建所谓的戳记文件,以跟踪每个软件包的构建步骤已完成的情况。它们存储在软件包构建目录中, output/build/<package>-<version>/
,并命名为 .stamp_<step-name>
。上面详细介绍的命令只是简单地操作这些戳记文件,以强制 Buildroot 重新启动软件包构建过程的特定步骤。
Further details about package special make targets are explained in
Section 8.13.5, “Package-specific make targets”.
有关软件包特殊的 make 目标的更多细节,请参阅第 8.13.5 节,“软件包特定的 make 目标”。
If you intend to do an offline build and just want to download
all sources that you previously selected in the configurator
(menuconfig, nconfig, xconfig or gconfig), then issue:
如果您打算进行离线构建,并且只想下载您先前在配置器(menuconfig、nconfig、xconfig 或 gconfig)中选择的所有源代码,请执行以下操作:
$ make source
You can now disconnect or copy the content of your dl
directory to the build-host.
您现在可以断开连接或复制您的 dl
目录内容到构建主机。
As default, everything built by Buildroot is stored in the directory
output
in the Buildroot tree.
默认情况下,Buildroot 构建的所有内容都存储在 Buildroot 树中的目录 output
中。
Buildroot also supports building out of tree with a syntax similar to
the Linux kernel. To use it, add O=<directory>
to the make command
line:
Buildroot 还支持类似于 Linux 内核的外部构建。要使用它,请将 O=<directory>
添加到 make 命令行中:
$ make O=/tmp/build menuconfig
Or:
$ cd /tmp/build; make O=$PWD -C path/to/buildroot menuconfig
All the output files will be located under /tmp/build
. If the O
path does not exist, Buildroot will create it.
所有输出文件将位于 /tmp/build
下。如果 O
路径不存在,Buildroot 将创建它。
Note: the O
path can be either an absolute or a relative path, but if it’s
passed as a relative path, it is important to note that it is interpreted
relative to the main Buildroot source directory, not the current working
directory.
注意: O
路径可以是绝对路径,也可以是相对路径,但如果作为相对路径传递,重要的是要注意,它是相对于主 Buildroot 源目录解释的,而不是当前工作目录。
When using out-of-tree builds, the Buildroot .config
and temporary
files are also stored in the output directory. This means that you can
safely run multiple builds in parallel using the same source tree as
long as they use unique output directories.
在使用 out-of-tree 构建时,Buildroot 的 .config
和临时文件也存储在输出目录中。这意味着只要它们使用唯一的输出目录,您可以安全地并行运行多个构建,使用相同的源树。
For ease of use, Buildroot generates a Makefile wrapper in the output
directory - so after the first run, you no longer need to pass O=<…>
and -C <…>
, simply run (in the output directory):
为了方便使用,Buildroot 在输出目录中生成一个 Makefile 包装器 - 因此在第一次运行后,您不再需要传递 O=<…>
和 -C <…>
,只需在(输出目录中)运行:
$ make <target>
Buildroot also honors some environment variables, when they are passed
to make
or set in the environment:
当传递给 make
或在环境中设置时,Buildroot 也会尊重一些环境变量:
HOSTCXX
, the host C++ compiler to use
HOSTCXX
,要使用的主机 C++ 编译器HOSTCC
, the host C compiler to use
HOSTCC
,要使用的主机 C 编译器UCLIBC_CONFIG_FILE=<path/to/.config>
, path to
the uClibc configuration file, used to compile uClibc, if an
internal toolchain is being built.
Note that the uClibc configuration file can also be set from the
configuration interface, so through the Buildroot .config
file; this
is the recommended way of setting it.
UCLIBC_CONFIG_FILE=<path/to/.config>
,用于编译 uClibc 的 uClibc 配置文件的路径,如果正在构建内部工具链。请注意,也可以从配置界面设置 uClibc 配置文件,因此通过 Buildroot .config
文件;这是建议的设置方式。BUSYBOX_CONFIG_FILE=<path/to/.config>
, path to
the BusyBox configuration file.
Note that the BusyBox configuration file can also be set from the
configuration interface, so through the Buildroot .config
file; this
is the recommended way of setting it.
BUSYBOX_CONFIG_FILE=<path/to/.config>
,BusyBox 配置文件的路径。请注意,也可以从配置界面设置 BusyBox 配置文件,因此通过 Buildroot .config
文件;这是建议的设置方式。BR2_CCACHE_DIR
to override the directory where
Buildroot stores the cached files when using ccache.
BR2_CCACHE_DIR
用于覆盖 Buildroot 在使用 ccache 时存储缓存文件的目录。BR2_DL_DIR
to override the directory in which
Buildroot stores/retrieves downloaded files.
Note that the Buildroot download directory can also be set from the
configuration interface, so through the Buildroot .config
file. See
Section 8.13.4, “Location of downloaded packages” for more details on how you can set the download
directory.
BR2_DL_DIR
用于覆盖 Buildroot 存储/检索下载文件的目录。请注意,Buildroot 下载目录也可以从配置界面设置,或通过 Buildroot .config
文件设置。有关如何设置下载目录的更多详细信息,请参阅第 8.13.4 节“下载软件包的位置”。BR2_GRAPH_ALT
, if set and non-empty, to use an alternate color-scheme in
build-time graphs
BR2_GRAPH_ALT
,如果设置且非空,则在构建时图表中使用替代配色方案。BR2_GRAPH_OUT
to set the filetype of generated graphs, either pdf
(the
default), or png
.
BR2_GRAPH_OUT
设置生成图形的文件类型,可以是 pdf
(默认值),也可以是 png
。BR2_GRAPH_DEPS_OPTS
to pass extra options to the dependency graph; see
Section 8.9, “Graphing the dependencies between packages” for the accepted options
BR2_GRAPH_DEPS_OPTS
传递额外选项给依赖图;请参阅第 8.9 节“绘制软件包之间的依赖关系图”以查看可接受的选项。BR2_GRAPH_DOT_OPTS
is passed verbatim as options to the dot
utility to
draw the dependency graph.
BR2_GRAPH_DOT_OPTS
按原样传递给 dot
实用程序作为绘制依赖图的选项。BR2_GRAPH_SIZE_OPTS
to pass extra options to the size graph; see
Section 8.11, “Graphing the filesystem size contribution of packages” for the acepted options
BR2_GRAPH_SIZE_OPTS
传递额外选项给大小图表;请参阅第 8.11 节,“图表化软件包的文件系统大小贡献”以获取接受的选项An example that uses config files located in the toplevel directory and
in your $HOME:
一个示例,使用位于顶层目录和您的 $HOME 中的配置文件:
$ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
If you want to use a compiler other than the default gcc
or g
++ for building helper-binaries on your host, then do
如果您想在主机上构建辅助二进制文件时使用除默认的 gcc
或 g
++ 之外的编译器,则执行
$ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
Filesystem images can get pretty big, depending on the filesystem you choose,
the number of packages, whether you provisioned free space… Yet, some
locations in the filesystems images may just be empty (e.g. a long run of
zeroes); such a file is called a sparse file.
文件系统映像可能会变得非常庞大,这取决于您选择的文件系统、软件包的数量、是否预留了空闲空间等因素... 然而,在文件系统映像中的某些位置可能是空的(例如,一长串零);这样的文件称为稀疏文件。
Most tools can handle sparse files efficiently, and will only store or write
those parts of a sparse file that are not empty.
大多数工具可以高效处理稀疏文件,并且只会存储或写入那些不为空的稀疏文件部分。
For example: 例如:
tar
accepts the -S
option to tell it to only store non-zero blocks
of sparse files:
tar
接受 -S
选项,告诉它仅存储稀疏文件的非零块:
tar cf archive.tar -S [files…]
will efficiently store sparse files
in a tarball
tar cf archive.tar -S [files…]
将有效地存储 tarball 中的稀疏文件tar xf archive.tar -S
will efficiently store sparse files extracted
from a tarball
tar xf archive.tar -S
将有效地存储从 tarball 中提取的稀疏文件
cp
accepts the --sparse=WHEN
option (WHEN
is one of auto
,
never
or always
):
cp
接受 --sparse=WHEN
选项 ( WHEN
是 auto
, never
或 always
之一) :
cp --sparse=always source.file dest.file
will make dest.file
a
sparse file if source.file
has long runs of zeroes
source.file
有长时间的零运行, cp --sparse=always source.file dest.file
将使 dest.file
成为稀疏文件Other tools may have similar options. Please consult their respective man
pages.
其他工具可能具有类似的选项。请参阅各自的 man 手册。
You can use sparse files if you need to store the filesystem images (e.g.
to transfer from one machine to another), or if you need to send them (e.g.
to the Q&A team).
如果您需要存储文件系统映像(例如,从一台机器传输到另一台机器),或者需要发送它们(例如,发送给问答团队),则可以使用稀疏文件。
Note however that flashing a filesystem image to a device while using the
sparse mode of dd
may result in a broken filesystem (e.g. the block bitmap
of an ext2 filesystem may be corrupted; or, if you have sparse files in
your filesystem, those parts may not be all-zeroes when read back). You
should only use sparse files when handling files on the build machine, not
when transferring them to an actual device that will be used on the target.
请注意,当使用 dd
的稀疏模式将文件系统映像刷写到设备时,可能会导致文件系统损坏(例如,ext2
文件系统的块位图可能会损坏;或者,如果文件系统中有稀疏文件,则在读取时这些部分可能不全为零)。只有在处理构建机器上的文件时才应使用稀疏文件,而不
是在将它们传输到将在目标设备上使用的实际设备时。
Buildroot can produce a JSON blurb that describes the set of enabled
packages in the current configuration, together with their
dependencies, licenses and other metadata. This JSON blurb is produced
by using the show-info
make target:
Buildroot 可以生成一个 JSON 摘要,描述当前配置中启用的软件包集合,以及它们的依赖关系、许可证和其他元数据。通过使用 show-info
make 目标生成此 JSON 摘要:
make show-info
Buildroot can also produce details about packages as HTML and JSON
output using the pkg-stats
make target. Amongst other things, these
details include whether known CVEs (security vulnerabilities) affect
the packages in your current configuration. It also shows if there is
a newer upstream version for those packages.
Buildroot 还可以使用 pkg-stats
make 目标生成有关软件包的 HTML 和 JSON 输出的详细信息。除其他事项外,这些详细信息还包括已知 CVE(安全漏洞)是否影响当前配置中的软件包。它还显示这些软件包是否有更新的上游版本。
make pkg-stats
One of Buildroot’s jobs is to know the dependencies between packages,
and make sure they are built in the right order. These dependencies
can sometimes be quite complicated, and for a given system, it is
often not easy to understand why such or such package was brought into
the build by Buildroot.
Buildroot 的工作之一是了解软件包之间的依赖关系,并确保它们按正确顺序构建。这些依赖关系有时可能相当复杂,对于给定的系统,通常不容易理解为什么 Buildroot 会将某个软件包引入构建过程中。
In order to help understanding the dependencies, and therefore better
understand what is the role of the different components in your
embedded Linux system, Buildroot is capable of generating dependency
graphs.
为了帮助理解依赖关系,从而更好地了解嵌入式 Linux 系统中不同组件的作用,Buildroot 能够生成依赖图。
To generate a dependency graph of the full system you have compiled,
simply run:
要生成您编译的完整系统的依赖图,只需运行:
make graph-depends
You will find the generated graph in
output/graphs/graph-depends.pdf
.
你将在 output/graphs/graph-depends.pdf
中找到生成的图形。
If your system is quite large, the dependency graph may be too complex
and difficult to read. It is therefore possible to generate the
dependency graph just for a given package:
如果您的系统非常庞大,则依赖图可能过于复杂且难以阅读。因此,可以仅为给定的软件包生成依赖图:
make <pkg>-graph-depends
You will find the generated graph in
output/graph/<pkg>-graph-depends.pdf
.
你将在 output/graph/<pkg>-graph-depends.pdf
中找到生成的图形。
Note that the dependency graphs are generated using the dot
tool
from the Graphviz project, which you must have installed on your
system to use this feature. In most distributions, it is available as
the graphviz
package.
请注意,依赖图是使用 Graphviz 项目中的 dot
工具生成的,您必须在系统上安装此工具才能使用此功能。在大多数发行版中,它作为 graphviz
软件包提供。
By default, the dependency graphs are generated in the PDF
format. However, by passing the BR2_GRAPH_OUT
environment variable, you
can switch to other output formats, such as PNG, PostScript or
SVG. All formats supported by the -T
option of the dot
tool are
supported.
默认情况下,依赖图以 PDF 格式生成。但是,通过传递 BR2_GRAPH_OUT
环境变量,您可以切换到其他输出格式,如 PNG、PostScript 或 SVG。所有 dot
工具的 -T
选项支持的格式都受支持。
BR2_GRAPH_OUT=svg make graph-depends
The graph-depends
behaviour can be controlled by setting options in the
BR2_GRAPH_DEPS_OPTS
environment variable. The accepted options are:
graph-depends
的行为可以通过在 BR2_GRAPH_DEPS_OPTS
环境变量中设置选项来控制。接受的选项包括:
--depth N
, -d N
, to limit the dependency depth to N
levels. The
default, 0
, means no limit.
--depth N
, -d N
,将依赖深度限制为 N
级。默认值 0
表示无限制。--stop-on PKG
, -s PKG
, to stop the graph on the package PKG
.
PKG
can be an actual package name, a glob, the keyword virtual
(to stop on virtual packages), or the keyword host (to stop on
host packages). The package is still present on the graph, but its
dependencies are not.
--stop-on PKG
, -s PKG
,停止图形在包 PKG
上。 PKG
可以是实际包名称、通配符、关键字 virtual(停在虚拟包上)或关键字 host(停在主机包上)。包仍然存在于图中,但其依赖关系不在图中。--exclude PKG
, -x PKG
, like --stop-on
, but also omits PKG
from
the graph.
--exclude PKG
, -x PKG
,类似于 --stop-on
,但也从图中省略 PKG
。--transitive
, --no-transitive
, to draw (or not) the transitive
dependencies. The default is to not draw transitive dependencies.
--transitive
, --no-transitive
,绘制(或不绘制)传递依赖项。默认情况下不绘制传递依赖项。--colors R,T,H
, the comma-separated list of colors to draw the
root package (R
), the target packages (T
) and the host packages
(H
). Defaults to: lightblue,grey,gainsboro
--colors R,T,H
,逗号分隔的颜色列表,用于绘制根包( R
),目标包( T
)和主机包( H
)。默认为: lightblue,grey,gainsboro
BR2_GRAPH_DEPS_OPTS='-d 3 --no-transitive --colors=red,green,blue' make graph-depends
When the build of a system takes a long time, it is sometimes useful
to be able to understand which packages are the longest to build, to
see if anything can be done to speed up the build. In order to help
such build time analysis, Buildroot collects the build time of each
step of each package, and allows to generate graphs from this data.
当系统构建时间较长时,有时了解构建时间最长的软件包是很有用的,以查看是否可以采取措施加快构建速度。为了帮助进行构建时间分析,Buildroot 收集每个软件包每个步骤的构建时间,并允许从这些数据生成图表。
To generate the build time graph after a build, run:
要在构建后生成构建时间图表,请运行:
make graph-build
This will generate a set of files in output/graphs
:
这将在 output/graphs
中生成一组文件:
build.hist-build.pdf
, a histogram of the build time for each
package, ordered in the build order.
build.hist-build.pdf
,每个软件包构建时间的直方图,按构建顺序排序。build.hist-duration.pdf
, a histogram of the build time for each
package, ordered by duration (longest first)
build.hist-duration.pdf
,每个软件包构建时间的直方图,按持续时间排序(最长的在前)。build.hist-name.pdf
, a histogram of the build time for each
package, order by package name.
build.hist-name.pdf
,每个软件包构建时间的直方图,按软件包名称排序。build.pie-packages.pdf
, a pie chart of the build time per package
build.pie-packages.pdf
,每个软件包构建时间的饼图build.pie-steps.pdf
, a pie chart of the global time spent in each
step of the packages build process.
build.pie-steps.pdf
,显示软件包构建过程中每个步骤中全局耗时的饼图This graph-build
target requires the Python Matplotlib and Numpy
libraries to be installed (python-matplotlib
and python-numpy
on
most distributions), and also the argparse
module if you’re using a
Python version older than 2.7 (python-argparse
on most
distributions).
此 graph-build
目标需要安装 Python Matplotlib 和 Numpy 库(在大多数发行版上为 python-matplotlib
和 python-numpy
),如果您使用的是早于 2.7 版本的 Python,则还需要 argparse
模块(在大多数发行版上为 python-argparse
)。
By default, the output format for the graph is PDF, but a different
format can be selected using the BR2_GRAPH_OUT
environment variable. The
only other format supported is PNG:
默认情况下,图形的输出格式为 PDF,但可以使用 BR2_GRAPH_OUT
环境变量选择不同的格式。唯一支持的其他格式是 PNG:
BR2_GRAPH_OUT=png make graph-build
When your target system grows, it is sometimes useful to understand
how much each Buildroot package is contributing to the overall root
filesystem size. To help with such an analysis, Buildroot collects
data about files installed by each package and using this data,
generates a graph and CSV files detailing the size contribution of
the different packages.
当目标系统增长时,了解每个 Buildroot 软件包对整体根文件系统大小的贡献是有用的。为了帮助进行这种分析,Buildroot 收集有关每个软件包安装的文件的数据,并使用这些数据生成关于不同软件包大小贡献的图形和 CSV 文件。
To generate these data after a build, run:
在构建后生成这些数据,请运行:
make graph-size
This will generate: 这将生成:
output/graphs/graph-size.pdf
, a pie chart of the contribution of
each package to the overall root filesystem size
output/graphs/graph-size.pdf
,显示每个软件包对总根文件系统大小的贡献的饼图output/graphs/package-size-stats.csv
, a CSV file giving the size
contribution of each package to the overall root filesystem size
output/graphs/package-size-stats.csv
,一个 CSV 文件,显示每个软件包对整体根文件系统大小的大小贡献output/graphs/file-size-stats.csv
, a CSV file giving the size
contribution of each installed file to the package it belongs, and
to the overall filesystem size.
output/graphs/file-size-stats.csv
,一个 CSV 文件,显示每个已安装文件对其所属软件包以及整体文件系统大小的大小贡献This graph-size
target requires the Python Matplotlib library to be
installed (python-matplotlib
on most distributions), and also the
argparse
module if you’re using a Python version older than 2.7
(python-argparse
on most distributions).
此 graph-size
目标需要安装 Python Matplotlib 库(在大多数发行版上为 python-matplotlib
),如果您使用的是早于 2.7 版本的 Python,则还需要安装 argparse
模块(在大多数发行版上为 python-argparse
)。
Just like for the duration graph, a BR2_GRAPH_OUT
environment variable
is supported to adjust the output file format. See Section 8.9, “Graphing the dependencies between packages”
for details about this environment variable.
就像持续图一样,支持一个 BR2_GRAPH_OUT
环境变量来调整输出文件格式。有关此环境变量的详细信息,请参见第 8.9 节“绘制软件包之间的依赖关系”。
Additionally, one may set the environment variable BR2_GRAPH_SIZE_OPTS
to further control the generated graph. Accepted options are:
另外,可以设置环境变量 BR2_GRAPH_SIZE_OPTS
来进一步控制生成的图。接受的选项包括:
--size-limit X
, -l X
, will group all packages which individual
contribution is below X
percent, to a single entry labelled Others
in the graph. By default, X=0.01
, which means packages each
contributing less than 1% are grouped under Others. Accepted values
are in the range [0.0..1.0]
.
--size-limit X
, -l X
,将所有个别贡献低于 X
%的软件包分组到一个名为“其他”的条目中。默认情况下, X=0.01
,这意味着每个贡献少于 1%的软件包都分组在其他下。接受的值范围为 [0.0..1.0]
。--iec
, --binary
, --si
, --decimal
, to use IEC (binary, powers
of 1024) or SI (decimal, powers of 1000; the default) prefixes.
--iec
, --binary
, --si
, --decimal
,使用 IEC(二进制,1024 的幂)或 SI(十进制,1000 的幂;默认)前缀。--biggest-first
, to sort packages in decreasing size order, rather
than in increasing size order.
--biggest-first
,按照大小递减的顺序对软件包进行排序,而不是按照大小递增的顺序。Note. The collected filesystem size data is only meaningful after a complete
clean rebuild. Be sure to run make clean all
before using make
graph-size
.
注意。只有在完全清理重建之后,收集的文件系统大小数据才有意义。确保在使用 make
graph-size
之前运行 make clean all
。
To compare the root filesystem size of two different Buildroot compilations,
for example after adjusting the configuration or when switching to another
Buildroot release, use the size-stats-compare
script. It takes two
file-size-stats.csv
files (produced by make graph-size
) as input.
Refer to the help text of this script for more details:
要比较两个不同 Buildroot 编译的根文件系统大小,例如在调整配置或切换到另一个 Buildroot 版本后,请使用 size-stats-compare
脚本。它以两个 file-size-stats.csv
文件(由 make graph-size
生成)作为输入。有关更多详细信息,请参考此脚本的帮助文本:
utils/size-stats-compare -h
Note. This section deals with a very experimental feature, which is known to
break even in some non-unusual situations. Use at your own risk.
注意。本部分涉及一个非常实验性的功能,即使在一些非常规情况下也可能出现故障。请自行承担风险。
Buildroot has always been capable of using parallel build on a per
package basis: each package is built by Buildroot using make -jN
(or
the equivalent invocation for non-make-based build systems). The level
of parallelism is by default number of CPUs + 1, but it can be
adjusted using the BR2_JLEVEL
configuration option.
Buildroot 一直能够在每个软件包基础上使用并行构建:每个软件包由 Buildroot 使用 make -jN
(或者对于非基于 make 的构建系统的等效调用)构建。并行度默认为 CPU 数量+1,但可以使用 BR2_JLEVEL
配置选项进行调整。
Until 2020.02, Buildroot was however building packages in a serial
fashion: each package was built one after the other, without
parallelization of the build between packages. As of 2020.02,
Buildroot has experimental support for top-level parallel build,
which allows some signicant build time savings by building packages
that have no dependency relationship in parallel. This feature is
however marked as experimental and is known not to work in some cases.
直
到 2020.02,Buildroot 仍然以串行方式构建软件包:每个软件包都是一个接一个地构建的,软件包之间没有构建并行化。从 2020.02
开始,Buildroot
具有顶层并行构建的实验性支持,允许在没有依赖关系的软件包之间并行构建,从而节省构建时间。但是,该功能被标记为实验性,并且已知在某些情况下无法正常
工作。
In order to use top-level parallel build, one must:
要使用顶层并行构建,必须:
BR2_PER_PACKAGE_DIRECTORIES
in the Buildroot
configuration
BR2_PER_PACKAGE_DIRECTORIES
make -jN
when starting the Buildroot build
make -jN
Internally, the BR2_PER_PACKAGE_DIRECTORIES
will enable a mechanism
called per-package directories, which will have the following
effects:
在内部, BR2_PER_PACKAGE_DIRECTORIES
将启用一个名为每包目录的机制,其将产生以下效果:
$(O)/per-package/<pkg>/target/
and
$(O)/per-package/<pkg>/host/
respectively. Those folders will be
populated from the corresponding folders of the package dependencies
at the beginning of <pkg>
build. The compiler and all other tools
will therefore only be able to see and access files installed by
dependencies explicitly listed by <pkg>
.
$(O)/per-package/<pkg>/target/
和 $(O)/per-package/<pkg>/host/
中分别使用。这些文件夹将在 <pkg>
构建开始时从软件包依赖项的相应文件夹中填充。因此,编译器和所有其他工具只能看到和访问由 <pkg>
明确列出的依赖项安装的文件。$(O)/target
and $(O)/host
respectively. This means that during the build, those folders will
be empty and it’s only at the very end of the build that they will
be populated.
$(O)/target
和 $(O)/host
中。这意味着在构建过程中,这些文件夹将是空的,只有在构建的最后阶段它们才会被填充。You may want to compile, for your target, your own programs or other
software that are not packaged in Buildroot. In order to do this you
can use the toolchain that was generated by Buildroot.
您可能希望为您的目标编译自己的程序或其他未打包在 Buildroot 中的软件。为了做到这一点,您可以使用 Buildroot 生成的工具链。
The toolchain generated by Buildroot is located by default in
output/host/
. The simplest way to use it is to add
output/host/bin/
to your PATH environment variable and then to
use ARCH-linux-gcc
, ARCH-linux-objdump
, ARCH-linux-ld
, etc.
Buildroot 生成的工具链默认位于 output/host/
。使用它的最简单方法是将 output/host/bin/
添加到您的 PATH 环境变量,然后使用 ARCH-linux-gcc
, ARCH-linux-objdump
, ARCH-linux-ld
等。
Alternatively, Buildroot can also export the toolchain and the development
files of all selected packages, as an SDK, by running the command
make sdk
. This generates a tarball of the content of the host directory
output/host/
, named <TARGET-TUPLE>_sdk-buildroot.tar.gz
(which can be
overriden by setting the environment variable BR2_SDK_PREFIX
) and
located in the output directory output/images/
.
或者,Buildroot 还可以通过运行命令 make sdk
将所选包的工具链和开发文件导出为 SDK。这将生成主机目录 output/host/
内容的 tarball,命名为 <TARGET-TUPLE>_sdk-buildroot.tar.gz
(可以通过设置环境变量 BR2_SDK_PREFIX
进行覆盖),并位于输出目录 output/images/
中。
This tarball can then be distributed to application developers, when
they want to develop their applications that are not (yet) packaged as
a Buildroot package.
然后可以将此 tarball 分发给应用程序开发人员,以便在他们想要开发尚未(尚未)打包为 Buildroot 软件包的应用程序时使用。
Upon extracting the SDK tarball, the user must run the script
relocate-sdk.sh
(located at the top directory of the SDK), to make
sure all paths are updated with the new location.
在提取 SDK tarball 后,用户必须运行位于 SDK 顶级目录的脚本 relocate-sdk.sh
,以确保所有路径都已更新为新位置。
Alternatively, if you just want to prepare the SDK without generating
the tarball (e.g. because you will just be moving the host
directory,
or will be generating the tarball on your own), Buildroot also allows
you to just prepare the SDK with make prepare-sdk
without actually
generating a tarball.
或者,如果您只想准备 SDK 而不生成 tarball(例如,因为您只会移动 host
目录,或者将自行生成 tarball),Buildroot 还允许您只使用 make prepare-sdk
准备 SDK 而不实际生成 tarball。
For your convenience, by selecting the option
BR2_PACKAGE_HOST_ENVIRONMENT_SETUP
, you can get a
environment-setup
script installed in output/host/
and therefore
in your SDK. This script can be sourced with
. your/sdk/path/environment-setup
to export a number of environment
variables that will help cross-compile your projects using the
Buildroot SDK: the PATH
will contain the SDK binaries, standard
autotools variables will be defined with the appropriate values, and
CONFIGURE_FLAGS
will contain basic ./configure
options to
cross-compile autotools projects. It also provides some useful
commands. Note however that once this script is sourced, the
environment is setup only for cross-compilation, and no longer for
native compilation.
为了您的方便,通过选择选项 BR2_PACKAGE_HOST_ENVIRONMENT_SETUP
,您可以在 output/host/
中安装一个 environment-setup
脚本,因此也在您的 SDK 中。 可以使用 . your/sdk/path/environment-setup
来源此脚本,以导出一些环境变量,这些变量将有助于使用 Buildroot SDK 交叉编译您的项目: PATH
将包含 SDK 二进制文件,标准 autotools 变量将定义为适当的值,并且 CONFIGURE_FLAGS
将包含用于交叉编译 autotools 项目的基本 ./configure
选项。 它还提供一些有用的命令。 但请注意,一旦源化此脚本,环境仅设置为交叉编译,不再适用于本地编译。
Buildroot allows to do cross-debugging, where the debugger runs on the
build machine and communicates with gdbserver
on the target to
control the execution of the program.
Buildroot 允许进行交叉调试,其中调试器在构建机器上运行,并与目标上的 gdbserver
通信以控制程序的执行。
To achieve this: 要实现这一点:
BR2_PACKAGE_HOST_GDB
, BR2_PACKAGE_GDB
and
BR2_PACKAGE_GDB_SERVER
. This ensures that both the cross gdb and
gdbserver get built, and that gdbserver gets installed to your target.
BR2_PACKAGE_HOST_GDB
, BR2_PACKAGE_GDB
和 BR2_PACKAGE_GDB_SERVER
。这样可以确保交叉 gdb 和 gdbserver 都被构建,并且 gdbserver 被安装到您的目标设备上。BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
, which will copy the
gdbserver included with the external toolchain to the target. If your
external toolchain does not have a cross gdb or gdbserver, it is also
possible to let Buildroot build them, by enabling the same options as
for the internal toolchain backend.
BR2_TOOLCHAIN_EXTERNAL_GDB_SERVER_COPY
,这将复制包含在外部工具链中的 gdbserver 到目标设备上。如果您的外部工具链没有交叉 gdb 或 gdbserver,也可以让 Buildroot 构建它们,方法是启用与内部工具链后端相同的选项。Now, to start debugging a program called foo
, you should run on the
target:
现在,要开始调试一个名为 foo
的程序,您应该在目标设备上运行:
gdbserver :2345 foo
This will cause gdbserver
to listen on TCP port 2345 for a connection
from the cross gdb.
这将导致 gdbserver
监听 TCP 端口 2345,以便从跨 gdb 接收连接。
Then, on the host, you should start the cross gdb using the following
command line:
然后,在主机上,您应该使用以下命令行启动跨 gdb:
<buildroot>/output/host/bin/<tuple>-gdb -ix <buildroot>/output/staging/usr/share/buildroot/gdbinit foo
Of course, foo
must be available in the current directory, built
with debugging symbols. Typically you start this command from the
directory where foo
is built (and not from output/target/
as the
binaries in that directory are stripped).
当然, foo
必须在当前目录中可用,并带有调试符号。通常,您从构建 foo
的目录启动此命令(而不是从 output/target/
启动,因为该目录中的二进制文件已经剥离了)。
The <buildroot>/output/staging/usr/share/buildroot/gdbinit
file will tell the
cross gdb where to find the libraries of the target.
<buildroot>/output/staging/usr/share/buildroot/gdbinit
文件将告诉交叉 gdb 在哪里找到目标的库。
Finally, to connect to the target from the cross gdb:
最后,从交叉 gdb 连接到目标:
(gdb) target remote <target ip address>:2345
ccache is a compiler cache. It stores the
object files resulting from each compilation process, and is able to
skip future compilation of the same source file (with same compiler
and same arguments) by using the pre-existing object files. When doing
almost identical builds from scratch a number of times, it can nicely
speed up the build process.
ccache 是一个编译器缓存。它存储每个编译过程产生的目标文件,并且能够通过使用预先存在的目标文件跳过对相同源文件(使用相同编译器和相同参数)的未来编译。当多次从头开始进行几乎相同的构建时,它可以很好地加快构建过程。
ccache
support is integrated in Buildroot. You just have to enable
Enable compiler cache
in Build options
. This will automatically
build ccache
and use it for every host and target compilation.
ccache
支持已集成在 Buildroot 中。您只需在 Build options
中启用 Enable compiler cache
。这将自动构建 ccache
并将其用于每个主机和目标编译。
The cache is located in the directory defined by the BR2_CCACHE_DIR
configuration option, which defaults to
$HOME/.buildroot-ccache
. This default location is outside of
Buildroot output directory so that it can be shared by separate
Buildroot builds. If you want to get rid of the cache, simply remove
this directory.
缓存位于由 BR2_CCACHE_DIR
配置选项定义的目录中,默认为 $HOME/.buildroot-ccache
。此默认位置位于 Buildroot 输出目录之外,以便可以被单独的 Buildroot 构建共享。如果要摆脱缓存,只需删除此目录。
You can get statistics on the cache (its size, number of hits,
misses, etc.) by running make ccache-stats
.
通过运行 make ccache-stats
,您可以获取有关缓存的统计信息(其大小、命中次数、未命中次数等)。
The make target ccache-options
and the CCACHE_OPTIONS
variable
provide more generic access to the ccache. For example
make 目标 ccache-options
和 CCACHE_OPTIONS
变量提供了对 ccache 的更通用访问。例如
# set cache limit size make CCACHE_OPTIONS="--max-size=5G" ccache-options # zero statistics counters make CCACHE_OPTIONS="--zero-stats" ccache-options
ccache
makes a hash of the source files and of the compiler options.
If a compiler option is different, the cached object file will not be
used. Many compiler options, however, contain an absolute path to the
staging directory. Because of this, building in a different output
directory would lead to many cache misses.
ccache
对源文件和编译器选项进行哈希处理。如果编译器选项不同,则不会使用缓存的对象文件。然而,许多编译器选项包含到暂存目录的绝对路径。因此,在不同的输出目录中构建将导致许多缓存未命中。
To avoid this issue, buildroot has the Use relative paths
option
(BR2_CCACHE_USE_BASEDIR
). This will rewrite all absolute paths that
point inside the output directory into relative paths. Thus, changing
the output directory no longer leads to cache misses.
为了避免这个问题,buildroot 有 Use relative paths
选项( BR2_CCACHE_USE_BASEDIR
)。这将把指向输出目录内部的所有绝对路径重写为相对路径。因此,更改输出目录不再导致缓存未命中。
A disadvantage of the relative paths is that they also end up to be
relative paths in the object file. Therefore, for example, the debugger
will no longer find the file, unless you cd to the output directory
first.
相对路径的一个缺点是它们最终也变成了目标文件中的相对路径。因此,例如,除非您首先 cd 到输出目录,否则调试器将不再找到文件。
See the
ccache manual’s section on "Compiling in different directories" for
more details about this rewriting of absolute paths.
有关绝对路径重写的更多详细信息,请参阅 ccache 手册中关于“在不同目录中编译”的部分。
When ccache
is enabled in Buildroot using the BR2_CCACHE=y
option:
当在 Buildroot 中使用 BR2_CCACHE=y
选项启用 ccache
时:
ccache
is used during the Buildroot build itself
ccache
ccache
is not used when building outside of Buildroot, for example
when directly calling the cross-compiler or using the SDK
ccache
,例如直接调用交叉编译器或使用 SDKOne can override this behavior using the BR2_USE_CCACHE
environment
variable: when set to 1
, usage of ccache is enabled (default during
the Buildroot build), when unset or set to a value different from 1
,
usage of ccache is disabled.
可以使用 BR2_USE_CCACHE
环境变量覆盖此行为:当设置为 1
时,启用 ccache 的使用(在 Buildroot 构建期间默认),当未设置或设置为与 1
不同的值时,禁用 ccache 的使用。
The various tarballs that are downloaded by Buildroot are all stored
in BR2_DL_DIR
, which by default is the dl
directory. If you want
to keep a complete version of Buildroot which is known to be working
with the associated tarballs, you can make a copy of this directory.
This will allow you to regenerate the toolchain and the target
filesystem with exactly the same versions.
Buildroot 下载的各种 tarball 都存储在 BR2_DL_DIR
中,默认情况下是 dl
目录。如果您想保留一个已知与相关 tarball 一起工作的完整版本的 Buildroot 副本,可以复制此目录。这将允许您使用完全相同的版本重新生成工具链和目标文件系统。
If you maintain several Buildroot trees, it might be better to have a
shared download location. This can be achieved by pointing the
BR2_DL_DIR
environment variable to a directory. If this is
set, then the value of BR2_DL_DIR
in the Buildroot configuration is
overridden. The following line should be added to <~/.bashrc>
.
如果您维护多个 Buildroot 树,则最好有一个共享的下载位置。这可以通过将 BR2_DL_DIR
环境变量指向一个目录来实现。如果设置了这个变量,则 Buildroot 配置中的 BR2_DL_DIR
的值将被覆盖。应添加以下行到 <~/.bashrc>
。
export BR2_DL_DIR=<shared download location>
The download location can also be set in the .config
file, with the
BR2_DL_DIR
option. Unlike most options in the .config file, this value
is overridden by the BR2_DL_DIR
environment variable.
下载位置也可以在 .config
文件中使用 BR2_DL_DIR
选项进行设置。与.config 文件中的大多数选项不同,这个值会被 BR2_DL_DIR
环境变量覆盖。
Running make <package>
builds and installs that particular package
and its dependencies.
运行 make <package>
构建并安装该特定软件包及其依赖项。
For packages relying on the Buildroot infrastructure, there are
numerous special make targets that can be called independently like
this:
对于依赖于 Buildroot 基础设施的软件包,有许多特殊的 make 目标可以像这样独立调用:
make <package>-<target>
The package build targets are (in the order they are executed):
软件包构建目标为(按执行顺序排列):
command/target 命令/目标 | Description |
---|---|
| Fetch the source (download the tarball, clone
the source repository, etc) |
| Build and install all dependencies required to
build the package |
| Put the source in the package build directory
(extract the tarball, copy the source, etc) |
| Apply the patches, if any |
| Run the configure commands, if any |
| Run the compilation commands |
| target package: Run the installation of the package in the
staging directory, if necessary |
| target package: Run the installation of the package in the
target directory, if necessary |
| target package: Run the 2 previous installation commands host package: Run the installation of the package in the host
directory |
Additionally, there are some other useful make targets:
另外,还有一些其他有用的 make 目标:
command/target 命令/目标 | Description |
---|---|
| Displays the first-order dependencies required to build the
package |
| Recursively displays the dependencies
required to build the package |
| Displays the first-order reverse dependencies of
the package (i.e packages that directly depend on it) |
| Recursively displays the reverse
dependencies of the package (i.e the packages that depend on it,
directly or indirectly) |
| Generate a dependency graph of the package, in the
context of the current Buildroot configuration. See
this section for more details about dependency
graphs. |
| Generate a graph of this package reverse
dependencies (i.e the packages that depend on it, directly or
indirectly) |
| Remove the whole package build directory |
| Re-run the install commands |
| Re-run the compilation commands - this only makes
sense when using the |
| Re-run the configure commands, then rebuild - this only
makes sense when using the |
The normal operation of Buildroot is to download a tarball, extract
it, configure, compile and install the software component found inside
this tarball. The source code is extracted in
output/build/<package>-<version>
, which is a temporary directory:
whenever make clean
is used, this directory is entirely removed, and
re-created at the next make
invocation. Even when a Git or
Subversion repository is used as the input for the package source
code, Buildroot creates a tarball out of it, and then behaves as it
normally does with tarballs.
Buildroot 的正常操作是下载一个 tarball,解压缩,配置,编译和安装该 tarball 中找到的软件组件。源代码被提取到 output/build/<package>-<version>
中,这是一个临时目录:每当使用 make clean
时,该目录将被完全删除,并在下一次 make
调用时重新创建。即使使用 Git 或 Subversion 存储库作为软件包源代码的输入,Buildroot 也会从中创建一个 tarball,然后像处理 tarball 一样处理。
This behavior is well-suited when Buildroot is used mainly as an
integration tool, to build and integrate all the components of an
embedded Linux system. However, if one uses Buildroot during the
development of certain components of the system, this behavior is not
very convenient: one would instead like to make a small change to the
source code of one package, and be able to quickly rebuild the system
with Buildroot.
当
Buildroot 主要用作集成工具,用于构建和集成嵌入式 Linux
系统的所有组件时,这种行为非常合适。然而,如果在系统的某些组件开发过程中使用
Buildroot,则这种行为并不是很方便:人们更希望对一个软件包的源代码进行小改动,并能够快速使用 Buildroot 重新构建系统。
Making changes directly in output/build/<package>-<version>
is not
an appropriate solution, because this directory is removed on make
clean
.
直接在 output/build/<package>-<version>
中进行更改并不是一个合适的解决方案,因为该目录会在 make
clean
时被删除。
Therefore, Buildroot provides a specific mechanism for this use case:
the <pkg>_OVERRIDE_SRCDIR
mechanism. Buildroot reads an override
file, which allows the user to tell Buildroot the location of the
source for certain packages.
因此,Buildroot 为此使用案例提供了一个特定的机制: <pkg>_OVERRIDE_SRCDIR
机制。Buildroot 读取一个覆盖文件,允许用户告诉 Buildroot 某些软件包的源位置。
The default location of the override file is $(CONFIG_DIR)/local.mk
,
as defined by the BR2_PACKAGE_OVERRIDE_FILE
configuration option.
$(CONFIG_DIR)
is the location of the Buildroot .config
file, so
local.mk
by default lives side-by-side with the .config
file,
which means:
覆盖文件的默认位置是 $(CONFIG_DIR)/local.mk
,由 BR2_PACKAGE_OVERRIDE_FILE
配置选项定义。 $(CONFIG_DIR)
是 Buildroot .config
文件的位置,因此 local.mk
默认情况下与 .config
文件并排,这意味着:
O=
is not used)
O=
时)O=
is used)
O=
时)If a different location than these defaults is required, it can be
specified through the BR2_PACKAGE_OVERRIDE_FILE
configuration
option.
如果需要不同于这些默认值的位置,则可以通过 BR2_PACKAGE_OVERRIDE_FILE
配置选项指定。
In this override file, Buildroot expects to find lines of the form:
在此覆盖文件中,Buildroot 期望找到以下形式的行:
<pkg1>_OVERRIDE_SRCDIR = /path/to/pkg1/sources <pkg2>_OVERRIDE_SRCDIR = /path/to/pkg2/sources
For example: 例如:
LINUX_OVERRIDE_SRCDIR = /home/bob/linux/ BUSYBOX_OVERRIDE_SRCDIR = /home/bob/busybox/
When Buildroot finds that for a given package, an
<pkg>_OVERRIDE_SRCDIR
has been defined, it will no longer attempt to
download, extract and patch the package. Instead, it will directly use
the source code available in the specified directory and make clean
will not touch this directory. This allows to point Buildroot to your
own directories, that can be managed by Git, Subversion, or any other
version control system. To achieve this, Buildroot will use rsync to
copy the source code of the component from the specified
<pkg>_OVERRIDE_SRCDIR
to output/build/<package>-custom/
.
当 Buildroot 发现对于给定的软件包,已经定义了 <pkg>_OVERRIDE_SRCDIR
,它将不再尝试下载、提取和打补丁软件包。相反,它将直接使用指定目录中可用的源代码, make clean
将不会触及此目录。这允许将 Buildroot 指向您自己的目录,可以由 Git、Subversion 或任何其他版本控制系统管理。为了实现这一点,Buildroot 将使用 rsync 将组件的源代码从指定的 <pkg>_OVERRIDE_SRCDIR
复制到 output/build/<package>-custom/
。
This mechanism is best used in conjunction with the make
<pkg>-rebuild
and make <pkg>-reconfigure
targets. A make
<pkg>-rebuild all
sequence will rsync the source code from
<pkg>_OVERRIDE_SRCDIR
to output/build/<package>-custom
(thanks to
rsync, only the modified files are copied), and restart the build
process of just this package.
这种机制最好与 make
<pkg>-rebuild
和 make <pkg>-reconfigure
目标一起使用。 make
<pkg>-rebuild all
序列将使用 rsync 将源代码从 <pkg>_OVERRIDE_SRCDIR
复制到 output/build/<package>-custom
(由于 rsync,只复制修改过的文件),并重新启动仅此软件包的构建过程。
In the example of the linux
package above, the developer can then
make a source code change in /home/bob/linux
and then run:
在上面的 linux
包示例中,开发人员可以在 /home/bob/linux
中进行源代码更改,然后运行:
make linux-rebuild all
and in a matter of seconds gets the updated Linux kernel image in
output/images
. Similarly, a change can be made to the BusyBox source
code in /home/bob/busybox
, and after:
然后在几秒钟内在 output/images
中获得更新的 Linux 内核映像。类似地,可以对 BusyBox 源代码进行更改 /home/bob/busybox
,然后:
make busybox-rebuild all
the root filesystem image in output/images
contains the updated
BusyBox.
output/images
中的根文件系统映像包含更新的 BusyBox。
Source trees for big projects often contain hundreds or thousands of
files which are not needed for building, but will slow down the process
of copying the sources with rsync. Optionally, it is possible define
<pkg>_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS
to skip syncing certain files
from the source tree. For example, when working on the webkitgtk
package, the following will exclude the tests and in-tree builds from
a local WebKit source tree:
大型项目的源树通常包含数百甚至数千个文件,这些文件在构建时并不需要,但会减慢使用 rsync 复制源文件的过程。可以选择定义 <pkg>_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS
以跳过从源树同步某些文件。例如,在处理 webkitgtk
软件包时,以下内容将从本地 WebKit 源树中排除测试和内部构建:
WEBKITGTK_OVERRIDE_SRCDIR = /home/bob/WebKit WEBKITGTK_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = \ --exclude JSTests --exclude ManualTests --exclude PerformanceTests \ --exclude WebDriverTests --exclude WebKitBuild --exclude WebKitLibraries \ --exclude WebKit.xcworkspace --exclude Websites --exclude Examples
By default, Buildroot skips syncing of VCS artifacts (e.g., the .git and
.svn directories). Some packages prefer to have these VCS directories
available during build, for example for automatically determining a precise
commit reference for version information. To undo this built-in filtering at a
cost of a slower speed, add these directories back:
默认情况下,Buildroot 跳过同步 VCS 文件(例如 .git 和 .svn 目录)。一些软件包希望在构建过程中保留这些 VCS 目录,例如用于自动确定精确的提交引用以获取版本信息。要取消这种内置过滤,以换取较慢的速度,请将这些目录添加回来:
LINUX_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS = --include .git
Typical actions you may need to perform for a given project are:
您可能需要为特定项目执行的典型操作包括:
customizing the generated target filesystem
自定义生成的目标文件系统
BR2_ROOTFS_OVERLAY
)
BR2_ROOTFS_OVERLAY
)BR2_ROOTFS_POST_BUILD_SCRIPT
)
BR2_ROOTFS_POST_BUILD_SCRIPT
)BR2_ROOTFS_POST_BUILD_SCRIPT
)
BR2_ROOTFS_POST_BUILD_SCRIPT
)BR2_ROOTFS_DEVICE_TABLE
)
BR2_ROOTFS_DEVICE_TABLE
)BR2_ROOTFS_STATIC_DEVICE_TABLE
)
BR2_ROOTFS_STATIC_DEVICE_TABLE
)BR2_ROOTFS_USERS_TABLES
)
BR2_ROOTFS_USERS_TABLES
)BR2_ROOTFS_POST_IMAGE_SCRIPT
)
BR2_ROOTFS_POST_IMAGE_SCRIPT
)BR2_GLOBAL_PATCH_DIR
)
BR2_GLOBAL_PATCH_DIR
)An important note regarding such project-specific customizations:
please carefully consider which changes are indeed project-specific and
which changes are also useful to developers outside your project. The
Buildroot community highly recommends and encourages the upstreaming of
improvements, packages and board support to the official Buildroot
project. Of course, it is sometimes not possible or desirable to
upstream because the changes are highly specific or proprietary.
关于这些项目特定定制的重要说明:请仔细考虑哪些更改确实是项目特定的,哪些更改对项目外的开发人员也有用。Buildroot 社区强烈建议并鼓励将改进、软件包和板支持上游到官方 Buildroot 项目。当然,有时由于更改非常具体或专有,可能无法或不希望上游。
This chapter describes how to make such project-specific customizations
in Buildroot and how to store them in a way that you can build the same
image in a reproducible way, even after running make clean. By
following the recommended strategy, you can even use the same Buildroot
tree to build multiple distinct projects!
本
章描述了如何在 Buildroot 中进行这种项目特定的定制以及如何以一种方式存储它们,以便您可以以可重现的方式构建相同的映像,即使在运行
make clean 后也是如此。通过遵循建议的策略,您甚至可以使用相同的 Buildroot 树来构建多个不同的项目!
When customizing Buildroot for your project, you will be creating one or
more project-specific files that need to be stored somewhere. While most
of these files could be placed in any location as their path is to be
specified in the Buildroot configuration, the Buildroot developers
recommend a specific directory structure which is described in this
section.
当为您的项目定制 Buildroot 时,您将创建一个或多个需要存储在某处的特定项目文件。尽管这些文件中的大多数可以放置在任何位置,因为它们的路径需要在 Buildroot 配置中指定,但 Buildroot 开发人员建议使用本节中描述的特定目录结构。
Orthogonal to this directory structure, you can choose where you place
this structure itself: either inside the Buildroot tree, or outside of
it using a br2-external tree. Both options are valid, the choice is up
to you.
与此目录结构正交的是,您可以选择将此结构放置在何处:要么在 Buildroot 树内部,要么在外部使用 br2-external 树。这两个选项都是有效的,选择权在您手中。
+-- board/ | +-- <company>/ | +-- <boardname>/ | +-- linux.config | +-- busybox.config | +-- <other configuration files> | +-- post_build.sh | +-- post_image.sh | +-- rootfs_overlay/ | | +-- etc/ | | +-- <some files> | +-- patches/ | +-- foo/ | | +-- <some patches> | +-- libbar/ | +-- <some other patches> | +-- configs/ | +-- <boardname>_defconfig | +-- package/ | +-- <company>/ | +-- Config.in (if not using a br2-external tree) | +-- <company>.mk (if not using a br2-external tree) | +-- package1/ | | +-- Config.in | | +-- package1.mk | +-- package2/ | +-- Config.in | +-- package2.mk | +-- Config.in (if using a br2-external tree) +-- external.mk (if using a br2-external tree) +-- external.desc (if using a br2-external tree)
Details on the files shown above are given further in this chapter.
上面显示的文件的详细信息将在本章中进一步给出。
Note: if you choose to place this structure outside of the Buildroot
tree but in a br2-external tree, the <company> and possibly <boardname>
components may be superfluous and can be left out.
注意:如果您选择将此结构放在 Buildroot 树之外,而是放在一个 br2-external 树中,则<company>和可能的<boardname>组件可能是多余的,可以省略。
It is quite common for a user to have several related projects that partly
need the same customizations. Instead of duplicating these
customizations for each project, it is recommended to use a layered
customization approach, as explained in this section.
用户经常有几个相关项目,其中部分需要相同的定制。建议不要为每个项目重复这些定制,而是建议使用分层定制方法,如本节所述。
Almost all of the customization methods available in Buildroot, like
post-build scripts and root filesystem overlays, accept a
space-separated list of items. The specified items are always treated in
order, from left to right. By creating more than one such item, one for
the common customizations and another one for the really
project-specific customizations, you can avoid unnecessary duplication.
Each layer is typically embodied by a separate directory inside
board/<company>/
. Depending on your projects, you could even introduce
more than two layers.
在
Buildroot
中提供的几乎所有定制方法,如构建后脚本和根文件系统叠加层,都接受一个以空格分隔的项目列表。指定的项目总是按顺序处理,从左到右。通过创建一个以上的
这种项目,一个用于常见定制,另一个用于真正的项目特定定制,您可以避免不必要的重复。每个层通常由 board/<company>/
内的单独目录体现。根据您的项目,甚至可以引入两个以上的层。
An example directory structure for where a user has two customization
layers common and fooboard is:
用户有两个定制层 common 和 fooboard 的示例目录结构如下:
+-- board/ +-- <company>/ +-- common/ | +-- post_build.sh | +-- rootfs_overlay/ | | +-- ... | +-- patches/ | +-- ... | +-- fooboard/ +-- linux.config +-- busybox.config +-- <other configuration files> +-- post_build.sh +-- rootfs_overlay/ | +-- ... +-- patches/ +-- ...
For example, if the user has the BR2_GLOBAL_PATCH_DIR
configuration
option set as:
例如,如果用户将 BR2_GLOBAL_PATCH_DIR
配置选项设置为:
BR2_GLOBAL_PATCH_DIR="board/<company>/common/patches board/<company>/fooboard/patches"
then first the patches from the common layer would be applied,
followed by the patches from the fooboard layer.
然后首先应用来自公共层的补丁,然后应用来自 fooboard 层的补丁。
As already briefly mentioned in Section 9.1, “Recommended directory structure”, you can
place project-specific customizations in two locations:
正如在第 9.1 节“推荐的目录结构”中简要提到的那样,您可以将项目特定的定制内容放在两个位置:
One can tell Buildroot to use one or more br2-external trees by setting
the BR2_EXTERNAL
make variable set to the path(s) of the br2-external
tree(s) to use. It can be passed to any Buildroot make
invocation. It
is automatically saved in the hidden .br2-external.mk
file in the output
directory. Thanks to this, there is no need to pass BR2_EXTERNAL
at
every make
invocation. It can however be changed at any time by
passing a new value, and can be removed by passing an empty value.
可以通过将 BR2_EXTERNAL
make 变量设置为要使用的 br2-external 树的路径(路径)来告诉 Buildroot 使用一个或多个 br2-external 树。它可以传递给任何 Buildroot make
调用。它会自动保存在输出目录中的隐藏 .br2-external.mk
文件中。由于这一点,没有必要在每次 make
调用时传递 BR2_EXTERNAL
。但是,可以随时通过传递新值来更改它,并且可以通过传递空值来删除它。
Note. The path to a br2-external tree can be either absolute or relative.
If it is passed as a relative path, it is important to note that it is
interpreted relative to the main Buildroot source directory, not to
the Buildroot output directory.
注意。对于 br2-external 树的路径可以是绝对路径,也可以是相对路径。如果作为相对路径传递,重要的是要注意,它是相对于主 Buildroot 源目录解释的,而不是相对于 Buildroot 输出目录。
Note: If using an br2-external tree from before Buildroot 2016.11, you need to
convert it before you can use it with Buildroot 2016.11 onward. See
Section 27.2, “Migrating to 2016.11” for help on doing so.
注意:如果使用的是 Buildroot 2016.11 之前的 br2-external 树,您需要在将其用于 Buildroot 2016.11 及以后版本之前进行转换。请参阅第 27.2 节“迁移到 2016.11”以获取帮助。
Some examples: 一些示例:
buildroot/ $ make BR2_EXTERNAL=/path/to/foo menuconfig
From now on, definitions from the /path/to/foo
br2-external tree
will be used:
从现在开始,将使用 /path/to/foo
br2-external 树中的定义:
buildroot/ $ make buildroot/ $ make legal-info
We can switch to another br2-external tree at any time:
我们可以随时切换到另一个 br2-external 树:
buildroot/ $ make BR2_EXTERNAL=/where/we/have/bar xconfig
We can also use multiple br2-external trees:
我们还可以使用多个 br2-external 树:
buildroot/ $ make BR2_EXTERNAL=/path/to/foo:/where/we/have/bar menuconfig
Or disable the usage of any br2-external tree:
或者禁用任何 br2-external 树的使用:
buildroot/ $ make BR2_EXTERNAL= xconfig
A br2-external tree must contain at least those three files, described
in the following chapters:
一个 br2-external 树必须至少包含以下章节中描述的这三个文件:
external.desc
external.mk
Config.in
Apart from those mandatory files, there may be additional and optional
content that may be present in a br2-external tree, like the configs/
or provides/
directories. They are described in the following chapters
as well.
除了那些强制性文件外,br2-external 树中可能还存在其他可选内容,例如 configs/
或 provides/
目录。它们也在后续章节中进行了描述。
A complete example br2-external tree layout is also described later.
完整的 br2-external 树布局示例也将在后面进行描述。
That file describes the br2-external tree: the name and description
for that br2-external tree.
该文件描述了 br2-external 树:br2-external 树的名称和描述。
The format for this file is line based, with each line starting by a
keyword, followed by a colon and one or more spaces, followed by the
value assigned to that keyword. There are two keywords currently
recognised:
该文件的格式是基于行的,每行以关键字开头,后跟一个冒号和一个或多个空格,然后是分配给该关键字的值。目前识别两个关键字:
name
, mandatory, defines the name for that br2-external tree. That
name must only use ASCII characters in the set [A-Za-z0-9_]
; any
other character is forbidden. Buildroot sets the variable
BR2_EXTERNAL_$(NAME)_PATH
to the absolute path of the br2-external
tree, so that you can use it to refer to your br2-external tree. This
variable is available both in Kconfig, so you can use it to source your
Kconfig files (see below) and in the Makefile, so that you can use it
to include other Makefiles (see below) or refer to other files (like
data files) from your br2-external tree.
name
,强制,定义了 br2-external 树的名称。该名称只能使用 ASCII 字符集中的字符 [A-Za-z0-9_]
;任何其他字符都是禁止的。Buildroot 将变量 BR2_EXTERNAL_$(NAME)_PATH
设置为 br2-external 树的绝对路径,以便您可以用它来引用您的 br2-external 树。此变量在 Kconfig
中可用,因此您可以用它来源自您的 Kconfig 文件(见下文),并且在 Makefile 中也可以使用它来包含其他
Makefile(见下文)或引用 br2-external 树中的其他文件(如数据文件)。
Note: Since it is possible to use multiple br2-external trees at once, this
name is used by Buildroot to generate variables for each of those trees.
That name is used to identify your br2-external tree, so try to come up
with a name that really describes your br2-external tree, in order for
it to be relatively unique, so that it does not clash with another name
from another br2-external tree, especially if you are planning on
somehow sharing your br2-external tree with third parties or using
br2-external trees from third parties.
注
意:由于可以同时使用多个 br2-external 树,因此 Buildroot 使用此名称为每个树生成变量。该名称用于标识您的
br2-external 树,因此请尽量想出一个真正描述您的 br2-external 树的名称,以使其相对唯一,以免与另一个
br2-external 树的名称冲突,特别是如果您计划以某种方式与第三方共享您的 br2-external 树或使用第三方的
br2-external 树。
desc
, optional, provides a short description for that br2-external
tree. It shall fit on a single line, is mostly free-form (see below),
and is used when displaying information about a br2-external tree (e.g.
above the list of defconfig files, or as the prompt in the menuconfig);
as such, it should relatively brief (40 chars is probably a good upper
limit). The description is available in the BR2_EXTERNAL_$(NAME)_DESC
variable.
desc
,可选,为该 br2-external 树提供简短描述。它应适合一行,大多是自由格式(见下文),在显示有关 br2-external
树的信息时使用(例如在 defconfig 文件列表上方,或作为 menuconfig 中的提示);因此,它应该相对简短(40
个字符可能是一个很好的上限)。描述可在 BR2_EXTERNAL_$(NAME)_DESC
变量中使用。Examples of names and the corresponding BR2_EXTERNAL_$(NAME)_PATH
variables:
名称示例及相应的 BR2_EXTERNAL_$(NAME)_PATH
变量:
FOO
→ BR2_EXTERNAL_FOO_PATH
BAR_42
→ BR2_EXTERNAL_BAR_42_PATH
In the following examples, it is assumed the name to be set to BAR_42
.
在以下示例中,假定名称设置为 BAR_42
。
Note: Both BR2_EXTERNAL_$(NAME)_PATH
and BR2_EXTERNAL_$(NAME)_DESC
are
available in the Kconfig files and the Makefiles. They are also
exported in the environment so are available in post-build, post-image
and in-fakeroot scripts.
注意:Kconfig 文件和 Makefiles 中都可以使用 BR2_EXTERNAL_$(NAME)_PATH
和 BR2_EXTERNAL_$(NAME)_DESC
。它们也会被导出到环境中,因此可以在构建后、生成镜像后以及伪根环境脚本中使用。
Those files (which may each be empty) can be used to define package
recipes (i.e. foo/Config.in
and foo/foo.mk
like for packages bundled
in Buildroot itself) or other custom configuration options or make logic.
这些文件(每个文件可能为空)可用于定义软件包配方(即类似于 Buildroot 本身捆绑软件包的 foo/Config.in
和 foo/foo.mk
)或其他自定义配置选项或构建逻辑。
Buildroot automatically includes the Config.in
from each br2-external
tree to make it appear in the top-level configuration menu, and includes
the external.mk
from each br2-external tree with the rest of the
makefile logic.
Buildroot 会自动将每个 br2-external 树中的 Config.in
包含在顶层配置菜单中,并将每个 br2-external 树中的 external.mk
与其余的 makefile 逻辑一起包含进来。
The main usage of this is to store package recipes. The recommended way
to do this is to write a Config.in
file that looks like:
这主要用于存储软件包配方。建议的做法是编写一个类似于 Config.in
的文件:
source "$BR2_EXTERNAL_BAR_42_PATH/package/package1/Config.in" source "$BR2_EXTERNAL_BAR_42_PATH/package/package2/Config.in"
Then, have an external.mk
file that looks like:
然后,编写一个类似于 external.mk
的文件:
include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/package/*/*.mk))
And then in $(BR2_EXTERNAL_BAR_42_PATH)/package/package1
and
$(BR2_EXTERNAL_BAR_42_PATH)/package/package2
create normal
Buildroot package recipes, as explained in Chapter 18, Adding new packages to Buildroot.
If you prefer, you can also group the packages in subdirectories
called <boardname> and adapt the above paths accordingly.
然后在 $(BR2_EXTERNAL_BAR_42_PATH)/package/package1
和 $(BR2_EXTERNAL_BAR_42_PATH)/package/package2
中创建普通的 Buildroot 软件包配方,如第 18 章“将新软件包添加到 Buildroot”中所述。如果您愿意,还可以将软件包分组到名为的子目录中,并相应地调整上述路径。
You can also define custom configuration options in Config.in
and
custom make logic in external.mk
.
您还可以在 Config.in
中定义自定义配置选项,并在 external.mk
中定义自定义构建逻辑。
One can store Buildroot defconfigs in the configs
subdirectory of
the br2-external tree. Buildroot will automatically show them in the
output of make list-defconfigs
and allow them to be loaded with the
normal make <name>_defconfig
command. They will be visible in the
make list-defconfigs output, below an External configs
label that
contains the name of the br2-external tree they are defined in.
可以将 Buildroot defconfigs 存储在 br2-external 树的 configs
子目录中。Buildroot 将自动在 make list-defconfigs
的输出中显示它们,并允许使用正常的 make <name>_defconfig
命令加载它们。它们将在 make list-defconfigs 输出中可见,在一个包含它们所定义的 br2-external 树名称的 External configs
标签下。
Note: If a defconfig file is present in more than one br2-external tree, then
the one from the last br2-external tree is used. It is thus possible
to override a defconfig bundled in Buildroot or another br2-external
tree.
注意:如果一个 defconfig 文件存在于多个 br2-external 树中,则将使用最后一个 br2-external 树中的文件。因此,可以覆盖 Buildroot 或另一个 br2-external 树中捆绑的 defconfig。
For some packages, Buildroot provides a choice between two (or more)
implementations of API-compatible such packages. For example, there is
a choice to choose either libjpeg ot jpeg-turbo; there is one between
openssl or libressl; there is one to select one of the known,
pre-configured toolchains…
对于一些软件包,Buildroot 提供了在两个(或更多)实现 API 兼容的软件包之间进行选择的选项。例如,可以选择 libjpeg 或 jpeg-turbo;可以选择 openssl 或 libressl;可以选择已知的、预配置的工具链之一…
It is possible for a br2-external to extend those choices, by providing
a set of files that define those alternatives:
通过提供一组定义这些替代方案的文件,br2-external 可以扩展这些选择:
provides/toolchains.in
defines the pre-configured toolchains, which
will then be listed in the toolchain selection;
provides/toolchains.in
定义了预配置的工具链,然后这些工具链将列在工具链选择中;provides/jpeg.in
defines the alternative libjpeg implementations;
provides/jpeg.in
定义了替代的 libjpeg 实现;provides/openssl.in
defines the alternative openssl implementations;
provides/openssl.in
定义了替代的 openssl 实现;provides/skeleton.in
defines the alternative skeleton implementations;
provides/skeleton.in
定义了替代的骨架实现;provides/init.in
defines the alternative init system implementations, this
can be used to select a default skeleton for your init.
provides/init.in
定义了替代的 init 系统实现,这可以用于选择默认的 init 骨架。One can store all the board-specific configuration files there, such
as the kernel configuration, the root filesystem overlay, or any other
configuration file for which Buildroot allows to set the location (by
using the BR2_EXTERNAL_$(NAME)_PATH
variable). For example, you
could set the paths to a global patch directory, to a rootfs overlay
and to the kernel configuration file as follows (e.g. by running
make menuconfig
and filling in these options):
可以将所有特定于板级的配置文件存储在那里,例如内核配置、根文件系统叠加,或者任何其他 Buildroot 允许设置位置的配置文件(通过使用 BR2_EXTERNAL_$(NAME)_PATH
变量)。例如,您可以设置全局补丁目录、根文件系统叠加和内核配置文件的路径,方法如下(例如,通过运行 make menuconfig
并填写这些选项):
BR2_GLOBAL_PATCH_DIR=$(BR2_EXTERNAL_BAR_42_PATH)/patches/ BR2_ROOTFS_OVERLAY=$(BR2_EXTERNAL_BAR_42_PATH)/board/<boardname>/overlay/ BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=$(BR2_EXTERNAL_BAR_42_PATH)/board/<boardname>/kernel.config
Additional Linux kernel extensions (see Section 18.22.2, “linux-kernel-extensions”) can
be added by storing them in the linux/
directory at the root of a
br2-external tree.
可以通过将附加的 Linux 内核扩展(请参阅第 18.22.2 节“linux-kernel-extensions”)存储在 br2-external 树的根目录中的 linux/
目录中来添加。
Here is an example layout using all features of br2-external (the sample
content is shown for the file above it, when it is relevant to explain
the br2-external tree; this is all entirely made up just for the sake of
illustration, of course):
这是一个使用 br2-external 所有功能的示例布局(当与解释 br2-external 树相关时,将显示上面文件的示例内容;当然,这完全是为了说明而虚构的)
/path/to/br2-ext-tree/ |- external.desc | |name: BAR_42 | |desc: Example br2-external tree | `---- | |- Config.in | |source "$BR2_EXTERNAL_BAR_42_PATH/toolchain/toolchain-external-mine/Config.in.options" | |source "$BR2_EXTERNAL_BAR_42_PATH/package/pkg-1/Config.in" | |source "$BR2_EXTERNAL_BAR_42_PATH/package/pkg-2/Config.in" | |source "$BR2_EXTERNAL_BAR_42_PATH/package/my-jpeg/Config.in" | | | |config BAR_42_FLASH_ADDR | | hex "my-board flash address" | | default 0x10AD | `---- | |- external.mk | |include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/package/*/*.mk)) | |include $(sort $(wildcard $(BR2_EXTERNAL_BAR_42_PATH)/toolchain/*/*.mk)) | | | |flash-my-board: | | $(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/flash-image \ | | --image $(BINARIES_DIR)/image.bin \ | | --address $(BAR_42_FLASH_ADDR) | `---- | |- package/pkg-1/Config.in | |config BR2_PACKAGE_PKG_1 | | bool "pkg-1" | | help | | Some help about pkg-1 | `---- |- package/pkg-1/pkg-1.hash |- package/pkg-1/pkg-1.mk | |PKG_1_VERSION = 1.2.3 | |PKG_1_SITE = /some/where/to/get/pkg-1 | |PKG_1_LICENSE = blabla | | | |define PKG_1_INSTALL_INIT_SYSV | | $(INSTALL) -D -m 0755 $(PKG_1_PKGDIR)/S99my-daemon \ | | $(TARGET_DIR)/etc/init.d/S99my-daemon | |endef | | | |$(eval $(autotools-package)) | `---- |- package/pkg-1/S99my-daemon | |- package/pkg-2/Config.in |- package/pkg-2/pkg-2.hash |- package/pkg-2/pkg-2.mk | |- provides/jpeg.in | |config BR2_PACKAGE_MY_JPEG | | bool "my-jpeg" | `---- |- package/my-jpeg/Config.in | |config BR2_PACKAGE_PROVIDES_JPEG | | default "my-jpeg" if BR2_PACKAGE_MY_JPEG | `---- |- package/my-jpeg/my-jpeg.mk | |# This is a normal package .mk file | |MY_JPEG_VERSION = 1.2.3 | |MY_JPEG_SITE = https://example.net/some/place | |MY_JPEG_PROVIDES = jpeg | |$(eval $(autotools-package)) | `---- | |- provides/init.in | |config BR2_INIT_MINE | | bool "my custom init" | | select BR2_PACKAGE_MY_INIT | | select BR2_PACKAGE_SKELETON_INIT_MINE if BR2_ROOTFS_SKELETON_DEFAULT | `---- | |- provides/skeleton.in | |config BR2_ROOTFS_SKELETON_MINE | | bool "my custom skeleton" | | select BR2_PACKAGE_SKELETON_MINE | `---- |- package/skeleton-mine/Config.in | |config BR2_PACKAGE_SKELETON_MINE | | bool | | select BR2_PACKAGE_HAS_SKELETON | | | |config BR2_PACKAGE_PROVIDES_SKELETON | | default "skeleton-mine" if BR2_PACKAGE_SKELETON_MINE | `---- |- package/skeleton-mine/skeleton-mine.mk | |SKELETON_MINE_ADD_TOOLCHAIN_DEPENDENCY = NO | |SKELETON_MINE_ADD_SKELETON_DEPENDENCY = NO | |SKELETON_MINE_PROVIDES = skeleton | |SKELETON_MINE_INSTALL_STAGING = YES | |$(eval $(generic-package)) | `---- | |- provides/toolchains.in | |config BR2_TOOLCHAIN_EXTERNAL_MINE | | bool "my custom toolchain" | | depends on BR2_some_arch | | select BR2_INSTALL_LIBSTDCPP | `---- |- toolchain/toolchain-external-mine/Config.in.options | |if BR2_TOOLCHAIN_EXTERNAL_MINE | |config BR2_TOOLCHAIN_EXTERNAL_PREFIX | | default "arch-mine-linux-gnu" | |config BR2_PACKAGE_PROVIDES_TOOLCHAIN_EXTERNAL | | default "toolchain-external-mine" | |endif | `---- |- toolchain/toolchain-external-mine/toolchain-external-mine.mk | |TOOLCHAIN_EXTERNAL_MINE_SITE = https://example.net/some/place | |TOOLCHAIN_EXTERNAL_MINE_SOURCE = my-toolchain.tar.gz | |$(eval $(toolchain-external-package)) | `---- | |- linux/Config.ext.in | |config BR2_LINUX_KERNEL_EXT_EXAMPLE_DRIVER | | bool "example-external-driver" | | help | | Example external driver | |--- |- linux/linux-ext-example-driver.mk | |- configs/my-board_defconfig | |BR2_GLOBAL_PATCH_DIR="$(BR2_EXTERNAL_BAR_42_PATH)/patches/" | |BR2_ROOTFS_OVERLAY="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/overlay/" | |BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/post-image.sh" | |BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_BAR_42_PATH)/board/my-board/kernel.config" | `---- | |- patches/linux/0001-some-change.patch |- patches/linux/0002-some-other-change.patch |- patches/busybox/0001-fix-something.patch | |- board/my-board/kernel.config |- board/my-board/overlay/var/www/index.html |- board/my-board/overlay/var/www/my.css |- board/my-board/flash-image `- board/my-board/post-image.sh |#!/bin/sh |generate-my-binary-image \ | --root ${BINARIES_DIR}/rootfs.tar \ | --kernel ${BINARIES_DIR}/zImage \ | --dtb ${BINARIES_DIR}/my-board.dtb \ | --output ${BINARIES_DIR}/image.bin `----
The br2-external tree will then be visible in the menuconfig (with
the layout expanded):
然后,br2-external 树将在 menuconfig 中可见(布局已展开):
External options ---> *** Example br2-external tree (in /path/to/br2-ext-tree/) [ ] pkg-1 [ ] pkg-2 (0x10AD) my-board flash address
If you are using more than one br2-external tree, it would look like
(with the layout expanded and the second one with name FOO_27
but no
desc:
field in external.desc
):
如果您使用多个 br2-external 树,它看起来会像这样(布局已展开,第二个树的名称为 FOO_27
,但在 external.desc
中没有 desc:
字段):
External options ---> Example br2-external tree ---> *** Example br2-external tree (in /path/to/br2-ext-tree) [ ] pkg-1 [ ] pkg-2 (0x10AD) my-board flash address FOO_27 ---> *** FOO_27 (in /path/to/another-br2-ext) [ ] foo [ ] bar
Additionally, the jpeg provider will be visible in the jpeg choice:
此外,jpeg 提供程序将在 jpeg 选择中可见:
Target packages ---> Libraries ---> Graphics ---> [*] jpeg support jpeg variant () ---> ( ) jpeg ( ) jpeg-turbo *** jpeg from: Example br2-external tree *** (X) my-jpeg *** jpeg from: FOO_27 *** ( ) another-jpeg
And similarly for the toolchains:
以及工具链类似:
Toolchain ---> Toolchain () ---> ( ) Custom toolchain *** Toolchains from: Example br2-external tree *** (X) my custom toolchain
Note. The toolchain options in toolchain/toolchain-external-mine/Config.in.options
will not appear in the Toolchain
menu. They must be explicitly included
from within the br2-external’s top-level Config.in
and will thus appear
in the External options
menu.
注意。 toolchain/toolchain-external-mine/Config.in.options
中的工具链选项不会出现在 Toolchain
菜单中。它们必须从 br2-external 的顶层 Config.in
中显式包含,因此会出现在 External options
菜单中。
The Buildroot configuration can be stored using the command
make savedefconfig
.
使用命令 make savedefconfig
可以存储 Buildroot 配置。
This strips the Buildroot configuration down by removing configuration
options that are at their default value. The result is stored in a file
called defconfig
. If you want to save it in another place, change the
BR2_DEFCONFIG
option in the Buildroot configuration itself, or call
make with make savedefconfig BR2_DEFCONFIG=<path-to-defconfig>
.
这将通过删除处于默认值的配置选项来简化 Buildroot 配置。结果存储在名为 defconfig
的文件中。如果想将其保存在其他位置,请在 Buildroot 配置本身中更改 BR2_DEFCONFIG
选项,或使用 make savedefconfig BR2_DEFCONFIG=<path-to-defconfig>
调用 make。
The recommended place to store this defconfig is
configs/<boardname>_defconfig
. If you follow this recommendation, the
configuration will be listed in make list-defconfigs
and can be set
again by running make <boardname>_defconfig
.
建议将此 defconfig 存储在 configs/<boardname>_defconfig
。如果遵循此建议,配置将列在 make list-defconfigs
中,并可以通过运行 make <boardname>_defconfig
再次设置。
Alternatively, you can copy the file to any other place and rebuild with
make defconfig BR2_DEFCONFIG=<path-to-defconfig-file>
.
或者,您可以将文件复制到任何其他位置,并使用 make defconfig BR2_DEFCONFIG=<path-to-defconfig-file>
重新构建。
The configuration files for BusyBox, the Linux kernel, Barebox, U-Boot
and uClibc should be stored as well if changed. For each of these
components, a Buildroot configuration option exists to point to an input
configuration file, e.g. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
. To store
their configuration, set these configuration options to a path where you
want to save the configuration files, and then use the helper targets
described below to actually store the configuration.
如果更改了 BusyBox、Linux 内核、Barebox、U-Boot 和 uClibc 的配置文件,则应该将其存储。对于这些组件中的每一个,都存在一个 Buildroot 配置选项,用于指向一个输入配置文件,例如 BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
。要存储它们的配置,请将这些配置选项设置为您想要保存配置文件的路径,然后使用下面描述的辅助目标来实际存储配置。
As explained in Section 9.1, “Recommended directory structure”, the recommended path to
store these configuration files is
board/<company>/<boardname>/foo.config
.
如第 9.1 节“推荐目录结构”中所解释的,存储这些配置文件的推荐路径是 board/<company>/<boardname>/foo.config
。
Make sure that you create a configuration file before changing
the BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
etc. options. Otherwise,
Buildroot will try to access this config file, which doesn’t exist
yet, and will fail. You can create the configuration file by running
make linux-menuconfig
etc.
在更改 BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
等选项之前,请确保创建配置文件。否则,Buildroot 将尝试访问此配置文件,但该文件尚不存在,操作将失败。您可以通过运行 make linux-menuconfig
等来创建配置文件。
Buildroot provides a few helper targets to make the saving of
configuration files easier.
Buildroot 提供了一些辅助目标,以使配置文件的保存更加容易。
make linux-update-defconfig
saves the linux configuration to the
path specified by BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
. It
simplifies the config file by removing default values. However,
this only works with kernels starting from 2.6.33. For earlier
kernels, use make linux-update-config
.
make linux-update-defconfig
将 Linux 配置保存到由 BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
指定的路径。它通过删除默认值简化配置文件。但是,这仅适用于从 2.6.33 开始的内核。对于较早的内核,请使用 make linux-update-config
。make busybox-update-config
saves the busybox configuration to the
path specified by BR2_PACKAGE_BUSYBOX_CONFIG
.
make busybox-update-config
将 BusyBox 配置保存到由 BR2_PACKAGE_BUSYBOX_CONFIG
指定的路径。make uclibc-update-config
saves the uClibc configuration to the
path specified by BR2_UCLIBC_CONFIG
.
make uclibc-update-config
将 uClibc 配置保存到由 BR2_UCLIBC_CONFIG
指定的路径。make barebox-update-defconfig
saves the barebox configuration to the
path specified by BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE
.
make barebox-update-defconfig
将 barebox 配置保存到指定路径 BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE
中。make uboot-update-defconfig
saves the U-Boot configuration to the
path specified by BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE
.
make uboot-update-defconfig
将 U-Boot 配置保存到指定路径 BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE
中。BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_CONFIG_FILE
.
BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_CONFIG_FILE
。Besides changing the configuration through make *config
,
there are a few other ways to customize the resulting target filesystem.
除了通过 make *config
更改配置之外,还有其他几种方式可以定制生成的目标文件系统。
The two recommended methods, which can co-exist, are root filesystem
overlay(s) and post build script(s).
两种推荐的方法,可以共存,分别是根文件系统叠加和构建后脚本。
BR2_ROOTFS_OVERLAY
)
BR2_ROOTFS_OVERLAY
)A filesystem overlay is a tree of files that is copied directly
over the target filesystem after it has been built. To enable this
feature, set config option BR2_ROOTFS_OVERLAY
(in the System
configuration
menu) to the root of the overlay. You can even specify
multiple overlays, space-separated. If you specify a relative path,
it will be relative to the root of the Buildroot tree. Hidden
directories of version control systems, like .git
, .svn
, .hg
,
etc., files called .empty
and files ending in ~
are excluded from
the copy.
文件系统叠加是一个文件树,它在构建完成后直接复制到目标文件系统上。要启用此功能,请将配置选项 BR2_ROOTFS_OVERLAY
(在 System
configuration
菜单中) 设置为叠加的根目录。您甚至可以指定多个叠加,以空格分隔。如果指定相对路径,它将相对于 Buildroot 树的根目录。版本控制系统的隐藏目录,如 .git
、 .svn
、 .hg
等,名为 .empty
的文件和以 ~
结尾的文件将被排除在复制之外。
When BR2_ROOTFS_MERGED_USR
is enabled, then the overlay must not
contain the /bin, /lib or /sbin directories, as Buildroot will
create them as symbolic links to the relevant folders in /usr. In
such a situation, should the overlay have any programs or libraries,
they should be placed in /usr/bin, /usr/sbin and /usr/lib.
当启用 BR2_ROOTFS_MERGED_USR
时,叠加不能包含 /bin、/lib 或 /sbin 目录,因为 Buildroot 将创建它们作为指向 /usr
中相关文件夹的符号链接。在这种情况下,如果叠加包含任何程序或库,它们应放置在 /usr/bin、/usr/sbin 和 /usr/lib 中。
As shown in Section 9.1, “Recommended directory structure”, the recommended path for
this overlay is board/<company>/<boardname>/rootfs-overlay
.
如第 9.1 节“推荐目录结构”所示,此叠加层的推荐路径为 board/<company>/<boardname>/rootfs-overlay
。
BR2_ROOTFS_POST_BUILD_SCRIPT
)
BR2_ROOTFS_POST_BUILD_SCRIPT
)Post-build scripts are shell scripts called after Buildroot builds
all the selected software, but before the rootfs images are
assembled. To enable this feature, specify a space-separated list of
post-build scripts in config option BR2_ROOTFS_POST_BUILD_SCRIPT
(in
the System configuration
menu). If you specify a relative path, it
will be relative to the root of the Buildroot tree.
构建后脚本是在 Buildroot 构建所有选定软件之后但在组装根文件系统镜像之前调用的 shell 脚本。要启用此功能,请在配置选项 BR2_ROOTFS_POST_BUILD_SCRIPT
(在 System configuration
菜单中)中指定一个以空格分隔的构建后脚本列表。如果指定相对路径,它将相对于 Buildroot 树的根目录。
Using post-build scripts, you can remove or modify any file in your
target filesystem. You should, however, use this feature with care.
Whenever you find that a certain package generates wrong or unneeded
files, you should fix that package rather than work around it with some
post-build cleanup scripts.
使用后构建脚本,您可以删除或修改目标文件系统中的任何文件。但是,您应该谨慎使用此功能。每当您发现某个软件包生成错误或不需要的文件时,您应该修复该软件包,而不是通过一些后构建清理脚本来解决问题。
As shown in Section 9.1, “Recommended directory structure”, the recommended path for
this script is board/<company>/<boardname>/post_build.sh
.
如第 9.1 节“推荐的目录结构”所示,此脚本的推荐路径为 board/<company>/<boardname>/post_build.sh
。
The post-build scripts are run with the main Buildroot tree as current
working directory. The path to the target filesystem is passed as the
first argument to each script. If the config option
BR2_ROOTFS_POST_SCRIPT_ARGS
is not empty, these arguments will be
passed to the script too. All the scripts will be passed the exact
same set of arguments, it is not possible to pass different sets of
arguments to each script.
后构建脚本在主 Buildroot 树中运行,当前工作目录为当前目标文件系统。目标文件系统的路径将作为第一个参数传递给每个脚本。如果配置选项 BR2_ROOTFS_POST_SCRIPT_ARGS
不为空,则这些参数也将传递给脚本。所有脚本将传递完全相同的参数集,无法向每个脚本传递不同的参数集。
In addition, you may also use these environment variables:
另外,您还可以使用这些环境变量:
BR2_CONFIG
: the path to the Buildroot .config file
BR2_CONFIG
:Buildroot .config 文件的路径CONFIG_DIR
: the directory containing the .config file, and
therefore the top-level Buildroot Makefile to use (which is
correct for both in-tree and out-of-tree builds)
CONFIG_DIR
:包含 .config 文件的目录,因此可以使用顶层 Buildroot Makefile(对于树内和树外构建都是正确的)HOST_DIR
, STAGING_DIR
, TARGET_DIR
: see
Section 18.6.2, “generic-package
reference”HOST_DIR
, STAGING_DIR
, TARGET_DIR
:请参阅第 18.6.2 节,“ generic-package
参考”
BUILD_DIR
: the directory where packages are extracted and built
BUILD_DIR
:包被提取和构建的目录BINARIES_DIR
: the place where all binary files (aka images) are
stored
BINARIES_DIR
:存储所有二进制文件(也称为图像)的位置BASE_DIR
: the base output directory
BASE_DIR
:基本输出目录Below three more methods of customizing the target filesystem are
described, but they are not recommended.
下面描述了另外三种自定义目标文件系统的方法,但不建议使用。
For temporary modifications, you can modify the target filesystem
directly and rebuild the image. The target filesystem is available
under output/target/
. After making your changes, run make
to
rebuild the target filesystem image.
对于临时修改,您可以直接修改目标文件系统并重新构建映像。目标文件系统可在 output/target/
下找到。进行更改后,运行 make
以重新构建目标文件系统映像。
This method allows you to do anything to the target filesystem, but if
you need to clean your Buildroot tree using make clean
, these
changes will be lost. Such cleaning is necessary in several cases,
refer to Section 8.2, “Understanding when a full rebuild is necessary” for details. This solution is therefore
only useful for quick tests: changes do not survive the make clean
command. Once you have validated your changes, you should make sure
that they will persist after a make clean
, using a root filesystem
overlay or a post-build script.
此方法允许您对目标文件系统进行任何操作,但如果您需要使用 make clean
清理您的 Buildroot 树,这些更改将会丢失。在几种情况下,这种清理是必要的,请参阅第 8.2 节“了解何时需要进行完全重建”以获取详细信息。因此,此解决方案仅适用于快速测试:更改不会在 make clean
命令后保留。一旦您验证了更改,您应确保它们在 make clean
后仍然存在,可以使用根文件系统叠加或后构建脚本。
BR2_ROOTFS_SKELETON_CUSTOM
)
BR2_ROOTFS_SKELETON_CUSTOM
)The root filesystem image is created from a target skeleton, on top of
which all packages install their files. The skeleton is copied to the
target directory output/target
before any package is built and
installed. The default target skeleton provides the standard Unix
filesystem layout and some basic init scripts and configuration files.
根文件系统镜像是从目标骨架创建的,在这个骨架上,所有软件包都会安装它们的文件。在构建和安装任何软件包之前,骨架会被复制到目标目录 output/target
中。默认的目标骨架提供了标准的 Unix 文件系统布局以及一些基本的初始化脚本和配置文件。
If the default skeleton (available under system/skeleton
) does not
match your needs, you would typically use a root filesystem overlay or
post-build script to adapt it. However, if the default skeleton is
entirely different than what you need, using a custom skeleton may be
more suitable.
如果默认的骨架(位于 system/skeleton
下)不符合您的需求,您通常会使用根文件系统叠加或后期构建脚本来进行调整。然而,如果默认的骨架与您的需求完全不同,使用自定义骨架可能更合适。
To enable this feature, enable config option
BR2_ROOTFS_SKELETON_CUSTOM
and set BR2_ROOTFS_SKELETON_CUSTOM_PATH
to the path of your custom skeleton. Both options are available in the
System configuration
menu. If you specify a relative path, it will
be relative to the root of the Buildroot tree.
要启用此功能,请启用配置选项 BR2_ROOTFS_SKELETON_CUSTOM
并将 BR2_ROOTFS_SKELETON_CUSTOM_PATH
设置为您自定义骨架的路径。这两个选项都可以在 System configuration
菜单中找到。如果指定相对路径,它将相对于 Buildroot 树的根目录。
Custom skeletons don’t need to contain the /bin, /lib or /sbin
directories, since they are created automatically during the build.
When BR2_ROOTFS_MERGED_USR
is enabled, then the custom skeleton must
not contain the /bin, /lib or /sbin directories, as Buildroot
will create them as symbolic links to the relevant folders in /usr.
In such a situation, should the skeleton have any programs or
libraries, they should be placed in /usr/bin, /usr/sbin and
/usr/lib.
自定义骨架不需要包含/bin、/lib 或/sbin 目录,因为它们会在构建过程中自动生成。当启用 BR2_ROOTFS_MERGED_USR
时,自定义骨架不应包含/bin、/lib 或/sbin 目录,因为 Buildroot 会将它们创建为指向/usr 中相关文件夹的符号链接。在这种情况下,如果骨架中有任何程序或库,它们应放置在/usr/bin、/usr/sbin 和/usr/lib 中。
This method is not recommended because it duplicates the entire
skeleton, which prevents taking advantage of the fixes or improvements
brought to the default skeleton in later Buildroot releases.
不推荐使用此方法,因为它会复制整个骨架,这将阻止利用后续 Buildroot 版本中默认骨架的修复或改进。
BR2_ROOTFS_POST_FAKEROOT_SCRIPT
)
BR2_ROOTFS_POST_FAKEROOT_SCRIPT
)When aggregating the final images, some parts of the process requires
root rights: creating device nodes in /dev
, setting permissions or
ownership to files and directories… To avoid requiring actual root
rights, Buildroot uses fakeroot
to simulate root rights. This is not
a complete substitute for actually being root, but is enough for what
Buildroot needs.
在聚合最终图像时,某些过程的某些部分需要 root 权限:在 /dev
中创建设备节点,设置文件和目录的权限或所有权... 为了避免需要实际的 root 权限,Buildroot 使用 fakeroot
来模拟 root 权限。这并不能完全替代实际的 root 权限,但对于 Buildroot 需要的内容足够了。
Post-fakeroot scripts are shell scripts that are called at the end of
the fakeroot phase, right before the filesystem image generator is
called. As such, they are called in the fakeroot context.
后伪装脚本是在伪装阶段结束时调用的 shell 脚本,在文件系统图像生成器被调用之前调用。因此,它们是在伪装上下文中调用的。
Post-fakeroot scripts can be useful in case you need to tweak the
filesystem to do modifications that are usually only available to the
root user.
后伪装脚本在需要调整文件系统以进行通常仅对 root 用户可用的修改时非常有用。
Note: It is recommended to use the existing mechanisms to set file permissions
or create entries in /dev
(see Section 9.5.1, “Setting file permissions and ownership and adding custom devices nodes”) or
to create users (see Section 9.6, “Adding custom user accounts”)
注意:建议使用现有机制设置文件权限或在 /dev
中创建条目(请参见第 9.5.1 节“设置文件权限和所有权以及添加自定义设备节点”)或创建用户(请参见第 9.6 节“添加自定义用户帐户”)
Note: The difference between post-build scripts (above) and fakeroot scripts,
is that post-build scripts are not called in the fakeroot context.
注意:后构建脚本(上文)和 fakeroot 脚本之间的区别在于后构建脚本不在 fakeroot 上下文中调用。
Note: Using fakeroot
is not an absolute substitute for actually being root.
fakeroot
only ever fakes the file access rights and types (regular,
block-or-char device…) and uid/gid; these are emulated in-memory.
注意:使用 fakeroot
并非绝对替代实际的 root。 fakeroot
只是伪造文件访问权限和类型(常规、块设备或字符设备...)以及 uid/gid;这些都是在内存中模拟的。
Sometimes it is needed to set specific permissions or ownership on files
or device nodes. For example, certain files may need to be owned by
root. Since the post-build scripts are not run as root, you cannot do
such changes from there unless you use an explicit fakeroot from the
post-build script.
有时需要在文件或设备节点上设置特定权限或所有权。例如,某些文件可能需要由 root 所有。由于后构建脚本不是以 root 身份运行的,因此除非您在后构建脚本中使用显式 fakeroot,否则无法进行此类更改。
Instead, Buildroot provides support for so-called permission tables.
To use this feature, set config option BR2_ROOTFS_DEVICE_TABLE
to a
space-separated list of permission tables, regular text files following
the makedev syntax.
相反,Buildroot 提供了所谓的权限表支持。要使用此功能,请将配置选项 BR2_ROOTFS_DEVICE_TABLE
设置为以空格分隔的权限表列表,这些权限表是遵循 makedev 语法的常规文本文件。
If you are using a static device table (i.e. not using devtmpfs
,
mdev
, or (e)udev
) then you can add device nodes using the same
syntax, in so-called device tables. To use this feature, set config
option BR2_ROOTFS_STATIC_DEVICE_TABLE
to a space-separated list of
device tables.
如果您正在使用静态设备表(即不使用 devtmpfs
, mdev
或 (e)udev
),那么您可以使用相同的语法在所谓的设备表中添加设备节点。要使用此功能,请将配置选项 BR2_ROOTFS_STATIC_DEVICE_TABLE
设置为设备表的空格分隔列表。
As shown in Section 9.1, “Recommended directory structure”, the recommended location for
such files is board/<company>/<boardname>/
.
如第 9.1 节“推荐的目录结构”所示,此类文件的推荐位置是 board/<company>/<boardname>/
。
It should be noted that if the specific permissions or device nodes are
related to a specific application, you should set variables
FOO_PERMISSIONS
and FOO_DEVICES
in the package’s .mk
file instead
(see Section 18.6.2, “generic-package
reference”).
应注意,如果特定权限或设备节点与特定应用程序相关,则应在软件包的 .mk
文件中设置变量 FOO_PERMISSIONS
和 FOO_DEVICES
(请参阅第 18.6.2 节“ generic-package
参考”)。
Sometimes it is needed to add specific users in the target system.
To cover this requirement, Buildroot provides support for so-called
users tables. To use this feature, set config option
BR2_ROOTFS_USERS_TABLES
to a space-separated list of users tables,
regular text files following the makeusers syntax.
有时需要在目标系统中添加特定用户。为了满足这一要求,Buildroot 提供了对所谓的用户表的支持。要使用此功能,请将配置选项 BR2_ROOTFS_USERS_TABLES
设置为用户表的空格分隔列表,这些用户表是遵循 makeusers 语法的常规文本文件。
As shown in Section 9.1, “Recommended directory structure”, the recommended location for
such files is board/<company>/<boardname>/
.
如第 9.1 节“推荐的目录结构”所示,此类文件的推荐位置是 board/<company>/<boardname>/
。
It should be noted that if the custom users are related to a specific
application, you should set variable FOO_USERS
in the package’s .mk
file instead (see Section 18.6.2, “generic-package
reference”).
需要注意的是,如果自定义用户与特定应用程序相关联,应该在软件包的 .mk
文件中设置变量 FOO_USERS
(请参阅第 18.6.2 节“ generic-package
参考”)。
While post-build scripts (Section 9.5, “Customizing the generated target filesystem”) are run before
building the filesystem image, kernel and bootloader, post-image
scripts can be used to perform some specific actions after all images
have been created.
在构建文件系统映像、内核和引导加载程序之前运行后构建脚本(第 9.5 节“定制生成的目标文件系统”),后图像脚本可用于在创建所有图像后执行一些特定操作。
Post-image scripts can for example be used to automatically extract your
root filesystem tarball in a location exported by your NFS server, or
to create a special firmware image that bundles your root filesystem and
kernel image, or any other custom action required for your project.
例如,后图像脚本可用于自动提取您的根文件系统 tarball 到由 NFS 服务器导出的位置,或者创建一个捆绑您的根文件系统和内核映像的特殊固件映像,或者为您的项目需要的任何其他自定义操作。
To enable this feature, specify a space-separated list of post-image
scripts in config option BR2_ROOTFS_POST_IMAGE_SCRIPT
(in the System
configuration
menu). If you specify a relative path, it will be
relative to the root of the Buildroot tree.
要启用此功能,请在配置选项 BR2_ROOTFS_POST_IMAGE_SCRIPT
(在 System
configuration
菜单中)中指定一组以空格分隔的后图像脚本列表。如果指定相对路径,它将相对于 Buildroot 树的根目录。
Just like post-build scripts, post-image scripts are run with the main
Buildroot tree as current working directory. The path to the images
output directory is passed as the first argument to each script. If the
config option BR2_ROOTFS_POST_SCRIPT_ARGS
is not empty, these
arguments will be passed to the script too. All the scripts will be
passed the exact same set of arguments, it is not possible to pass
different sets of arguments to each script.
就像后构建脚本一样,后图像脚本会以主 Buildroot 树作为当前工作目录运行。将 images
输出目录的路径作为每个脚本的第一个参数传递。如果配置选项 BR2_ROOTFS_POST_SCRIPT_ARGS
不为空,则这些参数也将传递给脚本。所有脚本将传递完全相同的参数集,无法向每个脚本传递不同的参数集。
Again just like for the post-build scripts, the scripts have access to
the environment variables BR2_CONFIG
, HOST_DIR
, STAGING_DIR
,
TARGET_DIR
, BUILD_DIR
, BINARIES_DIR
, CONFIG_DIR
and
BASE_DIR
.
就像对于后构建脚本一样,脚本可以访问环境变量 BR2_CONFIG
, HOST_DIR
, STAGING_DIR
, TARGET_DIR
, BUILD_DIR
, BINARIES_DIR
, CONFIG_DIR
和 BASE_DIR
。
The post-image scripts will be executed as the user that executes
Buildroot, which should normally not be the root user. Therefore, any
action requiring root permissions in one of these scripts will require
special handling (usage of fakeroot or sudo), which is left to the
script developer.
后图像脚本将以执行 Buildroot 的用户身份执行,这通常不应该是 root 用户。因此,在这些脚本中需要根权限的任何操作将需要特殊处理(使用 fakeroot 或 sudo),这留给脚本开发者处理。
It is sometimes useful to apply extra patches to packages - on top of
those provided in Buildroot. This might be used to support custom
features in a project, for example, or when working on a new
architecture.
有时候,在构建系统提供的基础上,向软件包应用额外的补丁是很有用的。这可能用于支持项目中的自定义功能,例如在开发新架构时。
The BR2_GLOBAL_PATCH_DIR
configuration option can be used to specify
a space separated list of one or more directories containing package
patches.
" BR2_GLOBAL_PATCH_DIR
"配置选项可用于指定一个或多个包含软件包补丁的空格分隔目录列表。
For a specific version <packageversion>
of a specific package
<packagename>
, patches are applied from BR2_GLOBAL_PATCH_DIR
as
follows:
对于特定版本 <packageversion>
的特定软件包 <packagename>
,补丁将从 BR2_GLOBAL_PATCH_DIR
应用如下:
For every directory - <global-patch-dir>
- that exists in
BR2_GLOBAL_PATCH_DIR
, a <package-patch-dir>
will be determined as
follows:
对于每个存在于 BR2_GLOBAL_PATCH_DIR
中的目录 - <global-patch-dir>
-,将按以下方式确定 <package-patch-dir>
:
<global-patch-dir>/<packagename>/<packageversion>/
if the
directory exists.
<global-patch-dir>/<packagename>/<packageversion>/
。<global-patch-dir>/<packagename>
if the directory
exists.
<global-patch-dir>/<packagename>
。
Patches will then be applied from a <package-patch-dir>
as
follows:
然后将从 <package-patch-dir>
应用补丁。
series
file exists in the package directory, then patches are
applied according to the series
file;
series
文件,则根据 series
文件应用补丁;*.patch
are applied in
alphabetical order. So, to ensure they are applied in the right
order, it is highly recommended to name the patch files like this:
<number>-<description>.patch
, where <number>
refers to the
apply order.
*.patch
匹配的补丁文件。因此,为确保它们按正确顺序应用,强烈建议将补丁文件命名为 <number>-<description>.patch
,其中 <number>
表示应用顺序。For information about how patches are applied for a package, see
Section 19.2, “How patches are applied”
有关如何为软件包应用补丁的信息,请参阅第 19.2 节“如何应用补丁”。
The BR2_GLOBAL_PATCH_DIR
option is the preferred method for
specifying a custom patch directory for packages. It can be used to
specify a patch directory for any package in buildroot. It should also
be used in place of the custom patch directory options that are
available for packages such as U-Boot and Barebox. By doing this, it
will allow a user to manage their patches from one top-level
directory.
BR2_GLOBAL_PATCH_DIR
选项是指定软件包自定义补丁目录的首选方法。它可用于为 buildroot 中的任何软件包指定补丁目录。还应该用它来替代可用于软件包(如 U-Boot 和 Barebox)的自定义补丁目录选项。通过这样做,用户可以从一个顶级目录管理他们的补丁。
The exception to BR2_GLOBAL_PATCH_DIR
being the preferred method for
specifying custom patches is BR2_LINUX_KERNEL_PATCH
.
BR2_LINUX_KERNEL_PATCH
should be used to specify kernel patches that
are available at a URL. Note: BR2_LINUX_KERNEL_PATCH
specifies kernel
patches that are applied after patches available in BR2_GLOBAL_PATCH_DIR
,
as it is done from a post-patch hook of the Linux package.
除了 BR2_GLOBAL_PATCH_DIR
是指定自定义补丁的首选方法之外, BR2_LINUX_KERNEL_PATCH
是一个例外。应该使用 BR2_LINUX_KERNEL_PATCH
来指定可在 URL 上找到的内核补丁。注意: BR2_LINUX_KERNEL_PATCH
指定了在 BR2_GLOBAL_PATCH_DIR
中可用的补丁之后应用的内核补丁,因为它是从 Linux 软件包的后补丁钩子中执行的。
Buildroot bundles a list of hashes against
which it checks the integrity of the downloaded archives, or of those
it generates locally from VCS checkouts. However, it can only do so
for the known versions; for packages where it is possible to specify
a custom version (e.g. a custom version string, a remote tarball URL,
or a VCS repository location and changeset), Buildroot can’t carry
hashes for those.
Buildroot
捆绑了一系列哈希值,用于检查下载的存档文件的完整性,或者从 VCS
检出本地生成的存档文件。但是,它只能对已知版本执行此操作;对于可以指定自定义版本的软件包(例如自定义版本字符串、远程 tarball URL 或
VCS 存储库位置和更改集的软件包),Buildroot 无法携带这些哈希值。
For users concerned with the integrity of such downloads, it is possible
to provide a list of hashes that Buildroot can use to check arbitrary
downloaded files. Those extra hashes are looked up similarly to the
extra patches (above); for each directory in BR2_GLOBAL_PATCH_DIR
,
the first file to exist is used to check a package download:
对于关心此类下载完整性的用户,可以提供一系列哈希值,Buildroot 可以用来检查任意下载的文件。这些额外的哈希值类似于额外的补丁(上文)进行查找;对于 BR2_GLOBAL_PATCH_DIR
中的每个目录,用于检查软件包下载的第一个存在的文件是:
<global-patch-dir>/<packagename>/<packageversion>/<packagename>.hash
<global-patch-dir>/<packagename>/<packagename>.hash
The utils/add-custom-hashes
script can be used to generate these files.
utils/add-custom-hashes
脚本可用于生成这些文件。
In general, any new package should be added directly in the package
directory and submitted to the Buildroot upstream project. How to add
packages to Buildroot in general is explained in full detail in
Chapter 18, Adding new packages to Buildroot and will not be repeated here. However, your
project may need some proprietary packages that cannot be upstreamed.
This section will explain how you can keep such project-specific
packages in a project-specific directory.
一般来说,任何新软件包都应直接添加到 package
目录,并提交到 Buildroot 上游项目。一般情况下如何向 Buildroot 添加软件包在第 18 章“向 Buildroot
添加新软件包”中有详细说明,这里不再重复。但是,您的项目可能需要一些无法上游的专有软件包。本节将解释如何将这些项目特定软件包保留在项目特定目录
中。
As shown in Section 9.1, “Recommended directory structure”, the recommended location for
project-specific packages is package/<company>/
. If you are using the
br2-external tree feature (see Section 9.2, “Keeping customizations outside of Buildroot”) the recommended
location is to put them in a sub-directory named package/
in your
br2-external tree.
如第 9.1 节“推荐的目录结构”所示,项目特定软件包的推荐位置是 package/<company>/
。如果您正在使用 br2-external 树功能(请参阅第 9.2 节“将自定义内容放在 Buildroot 之外”),建议将它们放在 br2-external 树中名为 package/
的子目录中。
However, Buildroot will not be aware of the packages in this location,
unless we perform some additional steps. As explained in
Chapter 18, Adding new packages to Buildroot, a package in Buildroot basically consists of two
files: a .mk
file (describing how to build the package) and a
Config.in
file (describing the configuration options for this
package).
但是,除非我们执行一些额外的步骤,否则 Buildroot 将不会意识到此位置中的软件包。如第 18 章“向 Buildroot 添加新软件包”中所解释的,Buildroot 中的软件包基本上由两个文件组成:一个 .mk
文件(描述如何构建软件包)和一个 Config.in
文件(描述此软件包的配置选项)。
Buildroot will automatically include the .mk
files in first-level
subdirectories of the package
directory (using the pattern
package/*/*.mk
). If we want Buildroot to include .mk
files from
deeper subdirectories (like package/<company>/package1/
) then we
simply have to add a .mk
file in a first-level subdirectory that
includes these additional .mk
files. Therefore, create a file
package/<company>/<company>.mk
with following contents (assuming you
have only one extra directory level below package/<company>/
):
Buildroot 将自动包含 package
目录的一级子目录中的 .mk
文件(使用模式 package/*/*.mk
)。如果我们希望 Buildroot 包含更深层子目录(如 package/<company>/package1/
)中的 .mk
文件,那么我们只需在包含这些额外 .mk
文件的一级子目录中添加一个 .mk
文件。因此,请创建一个文件 package/<company>/<company>.mk
,其中包含以下内容(假设您在 package/<company>/
下只有一个额外的目录级别):
include $(sort $(wildcard package/<company>/*/*.mk))
For the Config.in
files, create a file package/<company>/Config.in
that includes the Config.in
files of all your packages. An exhaustive
list has to be provided since wildcards are not supported in the source command of kconfig.
For example:
对于 Config.in
文件,请创建一个文件 package/<company>/Config.in
,其中包含所有软件包的 Config.in
文件。必须提供详尽的列表,因为 kconfig 的源命令中不支持通配符。例如:
source "package/<company>/package1/Config.in" source "package/<company>/package2/Config.in"
Include this new file package/<company>/Config.in
from
package/Config.in
, preferably in a company-specific menu to make
merges with future Buildroot versions easier.
包括从 package/Config.in
中的 package/<company>/Config.in
新文件,最好放在公司特定菜单中,以便将来更容易地与 Buildroot 版本合并。
If using a br2-external tree, refer to Section 9.2, “Keeping customizations outside of Buildroot” for how
to fill in those files.
如果使用 br2-external 树,请参阅第 9.2 节“将自定义内容保留在 Buildroot 之外”以了解如何填写这些文件。
Earlier in this chapter, the different methods for making
project-specific customizations have been described. This section will
now summarize all this by providing step-by-step instructions to storing your
project-specific customizations. Clearly, the steps that are not relevant to
your project can be skipped.
在本章的前面部分,已经描述了制作项目特定定制的不同方法。本节将通过提供逐步说明来总结所有内容,以存储您的项目特定定制。显然,与您的项目无关的步骤可以跳过。
make menuconfig
to configure toolchain, packages and kernel.
make menuconfig
配置工具链、软件包和内核。make linux-menuconfig
to update the kernel config, similar for
other configuration like busybox, uclibc, …
make linux-menuconfig
更新内核配置,其他配置类似于 busybox、uclibc 等。mkdir -p board/<manufacturer>/<boardname>
Set the following options to board/<manufacturer>/<boardname>/<package>.config
(as far as they are relevant):
将以下选项设置为 board/<manufacturer>/<boardname>/<package>.config
(只要它们是相关的):
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
BR2_PACKAGE_BUSYBOX_CONFIG
BR2_UCLIBC_CONFIG
BR2_TARGET_AT91BOOTSTRAP3_CUSTOM_CONFIG_FILE
BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE
BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE
Write the configuration files:
编写配置文件:
make linux-update-defconfig
make busybox-update-config
make uclibc-update-config
cp <output>/build/at91bootstrap3-*/.config
board/<manufacturer>/<boardname>/at91bootstrap3.config
make barebox-update-defconfig
make uboot-update-defconfig
board/<manufacturer>/<boardname>/rootfs-overlay/
and fill it
with additional files you need on your rootfs, e.g.
board/<manufacturer>/<boardname>/rootfs-overlay/etc/inittab
.
Set BR2_ROOTFS_OVERLAY
to