泰晓科技 -- 聚焦 Linux - 追本溯源,见微知著!
网站地址:https://tinylab.org

还在观望?5小时公开课入门RISC-V架构
请稍侯

使用 buildroot 构建 QEMU 和哪吒开发板的系统镜像

Kepontry 创作于 2023/02/27

Corrector: TinyCorrect v0.1 - [codeblock pangu] Author: Kepontry Kepontry@163.com Date: 2022/12/28 Revisor: Falcon Falcon@163.com,Wang Liming walimis@gmail.com Project: RISC-V Linux 内核剖析 Proposal: Embedded Linux 系统 for RISC-V Sponsor: PLCT Lab, ISCAS

1 简介

buildroot 是一种简单、高效、易用的嵌入式 Linux 系统生成工具。利用交叉编译工具链,它能够完成 rootfs 生成,内核镜像编译和 bootloader 的编译。像内核编译一样,它也支持 menuconfig, gconfig 和 xconfig 等配置方式。buildroot 支持数千个软件包,在理想的情况下,通常花费 15-30 分钟即可完成构建,本文实际使用中花了 1 个小时才编译完。

2 环境搭建

2.1 使用 Docker 启动 Ubuntu 20.04

Docker 是一种轻量级的容器,能够简化配置,统一环境。执行如下命令可以非常快速地配置好 Ubuntu 20.04 环境。需要注意的是,安装 docker 后,应该给当前用户(非 root 用户)使用 docker 的权限,避免以 root 权限启动 docker。

  1. # 把当前用户加入 docker 组,设置完成后,需要重新登陆用户
  2. $ sudo usermod -aG docker username
  3. # 设定当前用户的新初始组为 docker
  4. $ newgrp docker
  5. # 拉取 ubuntu20.04 镜像
  6. $ docker pull ubuntu:20.04
  7. # 启动镜像,通过指定-d 参数,使容器在后台运行
  8. $ docker run -itd --name ubuntu-2004 ubuntu:20.04 /bin/bash
  9. # 进入容器
  10. $ docker exec -it ubuntu-2004 /bin/bash

2.2 更换系统镜像源

Ubuntu 自带的镜像源对国内用户不太友好,软件包下载速度慢。我们这里换成阿里云的源,在容器里执行下面的命令,写入新的镜像源。最后执行 apt-get update 命令,获取最新软件包列表。

  1. $ echo "deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
  2. deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
  3. deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
  4. deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
  5. deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
  6. deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
  7. deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
  8. deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
  9. deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
  10. deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse">/etc/apt/sources.list

2.3 必要软件安装

接下来安装一些必要的软件包,例如版本控制软件 git,编译工具库 build-essential。由于 buildroot 的 Makefile 中有依赖检查功能,剩下的软件包只需要根据 make 命令的报错信息补充即可。

  1. # 软件包安装
  2. $ apt-get install git build-essential tree file wget cpio unzip rsync bc

2.4 获取 buildroot 源码

随后使用 git 命令从 官方仓库 克隆最新版本的源码,指定 --depth=1 可以避免下载历史提交记录,从而减小下载体积。如果开发板型号不是最新的可以下载 buildroot 的稳定版本。

  1. # 源码获取
  2. $ cd /home
  3. $ git clone git://git.buildroot.net/buildroot --depth=1
  4. $ cd buildroot

2.5 buildroot 目录结构介绍

buildroot 的目录结构如下所示,make 命令后面跟着的配置文件就存放在 configs 目录下。此外,编译完成后会多出两个目录:dl 和 output 目录。dl 目录用于存放构建过程中下载的软件源码压缩包,供后续使用。output 目录存放构建出的镜像文件和构建过程中产生的中间文件。

  1. $ tree -L 1
  2. .
  3. |-- CHANGES
  4. |-- COPYING
  5. |-- Config.in
  6. |-- Config.in.legacy
  7. |-- DEVELOPERS
  8. |-- Makefile # 构建脚本
  9. |-- Makefile.legacy
  10. |-- README
  11. |-- arch # 架构相关的配置脚本,如 arm/mips/x86/riscv
  12. |-- board # 存放各开发板的一些配置补丁
  13. |-- boot # 各类启动软件
  14. |-- configs # 各类开发板的配置文件
  15. |-- docs # 参考文档
  16. |-- fs # 各类文件系统源码
  17. |-- linux # linux kernel 的自动构建脚本
  18. |-- package # 存放各软件包的配置文件和构建脚本
  19. |-- support # 构件中可能用到的支持软件
  20. |-- system # 根目录的配置和构建脚本,skeleton 目录下存放根目录的骨架
  21. |-- toolchain # 存放构建工具链的脚本
  22. |-- utils # 一些工具软件

3 构建基于 QEMU 的 RISCV64 虚拟环境

QEMU 是一种高性能仿真器,利用动态代码翻译机制,可以模拟任意一种指令集的硬件,并在上面执行软件程序。接下来我们构建 QEMU-RISCV64 上的系统镜像,并用 QEMU 启动它。

3.1 config 配置文件生成

