using.txt 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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.org/[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. --------------------