xref: /OK3568_Linux_fs/buildroot/docs/manual/configure.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun// -*- mode:doc; -*-
2*4882a593Smuzhiyun// vim: set syntax=asciidoc:
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun[[configure]]
5*4882a593Smuzhiyun== Buildroot configuration
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunAll the configuration options in +make *config+ have a help text
8*4882a593Smuzhiyunproviding details about the option.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunThe +make *config+ commands also offer a search tool. Read the help
11*4882a593Smuzhiyunmessage in the different frontend menus to know how to use it:
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun* in _menuconfig_, the search tool is called by pressing +/+;
14*4882a593Smuzhiyun* in _xconfig_, the search tool is called by pressing +Ctrl+ + +f+.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunThe result of the search shows the help message of the matching items.
17*4882a593SmuzhiyunIn _menuconfig_, numbers in the left column provide a shortcut to the
18*4882a593Smuzhiyuncorresponding entry. Just type this number to directly jump to the
19*4882a593Smuzhiyunentry, or to the containing menu in case the entry is not selectable due
20*4882a593Smuzhiyunto a missing dependency.
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunAlthough the menu structure and the help text of the entries should be
23*4882a593Smuzhiyunsufficiently self-explanatory, a number of topics require additional
24*4882a593Smuzhiyunexplanation that cannot easily be covered in the help text and are
25*4882a593Smuzhiyuntherefore covered in the following sections.
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun=== Cross-compilation toolchain
28*4882a593Smuzhiyun
29*4882a593SmuzhiyunA compilation toolchain is the set of tools that allows you to compile
30*4882a593Smuzhiyuncode for your system. It consists of a compiler (in our case, +gcc+),
31*4882a593Smuzhiyunbinary utils like assembler and linker (in our case, +binutils+) and a
32*4882a593SmuzhiyunC standard library (for example
33*4882a593Smuzhiyunhttp://www.gnu.org/software/libc/libc.html[GNU Libc],
34*4882a593Smuzhiyunhttp://www.uclibc-ng.org/[uClibc-ng]).
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunThe system installed on your development station certainly already has
37*4882a593Smuzhiyuna compilation toolchain that you can use to compile an application
38*4882a593Smuzhiyunthat runs on your system. If you're using a PC, your compilation
39*4882a593Smuzhiyuntoolchain runs on an x86 processor and generates code for an x86
40*4882a593Smuzhiyunprocessor. Under most Linux systems, the compilation toolchain uses
41*4882a593Smuzhiyunthe GNU libc (glibc) as the C standard library. This compilation
42*4882a593Smuzhiyuntoolchain is called the "host compilation toolchain". The machine on
43*4882a593Smuzhiyunwhich it is running, and on which you're working, is called the "host
44*4882a593Smuzhiyunsystem" footnote:[This terminology differs from what is used by GNU
45*4882a593Smuzhiyunconfigure, where the host is the machine on which the application will
46*4882a593Smuzhiyunrun (which is usually the same as target)].
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunThe compilation toolchain is provided by your distribution, and
49*4882a593SmuzhiyunBuildroot has nothing to do with it (other than using it to build a
50*4882a593Smuzhiyuncross-compilation toolchain and other tools that are run on the
51*4882a593Smuzhiyundevelopment host).
52*4882a593Smuzhiyun
53*4882a593SmuzhiyunAs said above, the compilation toolchain that comes with your system
54*4882a593Smuzhiyunruns on and generates code for the processor in your host system. As
55*4882a593Smuzhiyunyour embedded system has a different processor, you need a
56*4882a593Smuzhiyuncross-compilation toolchain - a compilation toolchain that runs on
57*4882a593Smuzhiyunyour _host system_ but generates code for your _target system_ (and
58*4882a593Smuzhiyuntarget processor). For example, if your host system uses x86 and your
59*4882a593Smuzhiyuntarget system uses ARM, the regular compilation toolchain on your host
60*4882a593Smuzhiyunruns on x86 and generates code for x86, while the cross-compilation
61*4882a593Smuzhiyuntoolchain runs on x86 and generates code for ARM.
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunBuildroot provides two solutions for the cross-compilation toolchain:
64*4882a593Smuzhiyun
65*4882a593Smuzhiyun * The *internal toolchain backend*, called +Buildroot toolchain+ in
66*4882a593Smuzhiyun   the configuration interface.
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun * The *external toolchain backend*, called +External toolchain+ in
69*4882a593Smuzhiyun   the configuration interface.
70*4882a593Smuzhiyun
71*4882a593SmuzhiyunThe choice between these two solutions is done using the +Toolchain
72*4882a593SmuzhiyunType+ option in the +Toolchain+ menu. Once one solution has been
73*4882a593Smuzhiyunchosen, a number of configuration options appear, they are detailed in
74*4882a593Smuzhiyunthe following sections.
75*4882a593Smuzhiyun
76*4882a593Smuzhiyun[[internal-toolchain-backend]]
77*4882a593Smuzhiyun==== Internal toolchain backend
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunThe _internal toolchain backend_ is the backend where Buildroot builds
80*4882a593Smuzhiyunby itself a cross-compilation toolchain, before building the userspace
81*4882a593Smuzhiyunapplications and libraries for your target embedded system.
82*4882a593Smuzhiyun
83*4882a593SmuzhiyunThis backend supports several C libraries:
84*4882a593Smuzhiyunhttp://www.uclibc-ng.org[uClibc-ng],
85*4882a593Smuzhiyunhttp://www.gnu.org/software/libc/libc.html[glibc] and
86*4882a593Smuzhiyunhttp://www.musl-libc.org[musl].
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunOnce you have selected this backend, a number of options appear. The
89*4882a593Smuzhiyunmost important ones allow to:
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun * Change the version of the Linux kernel headers used to build the
92*4882a593Smuzhiyun   toolchain. This item deserves a few explanations. In the process of
93*4882a593Smuzhiyun   building a cross-compilation toolchain, the C library is being
94*4882a593Smuzhiyun   built. This library provides the interface between userspace
95*4882a593Smuzhiyun   applications and the Linux kernel. In order to know how to "talk"
96*4882a593Smuzhiyun   to the Linux kernel, the C library needs to have access to the
97*4882a593Smuzhiyun   _Linux kernel headers_ (i.e. the +.h+ files from the kernel), which
98*4882a593Smuzhiyun   define the interface between userspace and the kernel (system
99*4882a593Smuzhiyun   calls, data structures, etc.). Since this interface is backward
100*4882a593Smuzhiyun   compatible, the version of the Linux kernel headers used to build
101*4882a593Smuzhiyun   your toolchain do not need to match _exactly_ the version of the
102*4882a593Smuzhiyun   Linux kernel you intend to run on your embedded system. They only
103*4882a593Smuzhiyun   need to have a version equal or older to the version of the Linux
104*4882a593Smuzhiyun   kernel you intend to run. If you use kernel headers that are more
105*4882a593Smuzhiyun   recent than the Linux kernel you run on your embedded system, then
106*4882a593Smuzhiyun   the C library might be using interfaces that are not provided by
107*4882a593Smuzhiyun   your Linux kernel.
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun * Change the version of the GCC compiler, binutils and the C library.
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun * Select a number of toolchain options (uClibc only): whether the
112*4882a593Smuzhiyun   toolchain should have RPC support (used mainly for NFS),
113*4882a593Smuzhiyun   wide-char support, locale support (for internationalization),
114*4882a593Smuzhiyun   C++ support or thread support. Depending on which options you choose,
115*4882a593Smuzhiyun   the number of userspace applications and libraries visible in
116*4882a593Smuzhiyun   Buildroot menus will change: many applications and libraries require
117*4882a593Smuzhiyun   certain toolchain options to be enabled. Most packages show a comment
118*4882a593Smuzhiyun   when a certain toolchain option is required to be able to enable
119*4882a593Smuzhiyun   those packages. If needed, you can further refine the uClibc
120*4882a593Smuzhiyun   configuration by running +make uclibc-menuconfig+. Note however that
121*4882a593Smuzhiyun   all packages in Buildroot are tested against the default uClibc
122*4882a593Smuzhiyun   configuration bundled in Buildroot: if you deviate from this
123*4882a593Smuzhiyun   configuration by removing features from uClibc, some packages may no
124*4882a593Smuzhiyun   longer build.
125*4882a593Smuzhiyun
126*4882a593SmuzhiyunIt is worth noting that whenever one of those options is modified,
127*4882a593Smuzhiyunthen the entire toolchain and system must be rebuilt. See
128*4882a593Smuzhiyunxref:full-rebuild[].
129*4882a593Smuzhiyun
130*4882a593SmuzhiyunAdvantages of this backend:
131*4882a593Smuzhiyun
132*4882a593Smuzhiyun* Well integrated with Buildroot
133*4882a593Smuzhiyun* Fast, only builds what's necessary
134*4882a593Smuzhiyun
135*4882a593SmuzhiyunDrawbacks of this backend:
136*4882a593Smuzhiyun
137*4882a593Smuzhiyun* Rebuilding the toolchain is needed when doing +make clean+, which
138*4882a593Smuzhiyun  takes time. If you're trying to reduce your build time, consider
139*4882a593Smuzhiyun  using the _External toolchain backend_.
140*4882a593Smuzhiyun
141*4882a593Smuzhiyun[[external-toolchain-backend]]
142*4882a593Smuzhiyun==== External toolchain backend
143*4882a593Smuzhiyun
144*4882a593SmuzhiyunThe _external toolchain backend_ allows to use existing pre-built
145*4882a593Smuzhiyuncross-compilation toolchains. Buildroot knows about a number of
146*4882a593Smuzhiyunwell-known cross-compilation toolchains (from
147*4882a593Smuzhiyunhttp://www.linaro.org[Linaro] for ARM,
148*4882a593Smuzhiyunhttp://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/[Sourcery
149*4882a593SmuzhiyunCodeBench] for ARM, x86-64, PowerPC, and MIPS, and is capable of
150*4882a593Smuzhiyundownloading them automatically, or it can be pointed to a custom
151*4882a593Smuzhiyuntoolchain, either available for download or installed locally.
152*4882a593Smuzhiyun
153*4882a593SmuzhiyunThen, you have three solutions to use an external toolchain:
154*4882a593Smuzhiyun
155*4882a593Smuzhiyun* Use a predefined external toolchain profile, and let Buildroot
156*4882a593Smuzhiyun  download, extract and install the toolchain. Buildroot already knows
157*4882a593Smuzhiyun  about a few CodeSourcery and Linaro toolchains. Just select the
158*4882a593Smuzhiyun  toolchain profile in +Toolchain+ from the available ones. This is
159*4882a593Smuzhiyun  definitely the easiest solution.
160*4882a593Smuzhiyun
161*4882a593Smuzhiyun* Use a predefined external toolchain profile, but instead of having
162*4882a593Smuzhiyun  Buildroot download and extract the toolchain, you can tell Buildroot
163*4882a593Smuzhiyun  where your toolchain is already installed on your system. Just
164*4882a593Smuzhiyun  select the toolchain profile in +Toolchain+ through the available
165*4882a593Smuzhiyun  ones, unselect +Download toolchain automatically+, and fill the
166*4882a593Smuzhiyun  +Toolchain path+ text entry with the path to your cross-compiling
167*4882a593Smuzhiyun  toolchain.
168*4882a593Smuzhiyun
169*4882a593Smuzhiyun* Use a completely custom external toolchain. This is particularly
170*4882a593Smuzhiyun  useful for toolchains generated using crosstool-NG or with Buildroot
171*4882a593Smuzhiyun  itself. To do this, select the +Custom toolchain+ solution in the
172*4882a593Smuzhiyun  +Toolchain+ list. You need to fill the +Toolchain path+, +Toolchain
173*4882a593Smuzhiyun  prefix+ and +External toolchain C library+ options. Then, you have
174*4882a593Smuzhiyun  to tell Buildroot what your external toolchain supports. If your
175*4882a593Smuzhiyun  external toolchain uses the 'glibc' library, you only have to tell
176*4882a593Smuzhiyun  whether your toolchain supports C\++ or not and whether it has
177*4882a593Smuzhiyun  built-in RPC support. If your external toolchain uses the 'uClibc'
178*4882a593Smuzhiyun  library, then you have to tell Buildroot if it supports RPC,
179*4882a593Smuzhiyun  wide-char, locale, program invocation, threads and C++.
180*4882a593Smuzhiyun  At the beginning of the execution, Buildroot will tell you if
181*4882a593Smuzhiyun  the selected options do not match the toolchain configuration.
182*4882a593Smuzhiyun
183*4882a593SmuzhiyunOur external toolchain support has been tested with toolchains from
184*4882a593SmuzhiyunCodeSourcery and Linaro, toolchains generated by
185*4882a593Smuzhiyunhttp://crosstool-ng.org[crosstool-NG], and toolchains generated by
186*4882a593SmuzhiyunBuildroot itself. In general, all toolchains that support the
187*4882a593Smuzhiyun'sysroot' feature should work. If not, do not hesitate to contact the
188*4882a593Smuzhiyundevelopers.
189*4882a593Smuzhiyun
190*4882a593SmuzhiyunWe do not support toolchains or SDK generated by OpenEmbedded or
191*4882a593SmuzhiyunYocto, because these toolchains are not pure toolchains (i.e. just the
192*4882a593Smuzhiyuncompiler, binutils, the C and C++ libraries). Instead these toolchains
193*4882a593Smuzhiyuncome with a very large set of pre-compiled libraries and
194*4882a593Smuzhiyunprograms. Therefore, Buildroot cannot import the 'sysroot' of the
195*4882a593Smuzhiyuntoolchain, as it would contain hundreds of megabytes of pre-compiled
196*4882a593Smuzhiyunlibraries that are normally built by Buildroot.
197*4882a593Smuzhiyun
198*4882a593SmuzhiyunWe also do not support using the distribution toolchain (i.e. the
199*4882a593Smuzhiyungcc/binutils/C library installed by your distribution) as the
200*4882a593Smuzhiyuntoolchain to build software for the target. This is because your
201*4882a593Smuzhiyundistribution toolchain is not a "pure" toolchain (i.e. only with the
202*4882a593SmuzhiyunC/C++ library), so we cannot import it properly into the Buildroot
203*4882a593Smuzhiyunbuild environment. So even if you are building a system for a x86 or
204*4882a593Smuzhiyunx86_64 target, you have to generate a cross-compilation toolchain with
205*4882a593SmuzhiyunBuildroot or crosstool-NG.
206*4882a593Smuzhiyun
207*4882a593SmuzhiyunIf you want to generate a custom toolchain for your project, that can
208*4882a593Smuzhiyunbe used as an external toolchain in Buildroot, our recommendation is
209*4882a593Smuzhiyunto build it either with Buildroot itself (see
210*4882a593Smuzhiyunxref:build-toolchain-with-buildroot[]) or with
211*4882a593Smuzhiyunhttp://crosstool-ng.org[crosstool-NG].
212*4882a593Smuzhiyun
213*4882a593SmuzhiyunAdvantages of this backend:
214*4882a593Smuzhiyun
215*4882a593Smuzhiyun* Allows to use well-known and well-tested cross-compilation
216*4882a593Smuzhiyun  toolchains.
217*4882a593Smuzhiyun
218*4882a593Smuzhiyun* Avoids the build time of the cross-compilation toolchain, which is
219*4882a593Smuzhiyun  often very significant in the overall build time of an embedded
220*4882a593Smuzhiyun  Linux system.
221*4882a593Smuzhiyun
222*4882a593SmuzhiyunDrawbacks of this backend:
223*4882a593Smuzhiyun
224*4882a593Smuzhiyun* If your pre-built external toolchain has a bug, may be hard to get a
225*4882a593Smuzhiyun  fix from the toolchain vendor, unless you build your external
226*4882a593Smuzhiyun  toolchain by yourself using Buildroot or Crosstool-NG.
227*4882a593Smuzhiyun
228*4882a593Smuzhiyun[[build-toolchain-with-buildroot]]
229*4882a593Smuzhiyun==== Build an external toolchain with Buildroot
230*4882a593Smuzhiyun
231*4882a593SmuzhiyunThe Buildroot internal toolchain option can be used to create an
232*4882a593Smuzhiyunexternal toolchain. Here are a series of steps to build an internal
233*4882a593Smuzhiyuntoolchain and package it up for reuse by Buildroot itself (or other
234*4882a593Smuzhiyunprojects).
235*4882a593Smuzhiyun
236*4882a593SmuzhiyunCreate a new Buildroot configuration, with the following details:
237*4882a593Smuzhiyun
238*4882a593Smuzhiyun* Select the appropriate *Target options* for your target CPU
239*4882a593Smuzhiyun  architecture
240*4882a593Smuzhiyun
241*4882a593Smuzhiyun* In the *Toolchain* menu, keep the default of *Buildroot toolchain*
242*4882a593Smuzhiyun  for *Toolchain type*, and configure your toolchain as desired
243*4882a593Smuzhiyun
244*4882a593Smuzhiyun* In the *System configuration* menu, select *None* as the *Init
245*4882a593Smuzhiyun  system* and *none* as */bin/sh*
246*4882a593Smuzhiyun
247*4882a593Smuzhiyun* In the *Target packages* menu, disable *BusyBox*
248*4882a593Smuzhiyun
249*4882a593Smuzhiyun* In the *Filesystem images* menu, disable *tar the root filesystem*
250*4882a593Smuzhiyun
251*4882a593SmuzhiyunThen, we can trigger the build, and also ask Buildroot to generate a
252*4882a593SmuzhiyunSDK. This will conveniently generate for us a tarball which contains
253*4882a593Smuzhiyunour toolchain:
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun-----
256*4882a593Smuzhiyunmake sdk
257*4882a593Smuzhiyun-----
258*4882a593Smuzhiyun
259*4882a593SmuzhiyunThis produces the SDK tarball in +$(O)/images+, with a name similar to
260*4882a593Smuzhiyun+arm-buildroot-linux-uclibcgnueabi_sdk-buildroot.tar.gz+. Save this
261*4882a593Smuzhiyuntarball, as it is now the toolchain that you can re-use as an external
262*4882a593Smuzhiyuntoolchain in other Buildroot projects.
263*4882a593Smuzhiyun
264*4882a593SmuzhiyunIn those other Buildroot projects, in the *Toolchain* menu:
265*4882a593Smuzhiyun
266*4882a593Smuzhiyun* Set *Toolchain type* to *External toolchain*
267*4882a593Smuzhiyun
268*4882a593Smuzhiyun* Set *Toolchain* to *Custom toolchain*
269*4882a593Smuzhiyun
270*4882a593Smuzhiyun* Set *Toolchain origin* to *Toolchain to be downloaded and installed*
271*4882a593Smuzhiyun
272*4882a593Smuzhiyun* Set *Toolchain URL* to +file:///path/to/your/sdk/tarball.tar.gz+
273*4882a593Smuzhiyun
274*4882a593Smuzhiyun===== External toolchain wrapper
275*4882a593Smuzhiyun
276*4882a593SmuzhiyunWhen using an external toolchain, Buildroot generates a wrapper program,
277*4882a593Smuzhiyunthat transparently passes the appropriate options (according to the
278*4882a593Smuzhiyunconfiguration) to the external toolchain programs. In case you need to
279*4882a593Smuzhiyundebug this wrapper to check exactly what arguments are passed, you can
280*4882a593Smuzhiyunset the environment variable +BR2_DEBUG_WRAPPER+ to either one of:
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun* +0+, empty or not set: no debug
283*4882a593Smuzhiyun
284*4882a593Smuzhiyun* +1+: trace all arguments on a single line
285*4882a593Smuzhiyun
286*4882a593Smuzhiyun* +2+: trace one argument per line
287*4882a593Smuzhiyun
288*4882a593Smuzhiyun=== /dev management
289*4882a593Smuzhiyun
290*4882a593SmuzhiyunOn a Linux system, the +/dev+ directory contains special files, called
291*4882a593Smuzhiyun_device files_, that allow userspace applications to access the
292*4882a593Smuzhiyunhardware devices managed by the Linux kernel. Without these _device
293*4882a593Smuzhiyunfiles_, your userspace applications would not be able to use the
294*4882a593Smuzhiyunhardware devices, even if they are properly recognized by the Linux
295*4882a593Smuzhiyunkernel.
296*4882a593Smuzhiyun
297*4882a593SmuzhiyunUnder +System configuration+, +/dev management+, Buildroot offers four
298*4882a593Smuzhiyundifferent solutions to handle the +/dev+ directory :
299*4882a593Smuzhiyun
300*4882a593Smuzhiyun * The first solution is *Static using device table*. This is the old
301*4882a593Smuzhiyun   classical way of handling device files in Linux. With this method,
302*4882a593Smuzhiyun   the device files are persistently stored in the root filesystem
303*4882a593Smuzhiyun   (i.e. they persist across reboots), and there is nothing that will
304*4882a593Smuzhiyun   automatically create and remove those device files when hardware
305*4882a593Smuzhiyun   devices are added or removed from the system. Buildroot therefore
306*4882a593Smuzhiyun   creates a standard set of device files using a _device table_, the
307*4882a593Smuzhiyun   default one being stored in +system/device_table_dev.txt+ in the
308*4882a593Smuzhiyun   Buildroot source code. This file is processed when Buildroot
309*4882a593Smuzhiyun   generates the final root filesystem image, and the _device files_
310*4882a593Smuzhiyun   are therefore not visible in the +output/target+ directory. The
311*4882a593Smuzhiyun   +BR2_ROOTFS_STATIC_DEVICE_TABLE+ option allows to change the
312*4882a593Smuzhiyun   default device table used by Buildroot, or to add an additional
313*4882a593Smuzhiyun   device table, so that additional _device files_ are created by
314*4882a593Smuzhiyun   Buildroot during the build. So, if you use this method, and a
315*4882a593Smuzhiyun   _device file_ is missing in your system, you can for example create
316*4882a593Smuzhiyun   a +board/<yourcompany>/<yourproject>/device_table_dev.txt+ file
317*4882a593Smuzhiyun   that contains the description of your additional _device files_,
318*4882a593Smuzhiyun   and then you can set +BR2_ROOTFS_STATIC_DEVICE_TABLE+ to
319*4882a593Smuzhiyun   +system/device_table_dev.txt
320*4882a593Smuzhiyun   board/<yourcompany>/<yourproject>/device_table_dev.txt+. For more
321*4882a593Smuzhiyun   details about the format of the device table file, see
322*4882a593Smuzhiyun   xref:makedev-syntax[].
323*4882a593Smuzhiyun
324*4882a593Smuzhiyun * The second solution is *Dynamic using devtmpfs only*. _devtmpfs_ is
325*4882a593Smuzhiyun   a virtual filesystem inside the Linux kernel that has been
326*4882a593Smuzhiyun   introduced in kernel 2.6.32 (if you use an older kernel, it is not
327*4882a593Smuzhiyun   possible to use this option). When mounted in +/dev+, this virtual
328*4882a593Smuzhiyun   filesystem will automatically make _device files_ appear and
329*4882a593Smuzhiyun   disappear as hardware devices are added and removed from the
330*4882a593Smuzhiyun   system. This filesystem is not persistent across reboots: it is
331*4882a593Smuzhiyun   filled dynamically by the kernel. Using _devtmpfs_ requires the
332*4882a593Smuzhiyun   following kernel configuration options to be enabled:
333*4882a593Smuzhiyun   +CONFIG_DEVTMPFS+ and +CONFIG_DEVTMPFS_MOUNT+. When Buildroot is in
334*4882a593Smuzhiyun   charge of building the Linux kernel for your embedded device, it
335*4882a593Smuzhiyun   makes sure that those two options are enabled. However, if you
336*4882a593Smuzhiyun   build your Linux kernel outside of Buildroot, then it is your
337*4882a593Smuzhiyun   responsibility to enable those two options (if you fail to do so,
338*4882a593Smuzhiyun   your Buildroot system will not boot).
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun * The third solution is *Dynamic using devtmpfs + mdev*. This method
341*4882a593Smuzhiyun   also relies on the _devtmpfs_ virtual filesystem detailed above (so
342*4882a593Smuzhiyun   the requirement to have +CONFIG_DEVTMPFS+ and
343*4882a593Smuzhiyun   +CONFIG_DEVTMPFS_MOUNT+ enabled in the kernel configuration still
344*4882a593Smuzhiyun   apply), but adds the +mdev+ userspace utility on top of it. +mdev+
345*4882a593Smuzhiyun   is a program part of BusyBox that the kernel will call every time a
346*4882a593Smuzhiyun   device is added or removed. Thanks to the +/etc/mdev.conf+
347*4882a593Smuzhiyun   configuration file, +mdev+ can be configured to for example, set
348*4882a593Smuzhiyun   specific permissions or ownership on a device file, call a script
349*4882a593Smuzhiyun   or application whenever a device appears or disappear,
350*4882a593Smuzhiyun   etc. Basically, it allows _userspace_ to react on device addition
351*4882a593Smuzhiyun   and removal events. +mdev+ can for example be used to automatically
352*4882a593Smuzhiyun   load kernel modules when devices appear on the system. +mdev+ is
353*4882a593Smuzhiyun   also important if you have devices that require a firmware, as it
354*4882a593Smuzhiyun   will be responsible for pushing the firmware contents to the
355*4882a593Smuzhiyun   kernel. +mdev+ is a lightweight implementation (with fewer
356*4882a593Smuzhiyun   features) of +udev+. For more details about +mdev+ and the syntax
357*4882a593Smuzhiyun   of its configuration file, see
358*4882a593Smuzhiyun   http://git.busybox.net/busybox/tree/docs/mdev.txt.
359*4882a593Smuzhiyun
360*4882a593Smuzhiyun * The fourth solution is *Dynamic using devtmpfs + eudev*. This
361*4882a593Smuzhiyun   method also relies on the _devtmpfs_ virtual filesystem detailed
362*4882a593Smuzhiyun   above, but adds the +eudev+ userspace daemon on top of it. +eudev+
363*4882a593Smuzhiyun   is a daemon that runs in the background, and gets called by the
364*4882a593Smuzhiyun   kernel when a device gets added or removed from the system. It is a
365*4882a593Smuzhiyun   more heavyweight solution than +mdev+, but provides higher
366*4882a593Smuzhiyun   flexibility.  +eudev+ is a standalone version of +udev+, the
367*4882a593Smuzhiyun   original userspace daemon used in most desktop Linux distributions,
368*4882a593Smuzhiyun   which is now part of Systemd. For more details, see
369*4882a593Smuzhiyun   http://en.wikipedia.org/wiki/Udev.
370*4882a593Smuzhiyun
371*4882a593SmuzhiyunThe Buildroot developers recommendation is to start with the *Dynamic
372*4882a593Smuzhiyunusing devtmpfs only* solution, until you have the need for userspace
373*4882a593Smuzhiyunto be notified when devices are added/removed, or if firmwares are
374*4882a593Smuzhiyunneeded, in which case *Dynamic using devtmpfs + mdev* is usually a
375*4882a593Smuzhiyungood solution.
376*4882a593Smuzhiyun
377*4882a593SmuzhiyunNote that if +systemd+ is chosen as init system, /dev management will
378*4882a593Smuzhiyunbe performed by the +udev+ program provided by +systemd+.
379*4882a593Smuzhiyun
380*4882a593Smuzhiyun=== init system
381*4882a593Smuzhiyun
382*4882a593SmuzhiyunThe _init_ program is the first userspace program started by the
383*4882a593Smuzhiyunkernel (it carries the PID number 1), and is responsible for starting
384*4882a593Smuzhiyunthe userspace services and programs (for example: web server,
385*4882a593Smuzhiyungraphical applications, other network servers, etc.).
386*4882a593Smuzhiyun
387*4882a593SmuzhiyunBuildroot allows to use three different types of init systems, which
388*4882a593Smuzhiyuncan be chosen from +System configuration+, +Init system+:
389*4882a593Smuzhiyun
390*4882a593Smuzhiyun * The first solution is *BusyBox*. Amongst many programs, BusyBox has
391*4882a593Smuzhiyun   an implementation of a basic +init+ program, which is sufficient
392*4882a593Smuzhiyun   for most embedded systems. Enabling the +BR2_INIT_BUSYBOX+ will
393*4882a593Smuzhiyun   ensure BusyBox will build and install its +init+ program. This is
394*4882a593Smuzhiyun   the default solution in Buildroot. The BusyBox +init+ program will
395*4882a593Smuzhiyun   read the +/etc/inittab+ file at boot to know what to do. The syntax
396*4882a593Smuzhiyun   of this file can be found in
397*4882a593Smuzhiyun   http://git.busybox.net/busybox/tree/examples/inittab (note that
398*4882a593Smuzhiyun   BusyBox +inittab+ syntax is special: do not use a random +inittab+
399*4882a593Smuzhiyun   documentation from the Internet to learn about BusyBox
400*4882a593Smuzhiyun   +inittab+). The default +inittab+ in Buildroot is stored in
401*4882a593Smuzhiyun   +system/skeleton/etc/inittab+. Apart from mounting a few important
402*4882a593Smuzhiyun   filesystems, the main job the default inittab does is to start the
403*4882a593Smuzhiyun   +/etc/init.d/rcS+ shell script, and start a +getty+ program (which
404*4882a593Smuzhiyun   provides a login prompt).
405*4882a593Smuzhiyun
406*4882a593Smuzhiyun * The second solution is *systemV*. This solution uses the old
407*4882a593Smuzhiyun   traditional _sysvinit_ program, packed in Buildroot in
408*4882a593Smuzhiyun   +package/sysvinit+. This was the solution used in most desktop
409*4882a593Smuzhiyun   Linux distributions, until they switched to more recent
410*4882a593Smuzhiyun   alternatives such as Upstart or Systemd. +sysvinit+ also works with
411*4882a593Smuzhiyun   an +inittab+ file (which has a slightly different syntax than the
412*4882a593Smuzhiyun   one from BusyBox). The default +inittab+ installed with this init
413*4882a593Smuzhiyun   solution is located in +package/sysvinit/inittab+.
414*4882a593Smuzhiyun
415*4882a593Smuzhiyun * The third solution is *systemd*. +systemd+ is the new generation
416*4882a593Smuzhiyun   init system for Linux. It does far more than traditional _init_
417*4882a593Smuzhiyun   programs: aggressive parallelization capabilities, uses socket and
418*4882a593Smuzhiyun   D-Bus activation for starting services, offers on-demand starting
419*4882a593Smuzhiyun   of daemons, keeps track of processes using Linux control groups,
420*4882a593Smuzhiyun   supports snapshotting and restoring of the system state,
421*4882a593Smuzhiyun   etc. +systemd+ will be useful on relatively complex embedded
422*4882a593Smuzhiyun   systems, for example the ones requiring D-Bus and services
423*4882a593Smuzhiyun   communicating between each other. It is worth noting that +systemd+
424*4882a593Smuzhiyun   brings a fairly big number of large dependencies: +dbus+, +udev+
425*4882a593Smuzhiyun   and more. For more details about +systemd+, see
426*4882a593Smuzhiyun   http://www.freedesktop.org/wiki/Software/systemd.
427*4882a593Smuzhiyun
428*4882a593SmuzhiyunThe solution recommended by Buildroot developers is to use the
429*4882a593Smuzhiyun*BusyBox init* as it is sufficient for most embedded
430*4882a593Smuzhiyunsystems. *systemd* can be used for more complex situations.
431