Buildroot development

SDK libraries

SDK project directory introduction:

There are buildroot, app, kernel, u-boot, device, external, prebuilts, rockimg, tools , etc.

  • buildroot is used for generating root file system, cross-compiler and other tools as well as managing the applications

  • app is used for placing upper system applications

  • external is a relevant library used for placing audio, video, network settings and etc.

  • kernel is used for placing kernel source code

  • device/rockchip/px3-se is used for placing boot initialization script, third party libraries, bin, alsa, wifi and other configuration files, it also used for placing compile script

  • prebuilts is used for placing gcc and cross compiler toolschain, which are required for kernel compiling

  • rockimg is used for placing the compiled firmware

  • tools is used for placing platform tools

Buildroot development

The current Buildroot version is 2016.08.1

Buildroot directory introduction

  • buildroot/package/: in this folder, you can find the configuration file for applications. Each application has two configuration files: Config.in and soft_name.mk. And you can download the application packages via the soft_name.mk file, since it is the automated build script of Makefile script.

  • buildroot/output/: this folder is used for placing the output build. In the build/ folder, you can find the decompressed and compiled software packages. In the host/ folder, you can find the finished compiler toolchain. In the target/ folder, you can make rootfs, since it has the basic directory structure of Linux system, compiled application libraries and the bin executive file. In the Images/ folder, you can find the finally generated images, and you can burn them to the board.

  • buildroot/dl/: in this folder, you can find the downloaded source code packages and the compressed packages for application.

  • buildroot/fs/: in this folder, you can find the source code for various file system.

  • buildroot/fs/skeleton/: in this folder, you can find the file system images.

  • buildroot/linux/: in this folder, you can find the automated build script for Linux kernel.

  • buildroot/configs/: in this folder, you can find the configuration parameters for the development board.

  • buildroot/docs/: in this folder, you can find the reference documents.

  • buildroot/arch/: in this folder, you can find the configuration scripts for CPU framework, such as arm, mips, x86. Those CPU configruations are very useful when you want to make toolchains, bulid boot and kernel.

Configure Buildroot

The whole Buildroot is formed by the Makefile script and the Kconfig configuration files. You can build it just like build the Linux kernel.

$ make menuconfig

The configuration page is shown as below:

_images/make-menuconfig.png

You can add or remove some tools in Target packages according to the system function requirements. And you can configure all the frequently used tools there, like qt5, ssh, vsftpd, wpa_supplicant, pppd and etc.

You need to know:

  • To start compiling, according to the actual configuration, Buildroot will automatically get related software packages from the internet, which includes some third party libraries, plugins and other general utility tools. And those packages will be saved under dl/ library.

  • The software package will be decompressed and then compiled under output/build/.

  • If you want to modify the source code for a software package, you can put a patch for it. All the patches are saved in package/ folder and Buildroot will load related patches while decomressing the software package.

Compile Buildroot

Once Buildroot configured successfully, please run make to compile the source code directly.

Please note that the app, device and other folder under SDK will not be compiled directly. Therefore, after configuration, you need go to the SDK root directory and run ./build_all.sh to compile and build all.

If you modify the source code for some package under output/build/ during the developing process, compiliing the whole Buildroot will not work and you need to recompile that package alone.

During the package compiling process, Buildroot will record the compiling process via some identification files and save those files to the related directory of the package. All those identification files are:

.stamp_configured
.stamp_downloaded
.stamp_extracted
.stamp_patched
.stamp_staging_installed
.stamp_target_installe

These identification files mainly control the download, decompression, packaging, configuration, compilation, installation, etc. of this package. For details of its usage, please refer to the rebuilding-packages.txt under the following path:

docs/manual/rebuilding-packages.txt

You can also check the mk file directly to learn its priciple:

package/pkg-generic.mk

If you want to repeat a step, please delete its corresponding identification files first. for example , if you want to recompile the source code for building a software package, please delete the .stamp_built and the .stamp_target_installed in its current directory and rebuild the whole Buildroot again.

Of cause, there is also an easy way to do in Buildroot.

  • Run make show-targets to list all the targets(packages) that will be compiled in the current configuration.

  • Run make <package> to build and install the software packages and its dependencies.

we also can singly pick out one step from building the software package.

Package-specific:
  <pkg>                  - Build and install <pkg> and all its dependencies
  <pkg>-source           - Only download the source files for <pkg>
  <pkg>-extract          - Extract <pkg> sources
  <pkg>-patch            - Apply patches to <pkg>
  <pkg>-depends          - Build <pkg>'s dependencies
  <pkg>-configure        - Build <pkg> up to the configure step
  <pkg>-build            - Build <pkg> up to the build step
  <pkg>-graph-depends    - Generate a graph of <pkg>'s dependencies
  <pkg>-dirclean         - Remove <pkg> build directory
  <pkg>-reconfigure      - Restart the build from the configure step
  <pkg>-rebuild          - Restart the build from the build step

Therefore, if we want to rebuild the software package, just execute command like make xxx(the package name)-rebuild.

If you want to know more about how to use make, please use make help command to get it.

Buildroot official website

For more techniques about Buildroot developing, please go to its website for details.