嵌入式系统构建工具 - BuildRoot

Buildroot是一个用于生成嵌入式Linux系统的Makefiles和补丁集合,支持跨平台构建工具链、根文件系统、内核镜像和引导加载器镜像。通过其简单的配置接口和对数百个用户空间应用程序和库的支持,Buildroot简化了嵌入式系统开发的流程。本文介绍了在Ubuntu系统中设置Buildroot编译环境,下载源码,配置选项,并编译生成根文件系统的步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Buildroot is a set of Makefiles and patches that makes it easy to generate a complete embedded Linux system. Buildroot can generate any or all of a cross-compilation toolchain, a root filesystem, a kernel image and a bootloader image. Buildroot is useful mainly for people working with small or embedded systems, using various CPU architectures (x86, ARM, MIPS, PowerPC, etc.) : it automates the building process of your embedded system and eases the cross-compilation process.

The major Buildroot features are:

  • Can handle everything in your embedded system development project: cross-compiling toolchain, root filesystem generation, kernel image compilation and bootloader compilation. Buildroot is also sufficiently flexible that it can also be used for only one or several of these steps.
  • Is very easy to set up, thanks to its menuconfig, gconfig and xconfig configuration interfaces, familiar to all embedded Linux developers. Building a basic embedded Linux system with Buildroot typically takes 15-30 minutes.
  • Supports several hundreds of packages for userspace applications and libraries: X.org stack, Gtk2, Qt, DirectFB, SDL, GStreamer and a large number of network-related and system-related utilities and libraries are supported.
  • Supports multiple filesystem types for the root filesystem image: JFFS2, UBIFS, tarballs, romfs, cramfs, squashfs and more.
  • Can generate an uClibc cross-compilation toolchain, or re-use your existing glibc, eglibc or uClibc cross-compilation toolchain
  • Has a simple structure that makes it easy to understand and extend. It relies only on the well-known Makefile language.

1. ubuntu 系统下准备编译环境,安装编译所需软件包

$ sudo apt-get install build-essential libncurses5-dev bison flex texinfo zlib1g-dev gettext libssl-dev autoconf

buildroot 用 wget 下载软件包源码,因此需要安装 wget 

$ sudo apt-get install wget

Ubuntu 默认的 shell 是 dash,它跟 buildroot 的脚本有些不兼容。用下面的命令切换到 bash 

$ sudo dpkg-reconfigure dash

2. 下载 buildroot-2012.02,放在 HOME 目录

$ cd $ wget http://buildroot.net/downloads/buildroot-2012.02.tar.bz2 
$ tar jxf buildroot-2012.02.tar.bz2

3. 配置 buildroot

buildroot 采用了和 Linux 内核一样的配置工具,使用非常方便。

$ make menuconfig

to save the build time, please use the external toolchain

Toolchain -> Toolchain type (External toolchain) -> Toolchain (Sourcery CodeBench ARM 2011.03)

4. 编译 buildroot。这可能会花几个小时 这可能会花几个小时,取决于你的 Internet 带宽以及 CPU 性能 

$ make

编译好的软件包会放在 output/target 目录下,这个目录拥有根文件系统的目录结构。

5.最后生成的根文件系统在 /output/image 目录下


如果想要制作在目标平台运行的本机编译(Native Compile)工具链,则在 make menuconfig 时打开下面两个选项: 

1. Build options 子菜单下的 development files in target filesystem

2. Package Selection for the target 子菜单下的 native toolchain in the target filesystem


当然,为了能在目标平台上进行本机编译 还需要在配置时选择一些必要的编译工具以及程序库,如:make, autoconf, automake, bison, m4, flex, libz, libiconv 等等。
注:所谓本机编译(Native Compile) (Native Compile),是相对于交叉编译而言的。其实这是最常见的编译方式 其实这是最常见的编译方式,即在本机编译 程序用于在本机或与本机兼容的硬件平台上运行 于在本机或与本机兼容的硬件平台上运行。
补充: 

1. autoconf, automake 等软件包依赖于 microperl 软件包。在编译 microperl 时可能会遇到找不到 m4 的错误,这时只须执行 make host-m4 即可产生 buildroot_dir/output/host/usr/bin/m4, m4 ,然后再执行 make, 中断的编译将继续进行。 

2. 编译某些软件包需要 pkg-config for host config host(在编译平台上运行而非在目标平台上运行)

$ make host-pkgconfig

可编译产生 buil buildroot_dir/output/host/usr/bin/pkg-config



评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值