How to build Little Kernel for SD card boot?


#1

Hi,

I’m currently trying the new Yocto Rocko feature using an additional SD card image. I was able to adapt the my machine conf and the WKS file according to my needs. Our board is almost compatible with Variscite SD410.

Using LK from ‘firmware-qcom-dragonboard410c-bootloader-sdcard’ works well. However, I have various extensions/changes in my custom LK build for eMMC. And I need them also when booting from SD card.

Using my custom LK loads the boot image from eMMC instead of loading it from SD card though SBL1 and LK are running from SD card.

I’m using LK source base from here:

https://git.linaro.org/landing-teams/working/qualcomm/lk.git

I’m building platform msm8916.

The code tries to init slot 1 (eMMC) first and if it fails it tries slot 2 (external uSD):

https://git.linaro.org/landing-teams/working/qualcomm/lk.git/tree/target/msm8916/init.c#n107

In the SDHCI driver it tries to inititialize the ‘internal MMC’ and if it fails it tries to initialize the ‘SD card’:

https://git.linaro.org/landing-teams/working/qualcomm/lk.git/tree/platform/msm_shared/mmc_sdhci.c#n1494

The code referenced above seems not to be the base for the LK contained in the ‘firmware-qcom-dragonboard410c-bootloader-sdcard’ which obviously loads the boot image from SD card.

Hence, there must be another initialization sequence for the ‘SD card aware’ LK.

The boot messages from that bootloader tell me that MMC slot 2 is enforced for the first code snipped and the ‘internal MMC’ initialization failure resulting in ‘trying for SD card’ is also valid for the SD boot case:

[10] [10] platform_init()
[10] [10] target_init()
[20] [20] initialising mmc_slot =2
[30] [30] Error: Command timeout error
[30] [30] Failure getting OCR response from MMC Card
[30] [30] MMC card failed to respond, try for SD card
[200] [200] Done initialization of the card

I tried enforce MMC slot 2 too:

...
void target_sdc_init()
{
    ...
#if 0
    /* Try slot 1*/
    config.slot         = 1;
    config.sdhc_base    = mmc_sdhci_base[config.slot - 1];
    config.pwrctl_base  = mmc_pwrctl_base[config.slot - 1];
    config.pwr_irq      = mmc_sdc_pwrctl_irq[config.slot - 1];
    config.hs400_support = 0;

    if (!(dev = mmc_init(&config))) {
#endif
    /* Try slot 2 */
	    config.slot         = 2;
	    config.max_clk_rate = MMC_CLK_200MHZ;
	    config.sdhc_base    = mmc_sdhci_base[config.slot - 1];
	    config.pwrctl_base  = mmc_pwrctl_base[config.slot - 1];
	    config.pwr_irq      = mmc_sdc_pwrctl_irq[config.slot - 1];

	    if (!(dev = mmc_init(&config))) {
                    dprintf(CRITICAL, "mmc init failed!");
			ASSERT(0);
		    }
    #if 0
	    }
    #endif
    }
    ...

The LK never reaches ‘[200] [200] Done initialization of the card’ with the above hack.

Is the initialization sequence from the above firmware LK available?

@ndec Can you help?

Best regards
-Carsten


#2

I found that

card->ext_csd

is accessed though

MMC_CARD_MMC(card)

is not true:

https://git.linaro.org/landing-teams/working/qualcomm/lk.git/tree/platform/msm_shared/mmc_sdhci.c#n237
https://git.linaro.org/landing-teams/working/qualcomm/lk.git/tree/platform/msm_shared/mmc_sdhci.c#n1675

Guarding this code lines with

if (MMC_CARD_MMC(card)) {
   ...
}

solves the problem.

Another issue was that I had to initialize

config.bus_width = DATA_BUS_WIDTH_4BIT;

for the uSD slot.

Will provide a patch on Monday.

Best regards
-Carsten


#3

hi,

if you look at each build we make, e.g.

http://snapshots.linaro.org/96boards/dragonboard410c/linaro/rescue/latest/

You will find in the header at the top, a link to the LK commit we use for each build variant. e.g. for “SD Linux boot” it will point to here:

https://git.linaro.org/landing-teams/working/qualcomm/lk.git/log/?h=release/LA.BR.1.2.7-03810-8x16.0%2Bsdboot

And in this branch you will find the commit that enables SD boot.

Note that (at least for now) for SD boot, there is a custom SBL.mbn file that must be used. That will be fixed in the future (and the same sbl.mbn will be used for emmc or SD boot).

cheers