Qemu Freescale i.MX6 DualLite SABER:根文件系统无法安装

kai*_*wan 6 arm qemu linux-kernel embedded-linux imx6

目标:模仿Qemu特别支持的"sabrelite:飞思卡尔i.MX6 Quad SABRE Lite Board(Cortex A9)"(做'qemu-system-arm -M?'它出现).

Qemu ver:2.10.1(主持人:fedora-27).

我已成功交叉编译并构建了一个4.1.46 Linux内核(使用了imx_v6_v7_defconfig配置文件)以及一个简单的"骨架"根文件系统(基于busybox).(仅供参考,我对ARM Cortex-A9 Versatile Express平台有类似的工作设置 - 我使用自己的家用旋转嵌入式Linux系统SEALS进行此操作.

看看类似主板使用的U-Boot配置文件,我想用'root =/dev/mmcblk0p0'作为内核的root = param.所以,为了尝试一下,我按如下方式运行qemu(pl水平滚动以查看):

qemu-system-arm -m 512 -M sabrelite -kernel zImage -drive file=rfs.img,format=raw -append "console=ttymxc0 rootfstype=ext4 root=/dev/mmcblk0p0 rw rootwait init=/sbin/init " -nographic -dtb imx6dl-sabresd.dtb

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.1.46 (kai@klaptop) (gcc version 4.8.3 20140320 (prerelease) (Sourcery CodeBench Lite 2014.05-29) ) #2 SMP Mon Nov 27 17:16:22 IST 2017
[    0.000000] CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] Machine model: Freescale i.MX6 DualLite SABRE Smart Device Board
[    0.000000] cma: Reserved 16 MiB at 0x2f000000
Run Code Online (Sandbox Code Playgroud)

[...]

所以它开始启动就好了.但是之后:

[...]
[    2.210965] /soc/aips-bus@02100000/usdhc@02194000: voltage-ranges unspecified
[    2.211796] sdhci-esdhc-imx 2194000.usdhc: Got CD GPIO
[    2.212199] sdhci-esdhc-imx 2194000.usdhc: Got WP GPIO
[    2.214392] sdhci-esdhc-imx 2194000.usdhc: could not get ultra high speed state, work on normal mode
[    2.218084] sdhci-esdhc-imx 2194000.usdhc: No vmmc regulator found
[    2.218367] sdhci-esdhc-imx 2194000.usdhc: No vqmmc regulator found
[    2.265431] mmc0: SDHCI controller on 2194000.usdhc [2194000.usdhc] using ADMA
[    2.267300] mmc0: mmc_rescan_try_freq: trying to init card at 400000 Hz
[    2.281912] /soc/aips-bus@02100000/usdhc@02198000: voltage-ranges unspecified
[    2.282956] sdhci-esdhc-imx 2198000.usdhc: Got CD GPIO
[    2.283703] sdhci-esdhc-imx 2198000.usdhc: Got WP GPIO
[    2.284044] sdhci-esdhc-imx 2198000.usdhc: could not get ultra high speed state, work on normal mode
[    2.284892] sdhci-esdhc-imx 2198000.usdhc: No vmmc regulator found
[    2.285167] sdhci-esdhc-imx 2198000.usdhc: No vqmmc regulator found
[    2.298029] mmc0: mmc_rescan_try_freq: trying to init card at 300000 Hz
[    2.337904] mmc1: SDHCI controller on 2198000.usdhc [2198000.usdhc] using ADMA
[    2.357051] /soc/aips-bus@02100000/usdhc@0219c000: voltage-ranges unspecified
[    2.358313] sdhci-esdhc-imx 219c000.usdhc: No vmmc regulator found
[    2.358642] sdhci-esdhc-imx 219c000.usdhc: No vqmmc regulator found
[    2.368204] mmc0: mmc_rescan_try_freq: trying to init card at 200000 Hz
[    2.414722] mmc2: SDHCI controller on 219c000.usdhc [219c000.usdhc] using ADMA
[    2.440456] mmc0: mmc_rescan_try_freq: trying to init card at 100000 Hz

[...]

[    2.986441]   No soundcards found.
[    3.007698] Waiting for root device /dev/mmcblk0p0...
Run Code Online (Sandbox Code Playgroud)

在这里永远等待......

我知道,在实际的物理板上,必须"格式化"或分区MMC(或SD)卡,并让u-boot将内核和rootfs加载到RAM中.但我现在有兴趣让IMX6在Qemu上运行...所以,我的实际问题是:如何在Qemu上安装根文件系统并运行?任何帮助赞赏!TIA,

Pet*_*ell 6

这里有两个问题.首先,您的命令行实际上并没有创建SD卡:-drive选项会创建一个驱动对象,但不会尝试将其插入任何地方(因为sabrelite板没有定义"默认类型的块驱动器") .要将驱动器插入到您需要的模拟SD卡中

-drive file=yourfile.img,format=raw,id=mycard -device sd-card,drive=mycard
Run Code Online (Sandbox Code Playgroud)

其次,QEMU当前的imx6 sd控制器仿真存在缺陷,因为如果你这样做,那么客户内核会不断打印

[   28.971663] mmc1: Timeout waiting for hardware interrupt.
[   28.973619] mmc1: error -110 whilst initialising SD card
Run Code Online (Sandbox Code Playgroud)

...所以它已经找到了模拟卡,但没有得到它期望的中断.

这些可以通过目前在qemu-devel邮件列表上的补丁修复并通过代码审查:http://patchwork.ozlabs.org/patch/834805/加上对hw/arm/fsl-imx6.c的简单更改使它创建TYPE_IMX_USDHC设备而不是TYPE_SYSBUS_SDHCI.(基本上,imx6的SD控制器不是完全标准兼容的sdhci控制器,但我们在QEMU模型中创建的是简单的多样性.)

如果你做了所有这些,那么你可以启动一个可以看到mmc卡的内核:

[    8.878283] mmc1: new SD card at address 4567
[    8.910566] mmcblk0: mmc1:4567 QEMU! 256 MiB 
Run Code Online (Sandbox Code Playgroud)

运气不错,我们将能够在QEMU的2.12版本中修复此问题,该版本将在2018年春季推出.

编辑截至2018年3月9日 - 相关修复现在在QEMU master(提交fd1e5c81796,df2a5cf4c8),并将在2.12.