Originally from CSDN, this record is for the author’s learning needs.
Author: xixihaha331
What is Buildroot
Buildroot is a framework for building embedded Linux systems on the Linux platform. The entire Buildroot consists of Makefile scripts and Kconfig configuration files. Just like compiling the Linux kernel, you can configure Buildroot, modify it using menuconfig, and compile a complete Linux system software that can be directly flashed and run on the machine (including boot, kernel, rootfs, and various libraries and applications within rootfs).
Buildroot Directory Structure
1. The configuration files for application software are placed under buildroot/package/. Each application software configuration file contains Config.in and soft_name.mk, where soft_name.mk (which is actually an automatic build script in Makefile format) can be used to download the application software package.
2. buildroot/output/ is the output folder containing the compiled files. The build/ directory stores the various software packages after being decompressed and compiled. The host/ directory contains the compiled toolchain, and the target/ directory is used to create the root filesystem, containing the basic directory structure of the Linux system, as well as various compiled application libraries and executable binaries. The Images/ directory contains all the various images generated that can be flashed onto the board.
3. buildroot/dl stores downloaded source packages and compressed application software packages.
4. buildroot/fs contains the source code for various filesystems.
5. buildroot/fs/skeleton is where the filesystem image is generated, as well as the system inside the board.
6. buildroot/linux/ contains the automatic build scripts for the Linux kernel.
7. buildroot/configs contains some configuration parameters for the development board.
8. The buildroot/dl/ directory contains open-source software packages downloaded from the official website. After the first download, it will not download from the official website again but will take the open-source package from the dl/ directory to save time.
9. buildroot/docs/ contains relevant reference documents.
10. The buildroot/arch/ directory contains configuration scripts related to CPU architectures, such as arm/mips/x86. These CPU-related configurations are crucial when creating toolchains and compiling boot and kernel.
Buildroot Working Principle
Buildroot is essentially an automatic build framework. Although the official community has implemented build scripts for classic open-source packages like u-boot and linux kernel, sometimes you still need to add your unique app_pkg software package to build your application.
Buildroot provides a function framework and a variable command framework (details will be introduced in the next article). The app_pkg.mk script written using its framework will be expanded and filled into the Makefile in the Buildroot main directory by the core script package/pkg-generic.mk. Finally, executing make all will run the Makefile in the Buildroot main directory to generate the desired image.
The package/pkg-generic.mk script has already implemented a series of mechanized processes such as downloading, decompressing, and compiling dependency packages by calling the pkg-download.mk and pkg-utils.mk files in the same directory. You only need to write the app_pkg.mk Makefile according to the format, filling in the download address, linking the names of dependent libraries, and other specific build details.
In summary, Buildroot itself provides a framework for the build process. Developers write scripts according to the format, provide necessary build details, configure the entire system, and finally automatically build their system.
The buildroot/packages directory contains rich configuration files for application software, which can be selected through make menuconfig to access a graphical interface for choosing and compiling a variety of open-source software packages.
In the Buildroot forum, I learned about the STM32F4 series chips running the Nuttx system:
In case anyone is interested….
I modified Buildroot to create a distribution for the STM32F4 processor. (It should be fairly portable to different Cortex-M processors though, the STM32F4 is the only one I’ve tested so far).
So far it:
Builds the toolchain
Builds a modified Nuttx RTOS
Builds the ICSP tools for programming and debugging (openocd/gdb)
It also integrates the filesystem Buildroot generates into the Nuttx kernel so it shows up in Nuttx’s filesystem.
It still has a ways to go, but right now it builds everything and works on my hardware.
So far I’ve tested it on hardware I built, and on the STM32F407 discovery board with the attached baseboard.
You can find instructions here:
http://www.vxmdesign.com/STM32.html
The git repo is:
https://github.com/vxmdesign/prjpluto.git
and vdsc_defconfig is the config for the discovery board.
Happy programming!
-Chris
Thank you for completing the reading. I am a basketball enthusiast who loves coding. This is my public account; thank you for your attention and support. I started learning about electronics and embedded software in college, and now, after 9 years of work, I have accumulated enough experience in both technology and workplace experience. Currently, I am working in a very excellent team.
I am very happy to meet every friend who works hard on technology and treats people sincerely.