using.txt 12 KB

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