QEmu-ARM-Ubuntu: CPU1: 启动失败: -38

QEmu-ARM-Ubuntu: CPU1: failed to boot: -38

如何解决 QEmu 中的 "CPU1: failed to boot: -38" 问题?

我在 Windows 10 的 Virtual Box 上托管 Ubuntu 16.04。在 Ubuntu 16.04 中,有 QEmu 模拟 ARM 处理器,运行 Ubuntu 可信赖 (14.04)。当 ARM-Ubuntu 启动时,它会多次打印到控制台 "CPU1: failed to boot: -38" 和类似的内容。是一些命令行切换到 QEmu 还是配置文件的问题?还是另一个 VM 中的错误或不支持 QEmu ARM 仿真?

实际上,ARM-Ubuntu 仅使用物理机和中间虚拟机中可用的 6 个内核中的 1 个。

要在 QEmu 上设置 ARM-Linux,我主要遵循 these steps。我不得不做一些不同的事情,例如因为 Ubuntu Sauce 不再可用。具体我做的步骤是:

# 1) setup the rootfs

sudo apt-get install qemu-user-static qemu-system-arm

mkdir vexpress
cd vexpress
mkdir qemu-img

# Create 8-GB image
dd if=/dev/zero of=./vexpress-8G.img bs=8M count=1024
sudo losetup -f ./vexpress-8G.img
sudo mkfs.ext4 /dev/loop0
sudo mount /dev/loop0 qemu-img

# Bootstrap Ubuntu Trusty armhf rootfs in the qemu-img directory
# For Ubuntu versions later than Trusty some commands fail
# For Ubuntu versions before Saucy there is no port to ARM
# Ubuntu Saucy is not supported anymore
sudo qemu-debootstrap --arch=armhf trusty qemu-img
sudo cp `which qemu-arm-static` qemu-img/usr/bin/

# setup serial console, apt repositories and network
sudo chroot qemu-img
sed 's/tty1/ttyAMA0/g' /etc/init/tty1.conf > /etc/init/ttyAMA0.conf
echo "deb  http://ports.ubuntu.com trusty main restricted multiverse universe" > /etc/apt/sources.list
apt-get update
echo -e "\nauto eth0\niface eth0 inet dhcp" >> /etc/network/interfaces

# root password
passwd


# 2) pick and install a kernel

# Fix locale problems http://askubuntu.com/questions/162391/how-do-i-fix-my-locale-issue
locale
sudo locale-gen "be_BY.UTF-8"
sudo locale-gen "en_US"
sudo locale-gen "en_US.UTF-8"
sudo dpkg-reconfigure locales

apt-get install wget ca-certificates
wget https://launchpad.net/ubuntu/+archive/primary/+files/linux-image-3.13.0-24-generic-lpae_3.13.0-24.46_armhf.deb
dpkg -i linux-image-3.13.0-24-generic-lpae_3.13.0-24.46_armhf.deb

# So far I'm getting the following warnings:
#   Warning: cannot read table of mounted file systems: No such file or directory
#   warning: failed to read mtab

# !!! press CTRL+D to exit the chroot
^D


# 3) Boot it up


# copy kernel, initrd and dtb files
sudo cp qemu-img/boot/vmlinuz-3.13.0-24-generic-lpae .
sudo cp qemu-img/boot/initrd.img-3.13.0-24-generic-lpae .
sudo cp qemu-img/lib/firmware/3.13.0-24-generic-lpae/device-tree/vexpress-v2p-ca15-tc1.dtb .

# umount the rootfs img
sudo umount qemu-img

sudo chmod 777 vmlinuz-3.13.0-24-generic-lpae
sudo chmod 777 initrd.img-3.13.0-24-generic-lpae
sudo chmod 777 vexpress-v2p-ca15-tc1.dtb
sudo chmod 777 vexpress-8G.img

# http://unix.stackexchange.com/questions/167165/how-to-pass-ctrl-c-in-qemu
# Allow Ctrl+C and Ctrl+Z on guest, changing them on host to Ctrl+] and Ctrl+[
stty intr ^]
stty susp ^j

qemu-system-arm --drive format=raw,if=sd,file=vexpress-8G.img -kernel vmlinuz-3.13.0-24-generic-lpae -initrd initrd.img-3.13.0-24-generic-lpae -M vexpress-a15 -serial stdio -m 2048 -append 'root=/dev/mmcblk0 rw mem=2048M raid=noautodetect rootwait console=ttyAMA0,38400n8 devtmpfs.mount=0' -dtb ./vexpress-v2p-ca15-tc1.dtb
# Still getting error: "CPU1: failed to boot: -38"

您正在模拟的特定机器 (vexpress-v2p-ca15-tc1) 是双核机器,因此内核将尝试调出您在 DTB 中描述的辅助 CPU路过。然而,由于 QEMU 只模拟一个 CPU,次级自然不会因为不存在而无法上线。

该消息本身是完全无害的,但如果您对错误消息过敏,只需将 maxcpus=1 添加到内核命令行即可防止 Linux 甚至尝试调出任何错误消息二级核心。如果你真的想要模拟两个内核,将-smp 2选项传递给QEMU,尽管它很可能会导致更多的模拟开销并且整体上更慢。