使用 make qemu_riscv64_virt_defconfig 命令,在当前目录下生成 .config 文件,文件中包括系统镜像编译的配置参数。这和使用 make menuconfig 命令,在图形界面中配置并保存的 .config 文件的作用是相同的。系统镜像的构建都是直接使用开发板厂商预先写好的配置选项文件,并不需要手动配置。

  1. $ make qemu_riscv64_virt_defconfig
  2. mkdir -p /home/buildroot/output/build/buildroot-config/lxdialog
  3. PKG_CONFIG_PATH="" make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" \
  4. obj=/home/buildroot/output/build/buildroot-config -C support/kconfig -f Makefile.br conf
  5. make[1]: Entering directory '/home/buildroot/support/kconfig'
  6. /usr/bin/gcc -DCURSES_LOC="<curses.h>" -DLOCALE -I/home/buildroot/output/build/buildroot-config -DCONFIG_=\"\" -MM *.c > /home/buildroot/output/build/buildroot-config/.depend 2>/dev/null || :
  7. /usr/bin/gcc -DCURSES_LOC="<curses.h>" -DLOCALE -I/home/buildroot/output/build/buildroot-config -DCONFIG_=\"\" -c conf.c -o /home/buildroot/output/build/buildroot-config/conf.o
  8. /usr/bin/gcc -DCURSES_LOC="<curses.h>" -DLOCALE -I/home/buildroot/output/build/buildroot-config -DCONFIG_=\"\" -I. -c /home/buildroot/output/build/buildroot-config/zconf.tab.c -o /home/buildroot/output/build/buildroot-config/zconf.tab.o
  9. /usr/bin/gcc -DCURSES_LOC="<curses.h>" -DLOCALE -I/home/buildroot/output/build/buildroot-config -DCONFIG_=\"\" /home/buildroot/output/build/buildroot-config/conf.o /home/buildroot/output/build/buildroot-config/zconf.tab.o -o /home/buildroot/output/build/buildroot-config/conf
  10. rm /home/buildroot/output/build/buildroot-config/zconf.tab.c
  11. make[1]: Leaving directory '/home/buildroot/support/kconfig'
  12. #
  13. # configuration written to /home/buildroot/.config
  14. #

3.2 多核镜像编译

执行 make -j$(nproc) 命令,使用多核来并行编译。由于是初次编译,需要下载较多的软件包,大概经过一个小时完成。网络条件比较差的,要做好预留更多时间的准备。

  1. $ make -j$(nproc)
  2. ...
  3. >>> Generating filesystem image rootfs.tar
  4. mkdir -p /home/buildroot/output/images
  5. rm -rf /home/buildroot/output/build/buildroot-fs/tar
  6. mkdir -p /home/buildroot/output/build/buildroot-fs/tar
  7. rsync -auH --exclude=/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM /home/buildroot/output/target/ /home/buildroot/output/build/buildroot-fs/tar/target
  8. echo '#!/bin/sh' > /home/buildroot/output/build/buildroot-fs/tar/fakeroot
  9. ... # 省略 fakeroot 文件的写入过程
  10. chmod a+x /home/buildroot/output/build/buildroot-fs/tar/fakeroot
  11. PATH="/home/buildroot/output/host/bin:/home/buildroot/output/host/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin" FAKEROOTDONTTRYCHOWN=1 /home/buildroot/output/host/bin/fakeroot -- /home/buildroot/output/build/buildroot-fs/tar/fakeroot
  12. rootdir=/home/buildroot/output/build/buildroot-fs/tar/target
  13. table='/home/buildroot/output/build/buildroot-fs/full_devices_table.txt'
  14. ln -snf /home/buildroot/output/host/riscv64-buildroot-linux-gnu/sysroot /home/buildroot/output/staging
  15. >>> Executing post-image script board/qemu/post-image.sh
  16. $ ls output/images/
  17. Image fw_dynamic.bin fw_dynamic.elf fw_jump.bin fw_jump.elf rootfs.ext2 rootfs.tar start-qemu.sh

3.3 QEMU 启动编译的内核镜像和文件系统

接下来通过执行 output/images/start-qemu.sh 脚本文件,使用 QEMU 启动一个 riscv64 的虚拟环境。查看 start-qemu.sh 的内容,该脚本使用构建的 fw_jump.elf 文件作为 bios 参数,Image 文件作为内核参数,rootfs.ext2 作为文件系统参数启动 QEMU。

  1. $ cat output/images/start-qemu.sh
  2. #!/bin/sh
  3. (
  4. BINARIES_DIR="${0%/*}/"
  5. cd ${BINARIES_DIR}
  6. if [ "${1}" = "serial-only" ]; then
  7. EXTRA_ARGS='-nographic'
  8. else
  9. EXTRA_ARGS=''
  10. fi
  11. export PATH="/home/buildroot/output/host/bin:${PATH}"
  12. exec qemu-system-riscv64 -M virt -bios fw_jump.elf -kernel Image -append "rootwait root=/dev/vda ro" -drive file=rootfs.ext2,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -nographic ${EXTRA_ARGS}
  13. )

QEMU 成功启动内核,使用 uname -a 命令查看处理器以及操作系统的相关信息。

  1. $ ./output/images/start-qemu.sh
  2. OpenSBI v0.9
  3. ____ _____ ____ _____
  4. / __ \ / ____| _ \_ _|
  5. | | | |_ __ ___ _ __ | (___ | |_) || |
  6. | | | | '_ \ / _ \ '_ \ \___ \| _ < | |
  7. | |__| | |_) | __/ | | |____) | |_) || |_
  8. \____/| .__/ \___|_| |_|_____/|____/_____|
  9. | |
  10. |_|
  11. Platform Name : riscv-virtio,qemu
  12. Platform Features : timer,mfdeleg
  13. Platform HART Count : 1
  14. Firmware Base : 0x80000000
  15. Firmware Size : 124 KB
  16. Runtime SBI Version : 0.2
  17. ...
  18. Welcome to Buildroot
  19. buildroot login: root
  20. # uname -a
  21. Linux buildroot 5.15.43 #1 SMP Tue Dec 27 15:19:22 UTC 2022 riscv64 GNU/Linux
  22. # ls /
  23. bin lib lost+found opt run tmp
  24. dev lib64 media proc sbin usr
  25. etc linuxrc mnt root sys var
  26. #

