2
1

using.txt 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. // -*- mode:doc; -*-
  2. Using Buildroot
  3. ---------------
  4. Buildroot has a nice configuration tool similar to the one you can
  5. find in the http://www.kernel.org/[Linux kernel] or in
  6. http://www.busybox.net/[Busybox]. Note that you can (and should) build
  7. everything as a normal user. There is no need to be root to configure
  8. and use Buildroot. The first step is to run the configuration
  9. assistant:
  10. --------------------
  11. $ make menuconfig
  12. --------------------
  13. to run the curses-based configurator, or
  14. --------------------
  15. $ make xconfig
  16. --------------------
  17. or
  18. --------------------
  19. $ make gconfig
  20. --------------------
  21. to run the Qt or GTK-based configurators.
  22. All of these "make" commands will need to build a configuration
  23. utility, so you may need to install "development" packages for
  24. relevant libraries used by the configuration utilities. On Debian-like
  25. systems, the +libncurses5-dev+ package is required to use the
  26. 'menuconfig' interface, +libqt4-dev+ is required to use the 'xconfig'
  27. interface, and +libglib2.0-dev, libgtk2.0-dev and libglade2-dev+ are
  28. needed to use the 'gconfig' interface.
  29. For each menu entry in the configuration tool, you can find associated
  30. help that describes the purpose of the entry.
  31. Once everything is configured, the configuration tool generates a
  32. +.config+ file that contains the description of your
  33. configuration. It will be used by the Makefiles to do what's needed.
  34. Let's go:
  35. --------------------
  36. $ make
  37. --------------------
  38. You *should never* use +make -jN+ with Buildroot: it does not support
  39. 'top-level parallel make'. Instead, use the +BR2_JLEVEL+ option to
  40. tell Buildroot to run each package compilation with +make -jN+.
  41. This command will generally perform the following steps:
  42. * Download source files (as required)
  43. * Configure, build and install the cross-compiling toolchain if an
  44. internal toolchain is used, or import a toolchain if an external
  45. toolchain is used
  46. * Build/install selected target packages
  47. * Build a kernel image, if selected
  48. * Build a bootloader image, if selected
  49. * Create a root filesystem in selected formats
  50. Buildroot output is stored in a single directory, +output/+.
  51. This directory contains several subdirectories:
  52. * +images/+ where all the images (kernel image, bootloader and root
  53. filesystem images) are stored.
  54. * +build/+ where all the components except for the cross-compilation
  55. toolchain are built (this includes tools needed to run Buildroot on
  56. the host and packages compiled for the target). The +build/+
  57. directory contains one subdirectory for each of these components.
  58. * +staging/+ which contains a hierarchy similar to a root filesystem
  59. hierarchy. This directory contains the installation of the
  60. cross-compilation toolchain and all the userspace packages selected
  61. for the target. However, this directory is 'not' intended to be
  62. the root filesystem for the target: it contains a lot of development
  63. files, unstripped binaries and libraries that make it far too big
  64. for an embedded system. These development files are used to compile
  65. libraries and applications for the target that depend on other
  66. libraries.
  67. * +target/+ which contains 'almost' the complete root filesystem for
  68. the target: everything needed is present except the device files in
  69. +/dev/+ (Buildroot can't create them because Buildroot doesn't run
  70. as root and doesn't want to run as root). Therefore, this directory
  71. *should not be used on your target*. Instead, you should use one of
  72. the images built in the +images/+ directory. If you need an
  73. extracted image of the root filesystem for booting over NFS, then
  74. use the tarball image generated in +images/+ and extract it as
  75. root. Compared to +staging/+, +target/+ contains only the files and
  76. libraries needed to run the selected target applications: the
  77. development files (headers, etc.) are not present, unless the
  78. +development files in target filesystem+ option is selected.
  79. * +host/+ contains the installation of tools compiled for the host
  80. that are needed for the proper execution of Buildroot, including the
  81. cross-compilation toolchain.
  82. * +toolchain/+ contains the build directories for the various
  83. components of the cross-compilation toolchain.
  84. Offline builds
  85. --------------
  86. If you intend to do an offline build and just want to download
  87. all sources that you previously selected in the configurator
  88. ('menuconfig', 'xconfig' or 'gconfig'), then issue:
  89. --------------------
  90. $ make source
  91. --------------------
  92. You can now disconnect or copy the content of your +dl+
  93. directory to the build-host.
  94. Building out-of-tree
  95. --------------------
  96. Buildroot supports building out of tree with a syntax similar to the
  97. Linux kernel. To use it, add +O=<directory>+ to the make command line:
  98. --------------------
  99. $ make O=/tmp/build
  100. --------------------
  101. Or:
  102. --------------------
  103. $ cd /tmp/build; make O=$PWD -C path/to/buildroot
  104. --------------------
  105. All the output files will be located under +/tmp/build+.
  106. When using out-of-tree builds, the Buildroot +.config+ and temporary
  107. files are also stored in the output directory. This means that you can
  108. safely run multiple builds in parallel using the same source tree as
  109. long as they use unique output directories.
  110. For ease of use, Buildroot generates a Makefile wrapper in the output
  111. directory - So after the first run, you no longer need to pass +O=..+
  112. and +-C ..+, simply run (in the output directory):
  113. --------------------
  114. $ make <target>
  115. --------------------
  116. Environment variables
  117. ---------------------
  118. [[env-vars]]
  119. Buildroot also honors some environment variables, when they are passed
  120. to +make+ or set in the environment:
  121. * +HOSTCXX+, the host C++ compiler to use
  122. * +HOSTCC+, the host C compiler to use
  123. * +UCLIBC_CONFIG_FILE=<path/to/.config>+, path to
  124. the uClibc configuration file, used to compile uClibc, if an
  125. internal toolchain is being built
  126. * +BUSYBOX_CONFIG_FILE=<path/to/.config>+, path to
  127. the Busybox configuration file
  128. * +BUILDROOT_DL_DIR+ to override the directory in which
  129. Buildroot stores/retrieves downloaded files
  130. An example that uses config files located in the toplevel directory and
  131. in your $HOME:
  132. --------------------
  133. $ make UCLIBC_CONFIG_FILE=uClibc.config BUSYBOX_CONFIG_FILE=$HOME/bb.config
  134. --------------------
  135. If you want to use a compiler other than the default +gcc+
  136. or +g+++ for building helper-binaries on your host, then do
  137. --------------------
  138. $ make HOSTCXX=g++-4.3-HEAD HOSTCC=gcc-4.3-HEAD
  139. --------------------
  140. Complying with opensource licenses
  141. ----------------------------------
  142. [[legal-info]]
  143. All of the end products of Buildroot (toolchain, root filesystem, kernel,
  144. bootloaders) contain opensource software, released under various licenses.
  145. Using opensource software gives you the freedom to build rich embedded
  146. systems choosing from a wide range of packages, but also gives some
  147. obligations that you must know and honour.
  148. Some licenses require you to publish the license text in the documentation of
  149. your product. Other require you to redistribute the source code of the
  150. software to those that receive your product.
  151. The exact requirements of each license is documented in each package, and it is
  152. your (or your legal office's) responsibility to comply with these requirements.
  153. To make this easier for you, Buildroot can collect for you some material you
  154. will probably need. To produce this material, after you configured Buildroot
  155. with +make menuconfig+, +make xconfig+ or +make gconfig+, run:
  156. --------------------
  157. make legal-info
  158. --------------------
  159. Buildroot will collect legally-relevant material in your output directory,
  160. under the +legal-info/+ subdirectory.
  161. There you will find:
  162. * A +README+ file, that summarizes the produced material and contains warnings
  163. about material that Buildroot could not produce.
  164. * +buildroot.config+: this is the Buildroot configuration file that is usually
  165. produced with +make menuconfig+, and which is necessary to reproduce the
  166. build.
  167. * The source code for all packages; this is saved in the +sources/+
  168. subdirectory (except for proprietary packages, whose source code is not
  169. saved);
  170. patches applied to some packages by Buildroot are distributed with the
  171. Buildroot sources and are not duplicated in the +sources/+ subdirectory.
  172. * A manifest file listing the configured packages, their version, license and
  173. related information.
  174. Some of these information might be not defined in Buildroot; in this case
  175. they are clearly marked as "unknown" or similar.
  176. * A +licenses/+ subdirectory, which contains the license text of packages.
  177. If the license file(s) are not defined in Buildroot, the file is not produced
  178. and a warning in the +README+ indicates this.
  179. Please note that the aim of the +legal-info+ feature of Buildroot is to
  180. produce all the material that is somehow relevant for legal compliance with the
  181. package licenses. Buildroot does not try to produce the exact material that
  182. you must somehow make public. It does surely produce some more material than is
  183. needed for a strict legal compliance. For example, it produces the source code
  184. for packages released under BSD-like licenses, that you might not want to
  185. redistribute in source form.
  186. Moreover, due to technical limitations, Buildroot does not produce some
  187. material that you will or may need, such as the toolchain source code and the
  188. Buildroot source code itself.
  189. When you run +make legal-info+, Buildroot produces warnings in the +README+
  190. file to inform you of relevant material that could not be saved.
  191. Here is a list of the licenses that are most widely used by packages in
  192. Buildroot, with the name used in the manifest file:
  193. * +GPLv2+:
  194. http://www.gnu.org/licenses/old-licenses/gpl-2.0.html[
  195. GNU General Public License, version 2];
  196. * +GPLv2++:
  197. http://www.gnu.org/licenses/old-licenses/gpl-2.0.html[
  198. GNU General Public License, version 2]
  199. or (at your option) any later version;
  200. * +GPLv3+:
  201. http://www.gnu.org/licenses/gpl.html[
  202. GNU General Public License, version 3];
  203. * +GPLv3++:
  204. http://www.gnu.org/licenses/gpl.html[
  205. GNU General Public License, version 3]
  206. or (at your option) any later version;
  207. * +GPL+:
  208. http://www.gnu.org/licenses/gpl.html[
  209. GNU General Public License] (any version);
  210. * +LGPLv2.1+:
  211. http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html[
  212. GNU Lesser General Public License, version 2.1];
  213. * +LGPLv2.1++:
  214. http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html[
  215. GNU Lesser General Public License, version 2.1]
  216. or (at your option) any later version;
  217. * +LGPLv3+:
  218. http://www.gnu.org/licenses/lgpl.html[
  219. GNU Lesser General Public License, version 3];
  220. * +LGPLv3++:
  221. http://www.gnu.org/licenses/lgpl.html[
  222. GNU Lesser General Public License, version 3]
  223. or (at your option) any later version;
  224. * +LGPL+:
  225. http://www.gnu.org/licenses/lgpl.html[
  226. GNU Lesser General Public License] (any version);
  227. * +BSD-4c+: Original BSD 4-clause license;
  228. * +BSD-3c+: BSD 3-clause license;
  229. * +BSD-2c+: BSD 2-clause license;
  230. * +PROPRIETARY+: marks a non-opensource package;
  231. Buildroot does not save any licensing info or source code for these packages.
  232. Complying with the Buildroot license
  233. ------------------------------------
  234. Buildroot itself is an opensource software, released under the
  235. http://www.gnu.org/licenses/old-licenses/gpl-2.0.html[GNU General Public
  236. License, version 2] or (at your option) any later version.
  237. However, being a build system, it is not normally part of the end product:
  238. if you develop the root filesystem, kernel, bootloader or toolchain for a
  239. device, the code of Buildroot is only present on the development machine, not
  240. in the device storage.
  241. Nevertheless, the general view of the Buildroot developers is that you should
  242. release the Buildroot source code along with the source code of other packages
  243. when releasing a product that contains GPL-licensed software.
  244. This is because the
  245. http://www.gnu.org/licenses/old-licenses/gpl-2.0.html[GNU GPL]
  246. defines the "'complete source code'" for an executable work as "'all the
  247. source code for all modules it contains, plus any associated interface
  248. definition files, plus the scripts used to control compilation and installation
  249. of the executable'".
  250. Buildroot is part of the 'scripts used to control compilation and
  251. installation of the executable', and as such it is considered part of the
  252. material that must be redistributed.
  253. Keep in mind this is only the Buildroot developers' opinion, and you should
  254. consult your legal department or lawyer in case of any doubt.