首页 > 解决方案 > QEMU emulator does not initialize mmc card for i.MX6 sabrelite

问题描述

I'm trying to emulate below i.MX6Q device using QEMU emulator version 3.1.0 on host machines with #41-Ubuntu 4.15.0-38-generic SMP.

CPU:   Freescale i.MX6Q rev1.2 at 792 MHz
Board: Mx6Q 4G
Boot Device: SPI NOR
I2C:   ready
DRAM:  3.7 GiB
MMC:   FSL_SDHC: 0

Below is the step by step approach I have followed to emulate device

STEP 1:: Copied the uImage from actual device to host

STEP 2:: Cloned SD/MMC card from actual device using below command

sudo dd if=/dev/sdc of=sdcard1.img bs=4096 conv=notrunc,noerror

Now having copy of uImage and image of SD card on the host machine, below command was used to start the emulator.

$./qemu-3.1.0/arm-softmmu/qemu-system-arm 
-machine sabrelite,accel=kvm:tcg 
-kernel uImage 
-m 3840 
-smp cpus=4 
-serial mon:stdio 
-drive file=sdcard1.img,format=raw,id=mycard 
-device sd-card,drive=mycard

It has booted up the kernel uImage properly like below

VNC server running on 127.0.0.1:5900
Booting Linux on physical CPU 0x0
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 3.10.53 (build_team@u1004-swb02) (gcc version 4.7.3 20130102 (prerelease) (crosstool-NG 1.18.0) ) #1 SMP PREEMPT Tue Jun 13 16:03:05 PDT 2017
CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7), cr=10c53c7d
CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
Machine: i.MX6q 
... so on

However it did not attach the sdcard image cloned from the actual device, it just ignored it and went ahead like below without mounting mmc0.

mmc0: no vqmmc regulator found
mmc0: no vmmc regulator found
mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA
mmc2: no vqmmc regulator found
mmc2: no vmmc regulator found
mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc] using ADMA

On Actual device I believe mmc is initialized by U-Boot itself. And during kernel execution it gets mounted to mmblk0 like below.

mmc0: no vqmmc regulator found
mmc0: no vmmc regulator found
mmc0: SDHCI controller on 2190000.usdhc [2190000.usdhc] using ADMA
mmc2: no vqmmc regulator found
mmc2: no vmmc regulator found
mmc0: host does not support reading read-only switch. assuming write-enable.
mmc0: new high speed SDHC card at address 59b4
mmcblk0: mmc0:59b4 HSG04 3.74 GiB
 mmcblk0: p1 p2
mmc2: SDHCI controller on 2198000.usdhc [2198000.usdhc] using ADMA

Unlike actual device here mmc is not initialized by u-boot and kernel is booted up directly with QEMU, so after certain point of boot up kernel crashed with error "Unable to handle kernel paging request at virtual address ffffffec".

So my question here is how to initialize mmc drive with kernel (without u-boot) in QEMU. Or have I gone wrong in any of the steps in creation of mmc drive or qemu command used for initializing mmc drive?

Adding more info on device tree. It is actually custom built board. Not really sure about nodes of DT. Please see the excerpt of device tree related to mmc devices. Please review and provide your input.

aliases {
    .... other device info
    mmc0 = "/soc/aips-bus@02100000/usdhc@02190000";
    mmc1 = "/soc/aips-bus@02100000/usdhc@02194000";
    mmc2 = "/soc/aips-bus@02100000/usdhc@02198000";
    mmc3 = "/soc/aips-bus@02100000/usdhc@0219c000";
    ....
};


