我已经为树莓派模型 3 构建了一个 yocto 图像,我想在 Qemu 中运行它。构建过程运行core-image-minimal
良好,如果我为机器构建它raspberry3-64
而不是将qemuarm
图像闪存到 SD 卡,我可以按预期启动到控制台。
build git:(dunfell) bitbake core-image-base
WARNING: Host distribution "ubuntu-22.04" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |############################################| Time: 0:00:01
Loaded 3298 entries from dependency cache.
NOTE: Resolving any missing task queue dependencies
Build Configuration:
BB_VERSION = "1.46.0"
BUILD_SYS = "x86_64-linux"
NATIVELSBSTRING = "universal"
TARGET_SYS = "arm-poky-linux-gnueab"
MACHINE = "qemux86-64"
DISTRO = "poky"
DISTRO_VERSION = "3.1.22"
TUNE_FEATURES = "arm armv7ve vfp thumb neon callconvention-hard"
TARGET_FPU = "hard"
meta
meta-poky
meta-yocto-bsp = "dunfell:6b8a307b7843af23d189d7ffcecf32c05afac850"
meta-oe
meta-python
meta-multimedia
meta-networking = "dunfell:e707e9b7cf5c62bff4fee029965a87b22dd4ccba"
meta-raspberrypi = "dunfell:2081e1bb9a44025db7297bfd5d024977d42191ed"
Initialising tasks: 100% |#######################################| Time: 0:00:02
Checking sstate mirror object availability: 100% |###############| Time: 0:04:40
Sstate summary: Wanted 836 Found 7 Missed 829 Current 355 (0% match, 30% complete)
NOTE: Executing Tasks
NOTE: Tasks Summary: Attempted 3162 tasks of which 1267 didn't need to be rerun and all succeeded.
Summary: There was 1 WARNING message shown.
但是当我尝试在 qemu 中运行这个图像时,它似乎不起作用......
➜ build git:(dunfell) runqemu core-image-base
runqemu - INFO - Running bitbake -e ...
runqemu - INFO - Continuing with the following parameters:
KERNEL: [/home/wtech/Workspace/rpi-yocto/poky-dunfell/build/tmp/deploy/images/qemuarm/bzImage]
MACHINE: [qemuarm]
FSTYPE: [ext4]
ROOTFS: [/home/wtech/Workspace/rpi-yocto/poky-dunfell/build/tmp/deploy/images/qemuarm/core-image-base-qemuarm.ext4]
CONFFILE: [/home/wtech/Workspace/rpi-yocto/poky-dunfell/build/tmp/deploy/images/qemuarm/core-image-base-qemuarm.qemuboot.conf]
runqemu - INFO - Setting up tap interface under sudo
[sudo] password for wtech:
runqemu - INFO - Network configuration: ip=192.168.7.2::192.168.7.1:255.255.255.0
runqemu - INFO - Running /home/wtech/Workspace/rpi-yocto/poky-dunfell/build/tmp/work/x86_64-linux/qemu-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/qemu-system-arm -device virtio-net-device,netdev=net0,mac=52:54:00:12:34:02 -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -drive id=disk0,file=/home/wtech/Workspace/rpi-yocto/poky-dunfell/build/tmp/deploy/images/qemuarm/core-image-base-qemuarm.ext4,if=none,format=raw -device virtio-blk-device,drive=disk0 -show-cursor -device VGA,edid=on -device qemu-xhci -device usb-tablet -device usb-kbd -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -machine virt,highmem=off -cpu cortex-a15 -m 256 -serial mon:vc -serial null -kernel /home/wtech/Workspace/rpi-yocto/poky-dunfell/build/tmp/deploy/images/qemuarm/zImage -append 'root=/dev/vda rw mem=256M ip=192.168.7.2::192.168.7.1:255.255.255.0 console=ttyAMA0 '
之后没有任何进展。我也尝试过构建,qemux86_64
但结果是一样的。为了能够使用 qemu 模拟图像,我必须更改什么,这样我就不必为每次更改都刷新 SD 卡?
我的主机系统是虚拟化的 (VirtualBox) Ubutu 22.04
ps -la
更新:如果它添加任何信息,这是挂起时的输出runqemu
。
~ ps -la
F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
0 S 1000 1097 1091 0 80 0 - 57920 do_pol tty2 00:00:00 gnome-session-b
0 S 1000 2338 1811 0 80 0 - 8634 do_wai pts/0 00:00:00 python3
2 R 1000 2399 2338 89 80 0 - 311794 - pts/0 00:00:09 qemu-system-arm
0 R 1000 2434 2081 0 80 0 - 5331 - pts/1 00:00:00 ps
更新:
万一有人尝试过同样的事情。我无法在 yoctorunqemu
环境中运行它。最终起作用的是手动安装qemu-system-aarch64
并运行构建
qemu-system-aarch64 \
-M virt -cpu cortex-a57 \
-kernel tmp/deploy/images/qemuarm64/Image--5.4.228+gitAUTOINC+b00c12ce7a_2bd8ca7c09-r0-qemuarm64-20230208202924.bin \
-append "root=/dev/vda rw mem=512M earlyprintk console=ttyAMA0,115200" \
-drive id=disk0,file=tmp/deploy/images/qemuarm64/core-image-base-qemuarm64-20230215193657.rootfs.ext4,format=raw,if=none \
-smp 4 \
-device virtio-blk-device,drive=disk0 -device qemu-xhci \
-serial mon:vc -serial null \
-display sdl,gl=on \
-device virtio-rng-pci,rng=rng0 \
-object rng-random,filename=/dev/urandom,id=rng0
Yocto qemuarm 图像适用于 ARM926EJ-S 多功能板。runqemu 将配置 QEMU 以准确模拟该板。这与 Raspberry Pi 不同,尤其是 64 位的。
相反,只需直接使用 QEMU。检查
qemu-system-arm -M ?
列表raspi3b
,然后直接指定内核、DT 和 SD。谷歌搜索我发现了这个:不过,我还没有发现用于嵌入式开发的 QEMU 非常有用。要么你有一些隔离得很好的东西,你可以在本地为你的 Linux 设置编译,要么你有一些特定于硬件的东西,你更愿意在实际的硬件上而不是在不完整的仿真上进行测试。对于自动化测试,它肯定是不错的。
对于迭代缓慢的问题,请考虑从共享介质启动,例如通过网络或从可混合的 SD 卡(例如https://www.linux-automation.com/en/products/usb-sd-mux.html我的雇主出售)。