buildroot构建根文件系统

注:跟随笔完全跟随正点原子buildroot构建根文件系统操作
 
buildroot官网:https://buildroot.org/
 

buildroot基本概念:

busybox 仅仅只是帮我们构建好了一些常用的命令和文件,像 lib 库、/etc 目录下的一些文件都需要我们自己手动创建,而且 busybox 构建的根文件系统默认没有用户名和密码设置。在后续的实验中,我
们还要自己去移植一些第三方软件和库,比如 alsa、iperf、mplayer 等等。buildroot不仅仅包含了 busybox 的功能,而且里面还集成了各种软件,需要什么软件就选择什么软件,不需要我们去移植。
 

buildroot根文件系统构建:

1、官网下载buildroot源码并解压

见buildroot官网

 

2、配置buildroot

2.1 配置 Target options

Target options
    -> Target Architecture             = ARM (little endian) 
    -> Target Binary Format             = ELF
    -> Target Architecture Variant     = cortex-A7
    -> Target ABI                     = EABIhf
    -> Floating point strategy         = NEON/VFPv4
    -> ARM instruction set             = ARM

 

2.2 配置Toolchain

Toolchain
    -> Toolchain type = External toolchain
    -> Toolchain = Custom toolchain //用户自己的交叉编译器
    -> Toolchain origin = Pre-installed toolchain //预装的编译器
    -> Toolchain path =/usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf 
    -> Toolchain prefix = $(ARCH)-linux-gnueabihf //前缀
    -> External toolchain gcc version = 4.9.x
    -> External toolchain kernel headers series = 4.1.x
    -> External toolchain C library = glibc/eglibc 
    -> [*] Toolchain has SSP support? (NEW) //选中
    -> [*] Toolchain has RPC support? (NEW) //选中
    -> [*] Toolchain has C++ support? //选中
    -> [*] Enable MMU support (NEW) //选中
Toolchain 下几个比较重要的选项需要说明一下,如下所示:
Toolchain:设置为 Custom toolchain,表示使用用户自己的交叉编译器。
Toolchain origin:设置为 Pre-installed toolchain,表示使用预装的交叉编译器。
Toolchain path:设置自己安装的交叉编译器绝对路径!buildroot 要用到。
Toolchain prefix:设置交叉编译器前缀,要根据自己实际所使用的交叉编译器来设置,比
如我们使用的是 arm-linux-gnueabihf-gcc,因此前缀就是$(ARCH)-linux-gnueabihf,其中 ARCH我们前面已经设置为了 arm。
 

2.3、配置 System configuration

此选项用于设置一些系统配置,比如开发板名字、欢迎语、用户名、密码等。需要配置的项目和其对应的内容如下:
System configuration
    -> System hostname = lethe //平台名字,自行设置
    -> System banner = Welcome to buildroot //欢迎语
    -> Init system = BusyBox //使用 busybox
    -> /dev management = Dynamic using devtmpfs + mdev //使用 mdev
    -> [*] Enable root login with password (NEW) //使能登录密码
    -> Root password = 123456 //登录密码为 123456
在 System configuration 选项中可以配置平台名字,登录密码等信息。
 

2.4、配置 Filesystem images

此选项配置我们最终制作的根文件系统为什么格式的,配置如下:
-> Filesystem images
    -> [*] ext2/3/4 root filesystem         //如果是 EMMC 或 SD 卡的话就用 ext3/ext4
        -> ext2/3/4 variant     = ext4     //选择 ext4 格式

 

2.5、禁止编译 Linux 内核和 uboot

buildroot 不仅仅能构建根文件系统,也可以编译 linux 内核和 uboot。当配置 buildroot,使能 linux 内核和 uboot 以后 buildroot 就会自动下载最新的 linux 内核和 uboot 源码并编译。但是我们一般都不会使用 buildroot 下载的 linux 内核和 uboot,因为 buildroot 下载的 linux 和 uboot官方源码,里面会缺少很多驱动文件,而且最新的 linux 内核和 uboot 会对编译器版本号有要求,可能导致编译失败。因此我们需要配置 buildroot,关闭 linux 内核和 uboot 的编译,只使用buildroot 来构建根文件系统,首先是禁止 Linux 内核的编译,配置如下:
-> Kernel 
    -> [ ] Linux Kernel     //不要选择编译 Linux Kernel 选项!
-> Bootloaders 
    -> [ ] U-Boot             //不要选择编译 U-Boot 选项!

 

2.6、配置 Target packages

此选项用于配置要选择的第三方库或软件、比如 alsa-utils、ffmpeg、iperf 等工具
 

3、编译buildroot和解决编译问题

sudo make   //注意,一定要加 sudo,而且不能通过-jx 来指定多核编译!!!
编译问题可见本篇的参考
buildroot编译生成的rootfs,tar在output/images目录下,如下图:
0
 

4、根文件系统初步测试

和uboot、zImage、dtb、roofs启动系统正常
0
 
posted @ 2024-03-23 01:40  lethe1203  阅读(96)  评论(0编辑  收藏  举报