soc {
    #address-cells = <0x1>;
    #size-cells = <0x1>;
    compatible = "simple-bus";
    interrupt-parent = <0x1>;
    ranges;
    .....
        iomuxc@020e0000 {
            reg = <0x20e0000 0x4000>;
            compatible = "fsl,imx6q-iomuxc";
            pinctrl-names = "default";
            pinctrl-0 = <0x16>;
            ..........

            usdhc1 {

                usdhc1grp-1 {
                    fsl,pins = <0x348 0x730 0x0 0x0 0x0 0x17071 0x350 0x738 0x0 0x0 0x0 0x10071 0x340 0x728 0x0 0x0 0x0 0x17071 0x33c 0x724 0x0 0x0 0x0 0x17071 0x34c 0x734 0x0 0x0 0x0 0x17071 0x344 0x72c 0x0 0x0 0x0 0x17071>;
                    linux,phandle = <0x1d>;
                    phandle = <0x1d>;
                };
            };

            usdhc2 {

                usdhc2grp-1 {
                    fsl,pins = <0x358 0x740 0x0 0x0 0x0 0x17059 0x354 0x73c 0x0 0x0 0x0 0x10059 0x54 0x368 0x0 0x0 0x0 0x17059 0x4c 0x360 0x0 0x0 0x0 0x17059 0x50 0x364 0x0 0x0 0x0 0x17059 0x35c 0x744 0x0 0x0 0x0 0x17059 0x30c 0x6f4 0x0 0x1 0x0 0x17059 0x310 0x6f8 0x0 0x1 0x0 0x17059 0x314 0x6fc 0x0 0x1 0x0 0x17059 0x318 0x700 0x0 0x1 0x0 0x17059>;
                };

                usdhc2grp-2 {
                    fsl,pins = <0x358 0x740 0x0 0x0 0x0 0x17059 0x354 0x73c 0x0 0x0 0x0 0x10059 0x54 0x368 0x0 0x0 0x0 0x17059 0x4c 0x360 0x0 0x0 0x0 0x17059 0x50 0x364 0x0 0x0 0x0 0x17059 0x35c 0x744 0x0 0x0 0x0 0x17059>;
                };
            };

            usdhc3 {

                usdhc3grp-1 {
                    fsl,pins = <0x2b8 0x6a0 0x0 0x0 0x0 0x17059 0x2bc 0x6a4 0x0 0x0 0x0 0x10059 0x2c0 0x6a8 0x0 0x0 0x0 0x17059 0x2c4 0x6ac 0x0 0x0 0x0 0x17059 0x2c8 0x6b0 0x0 0x0 0x0 0x17059 0x2cc 0x6b4 0x0 0x0 0x0 0x17059 0x2b4 0x69c 0x0 0x0 0x0 0x17059 0x2b0 0x698 0x0 0x0 0x0 0x17059 0x2ac 0x694 0x0 0x0 0x0 0x17059 0x2a8 0x690 0x0 0x0 0x0 0x17059>;
                };

                usdhc3grp-1-100mhz {
                    fsl,pins = <0x2b8 0x6a0 0x0 0x0 0x0 0x170b9 0x2bc 0x6a4 0x0 0x0 0x0 0x100b9 0x2c0 0x6a8 0x0 0x0 0x0 0x170b9 0x2c4 0x6ac 0x0 0x0 0x0 0x170b9 0x2c8 0x6b0 0x0 0x0 0x0 0x170b9 0x2cc 0x6b4 0x0 0x0 0x0 0x170b9 0x2b4 0x69c 0x0 0x0 0x0 0x170b9 0x2b0 0x698 0x0 0x0 0x0 0x170b9 0x2ac 0x694 0x0 0x0 0x0 0x170b9 0x2a8 0x690 0x0 0x0 0x0 0x170b9>;
                };

                usdhc3grp-1-200mhz {
                    fsl,pins = <0x2b8 0x6a0 0x0 0x0 0x0 0x170f9 0x2bc 0x6a4 0x0 0x0 0x0 0x100f9 0x2c0 0x6a8 0x0 0x0 0x0 0x170f9 0x2c4 0x6ac 0x0 0x0 0x0 0x170f9 0x2c8 0x6b0 0x0 0x0 0x0 0x170f9 0x2cc 0x6b4 0x0 0x0 0x0 0x170f9 0x2b4 0x69c 0x0 0x0 0x0 0x170f9 0x2b0 0x698 0x0 0x0 0x0 0x170f9 0x2ac 0x694 0x0 0x0 0x0 0x170f9 0x2a8 0x690 0x0 0x0 0x0 0x170f9>;
                };

                usdhc3grp-2 {
                    fsl,pins = <0x2b8 0x6a0 0x0 0x0 0x0 0x17059 0x2bc 0x6a4 0x0 0x0 0x0 0x10059 0x2c0 0x6a8 0x0 0x0 0x0 0x17059 0x2c4 0x6ac 0x0 0x0 0x0 0x17059 0x2c8 0x6b0 0x0 0x0 0x0 0x17059 0x2cc 0x6b4 0x0 0x0 0x0 0x17059>;
                    linux,phandle = <0x1e>;
                    phandle = <0x1e>;
                };
            };

            usdhc4 {

                usdhc4grp-1 {
                    fsl,pins = <0x2f4 0x6dc 0x0 0x0 0x0 0x17059 0x2f8 0x6e0 0x0 0x0 0x0 0x10059 0x31c 0x704 0x0 0x1 0x0 0x17059 0x320 0x708 0x0 0x1 0x0 0x17059 0x324 0x70c 0x0 0x1 0x0 0x17059 0x328 0x710 0x0 0x1 0x0 0x17059 0x32c 0x714 0x0 0x1 0x0 0x17059 0x330 0x718 0x0 0x1 0x0 0x17059 0x334 0x71c 0x0 0x1 0x0 0x17059 0x338 0x720 0x0 0x1 0x0 0x17059>;
                };

                usdhc4grp-2 {
                    fsl,pins = <0x2f4 0x6dc 0x0 0x0 0x0 0x17059 0x2f8 0x6e0 0x0 0x0 0x0 0x10059 0x31c 0x704 0x0 0x1 0x0 0x17059 0x320 0x708 0x0 0x1 0x0 0x17059 0x324 0x70c 0x0 0x1 0x0 0x17059 0x328 0x710 0x0 0x1 0x0 0x17059>;
                };
            };

    aips-bus@02100000 {
        compatible = "fsl,aips-bus", "simple-bus";
        #address-cells = <0x1>;
        #size-cells = <0x1>;
        reg = <0x2100000 0x100000>;
        ranges;
        .....

        usdhc@02190000 {
            compatible = "fsl,imx6q-usdhc";
            reg = <0x2190000 0x4000>;
            interrupts = <0x0 0x16 0x4>;
            clocks = <0x2 0xa3 0x2 0xa3 0x2 0xa3>;
            clock-names = "ipg", "ahb", "per";
            bus-width = <0x4>;
            status = "okay";
            non-removable;
            pinctrl-names = "default";
            pinctrl-0 = <0x1d>;
            no-1-8-v;
        };

        usdhc@02194000 {
            compatible = "fsl,imx6q-usdhc";
            reg = <0x2194000 0x4000>;
            interrupts = <0x0 0x17 0x4>;
            clocks = <0x2 0xa4 0x2 0xa4 0x2 0xa4>;
            clock-names = "ipg", "ahb", "per";
            bus-width = <0x4>;
            status = "disabled";
        };

        usdhc@02198000 {
            compatible = "fsl,imx6q-usdhc";
            reg = <0x2198000 0x4000>;
            interrupts = <0x0 0x18 0x4>;
            clocks = <0x2 0xa5 0x2 0xa5 0x2 0xa5>;
            clock-names = "ipg", "ahb", "per";
            bus-width = <0x4>;
            status = "okay";
            non-removable;
            pinctrl-names = "default";
            pinctrl-0 = <0x1e>;
            no-1-8-v;
        };

        usdhc@0219c000 {
            compatible = "fsl,imx6q-usdhc";
            reg = <0x219c000 0x4000>;
            interrupts = <0x0 0x19 0x4>;
            clocks = <0x2 0xa6 0x2 0xa6 0x2 0xa6>;
            clock-names = "ipg", "ahb", "per";
            bus-width = <0x4>;
            status = "disabled";
        };

标签: linux-kernelarmembedded-linuxvirtualizationqemu

解决方案


推荐阅读