一、参考

Buildroot笔记 | hceng blog

二、概述

BuildrootLinux 平台上一个构建嵌入式 Linux 系统的框架。

整个 Buildroot是由 Makefile(*.mk) 脚本和 Kconfig(Config.in) 配置文件构成的,因此可以像配置 Linux 内核一样执行make menuconfig进行配置,编译出一个完整的、可以直接烧写到机器上运行的 Linux 系统文件(包含 bootloaderkernelrootfs 以及 rootfs 中的各种库和应用程序)。

构建大致流程如下:

  • 获取:获取源代码
  • 解压:解压源代码
  • 补丁:针对缺陷修复和增加的功能应用补丁
  • 配置:根据环境准备构建过程
  • 安装:复制二进制和辅助文件到它们的目标目录
  • 打包:为在其它系统上安装而打包二进制和辅助文件

三、源码下载

官网:Buildroot - Making Embedded Linux Easy

1、下载源码

onlylove@ubuntu:~/my/buildroot$ pwd
/home/onlylove/my/buildroot
onlylove@ubuntu:~/my/buildroot$ ls
buildroot-2022.08.tar.gz
onlylove@ubuntu:~/my/buildroot$

2、解压

tar -zxf buildroot-2022.08.tar.gz 
onlylove@ubuntu:~/my/buildroot$ pwd
/home/onlylove/my/buildroot
onlylove@ubuntu:~/my/buildroot$ ls
buildroot-2022.08.tar.gz
onlylove@ubuntu:~/my/buildroot$ tar -zxf buildroot-2022.08.tar.gz 
onlylove@ubuntu:~/my/buildroot$ ls 
buildroot-2022.08  buildroot-2022.08.tar.gz
onlylove@ubuntu:~/my/buildroot$

四、buildroot目录结构

onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ pwd
/home/onlylove/my/buildroot/buildroot-2022.08
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ ls
arch   boot     Config.in         configs  DEVELOPERS  fs     Makefile         package  support  toolchain
board  CHANGES  Config.in.legacy  COPYING  docs        linux  Makefile.legacy  README   system   utils
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

五、编译依赖安装

通过官方参考手册确定依赖包。

必须要安装的工具命令如下:

sudo apt install sed make binutils build-essential gcc g++ patch gzip bzip2 perl tar cpio unzip rsync file bc wget

可选安装的工具命令如下:

sudo apt install wget python libncurses5 bzr cvs git mercurial rsync subversion

六、配置buildroot

imx6ull 为例进行配置。

1、设置 imx6ull 默认配置

make imx6ullevk_defconfig
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ make ARCH=arm imx6ullevk_defconfig
mkdir -p /home/onlylove/my/buildroot/buildroot-2022.08/output/build/buildroot-config/lxdialog
PKG_CONFIG_PATH="" make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" \
    obj=/home/onlylove/my/buildroot/buildroot-2022.08/output/build/buildroot-config -C support/kconfig -f Makefile.br conf
/usr/bin/gcc -D_DEFAULT_SOURCE -D_XOPEN_SOURCE=600 -DCURSES_LOC="<ncurses.h>" -DNCURSES_WIDECHAR=1 -DLOCALE  -I/home/onlylove/my/buildroot/buildroot-2022.08/output/build/buildroot-config -DCONFIG_=\"\"   /home/onlylove/my/buildroot/buildroot-2022.08/output/build/buildroot-config/conf.o /home/onlylove/my/buildroot/buildroot-2022.08/output/build/buildroot-config/zconf.tab.o  -o /home/onlylove/my/buildroot/buildroot-2022.08/output/build/buildroot-config/conf
#
# configuration written to /home/onlylove/my/buildroot/buildroot-2022.08/.config
#
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

2、配置 buildroot

make menuconfig

Linux 驱动开发 五十六:Buildroot 笔记-LMLPHP

1、Target options 配置项

Linux 驱动开发 五十六:Buildroot 笔记-LMLPHP

2、Toolchain 配置

Toolchain
	Toolchain type:External toolchain
	Toolchain:Custom toolchain(使用自己编译工具链)
	Toolchain origin:Pre-installed toolchain(使用预装工具链)
	Toolchain path:/home/onlylove/my/gcc/gcc-linaro-4.9.4(编译工具链的绝对路径)
	Toolchain prefix:arm-linux-gnueabihf(设置编译器前缀)

