You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Poky-tiny构建qemuarmv5+systemd启动失败问题求助

使用Poky-tiny构建qemuarmv5镜像(指定systemd为初始化管理器)启动失败排查

疑问

  • Qemu在qemux86-64上可正常运行,为何qemuarm不行?
  • qemuarm使用sysvinit可正常运行,为何换成systemd就失败?

local.conf配置文件

DISTRO ?= 'poky-tiny'
PACKAGE_CLASSES ?= 'package_rpm'
EXTRA_IMAGE_FEATURES ?= "debug-tweaks"
USER_CLASSES ?= "buildstats"
PATCHRESOLVE = "noop"
BB_DISKMON_DIRS ??= "\
    STOPTASKS,${TMPDIR},1G,100K \
    STOPTASKS,${DL_DIR},1G,100K \
    STOPTASKS,${SSTATE_DIR},1G,100K \
    STOPTASKS,/tmp,100M,100K \
    HALT,${TMPDIR},100M,1K \
    HALT,${DL_DIR},100M,1K \
    HALT,${SSTATE_DIR},100M,1K \
    HALT,/tmp,10M,1K"
PACKAGECONFIG:append:pn-qemu-system-native = " sdl"
CONF_VERSION = "2"

require ../../conf/git-describe.inc
MANIFEST_VERSION := "${@git_describe(d.getVar("BSPDIR"), d.getVar("DISTRO"))}"

CONNECTIVITY_CHECK_URIS = ""


INHERIT += "rm_work"
MACHINE = "qemuarmv5"

#PACKAGECONFIG:append:pn-systemd = " networkd"
INITRAMFS_MAXSIZE = "200000"
#INHERIT+="toaster buildhistory"
ACCEPT_FSL_EULA = "1"

# use systemd as the default init manager
DISTRO_FEATURES:append = "systemd"
DISTRO_FEATURES_BACKFILL_CONSIDERED += "sysvinit"
VIRTUAL-RUNTIME_init_manager = "busybox"
#VIRTUAL-RUNTIME_initscripts = "initscripts"
VIRTUAL-RUNTIME_login_manager = "busybox"
VIRTUAL-RUNTIME_initscripts = "systemd-compat-units"
KERNEL_FEATURES:append = " cfg/systemd.scc"

Qemu启动失败日志

[    5.829313] workingset: timestamp_bits=30 max_order=16 bucket_order=0
[    5.883554] brd: module loaded
[    5.899423] rtc-pl031 9010000.pl031: registered as rtc0
[    5.901240] usbcore: registered new interface driver usbhid
[    5.901537] usbhid: USB HID core driver
[    5.903321] NET: Registered PF_PACKET protocol family
[    5.904744] NET: Registered PF_VSOCK protocol family
[    5.906121] Registering SWP/SWPB emulation handler
[    6.383892] printk: console [netcon0] enabled
[    6.384189] netconsole: network logging started
[    6.452892] IP-Config: Complete:
[    6.453157]      device=eth0, hwaddr=52:54:00:12:34:08, ipaddr=192.168.7.8, mask=255.255.255.0, gw=192.168.7.7
[    6.453934]      host=192.168.7.8, domain=, nis-domain=(none)
[    6.454198]      bootserver=255.255.255.255, rootserver=255.255.255.255, rootpath=
[    6.454287]      nameserver0=8.8.8.8
[    6.462345] uart-pl011 9000000.pl011: no DMA platform data
[    6.513454] Freeing unused kernel image (initmem) memory: 196K
[    6.513771] Kernel memory protection not selected by kernel config.
[    6.514395] Run /init as init process
init started: BusyBox v1.35.0 ()
starting pid 108, tty '': '/bin/mount -t proc proc /proc'
starting pid 109, tty '': '/bin/mount -t sysfs sysfs /sys'
starting pid 110, tty '': '/bin/mount -t devtmpfs devtmpfs /dev'
starting pid 111, tty '': '/bin/mount -o remount,rw /'
starting pid 112, tty '': '/bin/mkdir -p /dev/pts'
starting pid 113, tty '': '/bin/mount -t devpts devpts /dev/pts'
starting pid 114, tty '': '/bin/mount -a'
starting pid 115, tty '': '/sbin/swapon -a'
starting pid 121, tty '': '/etc/init.d/rcS'
can't run '/etc/init.d/rcS': No such file or directory
starting pid 122, tty '/dev/ttyAMA0': '/sbin/getty 115200 ttyAMA0'
can't open /dev/hvc0: No such file or directory
process '/sbin/getty 115200 hvc0' (pid 123) exited. Scheduling for restart.
can't open /dev/hvc0: No such file or directory
process '/sbin/getty 115200 hvc0' (pid 125) exited. Scheduling for restart.
can't open /dev/hvc0: No such file or directory
process '/sbin/getty 115200 hvc0' (pid 126) exited. Scheduling for restart.
can't open /dev/hvc0: No such file or directory
process '/sbin/getty 115200 hvc0' (pid 127) exited. Scheduling for restart.

问题分析与修复

核心问题

从日志可见,系统实际启动的是BusyBox的init而非systemd,结合配置文件,问题出在:

  1. VIRTUAL-RUNTIME_init_manager = "busybox" 直接指定了用busybox作为初始化管理器,覆盖了systemd的配置。
  2. Poky-tiny是极简发行版,默认不包含systemd的依赖组件,即便添加了DISTRO_FEATURES,也需要确保systemd被正确打包进镜像。
  3. ARMv5架构对systemd的支持有限,systemd本身对该老旧架构的兼容性不如x86_64,且Poky-tiny针对ARMv5的默认配置未启用systemd所需的内核特性。

疑问解答

  • qemux86-64正常、qemuarm不行:x86_64是systemd的核心支持架构,Poky-tiny针对x86_64的默认配置已包含systemd所需的依赖和内核特性;而ARMv5属于老旧架构,systemd对其优化不足,且Poky-tiny的ARMv5默认配置未适配systemd。
  • sysvinit正常、systemd失败:sysvinit/busybox init是轻量工具,资源占用极低,符合Poky-tiny的极简定位;而systemd需要cgroups、dbus等内核特性和额外依赖,Poky-tiny默认未为ARMv5配置这些,再加上你错误指定了busybox init,导致systemd根本没启动。

修复步骤

  1. 修正初始化管理器配置:
    将local.conf中的VIRTUAL-RUNTIME_init_manager = "busybox"改为:
    VIRTUAL-RUNTIME_init_manager = "systemd"
    
  2. 添加systemd依赖包:
    在local.conf中添加:
    IMAGE_INSTALL:append = " systemd systemd-sysvinit"
    
  3. 调整内核特性:
    确认ARMv5内核开启了CONFIG_CGROUPS、CONFIG_CGROUP_SCHED、CONFIG_NAMESPACES等systemd必需选项,可通过内核配置文件或KERNEL_FEATURES调整。
  4. 增大initramfs容量:
    systemd体积大于busybox,当前INITRAMFS_MAXSIZE = "200000"可能不足,可改为:
    INITRAMFS_MAXSIZE = "300000"
    
  5. 架构兼容性检查:
    部分新版本Poky已放弃ARMv5的systemd支持,若上述调整无效,可尝试改用ARMv7架构(qemuarm)或降级Poky版本。

内容的提问来源于stack exchange,提问作者Kamran Danish

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 07:25:29