树莓派0,用buildroot构建、编译属于自己的image!
- 下载buildroot
官网下载buildroot:https://buildroot.org/download.html,解压后文件:
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1$ ls -l
总用量 808
drwxrwxr-x 2 eric eric 4096 4月 11 04:42 arch
drwxrwxr-x 60 eric eric 4096 4月 11 04:42 board
drwxrwxr-x 22 eric eric 4096 4月 11 04:42 boot
-rw-rw-r-- 1 eric eric 361963 4月 11 04:42 CHANGES
-rw-rw-r-- 1 eric eric 27824 4月 11 04:42 Config.in
-rw-rw-r-- 1 eric eric 149872 4月 11 04:42 Config.in.legacy
drwxrwxr-x 2 eric eric 16384 4月 11 04:42 configs
-rw-rw-r-- 1 eric eric 18767 4月 11 04:42 COPYING
-rw-rw-r-- 1 eric eric 63617 4月 11 04:42 DEVELOPERS
drwxr-xr-x 5 eric eric 4096 4月 11 04:44 docs
drwxrwxr-x 18 eric eric 4096 4月 11 04:42 fs
drwxrwxr-x 2 eric eric 4096 4月 11 04:42 linux
-rw-rw-r-- 1 eric eric 44854 4月 11 04:42 Makefile
-rw-rw-r-- 1 eric eric 2292 4月 11 04:42 Makefile.legacy
drwxr-xr-x 6 eric eric 4096 4月 23 13:59 output
drwxrwxr-x 2334 eric eric 69632 4月 23 11:00 package
-rw-rw-r-- 1 eric eric 1079 4月 11 04:42 README
drwxrwxr-x 13 eric eric 4096 4月 11 04:42 support
drwxrwxr-x 3 eric eric 4096 4月 11 04:42 system
drwxrwxr-x 5 eric eric 4096 4月 11 04:42 toolchain
drwxrwxr-x 3 eric eric 4096 4月 11 04:42 utils
- 设置配置文件
configs目录下放置默认支持的板卡配置,查看树莓派的相关配置:
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1/configs$ ls rasp* -l
-rw-rw-r-- 1 eric eric 1159 4月 11 04:42 raspberrypi0_defconfig
-rw-rw-r-- 1 eric eric 1036 4月 11 04:42 raspberrypi0w_defconfig
-rw-rw-r-- 1 eric eric 1123 4月 11 04:42 raspberrypi2_defconfig
-rw-rw-r-- 1 eric eric 1222 4月 11 04:42 raspberrypi3_64_defconfig
-rw-rw-r-- 1 eric eric 1141 4月 11 04:42 raspberrypi3_defconfig
-rw-rw-r-- 1 eric eric 1558 4月 11 04:42 raspberrypi3_qt5we_defconfig
-rw-rw-r-- 1 eric eric 1206 4月 11 04:42 raspberrypi4_64_defconfig
-rw-rw-r-- 1 eric eric 1143 4月 11 04:42 raspberrypi4_defconfig
-rw-rw-r-- 1 eric eric 1165 4月 11 04:42 raspberrypi_defconfig
- 顶层目录,选择raspberrypi0_defconfig
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1$ make raspberrypi0_defconfig
#
# configuration written to /home/eric/Documents/work/linux-c/buildroot-2020.02.1/.config
#
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1$
- 查看menuconfig:
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1$ make menuconfig
/home/eric/Documents/work/linux-c/buildroot-2020.02.1/.config - Buildroot 2020.02.1 Configuration
──────────────────────────────────────────────────────────────────────────────────────────────────
┌───────────────────────────── Buildroot 2020.02.1 Configuration ─────────────────────────────┐
│ Arrow keys navigate the menu. <Enter> selects submenus ---> (or empty submenus ----). │
│ Highlighted letters are hotkeys. Pressing <Y> selects a feature, while <N> excludes a │
│ feature. Press <Esc><Esc> to exit, <?> for Help, </> for Search. Legend: [*] feature is │
│ selected [ ] feature is excluded │
│ ┌─────────────────────────────────────────────────────────────────────────────────────────┐ │
│ │ Target options ---> │ │
│ │ Build options ---> │ │
│ │ Toolchain ---> │ │
│ │ System configuration ---> │ │
│ │ Kernel ---> │ │
│ │ Target packages ---> │ │
│ │ Filesystem images ---> │ │
│ │ Bootloaders ---> │ │
│ │ Host utilities ---> │ │
│ │ Legacy config options ---> │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────────────────────────┘ │
├─────────────────────────────────────────────────────────────────────────────────────────────┤
│ <Select> < Exit > < Help > < Save > < Load > │
└─────────────────────────────────────────────────────────────────────────────────────────────┘
以上配置,已经加载了默认raspberrypi0_defconfig,无需做修改,直接使用。
- 编译 make
首次make过程比较耗时,,期间会下载依赖的插件包,在dl目录下。
编译完成后,output目录下会生成如下文件
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1$ cd output/
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1/output$ ls -l
总用量 20
drwxr-xr-x 51 eric eric 4096 4月 23 14:31 build
drwxr-xr-x 10 eric eric 4096 4月 23 11:47 host
drwxr-xr-x 3 eric eric 4096 4月 23 14:31 images
lrwxrwxrwx 1 eric eric 109 4月 23 14:31 staging -> /home/eric/Documents/work/linux-c/buildroot-2020.02.1/output/host/arm-buildroot-linux-uclibcgnueabihf/sysroot
drwxr-xr-x 17 eric eric 4096 4月 23 12:07 target
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1/output$
- images目录下,可以看到树莓派0的sdcard.image,以及对应的设备树二进制文件bcm2708-rpi-zero.dtb
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1/output$ cd images/
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1/output/images$ ls -l
总用量 145364
-rw-r--r-- 1 eric eric 23643 4月 23 12:26 bcm2708-rpi-zero.dtb
-rw-r--r-- 1 eric eric 33554432 4月 23 14:31 boot.vfat
-rw-r--r-- 1 eric eric 125829120 4月 23 14:31 rootfs.ext2
lrwxrwxrwx 1 eric eric 11 4月 23 14:31 rootfs.ext4 -> rootfs.ext2
drwxr-xr-x 3 eric eric 4096 4月 23 12:08 rpi-firmware
-rw-r--r-- 1 eric eric 159384064 4月 23 14:31 sdcard.img
-rw-r--r-- 1 eric eric 5121800 4月 23 12:26 zImage
eric@eric-PC:~/Documents/work/linux-c/buildroot-2020.02.1/output/images$