1

I would like to boot an U-boot image from eMMC flash user data partition, done some changes in spl(second program loader) of u-boot source code to add this support I mean fsbl(First stage boot loader) load the u-boot image from emmc flash to DRAM and boot from there and should get the u-boot prompt.

Before this initialise the eMMC user-data partition and U-boot load and start at specific address defined by CONFIG_SYS_TEXT_BASE=0x60000000. Using flashing tool able to flash the u-boot image into emmc user-data partition.

Able to see the u-boot contents at memory location 0x60000000 in memory window of ds5 with help of jtag with simple application which will read the data from the emmc flash to DDR location 0x60000000. My doubt: Do we need to copy u-boot image from emmc userdata flash to DRAM location 0x60000000?

2nd Doubt:

I modified below code to make the fsbl load the u-boot image from eMMC flash to DRAM and boot from there.

spl_mmc_load_image(struct spl_image_info *spl_image,
                       struct spl_boot_device *bootdev)
{
        struct mmc *mmc = NULL;
        u32 boot_mode;
        int err = 0;
        __maybe_unused int part;

        err = spl_mmc_find_device(&mmc, bootdev->boot_device);
        if (err)
                return err;

        err = mmc_init(mmc);
        if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
                printf("spl: mmc init failed with error: %d\n", err);
#endif
                return err;
        }

        boot_mode = spl_boot_mode(bootdev->boot_device);
        err = -EINVAL;
        switch (boot_mode) {
        case MMCSD_MODE_EMMCBOOT:
                        /*
                         * We need to check what the partition is configured to.
                         * 1 and 2 match up to boot0 / boot1 and 7 is user data
                         * which is the first physical partition (0).
                         */
                        part = (mmc->part_config >> 3) & PART_ACCESS_MASK;

                        if (part == 7)
                                part = 0;

                        if (CONFIG_IS_ENABLED(MMC_TINY))
                                err = mmc_switch_part(mmc, part);
                        else
                 err = blk_dselect_hwpart(mmc_get_blk_desc(mmc), part);

                        if (err) {
#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
                                puts("spl: mmc partition switch failed\n");
#endif
                                return err;
                        }
                        /* Fall through */
        case MMCSD_MODE_RAW:
                debug("spl: mmc boot mode: raw\n");

                if (!spl_start_uboot()) {
                        err = mmc_load_image_raw_os(spl_image, mmc);
                        if (!err)
                                return err;
                }

                err = mmc_load_image_raw_partition(spl_image, mmc,
                        CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION);
                if (!err)
                        return err;
#ifdef CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_USE_SECTOR
                err = mmc_load_image_raw_sector(spl_image, mmc,
                        CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR);
                if (!err)
                        return err;

}

Inside this function: mmc_load_image_raw_sector() under u-boot-src/common/spl/spl_mmc.c

   count = blk_dread(mmc_get_blk_desc(mmc), sector, 1, header);

count is always zero . Interanlly blk_dread is calling the CMD16(set the block length) and CMD17(Reading blocks) are failing. For CMD16 set block lenght=512 and reading no of blocks= some no xxx manually gave to pass through the count value. My main intention fsbl load the u-boot and booting , get the u-boot prompt. Finally reached to below code under u-boot-src/common/spl/spl_mmc.c

    debug("loaded - jumping to U-Boot...");
    spl_board_prepare_for_boot();
    jump_to_image_no_args(&spl_image);

    After this fsbl reseting .....

3rd doubt:

Can I use this code for copying u-boot image from emmc flash to RAM, which is preset in u-boot source?

    function name void copy_uboot_to_ram(void)

present under arch/arm/mach-exynos/spl_boot.c

ifdef CONFIG_SUPPORT_EMMC_BOOT
        case BOOT_MODE_EMMC:
                /* Set the FSYS1 clock divisor value for EMMC boot */
                emmc_boot_clk_div_set();

                copy_bl2_from_emmc = get_irom_func(EMMC44_INDEX);
                end_bootop_from_emmc = get_irom_func(EMMC44_END_INDEX);

                copy_bl2_from_emmc(BL2_SIZE_BLOC_COUNT, CONFIG_SYS_TEXT_BASE);
                end_bootop_from_emmc();
                break;
shaikh kamal
  • 36
  • 2
  • 8
  • Problem is that I should copy the u-boot image from the eMMC flash to DDR location at 0x60000000. We need CMD17 which will read the no of blocks from the emmc flash and copy to DDR, since I'm hard coded this CMD17, I should not do this. Still I need inputs from the expert . – shaikh kamal Feb 24 '18 at 05:48
  • 1
    Problem is resolved, since struct image_header *header; header = (struct image_header *)(CONFIG_SYS_TEXT_BASE - sizeof(struct image_header));, now header is pointing to (0x600000000 -0x0000040) =0x5FFFFFC0, SPL copied the u-boot data to DDR location 0x5FFFFFC0, system will start u-boot at DDR location 0x600000000 i.e u-boot header is 64 bytes and actual u-boot data present at 0x600000000. header(64 bytes)[0x5FFFFFC0 + data[0x600000000], able to get u-boot console – shaikh kamal May 01 '18 at 09:40

0 Answers0