嵌入式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 ...
随机推荐
- metadata的使用以及简单的orm模式
使用sqllite3和metadata简单的封装了个简单的orm #!/usr/bim/python #-*-coding: utf-8 -*- import threading import sql ...
- 在JavaScript中获取Map集合中的key和value值(前提是:既不知道key为什么值,也不知道value有哪些值)
- CodeForces 556 --Case of Fake Numbers
B. Case of Fake Numbers time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- VMware搭建Oracle 11g RAC测试环境 For Linux
环境如下: Linux操作系统:Centos 6.5 64bit (这个版本的redhat 6内核等OS在安装grid最后执行root.sh时会出现crs-4124,是oracle11.2.0.1的b ...
- BZOJ3027 - [CEOI2004]Sweet
Portal Description 给出\(n(n\leq10),a,b(a,b\leq10^7)\)与\(\{c_n\}(c_i\leq10^6)\),求使得\(\sum_{i=1}^n x_i ...
- ubuntu使用git提交github时,执行pull或者push命令要重新输入用户名和密码
ubuntu使用git提交github时,执行pull或者push命令要重新输入用户名和密码: 1:问题现象: hlp@hlp:~/code/github_code/catch_imooc1$ git ...
- Error:Uninitialized object exists on backward branch 70 Exception Details:
网上下载了一个demo,编译出现如下错误: Gradle sync failed: Uninitialized object exists on backward branch 70 Exceptio ...
- Codeforces Round #297 (Div. 2) [ 折半 + 三进制状压 + map ]
传送门 E. Anya and Cubes time limit per test 2 seconds memory limit per test 256 megabytes input standa ...
- POJ 2391 多源多汇拆点最大流 +flody+二分答案
题意:在一图中,每个点有俩个属性:现在牛的数量和雨棚大小(下雨时能容纳牛的数量),每个点之间有距离, 给出牛(速度一样)在顶点之间移动所需时间,问最少时间内所有牛都能避雨. 模型分析:多源点去多汇点( ...
- 洛谷—— P2002 消息扩散
P2002 消息扩散 题目背景 本场比赛第一题,给个简单的吧,这 100 分先拿着. 题目描述 有n个城市,中间有单向道路连接,消息会沿着道路扩散,现在给出n个城市及其之间的道路,问至少需要在几个城市 ...