4 构建哪吒开发板的系统镜像

最后我们使用 buildroot 构建哪吒开发板的系统镜像,并上板测试。

4.1 config 配置文件生成及编译

按照与之前一样的流程生成配置文件并编译,将 output/images 目录下的 sdcard.img 镜像拷贝至宿主机中。

  1. # 切换到 2022.11 release,此版本可以在哪吒开发板上正常启动和运行
  2. $ git checkout -b 2022.11.test 2022.11
  3. # 生成.config 配置文件
  4. $ make nezha_defconfig
  5. #
  6. # configuration written to /home/buildroot/.config
  7. #
  8. # 编译
  9. $ make -j$(nproc)
  10. # 查看生成的文件
  11. $ ls output/images/
  12. Image fw_dynamic.bin fw_dynamic.elf rootfs.ext2 rootfs.ext4 sdcard.img sun20i-d1-nezha.dtb u-boot-sunxi-with-spl.bin

4.2 拷贝编译好的 image 到宿主机

编译完成后,我们在宿主机通过 docker cp 命令拷贝生成的 sdcard.img 文件到宿主机。

  1. # 宿主机中执行,将 sdcard.img 拷贝到宿主机中
  2. $ docker cp ubuntu-2004:/home/buildroot/output/images/sdcard.img ./

4.3 镜像烧写及上板测试

