This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/AM5708: SD/EMMC detect sequence problem

Part Number: AM5708

Tool/software: Linux

Hi,

I'm using AM5708 based custom board.

We have SD card slot on MMC1 and EMMC mounted on MMC2.

Previously, we were booting with kernel 4.4.41. In that kernel, when we have SD card attached in our board, then SD card was detecting on mmcblk0 and EMMC was detecting on mmcblk1. And when SD card was not attached on the board, then EMMC was detecting on mmcblk0. So, we were always booting using mmcblk0 because our priority was SD card ->  EMMC.

Now, we are trying to upgrade our kernel to 4.14.79. In this kernel version, even when SD card is not attached, EMMC is detected on mmcblk1. So, kernel is stuck at "Waiting for root device /dev/mmcblk0p2".

If SD card is attached, it is successfully booting from it, but we require to have both option (SD/EMMC) working so we can't change the command line argument for rootfs.

Is there any way I can put any fix in kernel to start detecting mmc like the previous kernel.

Thanks,

Gunjal

  • Hello Gunjal,

    Are you preserving the old U-Boot while updating to the new kernel version, or you consider to update the U-Boot version too?

    Best regards,
    Kemal

  • We have already updated uboot to 2018.01

    Regards,

    Gunjal

  • Any help on this?
  • Hello Gunjal,

    I need to check what has changed between the two kernel versions to answer you, but you can do that though. Compare the two kernel versions and try to find out what change caused this behavior. Keep in mind that it can be U-Boot related too.

    Best regards,
    Kemal
  • Hi Kemal,

    I compared the kernel source code with older source (4.4.41).

    Here's what I have found,

    In mmc core block driver, during memory block allocation it was using mmc card's host index to create disk name. So, mmc0 device was getting mmcblk0 and mmc1 device was getting mmcblk1.

    While in older kernel it was keeping track of number of devices that was getting probed and detected. So, whichever mmc device gets detected first was getting mmcblk0.

    So, I made change in mmc core block driver to use the old logic.

    +    /*
    +     * !subname implies we are creating main mmc_blk_data that will be
    +     * associated with mmc_card with dev_set_drvdata. Due to device
    +     * partitions, devidx will not coincide with a per-physical card
    +     * index anymore so we keep track of a name index.
    +     */
    +    if (!subname) {
    +        md->name_idx = find_first_zero_bit(name_use, max_devices);
    +        __set_bit(md->name_idx, name_use);
    +    } else
    +        md->name_idx = ((struct mmc_blk_data *)
    +                        dev_to_disk(parent)->private_data)->name_idx;
    
    
        snprintf(md->disk->disk_name, sizeof(md->disk->disk_name),
    -        "mmcblk%u%s", card->host->index, subname ? subname : "");
    +        "mmcblk%u%s", md->name_idx, subname ? subname : "");

    Now, after doing this, when I don't insert SD card then emmc was getting detected on mmcblk0 but when I insert SD card and boot, then EMMC was getting mount on mmcblk0 and SD card was getting mount on mmcblk1 because mmc1 device was getting detected first and then mmc0 was getting detected. And I wanted SD on mmcblk0 and EMMC on mmcblk1 in case of SD card inserted.

    These are my boot logs,

    [    1.908270] sdhci: Secure Digital Host Controller Interface driver
    [    1.914493] sdhci: Copyright(c) Pierre Ossman
    [    1.919379] sdhci-pltfm: SDHCI platform and OF driver helper
    [    1.925625] 
    [    1.925625] ## HOST : mmc_alloc_host : host index = 0
    [    1.932524] sdhci-omap 4809c000.mmc: 4809c000.mmc supply vqmmc not found, using dummy regulator
    [    1.941666] sdhci-omap 4809c000.mmc: no pinctrl state for ddr_1_8v mode
    [    1.948316] sdhci-omap 4809c000.mmc: no pinctrl state for hs200_1_8v mode
    [    2.010893] 
    [    2.010893] ## mmc_rescan : mmc_host index = 0
    [    2.016862] mmc0: SDHCI controller on 4809c000.mmc [4809c000.mmc] using ADMA
    [    2.025518] 
    [    2.025518] ## HOST : mmc_alloc_host : host index = 1
    [    2.100881] mmc1: SDHCI controller on 480b4000.mmc [480b4000.mmc] using ADMA
    [    2.108311] 
    [    2.108311] ## HOST : mmc_alloc_host : host index = 2
    [    2.114894] 
    [    2.114894] ## mmc_rescan : mmc_host index = 1
    [    2.121272] sdhci-omap 480ad000.mmc: 480ad000.mmc supply vqmmc not found, using dummy regulator
    [    2.143710] sdhci-omap 480ad000.mmc: no pinctrl state for sdr104 mode
    [    2.150182] sdhci-omap 480ad000.mmc: no pinctrl state for ddr50 mode
    [    2.156615] sdhci-omap 480ad000.mmc: no pinctrl state for hs200_1_8v mode
    [    2.164599] 
    [    2.164599] ## mmc_set_uhs_voltage : 1556 : try again error
    [    2.171930] 
    [    2.171930] ## mmc0: Signal voltage switch failed, power cycling card
    [    2.181646] mmc1: new MMC card at address 0001
    [    2.186246] 
    [    2.186246] ## mmc_blk_probe : HOST_INDEX = 1
    [    2.192170] 
    [    2.192170] ## mmc_blk_alloc_req : devidx = 0
    [    2.198061] 
    [    2.198061] ## mmc_blk_alloc_req : name_idx = 0
    [    2.204460] mmcblk0: mmc1:0001 SDM032 30.6 MiB 
    [    2.320884] mmc2: SDHCI controller on 480ad000.mmc [480ad000.mmc] using PIO
    [    2.328550] 
    [    2.328550] ## mmc_rescan : mmc_host index = 2
    [    2.334559] ledtrig-cpu: registered to indicate activity on CPUs
    [    2.342495] usbcore: registered new interface driver usbhid
    [    2.342499] usbhid: USB HID core driver
    [    2.351994] davinci-mcasp 48464000.mcasp: invalid tdm slots: 0
    [    2.352892] nf_conntrack version 0.5.0 (8192 buckets, 32768 max)
    [    2.353262] ip_tables: (C) 2000-2006 Netfilter Core Team
    [    2.357221] mmc0: host does not support reading read-only switch, assuming write-enable
    [    2.363286] mmc0: new high speed SDHC card at address aaaa
    [    2.363425] 
    [    2.363425] ## mmc_blk_probe : HOST_INDEX = 0
    [    2.363432] 
    [    2.363432] ## mmc_blk_alloc_req : devidx = 1
    [    2.363436] 
    [    2.363436] ## mmc_blk_alloc_req : name_idx = 1
    [    2.375005] mmcblk1: mmc0:aaaa SC32G 29.7 GiB 
    [    2.407182]  mmcblk1: p1 p2 p3 p4 < p5 p6 p7 p8 >
    [    2.422708] NET: Registered protocol family 10
    

    I noticed that there was delay in mmc0 detection because of some voltage switch warnings and thats why mmc1 was getting detected first.

    So, I put 200 millisecond delay before initialization on mmc. And this solved my problem temporarily.

    I am not sure this is the correct method to do.

    Can I get some suggestion on this?

    Regards,

    Gunjal

  • Hi,

    I don't think this could be a permanent solution, it's just a temporary solution. Because if SD card detection taken little more time than the delay I put, then this would again break my functionality.
    So, I can't go ahead with this solution.

    I need some reliable solution.

    Regards,
    Gunjal
  • The most reliable solution I've found is to change the emmc_linux_boot environment variable in U-Boot.

    => setenv emmc_linux_boot 'echo Trying to boot Linux from eMMC ...; setenv mmcdev 1; setenv bootpart 1:2; setenv mmcroot /dev/mmcblk1p2 rw; run mmcboot;'
    => saveenv

  • Hello Gunjal,

    Please, apply this patch if you want to bring that behavior you have lost.

    cd <Processor SDK>/board-support/linux-<version>/
    git apply 0001-AM57xx-Revert-the-three-fixed-mmcblk-device-patches.patch

    Please, also close this thread by clicking on "This resolved my issue" button, as we will continue the discussion in your new thread.

    Best regards,
    Kemal