3、Build options

Build options
	

注:不修改。

4、System configuration

System configuration
	System hostname:imx6ull(平台名字)
	System banner:Welcome to imx6ull(欢迎语)
	Init system:BusyBox
	/dev management:Dynamic using devtmpfs + mdev
	[*] Enable root login with password:使用登录密码
		Root password:123456(默认登录密码为 123456

5、Kernel

Kernel
	[ ] Linux Kernel

注:去掉内核编译。

6、Target packages

Target packages
	

注:不修改。

7、Filesystem images

Filesystem images
	

注:不修改。

8、Bootloaders

Bootloaders
	[ ] U-Boot

注:去掉 uboot 编译。

9、Host utilities

Host utilities
	

注:不修改。

10、Legacy config options

Legacy config options
	

注:不修改。

七、编译

make -j4
# 编译前
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ ls
arch   boot     Config.in         configs  DEVELOPERS  fs     Makefile         package  support  toolchain
board  CHANGES  Config.in.legacy  COPYING  docs        linux  Makefile.legacy  README   system   utils
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$
# 编译后
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ ls
arch   boot     Config.in         configs  DEVELOPERS  docs  linux     Makefile.legacy  package  support  toolchain
board  CHANGES  Config.in.legacy  COPYING  dl          fs    Makefile  output           README   system   utils
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ cd output/
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/output$ ls
build  host  images  staging  target
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/output$ cd images/
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/output/images$ ls
rootfs.ext2  rootfs.ext4  rootfs.tar
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/output/images$ cd ..
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/output$ cd ..
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ cd dl/
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/dl$ ls
acl   autoconf  bison    dosfstools  e2fsprogs  flex      gettext-tiny  libconfuse  libzlib  m4      patchelf  util-linux
attr  automake  busybox  dtc         fakeroot   genimage  kmod          libtool     lzip     mtools  pkgconf
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/dl$ cd kmod/
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/dl/kmod$ ls
kmod-29.tar.xz
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08/dl/kmod$

编译完成后,buildroot 目录下会生成 dloutput 目录。

dl:保存下载的一些源码包。

output:保存编译生成的输出文件。

八、测试

U-Boot 2016.03 (Aug 20 2022 - 00:46:14 -0700)

CPU:   Freescale i.MX6ULL rev1.1 69 MHz (running at 396 MHz)
CPU:   Industrial temperature grade (-40C to 105C) at 43C
Reset cause: POR
Board: MX6ULL ALIENTEK EMMC
I2C:   ready
DRAM:  512 MiB
MMC:   FSL_SDHC: 0, FSL_SDHC: 1
unsupported panel ATK-LCD-7-1024x600
In:    serial
Out:   serial
Err:   serial
switch to partitions #0, OK
mmc0 is current device
Net:   FEC1
Normal Boot
Hit any key to stop autoboot:  0
FEC1 Waiting for PHY auto negotiation to complete.... done
Using FEC1 device
TFTP from server 192.168.6.129; our IP address is 192.168.6.20
Filename 'zImage'.
Load address: 0x80800000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #############
         2.3 MiB/s
done
Bytes transferred = 5901744 (5a0db0 hex)
Using FEC1 device
TFTP from server 192.168.6.129; our IP address is 192.168.6.20
Filename 'imx6ull-alientek-emmc.dtb'.
Load address: 0x83000000
Loading: ###
         2.5 MiB/s
done
Bytes transferred = 38884 (97e4 hex)
Kernel image @ 0x80800000 [ 0x000000 - 0x5a0db0 ]
## Flattened Device Tree blob at 83000000
   Booting using the fdt blob at 0x83000000
   Using Device Tree in place at 83000000, end 8300c7e3

Starting kernel ...

Booting Linux on physical CPU 0x0
Linux version 4.1.15 (onlylove@ubuntu) (gcc version 4.9.4 (Linaro GCC 4.9-2017.01) ) #1 SMP PREEMPT Sat Sep 17 04:04:04 PDT 2022
CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache
Machine model: Freescale i.MX6 ULL 14x14 EVK Board
Reserved memory: created CMA memory pool at 0x8c000000, size 320 MiB
Reserved memory: initialized node linux,cma, compatible id shared-dma-pool
Memory policy: Data cache writealloc
PERCPU: Embedded 12 pages/cpu @8bb30000 s16768 r8192 d24192 u49152
Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 130048
Kernel command line: console=ttymxc0,115200 kgdboc=ttymxc0,115200 root=/dev/nfs nfsroot=192.168.6.129:/home/onlylove/my/nfs,proto=tcp,nfsvers=4 rw ip=192.168.6.200:192.168.6.129:192.168.6.2:255.255.255.0::eth0:off
PID hash table entries: 2048 (order: 1, 8192 bytes)
Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
Memory: 180224K/524288K available (7300K kernel code, 333K rwdata, 2524K rodata, 404K init, 439K bss, 16384K reserved, 327680K cma-reserved, 0K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xa0800000 - 0xff000000   (1512 MB)
    lowmem  : 0x80000000 - 0xa0000000   ( 512 MB)
    pkmap   : 0x7fe00000 - 0x80000000   (   2 MB)
    modules : 0x7f000000 - 0x7fe00000   (  14 MB)
      .text : 0x80008000 - 0x809a0308   (9825 kB)
      .init : 0x809a1000 - 0x80a06000   ( 404 kB)
      .data : 0x80a06000 - 0x80a595e0   ( 334 kB)
       .bss : 0x80a5c000 - 0x80ac9fc4   ( 440 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
Preemptible hierarchical RCU implementation.
        Additional per-CPU info printed with stalls.
        RCU restricting CPUs from NR_CPUS=4 to nr_cpu_ids=1.
RCU: Adjusting geometry for rcu_fanout_leaf=16, nr_cpu_ids=1
NR_IRQS:16 nr_irqs:16 16
mxc_clocksource_init 3000000
Switching to timer-based delay loop, resolution 333ns
sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 715827882841ns
clocksource mxc_timer1: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 637086815595 ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 6.00 BogoMIPS (lpj=30000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
CPU: Testing write buffer coherency: ok
/cpus/cpu@0 missing clock-frequency property
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x80008280 - 0x800082f0
Brought up 1 CPUs
SMP: Total of 1 processors activated (6.00 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
device-tree: Duplicate name in lcdif@021c8000, renamed to "display#1"
VFP support v0.3: implementor 41 architecture 2 part 30 variant 7 rev 5
clocksource jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor ladder
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 8 bytes.
imx6ul-pinctrl 20e0000.iomuxc: Invalid fsl,pins property in node /soc/aips-bus@02000000/iomuxc@020e0000/imx6ul-evk/flexcan2grp
imx6ul-pinctrl 20e0000.iomuxc: Invalid fsl,pins property in node /soc/aips-bus@02000000/iomuxc@020e0000/imx6ul-evk/uart2dtegrp
imx6ul-pinctrl 20e0000.iomuxc: initialized IMX pinctrl driver
imx6ul-pinctrl 2290000.iomuxc-snvs: Invalid fsl,pins property in node /soc/aips-bus@02200000/iomuxc-snvs@02290000/imx6ul-evk/lcdifresetgrp
imx6ul-pinctrl 2290000.iomuxc-snvs: initialized IMX pinctrl driver
mxs-dma 1804000.dma-apbh: initialized
SCSI subsystem initialized
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
i2c i2c-0: IMX I2C adapter registered
i2c i2c-0: can't use DMA
i2c i2c-1: IMX I2C adapter registered
i2c i2c-1: can't use DMA
Linux video capture interface: v2.00
pps_core: LinuxPPS API ver. 1 registered
pps_core: Software ver. 5.3.6 - Copyright 2005-2007 Rodolfo Giometti <giometti@linux.it>
PTP clock support registered
Advanced Linux Sound Architecture Driver Initialized.
Switched to clocksource mxc_timer1
NET: Registered protocol family 2
TCP established hash table entries: 4096 (order: 2, 16384 bytes)
TCP bind hash table entries: 4096 (order: 3, 32768 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
UDP hash table entries: 256 (order: 1, 8192 bytes)
UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
imx rpmsg driver is registered.
Bus freq driver module loaded
futex hash table entries: 256 (order: 2, 16384 bytes)
VFS: Disk quotas dquot_6.6.0
VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
jffs2: version 2.2. (NAND) © 2001-2006 Red Hat, Inc.
fuse init (API version 7.23)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
imx-weim 21b8000.weim: Driver registered.
backlight supply power not found, using dummy regulator
21c8000.lcdif supply lcd not found, using dummy regulator
mxsfb 21c8000.lcdif: failed to find mxc display driver
Console: switching to colour frame buffer device 128x37
mxsfb 21c8000.lcdif: initialized
imx-sdma 20ec000.sdma: no event needs to be remapped
imx-sdma 20ec000.sdma: loaded firmware 3.3
imx-sdma 20ec000.sdma: initialized
2020000.serial: ttymxc0 at MMIO 0x2020000 (irq = 19, base_baud = 5000000) is a IMX
console [ttymxc0] enabled
21ec000.serial: ttymxc2 at MMIO 0x21ec000 (irq = 233, base_baud = 5000000) is a IMX
imx sema4 driver is registered.
[drm] Initialized drm 1.1.0 20060810
[drm] Initialized vivante 1.0.0 20120216 on minor 0
brd: module loaded
loop: module loaded
fsl-quadspi 21e0000.qspi: unrecognized JEDEC id bytes: ff, ff, ff
fsl-quadspi 21e0000.qspi: Freescale QuadSPI probe failed
spi_imx 2010000.ecspi: probed
CAN device driver interface
flexcan 2090000.can: device registered (reg_base=a09e8000, irq=25)
20b4000.ethernet supply phy not found, using dummy regulator
pps pps0: new PPS source ptp0
libphy: fec_enet_mii_bus: probed
fec 20b4000.ethernet eth0: registered PHC device 0
2188000.ethernet supply phy not found, using dummy regulator
pps pps1: new PPS source ptp1
fec 2188000.ethernet eth1: registered PHC device 1
PPP generic driver version 2.4.2
PPP BSD Compression module registered
PPP Deflate Compression module registered
PPP MPPE Compression module registered
NET: Registered protocol family 24
usbcore: registered new interface driver rtl8187
usbcore: registered new interface driver rndis_wlan
usbcore: registered new interface driver r8152
usbcore: registered new interface driver asix
usbcore: registered new interface driver ax88179_178a
usbcore: registered new interface driver cdc_ether
usbcore: registered new interface driver net1080
usbcore: registered new interface driver rndis_host
usbcore: registered new interface driver cdc_subset
usbcore: registered new interface driver zaurus
usbcore: registered new interface driver cdc_ncm
GobiNet: Quectel_WCDMA&LTE_Linux&Android_GobiNet_Driver_V1.3.0
usbcore: registered new interface driver GobiNet
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-mxc: Freescale On-Chip EHCI Host driver
ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
usbcore: registered new interface driver usb-storage
usbcore: registered new interface driver usbserial
usbcore: registered new interface driver option
usbserial: USB Serial support registered for GSM modem (1-port)
2184800.usbmisc supply vbus-wakeup not found, using dummy regulator
2184000.usb supply vbus not found, using dummy regulator
ci_hdrc ci_hdrc.0: EHCI Host Controller
ci_hdrc ci_hdrc.0: new USB bus registered, assigned bus number 1
ci_hdrc ci_hdrc.0: USB 2.0 started, EHCI 1.00
hub 1-0:1.0: USB hub found
hub 1-0:1.0: 1 port detected
2184200.usb supply vbus not found, using dummy regulator
ci_hdrc ci_hdrc.1: EHCI Host Controller
ci_hdrc ci_hdrc.1: new USB bus registered, assigned bus number 2
ci_hdrc ci_hdrc.1: USB 2.0 started, EHCI 1.00
hub 2-0:1.0: USB hub found
hub 2-0:1.0: 1 port detected
mousedev: PS/2 mouse device common for all mice
input: 20cc000.snvs:snvs-powerkey as /devices/platform/soc/2000000.aips-bus/20cc000.snvs/20cc000.snvs:snvs-powerkey/input/input0
usbcore: registered new interface driver xpad
usb 2-1: new high-speed USB device number 2 using ci_hdrc
input: EP0820M09 as /devices/platform/soc/2100000.aips-bus/21a4000.i2c/i2c-1/1-0038/input/input1
snvs_rtc 20cc000.snvs:snvs-rtc-lp: rtc core: registered 20cc000.snvs:snvs-r as rtc0
i2c /dev entries driver
IR NEC protocol handler initialized
IR RC5(x/sz) protocol handler initialized
IR RC6 protocol handler initialized
IR JVC protocol handler initialized
IR Sony protocol handler initialized
IR SANYO protocol handler initialized
IR Sharp protocol handler initialized
IR MCE Keyboard/mouse protocol handler initialized
IR XMP protocol handler initialized
pxp-v4l2 pxp_v4l2: initialized
imx2-wdt 20bc000.wdog: use WDOG_B to reboot.
imx2-wdt 20bc000.wdog: timeout 60 sec (nowayout=0)
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
/soc/aips-bus@02100000/usdhc@02190000: voltage-ranges unspecified
sdhci-esdhc-imx 2190000.usdhc: Got CD GPIO
sdhci-esdhc-imx 2190000.usdhc: No vqmmc regulator found
hub 2-1:1.0: USB hub found
hub 2-1:1.0: 4 ports detected
mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA
/soc/aips-bus@02100000/usdhc@02194000: voltage-ranges unspecified
sdhci-esdhc-imx 2194000.usdhc: No vmmc regulator found
sdhci-esdhc-imx 2194000.usdhc: No vqmmc regulator found
mmc0: host does not support reading read-only switch, assuming write-enable
mmc1: SDHCI controller on 2194000.usdhc [2194000.usdhc] using ADMA
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
mmc0: new high speed SDHC card at address aaaa
mmcblk0: mmc0:aaaa SC16G 14.8 GiB
 mmcblk0: p1
fsl-asrc 2034000.asrc: driver registered
imx-wm8960 sound: wm8960-hifi <-> 202c000.sai mapping ok
imx-wm8960 sound: snd-soc-dummy-dai <-> 2034000.asrc mapping ok
imx-wm8960 sound: wm8960-hifi <-> 202c000.sai mapping ok
mmc1: MAN_BKOPS_EN bit is not set
NET: Registered protocol family 10
mmc1: new HS200 MMC card at address 0001
mmcblk1: mmc1:0001 8GTF4R 7.28 GiB
sit: IPv6 over IPv4 tunneling driver
NET: Registered protocol family 17
can: controller area network core (rev 20120528 abi 9)
mmcblk1boot0: mmc1:0001 8GTF4R partition 1 4.00 MiB
mmcblk1boot1: mmc1:0001 8GTF4R partition 2 4.00 MiB
mmcblk1rpmb: mmc1:0001 8GTF4R partition 3 512 KiB
NET: Registered protocol family 29
can: raw protocol (rev 20120528)
 mmcblk1: p1 p2
can: broadcast manager protocol (rev 20120528 t)
can: netlink gateway (rev 20130117) max_hops=1
lib80211: common routines for IEEE802.11 drivers
Key type dns_resolver registered
Registering SWP/SWPB emulation handler
snvs_rtc 20cc000.snvs:snvs-rtc-lp: setting system clock to 1970-01-01 00:06:20 UTC (380)
fec 20b4000.ethernet eth0: Freescale FEC PHY driver [SMSC LAN8710/LAN8720] (mii_bus:phy_addr=20b4000.ethernet:01, irq=-1)
IPv6: ADDRCONF(NETDEV_UP): eth0: link is not ready
fec 20b4000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
IP-Config: Complete:
     device=eth0, hwaddr=b8:ae:1d:01:00:00, ipaddr=192.168.6.200, mask=255.255.255.0, gw=192.168.6.2
     host=192.168.6.200, domain=, nis-domain=(none)
     bootserver=192.168.6.129, rootserver=192.168.6.129, rootpath=
gpio_dvfs: disabling
can-3v3: disabling
ALSA device list:
  #0: wm8960-audio
VFS: Mounted root (nfs4 filesystem) on device 0:15.
devtmpfs: mounted
Freeing unused kernel memory: 404K (809a1000 - 80a06000)
devpts: called with bogus options
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Starting mdev... OK
modprobe: can't change directory to '/lib/modules': No such file or directory
Initializing random number generator: OK
Saving random seed: random: dd urandom read with 62 bits of entropy available
OK
Starting network: ip: RTNETLINK answers: File exists
FAIL

Welcome to imx6ull
imx6ull login: root
Password:
# ls
# cd /
# ls
bin      lib      media    proc     sbin     usr
dev      lib32    mnt      root     sys      var
etc      linuxrc  opt      run      tmp
#

通过日志中 Welcome to imx6ull 可以确定 rootfs 制作成功。

九、异常处理

1、异常一

onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ make -j4
>>> toolchain-external-custom  Configuring
Incorrect selection of kernel headers: expected 2.6.x, got 4.0.x
make[1]: *** [package/pkg-generic.mk:283: /home/onlylove/my/buildroot/buildroot-2022.08/output/build/toolchain-external-custom/.stamp_configured] Error 1
make: *** [Makefile:84: _all] Error 2
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

解决方案:

Toolchain
	External toolchain gcc version (4.9.x)
	External toolchain kernel headers series (4.0.x)

2、异常二

onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ make -j4
>>> toolchain-external-custom  Configuring
Incorrect selection of the C library
make[1]: *** [package/pkg-generic.mk:283: /home/onlylove/my/buildroot/buildroot-2022.08/output/build/toolchain-external-custom/.stamp_configured] Error 255
make: *** [Makefile:84: _all] Error 2
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

解决方案:

Toolchain
	External toolchain C library (glibc)

3、异常三

onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ make -j4
>>> toolchain-external-custom  Configuring
RPC support available in C library, please enable BR2_TOOLCHAIN_EXTERNAL_INET_RPC
make[1]: *** [package/pkg-generic.mk:283: /home/onlylove/my/buildroot/buildroot-2022.08/output/build/toolchain-external-custom/.stamp_configured] Error 1
make: *** [Makefile:84: _all] Error 2
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

解决方案:

Toolchain
	[*] Toolchain has RPC support?

4、异常四

onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ make -j4
/usr/bin/make -j1 O=/home/onlylove/my/buildroot/buildroot-2022.08/output HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" syncconfig
make[2]: warning: -j1 forced in submake: resetting jobserver mode.
>>> toolchain-external-custom  Configuring
SSP support available in this toolchain, please enable BR2_TOOLCHAIN_EXTERNAL_HAS_SSP
make[1]: *** [package/pkg-generic.mk:283: /home/onlylove/my/buildroot/buildroot-2022.08/output/build/toolchain-external-custom/.stamp_configured] Error 1
make: *** [Makefile:84: _all] Error 2
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

解决方案:

Toolchain
	[*] Toolchain has SSP support?

5、异常五

onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$ make -j4
>>> toolchain-external-custom  Installing to staging directory
/usr/bin/install -D -m 0755 /home/onlylove/my/buildroot/buildroot-2022.08/output/build/toolchain-external-custom/toolchain-wrapper /home/onlylove/my/buildroot/buildroot-2022.08/output/host/bin/toolchain-wrapper
ln: failed to create symbolic link '/home/onlylove/my/buildroot/buildroot-2022.08/output/host/arm-buildroot-linux-gnueabihf/sysroot/usr/lib': No such file or directory
make[1]: *** [package/pkg-generic.mk:332: /home/onlylove/my/buildroot/buildroot-2022.08/output/build/toolchain-external-custom/.stamp_staging_installed] Error 1
make: *** [Makefile:84: _all] Error 2
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

6、异常六

>>> host-kmod 29 Downloading
wget --passive-ftp -nd -t 3 -O '/home/onlylove/my/buildroot/buildroot-2022.08/output/build/.kmod-29.tar.xz.zvvUDh/output' 'https://cdn.kernel.org/pub/linux/utils/kernel/kmod/kmod-29.tar.xz' 
--2022-09-25 01:18:35--  https://cdn.kernel.org/pub/linux/utils/kernel/kmod/kmod-29.tar.xz
Resolving cdn.kernel.org (cdn.kernel.org)... 151.101.109.176, 2a04:4e42:8c::432
Connecting to cdn.kernel.org (cdn.kernel.org)|151.101.109.176|:443... connected.
Unable to establish SSL connection.
wget --passive-ftp -nd -t 3 -O '/home/onlylove/my/buildroot/buildroot-2022.08/output/build/.kmod-29.tar.xz.qMK8dM/output' 'http://sources.buildroot.net/kmod/kmod-29.tar.xz' 
--2022-09-25 01:18:56--  http://sources.buildroot.net/kmod/kmod-29.tar.xz
Resolving sources.buildroot.net (sources.buildroot.net)... 172.67.72.56, 104.26.1.37, 104.26.0.37, ...
Connecting to sources.buildroot.net (sources.buildroot.net)|172.67.72.56|:80... failed: Connection refused.
Connecting to sources.buildroot.net (sources.buildroot.net)|104.26.1.37|:80... failed: Connection refused.
Connecting to sources.buildroot.net (sources.buildroot.net)|104.26.0.37|:80... failed: Connection refused.
Connecting to sources.buildroot.net (sources.buildroot.net)|2606:4700:20::681a:25|:80... failed: Network is unreachable.
Connecting to sources.buildroot.net (sources.buildroot.net)|2606:4700:20::ac43:4838|:80... failed: Network is unreachable.
Connecting to sources.buildroot.net (sources.buildroot.net)|2606:4700:20::681a:125|:80... failed: Network is unreachable.
wget --passive-ftp -nd -t 3 -O '/home/onlylove/my/buildroot/buildroot-2022.08/output/build/.kmod-29.tar.xz.LQM3cu/output' 'http://sources.buildroot.net/kmod-29.tar.xz' 
--2022-09-25 01:20:00--  http://sources.buildroot.net/kmod-29.tar.xz
Resolving sources.buildroot.net (sources.buildroot.net)... 104.26.0.37, 104.26.1.37, 172.67.72.56, ...
Connecting to sources.buildroot.net (sources.buildroot.net)|104.26.0.37|:80... failed: Connection refused.
Connecting to sources.buildroot.net (sources.buildroot.net)|104.26.1.37|:80... failed: Connection refused.
Connecting to sources.buildroot.net (sources.buildroot.net)|172.67.72.56|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2022-09-25 01:20:44 ERROR 404: Not Found.

make[1]: *** [package/pkg-generic.mk:189: /home/onlylove/my/buildroot/buildroot-2022.08/output/build/host-kmod-29/.stamp_downloaded] Error 1
make: *** [Makefile:84: _all] Error 2
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

解决方案:


7、异常七

>>>   Executing post-image script board/freescale/common/imx/post-image.sh
INFO: cmd: "mkdir -p "/home/onlylove/my/buildroot/buildroot-2022.08/output/build/genimage.tmp"" (stderr):
INFO: cmd: "rm -rf "/home/onlylove/my/buildroot/buildroot-2022.08/output/build/genimage.tmp"/*" (stderr):
INFO: cmd: "mkdir -p "/home/onlylove/my/buildroot/buildroot-2022.08/output/build/genimage.tmp"" (stderr):
INFO: cmd: "cp -a "/home/onlylove/my/buildroot/buildroot-2022.08/output/target" "/home/onlylove/my/buildroot/buildroot-2022.08/output/build/genimage.tmp/root"" (stderr):
INFO: cmd: "find '/home/onlylove/my/buildroot/buildroot-2022.08/output/build/genimage.tmp/root' -depth -type d -printf '%P\0' | xargs -0 -I {} touch -r '/home/onlylove/my/buildroot/buildroot-2022.08/output/target/{}' '/home/onlylove/my/buildroot/buildroot-2022.08/output/build/genimage.tmp/root/{}'" (stderr):
ERROR: file(zImage): stat(/home/onlylove/my/buildroot/buildroot-2022.08/output/images/zImage) failed: No such file or directory
ERROR: vfat(boot.vfat): could not setup zImage
onlylove@ubuntu:~/my/buildroot/buildroot-2022.08$

问题分析:

不准备使用 buildroot 编译 ubootkernel,在生成 sdcard.img 的时候需要 ubootkernelrootfs。我们没有编译 ubootkernel,因此找不到 zImage

解决方案:

修改 Makefile 文件不生成 sdcard.img

.PHONY: target-post-image
target-post-image: $(TARGETS_ROOTFS) target-finalize staging-finalize
	@rm -f $(ROOTFS_COMMON_TAR)
	$(Q)mkdir -p $(BINARIES_DIR)
#	@$(foreach s, $(call qstrip,$(BR2_ROOTFS_POST_IMAGE_SCRIPT)), \
		$(call MESSAGE,"Executing post-image script $(s)"); \
		$(EXTRA_ENV) $(s) $(BINARIES_DIR) $(call qstrip,$(BR2_ROOTFS_POST_SCRIPT_ARGS))$(sep))

参考:ERROR: vfat(boot.vfat): could not setup zImage_酣楼驻海的博客-CSDN博客

09-29 16:15