首页 > 解决方案 > QEMU - 支持 mcimx6ul-evk 机器

问题描述

最近,我正在尝试使用 buildroot在 qemu-arm mcimx6ul-evk机器上启动 Linux。我已经生成了目标机器所需的所有图像。以下是我在 buildroot(版本:buildroot-2016.11.1)上构建映像所遵循的步骤。

$ make freescale_imx6ulevk_defconfig
$ make nconfig

我已经选择了所需的包,然后使用命令构建了图像

$ make

在“输出/图像”中,我看到生成了以下图像, boot.vfat、imx6ul-14x14-evk.dtb、rootfs.ext2、rootfs.ext4、rootfs.tar、sdcard.img、u-boot.bin、u-boot .imx,zImage

我指的是这篇文章为 mcimx6ul-evk 复制相同的内容。我运行以下命令在我的目标机器上启动 Linux

$ qemu-system-arm -M mcimx6ul-evk -m 512M -kernel output/images/zImage -monitor stdio -drive file=output/images/rootfs.ext2,format=raw

当使用-d int运行上述命令时,我得到如下异常日志

    QEMU 4.1.0 monitor - type 'help' for more information
(qemu) Exception return from AArch32 hyp to svc PC 0x80010088
Taking exception 11 [Hypervisor Call]
...from EL1 to EL2
...with ESR 0x12/0x4a000000
Exception return from AArch32 hyp to svc PC 0x800134dc
Taking exception 11 [Hypervisor Call]
...from EL1 to EL2
...with ESR 0x12/0x4a000000
Exception return from AArch32 hyp to svc PC 0x800134dc
Taking exception 11 [Hypervisor Call]
...from EL1 to EL2
...with ESR 0x12/0x4a000000
Exception return from AArch32 hyp to svc PC 0x80be4d1c
Taking exception 11 [Hypervisor Call]
...from EL1 to EL2
...with ESR 0x12/0x4a000000
Exception return from AArch32 hyp to svc PC 0x80008034
AArch32 mode switch from svc to irq PC 0x800118b4
AArch32 mode switch from irq to abt PC 0x800118b8
AArch32 mode switch from abt to und PC 0x800118c4
AArch32 mode switch from und to fiq PC 0x800118d0
AArch32 mode switch from fiq to svc PC 0x800118dc
Taking exception 4 [Data Abort]
...from EL1 to EL1
...with ESR 0x25/0x9600003f
...with DFSR 0x5 DFAR 0x0
Exception return from AArch32 abt to svc PC 0x800130e0

我在 serial0 控制台上看不到 Linux 启动日志。有人可以帮我解决这个问题吗?或者我在这里错过了什么?

注意:qemu(版本:qemu-4.1.0)是使用以下命令为 arm 目标构建的。

$ ./configure --target-list=arm-softmmu --enable-sdl
$ make
$ sudo make install

标签: qemubuildroot

解决方案


我也遇到了这个问题。以下是我为调查它所做的步骤:

  1. 在启用调试信息的情况下编译内核:

    CONFIG_DEBUG_INFO=y

  2. 使用 gdb 调试启动 qemu:

    $qemu-system-arm -M mcimx6ul-evk -cpu cortex-a7 -m 512M -kernel arch/arm/boot/zImage -nographic -dtb arch/arm/boot/dts/imx6ul-14x14-evk.dtb -s -S -d int

    记下这些 qemu 参数:

    -s : -gdb tcp::1234 用于 gdb 调试
    -S : 启动时不启动 CPU(使用 'c' 开始执行)。在启动代码处停止。需要在 gdb 中执行 'c' 命令。

  3. 使用 gdb-multiarch 进行调试:

    $gdb-multiarch  
    
    (gdb) target remote localhost:1234  
    (gdb) file vmlinux  
    (gdb) b start_kernel  
    Breakpoint 1 at 0x80e008cc: file init/main.c, line 482.  
    (gdb) c  
    Continuing.  
    Breakpoint 1, start_kernel () at init/main.c:482  
    482     {  
    (gdb)
    

    内核正在启动,因为它遇到了断点。

  4. 添加内核命令行条目以查看更多日志:

    $qemu-system-arm -M mcimx6ul-evk -cpu cortex-a7 -m 512M -kernel arch/arm/boot/zImage -nographic -dtb arch/arm/boot/dts/imx6ul-14x14-evk.dtb -append "console=ttymxc0 loglevel=8 earlycon earlyprintk"

    根据日志,我禁用了导致内核崩溃的驱动程序(这是因为 qemu mcimx6ul-evk 机器不支持它们)。您可以从 menuconfig 禁用它们,然后重新编译内核。

请注意,我没有使用 buildroot。这是我的设置:

Repository: https://source.codeaurora.org/external/imx/linux-imx  
Config: imx_v7_defconfig
Toolchain: arm-linux-gnueabihf-
Host: WSL2  

推荐阅读