嵌入式Linux内核+根文件系统构建工具-Buildroot 快速入手指导【转】
本文转载自:https://my.oschina.net/freeblues/blog/596448
嵌入式Linux内核+根文件系统构建工具-Buildroot 快速入手指导
buildroot 是一款专门用来定制嵌入式 Linux 的内核和根文件系统(rootfs) 的开源工具, 非常强大兼方便, 不过对于新手来说, 过多的配置项明显有些难度, 本文的目标就是简要介绍这款工具, 让新手迅速入门.
目标:
- 1 新手需要了解的2个目录和1个文件
- 2 熟悉该工具的基本命令 ;
- 3 构建出一个内核和一个根文件系统
练习:
- 1 查看针对特定开发板的典型配置文件的选项
- 2 利用工具自带的配置文件生成一个 Linux 内核和根文件系统;
首先是获取该工具, 在 github 上, 命令如下:
git clone https://github.com/buildroot/buildroot
进入目录, 查看:
pi@rpi /opt/github/buildroot $ ls -al
total 420
drwxr-xr-x 15 root root 4096 Dec 24 21:18 .
drwxr-xr-x 73 git git 4096 Jan 3 08:01 ..
drwxr-xr-x 2 root root 4096 Dec 24 21:15 arch
drwxr-xr-x 25 root root 4096 Dec 24 21:15 board
drwxr-xr-x 15 root root 4096 Dec 24 21:15 boot
-rw-r--r-- 1 root root 146433 Dec 24 21:15 CHANGES
-rw-r--r-- 1 root root 44501 Dec 24 21:16 .config
-rw-r--r-- 1 root root 19111 Dec 24 21:15 Config.in
-rw-r--r-- 1 root root 42879 Dec 24 21:15 Config.in.legacy
drwxr-xr-x 2 root root 4096 Dec 24 21:15 configs
-rw-r--r-- 1 root root 17987 Dec 24 21:15 COPYING
-rw-r--r-- 1 root root 1246 Dec 24 21:15 .defconfig
drwxr-xr-x 5 root root 4096 Dec 24 21:15 docs
drwxr-xr-x 15 root root 4096 Dec 24 21:15 fs
drwxr-xr-x 8 root root 4096 Dec 24 21:18 .git
-rw-r--r-- 1 root root 125 Dec 24 21:15 .gitignore
drwxr-xr-x 2 root root 4096 Dec 24 21:15 linux
-rw-r--r-- 1 root root 34899 Dec 24 21:15 Makefile
-rw-r--r-- 1 root root 2432 Dec 2421:15 Makefile.legacy
drwxr-xr-x 3 root root 4096 Dec 24 21:18 output
drwxr-xr-x 1266 root root 36864 Dec 24 21:15 package
-rw-r--r-- 1 root root 972 Dec 2421:15 README
drwxr-xr-x 11 root root 4096 Dec 24 21:15 support
drwxr-xr-x 3 root root 4096 Dec 24 21:15 system
drwxr-xr-x 5 root root 4096 Dec 24 21:15 toolchain
pi@rpi /opt/github/buildroot $
1. 新手需要了解的2个目录和1个文件
先说目录:
- 目录1:
configs
一个是 configs 目录, 存放着工具提供的一些特定系统的构建配置, 换句话说就是一些使用比较广泛的 Linux 嵌入式系统的构建配置文件, 例如, 我们熟悉的树莓派1 raspberrypi_defconfig 和2 raspberrypi2_defconfig 的构建配置文件就在其中, 我们可以看一下内容:
pi@rpi /opt/github/buildroot $ ls ./configs
altera_sockit_defconfig calao_usb_a9g20_lpw_defconfig minnowboard_defconfig qemu_ppc_virtex_ml507_defconfig
armadeus_apf27_defconfig ci20_defconfig minnowboard_max_defconfig qemu_sh4_r2d_defconfig
armadeus_apf28_defconfig cubieboard2_defconfig mx53loco_defconfig qemu_sparc_ss10_defconfig
armadeus_apf51_defconfig cubieboard_defconfig nitrogen6x_defconfig qemu_x86_64_defconfig
armadeus_apf9328_defconfig freescale_imx28evk_defconfig olimex_imx233_olinuxino_defconfig qemu_x86_defconfig
arm_foundationv8_defconfig freescale_imx31_3stack_defconfig openblocks_a6_defconfig qemu_xtensa_lx60_defconfig
at91rm9200df_defconfig freescale_imx6dlsabreauto_defconfig pandaboard_defconfig qmx6_defconfig
at91sam9260dfc_defconfig freescale_imx6dlsabresd_defconfig qemu_aarch64_virt_defconfig raspberrypi2_defconfig
at91sam9260eknf_defconfig freescale_imx6qsabreauto_defconfig qemu_arm_nuri_defconfig raspberrypi_defconfig
at91sam9261ek_defconfig freescale_imx6qsabresd_defconfig qemu_arm_versatile_defconfig raspberrypi_dt_defconfig
at91sam9263ek_defconfig freescale_imx6sololiteevk_defconfig qemu_arm_vexpress_defconfig riotboard_defconfig
at91sam9g20dfc_defconfig freescale_mpc8315erdb_defconfig qemu_microblazebe_mmu_defconfig s6lx9_microboard_defconfig
at91sam9g45m10ek_defconfig freescale_p1010rdb_pa_defconfig qemu_microblazeel_mmu_defconfig sheevaplug_defconfig
atmel_xplained_defconfig freescale_p2020ds_defconfig qemu_mips64el_malta_defconfig telit_evk_pro3_defconfig
beaglebone_defconfig gnublin_defconfig qemu_mips64_malta_defconfig ts5x00_defconfig
calao_qil_a9260_defconfig integrator926_defconfig qemu_mipsel_malta_defconfig udoo_quad_defconfig
calao_snowball_defconfig kb9202_defconfig qemu_mips_malta_defconfig wandboard_defconfig
calao_tny_a9g20_lpw_defconfig lego_ev3_defconfig qemu_ppc64_pseries_defconfig zedboard_defconfig
calao_usb_a9260_defconfig loongson1c_smartloong_defconfig qemu_ppc_g3beige_defconfig
calao_usb_a9263_defconfig mini2440_defconfig qemu_ppc_mpc8544ds_defconfig
pi@rpi /opt/github/buildroot $
- 目录2:
output
另一个是 output 目录, 存放着你构建好之后的输出, 在 output/images/ 目录下放着构建好的内核和根文件系统, 我们可以在开始构建之前看看该目录的结构:
pi@rpi /opt/github/buildroot $ tree ./output
./output
└── build
└── buildroot-config
├── conf.o
├── lxdialog
│ ├── checklist.o
│ ├── inputbox.o
│ ├── menubox.o
│ ├── textbox.o
│ ├── util.o
│ └── yesno.o
├── mconf
├── mconf.o
├── zconf.hash.c
├── zconf.lex.c
└── zconf.tab.o
3 directories, 12 files
pi@rpi /opt/github/buildroot $
- 文件:
.config
一个文件就是 .config, 它就是构建时使用的配置文件, 举个例子, 如果我们打算使用工具自带的配置文件来构建树莓派2的内核和根文件系统, 那么首先把它从 configs 目录拷出来, 覆盖掉当前目录下的 .config 文件, 命令如下:
cp ./configs/ raspberrypi2_defconfig ./.config
讲解了简单的2个目录和1个文件, 接下来说一下基本命令
2. 熟悉该工具的基本命令
buildroot 基本的命令就是 make, 对于新手来说只需要执行2次:
- 第1次带参数执行用来定制系统: 定制系统的命令为:
make menuconfig
执行后会启动一个配置菜单, 进去之后可以根据你自己的需要增加或裁剪系统功能, 然后选择保存, 所有的配置会被保存为当前目录下的 .config 文件.
执行界面就是这个样子: 
也可以通过 load 选项加载工具自带的配置文件, 看看典型配置是什么样的.
- 第2次不带参数执行用来构建系统: 构建命令为:
make
会构建比较长的时间, 构建完成后可以查看刚才说过的 ./output/images/ 目录, 恰好我刚刚完成一次对龙芯智龙开源开发板的根文件系统构建, 我们可以看看:
git@debian:/opt/github/pengphai-buildroot$ ls -al ./output
总用量 28
drwxr-xr-x 6 git git 4096 8月 6 06:51 .
drwxr-xr-x 16 git git 4096 8月 6 06:51 ..
drwxr-xr-x 54 git git 4096 8月 6 07:36 build
drwxr-xr-x 5 git git 4096 8月 6 07:12 host
drwxr-xr-x 2 git git 4096 8月 6 07:36 images
lrwxrwxrwx 1 git git 81 8月 6 06:51 staging -> /opt/github/pengphai-buildroot/output/host/usr/mipsel-buildroot-linux-gnu/sysroot
drwxr-xr-x 19 git git 4096 8月 6 07:36 target
git@debian:/opt/github/pengphai-buildroot$ ls -al ./output/images
总用量 22956
drwxr-xr-x 2 git git 4096 8月 6 07:36 .
drwxr-xr-x 6 git git 4096 8月 6 06:51 ..
-rw------- 1 git git 23498112 8月 6 07:36 rootfs.yaffs2img
git@debian:/opt/github/pengphai-buildroot$
3. 构建出一个内核和一个根文件系统
命令很简单, 我们以树莓派2为例, 直接使用工具自带的配置文件, 命令如下:
pi@rpi /opt/github/buildroot $ sudo cp ./configs/raspberrypi2_defconfig ./config
pi@rpi /opt/github/buildroot $ sudo make
我是在树莓派2上执行的构建, 所以应该会有一个漫长的构建过程
===补充说明, 刚发现树莓派2的配置文件还有很多项没配置, 需要用户选择, 后续我写一个完全配置好的, 这个例子只会让新手疑惑
--结束
嵌入式Linux内核+根文件系统构建工具-Buildroot 快速入手指导【转】的更多相关文章
- linux 内核根文件系统
参考: http://blog.csdn.net/guopeixin/article/details/5962482 http://www.yunweipai.com/archives/1184.ht ...
- 小白自制Linux开发板 三. Linux内核与文件系统移植
上一篇完成了uboot的移植,但是想要愉快的在开发板上玩耍还需要移植Linux内核和文件系统. 1.Linux内核 事实上对于F1C100S/F1C200S,Linux官方源码已经对licheepi ...
- ubuntu下linux内核源码阅读工具和调试方法总结
http://blog.chinaunix.net/uid-20940095-id-66148.html 一 linux内核源码阅读工具 windows下当然首选source insight, 但是l ...
- 制作嵌入式linux内核
拿到一个嵌入式linux内核代码,首先make distclean 接下来,如果在x86平台,就直接make menuconfig,如果是在ARM平台,就直接make menuconfig ARCH= ...
- 嵌入式linux内核制作、根文件系统制作
嵌入式系统构成: 主要由bootloader.kernel.以及根文件系统三部分组成. 内核制作步骤: 制作嵌入式平台使用的linux内核制作方法与pc平台上的linux内核基本一致 1.清除原有配置 ...
- Linux之根文件系统的构建20160611
说一下LINUX根文件系统的构建: 制作文件系统 1. 交叉编译busybox 安装:make install CONFIG_PREFIX=/work/nfs_root/fs_mini_mdev_ne ...
- ARM-Linux移植之(四)——根文件系统构建
相关工具版本: busybox-1.7.0 arm-linux-4.3.2 linux-2.6.22 1.配置busybox并安装. 在我们的根文件系统中的/bin和/sbin目录下有各种命令的应 ...
- Linux内核,文件系统移植过程中出现的一些问题与解决办法
1.bootm地址和load address一样 此种情况下,bootm不会对uImage header后的zImage进行memory move的动作,而会直接go到entry point开始执行. ...
- 用SD卡下载uboot、linux内核和文件系统
1. 移植mtd-utils: a) 下载utd-utils 下载地址为ftp://ftp.infradead.org/pub/mtd-utils/b) 交叉编译mtd-utilsi 修改Make ...
随机推荐
- tiles介绍
主要目的是为了将复数的jsp页面作为一个的页面的部分机能,然后用来组合成一个最终表示用页面用的,这样的话,便于对页面的各个机能的变更及维护. Tiles使得struts在页面的处理方面多了一种选择.并 ...
- luogu3168 [CQOI2015]任务查询系统
树状数组不用动脑子真爽啊 #include <algorithm> #include <iostream> #include <cstdio> using name ...
- 大数据学习——linux常用命令(一)
一.基本日常操作命令 1 查看当前所在工作目录的全路径 pwd 2 查看当前系统的时间 date 设置时间,date -s"2018-11-12" 修改时间后,需要写入硬件bios ...
- CLR Via CSharp读书笔记(26) - 计算限制的异步操作
执行上下文: 执行上下文包括安全设置(压缩栈.Thread的Principal属性和Windows身份),宿主设置(System.Threading.HostExecutionContextManag ...
- react.js 给标识ref,获取内容
import React,{Component} from 'react' import ReactDOM from 'react-dom' class App extends Component{ ...
- linux date 格式化时间和日期
[root@108test ~]# date -d today +"%Y-%m-%d" 2008-05-07 [root@108test ~]# date -d today + ...
- 洛谷——P2434 [SDOI2005]区间
P2434 [SDOI2005]区间 题目描述 现给定n个闭区间[ai, bi],1<=i<=n.这些区间的并可以表示为一些不相交的闭区间的并.你的任务就是在这些表示方式中找出包含最少区间 ...
- Java简单实验--关于课后提到的java重载函数的简单分析
根据这一小段代码,获得了以下的测试截图: 简单分析:根据输出结果,判断这段代码用到了两个不同的函数方法,输出的不止有double类型的数,还有整型的数. 又根据类中的定义情况,square是根据判断传 ...
- SSH移植
1. 下载需要的源码,直接google最新的版本吧 mkdir -p ~/arm/fs ;mkdir -p ~/arm/source 下载zlib: zlib-1.2.3.tar.gz 下载ssl : ...
- JavaScript 中 for 循环
在ECMAScript5(简称 ES5)中,有三种 for 循环,分别是: 简单for循环 for-in forEach 在2015年6月份发布的ECMAScript6(简称 ES6)中,新增了一种循 ...