以下命令都在宿主机上运行。

  1. 把 SD 卡插入读卡器,并将读卡器连接至电脑 USB 口,使用 dd 命令烧写 sdcard.img 文件到 SD 卡

  2. 烧写结果如下:

  1. $ time sudo dd if=sdcard.img of=/dev/sda bs=2M
  2. 39+0 records in
  3. 39+0 records out
  4. 81788928 bytes (82 MB, 78 MiB) copied, 10.4105 s, 7.9 MB/s
  5. real 0m10.436s
  6. user 0m0.009s
  7. sys 0m0.013s
  1. 把烧写好的 SD 卡拔出,插入哪吒开发板的 SD 卡槽,上电启动哪吒开发板
  2. buildroot 详细启动信息如下:
  1. [227]HELLO! BOOT0 is starting!
  2. [230]BOOT0 commit : 40bd4a32aa
  3. [233]set pll start
  4. [235]periph0 has been enabled
  5. [238]set pll end
  6. [239]board init ok
  7. [241]DRAM only have internal ZQ!!
  8. [244]get_pmu_exist() = -1
  9. [247]ddr_efuse_type: 0x0
  10. [250][AUTO DEBUG] two rank and full DQ!
  11. [253]ddr_efuse_type: 0x0
  12. [256][AUTO DEBUG] rank 0 row = 15
  13. [259][AUTO DEBUG] rank 0 bank = 8
  14. [263][AUTO DEBUG] rank 0 page size = 2 KB
  15. [266][AUTO DEBUG] rank 1 row = 15
  16. [269][AUTO DEBUG] rank 1 bank = 8
  17. [273][AUTO DEBUG] rank 1 page size = 2 KB
  18. [276]rank1 config same as rank0
  19. [279]DRAM BOOT DRIVE INFO: V0.24
  20. [282]DRAM CLK = 792 MHz
  21. [285]DRAM Type = 3 (2:DDR2,3:DDR3)
  22. [288]DRAMC ZQ value: 0x7b7bfb
  23. [291]DRAM ODT value: 0x42.
  24. [293]ddr_efuse_type: 0x0
  25. [296]DRAM SIZE =1024 M
  26. [300]DRAM simple test OK.
  27. [302]dram size =1024
  28. [304]card no is 0
  29. [306]sdcard 0 line count 4
  30. [308][mmc]: mmc driver ver 2021-04-2 16:45
  31. [317][mmc]: Wrong media type 0x0
  32. [320][mmc]: ***Try SD card 0***
  33. [329][mmc]: HSSDR52/SDR25 4 bit
  34. [332][mmc]: 50000000 Hz
  35. [334][mmc]: 29818 MB
  36. [336][mmc]: ***SD/MMC 0 init OK!!!***
  37. [387]Loading boot-pkg Succeed(index=0).
  38. [390]Entry_name = opensbi
  39. [393]Entry_name = dtb
  40. [396]Entry_name = u-boot
  41. [400]Adding DRAM info to DTB.
  42. [405]Jump to second Boot.
  43. OpenSBI v1.1
  44. ____ _____ ____ _____
  45. / __ \ / ____| _ \_ _|
  46. | | | |_ __ ___ _ __ | (___ | |_) || |
  47. | | | | '_ \ / _ \ '_ \ \___ \| _ < | |
  48. | |__| | |_) | __/ | | |____) | |_) || |_
  49. \____/| .__/ \___|_| |_|_____/|____/_____|
  50. | |
  51. |_|
  52. Platform Name : Allwinner D1 Nezha
  53. Platform Features : medeleg
  54. Platform HART Count : 1
  55. Platform IPI Device : ---
  56. Platform Timer Device : --- @ 0Hz
  57. Platform Console Device : uart8250
  58. Platform HSM Device : sun20i-d1-ppu
  59. Platform Reboot Device : sunxi-wdt-reset
  60. Platform Shutdown Device : ---
  61. Firmware Base : 0x40000000
  62. Firmware Size : 240 KB
  63. Runtime SBI Version : 1.0
  64. Domain0 Name : root
  65. Domain0 Boot HART : 0
  66. Domain0 HARTs : 0*
  67. Domain0 Region00 : 0x0000000040000000-0x000000004003ffff ()
  68. Domain0 Region01 : 0x0000000000000000-0xffffffffffffffff (R,W,X)
  69. Domain0 Next Address : 0x000000004a000000
  70. Domain0 Next Arg1 : 0x0000000044000000
  71. Domain0 Next Mode : S-mode
  72. Domain0 SysReset : yes
  73. Boot HART ID : 0
  74. Boot HART Domain : root
  75. Boot HART Priv Version : v1.11
  76. Boot HART Base ISA : rv64imafdcvx
  77. Boot HART ISA Extensions : time
  78. Boot HART PMP Count : 8
  79. Boot HART PMP Granularity : 2048
  80. Boot HART PMP Address Bits: 38
  81. Boot HART MHPM Count : 0
  82. Boot HART MIDELEG : 0x0000000000000222
  83. Boot HART MEDELEG : 0x000000000000b109
  84. U-Boot 2022.07-rc3 (Dec 27 2022 - 23:25:44 +0800)
  85. CPU: rv64imafdc
  86. Model: Allwinner D1 Nezha
  87. DRAM: 1 GiB
  88. sunxi_set_gate: (CLK#24) unhandled
  89. Core: 66 devices, 24 uclasses, devicetree: board
  90. WDT: Started watchdog@6011000 with servicing (16s timeout)
  91. MMC: mmc@4020000: 0, mmc@4021000: 1
  92. Loading Environment from nowhere... OK
  93. In: serial@2500000
  94. Out: serial@2500000
  95. Err: serial@2500000
  96. Net:
  97. Warning: ethernet@4500000 (eth0) using random MAC address - 06:58:7d:c3:58:d6
  98. eth0: ethernet@4500000
  99. Hit any key to stop autoboot: 0
  100. switch to partitions #0, OK
  101. mmc0 is current device
  102. Scanning mmc 0:1...
  103. Found /boot/extlinux/extlinux.conf
  104. Retrieving file: /boot/extlinux/extlinux.conf
  105. 1: linux
  106. Retrieving file: /boot/Image
  107. append: console=ttyS0,115200 root=/dev/mmcblk0p1 ro rootwait
  108. Moving Image from 0x40040000 to 0x40200000, end=415e7c98
  109. ## Flattened Device Tree blob at 7fb14730
  110. Booting using the fdt blob at 0x7fb14730
  111. Loading Device Tree to 0000000042df5000, end 0000000042dff68f ... OK
  112. Starting kernel ...
  113. [ 0.000000] Linux version 5.19.0-rc1 (root@603c9b6a45b4) (riscv64-buildroot-linux-gnu-gcc.br_real (Buildroot 2022.11) 11.3.0, GNU ld (GNU Binutils) 2.38) #1 PREEMPT Tue Dec 27 23:26:20 CST 2022
  114. [ 0.000000] OF: fdt: Ignoring memory range 0x40000000 - 0x40200000
  115. [ 0.000000] Machine model: Allwinner D1 Nezha
  116. [ 0.000000] Zone ranges:
  117. [ 0.000000] DMA32 [mem 0x0000000040200000-0x000000007fffffff]
  118. [ 0.000000] Normal empty
  119. [ 0.000000] Movable zone start for each node
  120. [ 0.000000] Early memory node ranges
  121. [ 0.000000] node 0: [mem 0x0000000040200000-0x000000007fffffff]
  122. [ 0.000000] Initmem setup node 0 [mem 0x0000000040200000-0x000000007fffffff]
  123. [ 0.000000] riscv: SBI specification v1.0 detected
  124. [ 0.000000] riscv: SBI implementation ID=0x1 Version=0x10001
  125. [ 0.000000] riscv: SBI TIME extension detected
  126. [ 0.000000] riscv: SBI IPI extension detected
  127. [ 0.000000] riscv: SBI RFENCE extension detected
  128. [ 0.000000] riscv: SBI SRST extension detected
  129. [ 0.000000] riscv: base ISA extensions acdfim
  130. [ 0.000000] riscv: ELF capabilities acdfim
  131. [ 0.000000] Built 1 zonelists, mobility grouping on. Total pages: 257544
  132. [ 0.000000] Kernel command line: console=ttyS0,115200 root=/dev/mmcblk0p1 ro rootwait
  133. [ 0.000000] Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes, linear)
  134. [ 0.000000] Inode-cache hash table entries: 65536 (order: 7, 524288 bytes, linear)
  135. [ 0.000000] mem auto-init: stack:off, heap alloc:off, heap free:off
  136. [ 0.000000] Memory: 1007888K/1046528K available (6885K kernel code, 5580K rwdata, 4096K rodata, 2191K init, 319K bss, 38640K reserved, 0K cma-reserved)
  137. [ 0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
  138. [ 0.000000] trace event string verifier disabled
  139. [ 0.000000] rcu: Preemptible hierarchical RCU implementation.
  140. [ 0.000000] Trampoline variant of Tasks RCU enabled.
  141. [ 0.000000] rcu: RCU calculated value of scheduler-enlistment delay is 25 jiffies.
  142. [ 0.000000] NR_IRQS: 64, nr_irqs: 64, preallocated irqs: 0
  143. [ 0.000000] OF: of_irq_init: found /cpus/cpu@0/interrupt-controller with parent (null)
  144. [ 0.000000] OF: of_irq_init: found /soc/interrupt-controller@6010000 with parent /soc/interrupt-controller@10000000
  145. [ 0.000000] OF: of_irq_init: found /soc/interrupt-controller@10000000 with parent /cpus/cpu@0/interrupt-controller
  146. [ 0.000000] OF: of_irq_init: init /cpus/cpu@0/interrupt-controller with parent (null)
  147. [ 0.000000] riscv-intc: 64 local interrupts mapped
  148. [ 0.000000] OF: of_irq_init: init /soc/interrupt-controller@10000000 with parent /cpus/cpu@0/interrupt-controller
  149. [ 0.000000] plic: interrupt-controller@10000000: mapped 176 interrupts with 1 handlers for 2 contexts.
  150. [ 0.000000] OF: of_irq_init: init /soc/interrupt-controller@6010000 with parent /soc/interrupt-controller@10000000
  151. [ 0.000000] rcu: srcu_init: Setting srcu_struct sizes based on contention.
  152. [ 0.000000] riscv_timer_init_dt: Registering clocksource cpuid [0] hartid [0]
  153. [ 0.000000] clocksource: riscv_clocksource: mask: 0xffffffffffffffff max_cycles: 0x588fe9dc0, max_idle_ns: 440795202592 ns
  154. [ 0.000001] sched_clock: 64 bits at 24MHz, resolution 41ns, wraps every 4398046511097ns
  155. [ 0.000368] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 79635851949 ns
  156. [ 0.001017] Console: colour dummy device 80x25
  157. [ 0.001106] Calibrating delay loop (skipped), value calculated using timer frequency.. 48.00 BogoMIPS (lpj=96000)
  158. [ 0.001130] pid_max: default: 32768 minimum: 301
  159. [ 0.001438] Mount-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
  160. [ 0.001466] Mountpoint-cache hash table entries: 2048 (order: 2, 16384 bytes, linear)
  161. [ 0.003917] cblist_init_generic: Setting adjustable number of callback queues.
  162. [ 0.003932] cblist_init_generic: Setting shift to 0 and lim to 1.
  163. [ 0.004095] riscv: ELF compat mode failed
  164. [ 0.004145] ASID allocator using 16 bits (65536 entries)
  165. [ 0.004351] rcu: Hierarchical SRCU implementation.
  166. [ 0.005440] devtmpfs: initialized
  167. [ 0.018343] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 7645041785100000 ns
  168. [ 0.018369] futex hash table entries: 256 (order: 0, 6144 bytes, linear)
  169. [ 0.018513] pinctrl core: initialized pinctrl subsystem
  170. [ 0.020648] NET: Registered PF_NETLINK/PF_ROUTE protocol family
  171. [ 0.021016] DMA: preallocated 128 KiB GFP_KERNEL pool for atomic allocations
  172. [ 0.021068] DMA: preallocated 128 KiB GFP_KERNEL|GFP_DMA32 pool for atomic allocations
  173. [ 0.021877] thermal_sys: Registered thermal governor 'bang_bang'
  174. [ 0.021890] thermal_sys: Registered thermal governor 'step_wise'
  175. [ 0.021896] thermal_sys: Registered thermal governor 'user_space'
  176. [ 0.022489] cpuidle: using governor menu
  177. [ 0.049441] platform 5460000.tcon-top: Fixing up cyclic dependency with 5200000.mixer
  178. [ 0.049572] platform 5460000.tcon-top: Fixing up cyclic dependency with 5100000.mixer
  179. [ 0.050332] platform 5461000.lcd-controller: Fixing up cyclic dependency with 5460000.tcon-top
  180. [ 0.051027] platform 5470000.lcd-controller: Fixing up cyclic dependency with 5460000.tcon-top
  181. [ 0.051900] platform 5500000.hdmi: Fixing up cyclic dependency with 5460000.tcon-top
  182. [ 0.055442] platform 7090000.rtc: Fixing up cyclic dependency with 7010000.clock-controller
  183. [ 0.057826] platform connector: Fixing up cyclic dependency with 5500000.hdmi
  184. [ 0.090637] iommu: Default domain type: Translated
  185. [ 0.090647] iommu: DMA domain TLB invalidation policy: strict mode
  186. [ 0.091084] SCSI subsystem initialized
  187. [ 0.091448] usbcore: registered new interface driver usbfs
  188. [ 0.091537] usbcore: registered new interface driver hub
  189. [ 0.091612] usbcore: registered new device driver usb
  190. [ 0.091979] mc: Linux media interface: v0.10
  191. [ 0.092084] videodev: Linux video capture interface: v2.00
  192. [ 0.092909] Advanced Linux Sound Architecture Driver Initialized.
  193. [ 0.094037] clocksource: Switched to clocksource riscv_clocksource
  194. [ 0.132085] NET: Registered PF_INET protocol family
  195. [ 0.132447] IP idents hash table entries: 16384 (order: 5, 131072 bytes, linear)
  196. [ 0.135984] tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 4096 bytes, linear)
  197. [ 0.136047] TCP established hash table entries: 8192 (order: 4, 65536 bytes, linear)
  198. [ 0.136153] TCP bind bhash tables hash table entries: 8192 (order: 5, 131072 bytes, linear)
  199. [ 0.136604] TCP: Hash tables configured (established 8192 bind 8192)
  200. [ 0.136747] UDP hash table entries: 512 (order: 2, 16384 bytes, linear)
  201. [ 0.136805] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes, linear)
  202. [ 0.137070] NET: Registered PF_UNIX/PF_LOCAL protocol family
  203. [ 0.142163] workingset: timestamp_bits=46 max_order=18 bucket_order=0
  204. [ 0.166131] SGI XFS with ACLs, security attributes, no debug enabled
  205. [ 0.174601] NET: Registered PF_ALG protocol family
  206. [ 0.174852] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 248)
  207. [ 0.241896] Serial: 8250/16550 driver, 6 ports, IRQ sharing disabled
  208. [ 0.257537] sun8i-mixer 5100000.mixer: Adding to iommu group 0
  209. [ 0.262237] sun8i-mixer 5200000.mixer: Adding to iommu group 0
  210. [ 0.271661] zram: Added device: zram0
  211. [ 0.275655] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
  212. [ 0.275665] ehci-platform: EHCI generic platform driver
  213. [ 0.276200] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
  214. [ 0.276261] ohci-platform: OHCI generic platform driver
  215. [ 0.282316] usbcore: registered new interface driver uas
  216. [ 0.282416] usbcore: registered new interface driver usb-storage
  217. [ 0.282574] usbcore: registered new interface driver ch341
  218. [ 0.282623] usbserial: USB Serial support registered for ch341-uart
  219. [ 0.283353] UDC core: g_ether: couldn't find an available UDC
  220. [ 0.286610] sun6i-rtc 7090000.rtc: registered as rtc0
  221. [ 0.286714] sun6i-rtc 7090000.rtc: setting system clock to 1970-01-02T00:00:07 UTC (86407)
  222. [ 0.286949] sun6i-rtc 7090000.rtc: RTC enabled
  223. [ 0.287316] i2c_dev: i2c /dev entries driver
  224. [ 0.294410] sunxi-wdt 6011000.watchdog: Watchdog enabled (timeout=16 sec, nowayout=0)
  225. [ 0.297354] ledtrig-cpu: registered to indicate activity on CPUs
  226. [ 0.297750] sun8i-ce 3040000.crypto: Set mod clock to 300000000 (300 Mhz) from 400000000 (400 Mhz)
  227. [ 0.302118] sun8i-ce 3040000.crypto: will run requests pump with realtime priority
  228. [ 0.302355] sun8i-ce 3040000.crypto: will run requests pump with realtime priority
  229. [ 0.306114] sun8i-ce 3040000.crypto: will run requests pump with realtime priority
  230. [ 0.306346] sun8i-ce 3040000.crypto: will run requests pump with realtime priority
  231. [ 0.306480] sun8i-ce 3040000.crypto: Register cbc(aes)
  232. [ 0.306510] sun8i-ce 3040000.crypto: Register ecb(aes)
  233. [ 0.306522] sun8i-ce 3040000.crypto: Register cbc(des3_ede)
  234. [ 0.306534] sun8i-ce 3040000.crypto: Register ecb(des3_ede)
  235. [ 0.306549] sun8i-ce 3040000.crypto: Register md5
  236. [ 0.306563] sun8i-ce 3040000.crypto: Register sha1
  237. [ 0.306579] sun8i-ce 3040000.crypto: Register sha224
  238. [ 0.306594] sun8i-ce 3040000.crypto: Register sha256
  239. [ 0.306617] sun8i-ce 3040000.crypto: Register sha384
  240. [ 0.306635] sun8i-ce 3040000.crypto: Register sha512
  241. [ 0.306651] sun8i-ce 3040000.crypto: Register stdrng
  242. [ 0.310683] sun8i-ce 3040000.crypto: CryptoEngine Die ID 0
  243. [ 0.311302] usbcore: registered new interface driver usbhid
  244. [ 0.311311] usbhid: USB HID core driver
  245. [ 0.311552] cedrus 1c0e000.video-codec: Adding to iommu group 0
  246. [ 0.312241] cedrus 1c0e000.video-codec: Device registered as /dev/video0
  247. [ 0.313213] random: crng init done
  248. [ 0.322269] usbcore: registered new interface driver snd-usb-audio
  249. [ 0.330889] sun20i-codec 2030000.audio-codec: ASoC: Adding component 2030000.audio-codec for platform /soc/audio-codec@2030000
  250. [ 0.330914] sun20i-codec 2030000.audio-codec: ASoC: Adding component 2030000.audio-codec for platform /soc/audio-codec@2030000
  251. [ 0.347968] NET: Registered PF_INET6 protocol family
  252. [ 0.354639] Segment Routing with IPv6
  253. [ 0.354687] In-situ OAM (IOAM) with IPv6
  254. [ 0.354792] NET: Registered PF_PACKET protocol family
  255. [ 0.457383] sun20i-d1-pinctrl 2000000.pinctrl: initialized sunXi PIO driver
  256. [ 0.466253] printk: console [ttyS0] disabled
  257. [ 0.510089] 2500000.serial: ttyS0 at MMIO 0x2500000 (irq = 207, base_baud = 1500000) is a 16550A
  258. [ 0.514152] printk: console [ttyS0] enabled
  259. [ 0.536244] printk: console [ttyS0] printing thread started
  260. [ 0.582086] 2500400.serial: ttyS1 at MMIO 0x2500400 (irq = 208, base_baud = 1500000) is a 16550A
  261. [ 0.583291] sun4i-drm display-engine: Adding to iommu group 0
  262. [ 0.696996] sun4i-drm display-engine: bound 5100000.mixer (ops 0xffffffff80c62638)
  263. [ 0.708330] sun4i-drm display-engine: bound 5200000.mixer (ops 0xffffffff80c62638)
  264. [ 0.708959] sun4i-drm display-engine: bound 5460000.tcon-top (ops 0xffffffff80c66cd8)
  265. [ 0.709719] sun4i-drm display-engine: No panel or bridge found... RGB output disabled
  266. [ 0.709742] sun4i-drm display-engine: bound 5461000.lcd-controller (ops 0xffffffff80c5f668)
  267. [ 0.720010] sun4i-drm display-engine: bound 5470000.lcd-controller (ops 0xffffffff80c5f668)
  268. [ 0.720662] sun8i-dw-hdmi 5500000.hdmi: Detected HDMI TX controller v2.12a with HDCP (sun8i_dw_hdmi_phy)
  269. [ 0.726624] sun8i-dw-hdmi 5500000.hdmi: registered DesignWare HDMI I2C bus driver
  270. [ 0.727177] sun4i-drm display-engine: bound 5500000.hdmi (ops 0xffffffff80c61708)
  271. [ 0.732796] [drm] Initialized sun4i-drm 1.0.0 20150629 for display-engine on minor 0
  272. [ 0.732948] sun4i-drm display-engine: [drm] Cannot find any crtc or sizes
  273. [ 0.735713] spi-nand spi0.0: Macronix SPI NAND was found.
  274. [ 0.735726] spi-nand spi0.0: 256 MiB, block size: 128 KiB, page size: 2048, OOB size: 64
  275. [ 0.742469] 4 fixed-partitions partitions found on MTD device spi0.0
  276. [ 0.742489] Creating 4 MTD partitions on "spi0.0":
  277. [ 0.742501] 0x000000000000-0x000000100000 : "boot0"
  278. [ 0.751498] 0x000000100000-0x000000400000 : "uboot"
  279. [ 0.772891] 0x000000400000-0x000000500000 : "secure_storage"
  280. [ 0.781553] 0x000000500000-0x000010000000 : "sys"
  281. [ 2.349527] dwmac-sun8i 4500000.ethernet: IRQ eth_wake_irq not found
  282. [ 2.349542] dwmac-sun8i 4500000.ethernet: IRQ eth_lpi not found
  283. [ 2.349977] dwmac-sun8i 4500000.ethernet: PTP uses main clock
  284. [ 2.350029] dwmac-sun8i 4500000.ethernet: Current syscon value is not the default 50006 (expect 0)
  285. [ 2.356780] dwmac-sun8i 4500000.ethernet: No HW DMA feature register supported
  286. [ 2.356795] dwmac-sun8i 4500000.ethernet: RX Checksum Offload Engine supported
  287. [ 2.356800] dwmac-sun8i 4500000.ethernet: COE Type 2
  288. [ 2.356809] dwmac-sun8i 4500000.ethernet: TX Checksum insertion supported
  289. [ 2.356817] dwmac-sun8i 4500000.ethernet: Normal descriptors
  290. [ 2.356824] dwmac-sun8i 4500000.ethernet: Chain mode enabled
  291. [ 2.424329] input: 2009800.keys as /devices/platform/soc/2009800.keys/input/input0
  292. [ 2.436951] pcf857x 2-0038: probed
  293. [ 2.449370] sun50i-r329-ledc 2008000.led-controller: Registered 1 LEDs
  294. [ 2.456891] sunxi-mmc 4021000.mmc: allocated mmc-pwrseq
  295. [ 2.457435] sunxi-mmc 4020000.mmc: Got CD GPIO
  296. [ 2.467761] phy phy-4100400.phy.0: Changing dr_mode to 1
  297. [ 2.467777] phy phy-4100400.phy.0: External vbus detected, not enabling our own vbus
  298. [ 2.467785] ehci-platform 4101000.usb: EHCI Host Controller
  299. [ 2.467826] ehci-platform 4101000.usb: new USB bus registered, assigned bus number 1
  300. [ 2.468024] ehci-platform 4101000.usb: irq 222, io mem 0x04101000
  301. [ 2.470013] musb-sunxi 4100000.usb: Invalid or missing 'dr_mode' property
  302. [ 2.470026] musb-sunxi: probe of 4100000.usb failed with error -22
  303. [ 2.471554] ehci-platform 4200000.usb: EHCI Host Controller
  304. [ 2.471594] ehci-platform 4200000.usb: new USB bus registered, assigned bus number 2
  305. [ 2.471805] ehci-platform 4200000.usb: irq 223, io mem 0x04200000
  306. [ 2.473654] ALSA device list:
  307. [ 2.473665] #0: sun20i-codec
  308. [ 2.474897] ohci-platform 4200400.usb: Generic Platform OHCI controller
  309. [ 2.474935] ohci-platform 4200400.usb: new USB bus registered, assigned bus number 3
  310. [ 2.475099] ohci-platform 4200400.usb: irq 224, io mem 0x04200400
  311. [ 2.475611] ohci-platform 4101400.usb: Generic Platform OHCI controller
  312. [ 2.475648] ohci-platform 4101400.usb: new USB bus registered, assigned bus number 4
  313. [ 2.475830] ohci-platform 4101400.usb: irq 225, io mem 0x04101400
  314. [ 2.480706] sunxi-mmc 4021000.mmc: initialized, max. request size: 2047 KB, uses new timings mode
  315. [ 2.486792] ehci-platform 4101000.usb: USB 2.0 started, EHCI 1.00
  316. [ 2.487243] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.19
  317. [ 2.487260] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
  318. [ 2.487269] usb usb1: Product: EHCI Host Controller
  319. [ 2.487276] usb usb1: Manufacturer: Linux 5.19.0-rc1 ehci_hcd
  320. [ 2.487282] usb usb1: SerialNumber: 4101000.usb
  321. [ 2.488341] hub 1-0:1.0: USB hub found
  322. [ 2.488420] hub 1-0:1.0: 1 port detected
  323. [ 2.498796] sunxi-mmc 4020000.mmc: initialized, max. request size: 2047 KB, uses new timings mode
  324. [ 2.505114] ehci-platform 4200000.usb: USB 2.0 started, EHCI 1.00
  325. [ 2.505417] usb usb2: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 5.19
  326. [ 2.505434] usb usb2: New USB device strings: Mfr=3, Product=2, SerialNumber=1
  327. [ 2.505442] usb usb2: Product: EHCI Host Controller
  328. [ 2.505449] usb usb2: Manufacturer: Linux 5.19.0-rc1 ehci_hcd
  329. [ 2.505456] usb usb2: SerialNumber: 4200000.usb
  330. [ 2.506501] hub 2-0:1.0: USB hub found
  331. [ 2.506607] hub 2-0:1.0: 1 port detected
  332. [ 2.543847] usb usb4: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 5.19
  333. [ 2.543865] usb usb4: New USB device strings: Mfr=3, Product=2, SerialNumber=1
  334. [ 2.543874] usb usb4: Product: Generic Platform OHCI controller
  335. [ 2.543881] usb usb4: Manufacturer: Linux 5.19.0-rc1 ohci_hcd
  336. [ 2.543888] usb usb4: SerialNumber: 4101400.usb
  337. [ 2.550683] hub 4-0:1.0: USB hub found
  338. [ 2.550750] hub 4-0:1.0: 1 port detected
  339. [ 2.552957] usb usb3: New USB device found, idVendor=1d6b, idProduct=0001, bcdDevice= 5.19
  340. [ 2.552975] usb usb3: New USB device strings: Mfr=3, Product=2, SerialNumber=1
  341. [ 2.552984] usb usb3: Product: Generic Platform OHCI controller
  342. [ 2.552990] usb usb3: Manufacturer: Linux 5.19.0-rc1 ohci_hcd
  343. [ 2.552997] usb usb3: SerialNumber: 4200400.usb
  344. [ 2.554194] hub 3-0:1.0: USB hub found
  345. [ 2.554259] hub 3-0:1.0: 1 port detected
  346. [ 2.557300] Waiting for root device /dev/mmcblk0p1...
  347. [ 2.579394] mmc1: new high speed SDIO card at address 0001
  348. [ 2.636561] mmc0: new high speed SDHC card at address b368
  349. [ 2.645982] mmcblk0: mmc0:b368 NCard 29.1 GiB
  350. [ 2.654639] mmcblk0: p1
  351. [ 2.724440] EXT4-fs (mmcblk0p1): mounted filesystem with ordered data mode. Quota mode: disabled.
  352. [ 2.724512] VFS: Mounted root (ext4 filesystem) readonly on device 179:1.
  353. [ 2.729489] devtmpfs: mounted
  354. [ 2.730994] Freeing unused kernel image (initmem) memory: 2188K
  355. [ 2.731043] Run /sbin/init as init process
  356. [ 3.091293] EXT4-fs (mmcblk0p1): re-mounted. Quota mode: disabled.
  357. Starting syslogd: OK
  358. Starting klogd: OK
  359. Running sysctl: OK
  360. Saving random seed: OK
  361. Starting network: [ 3.686081] dwmac-sun8i 4500000.ethernet eth0: PHY [stmmac-0:01] driver [RTL8211F Gigabit Ethernet] (irq=POLL)
  362. [ 3.686499] dwmac-sun8i 4500000.ethernet eth0: Register MEM_TYPE_PAGE_POOL RxQ-0
  363. [ 3.687401] dwmac-sun8i 4500000.ethernet eth0: No Safety Features support found
  364. [ 3.687419] dwmac-sun8i 4500000.ethernet eth0: No MAC Management Counters available
  365. [ 3.687429] dwmac-sun8i 4500000.ethernet eth0: PTP not supported by HW
  366. [ 3.687867] dwmac-sun8i 4500000.ethernet eth0: configuring for phy/rgmii-id link mode
  367. udhcpc: started, v1.35.0
  368. udhcpc: broadcasting discover
  369. udhcpc: no lease, forking to background
  370. OK
  371. Welcome to Buildroot
  372. buildroot login:

5 总结

本次实验中,我们使用 buildroot 构建了基于 QEMU 的 RISCV64 虚拟环境,编译了哪吒开发板的系统镜像,并通过了上板测试,体会到了使用 buildroot 构建系统镜像的方便、快捷。

6 参考资料



Read Album:

Read Related:

Read Latest: