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.

SK-AM62: Hardcode to boot from eMMC boot partition #1

Part Number: SK-AM62
Other Parts Discussed in Thread: CSD

Hi TI engineers,

I want to modify the source code so that my board will always boot from eMMC boot partition #1 during initialization and before going into uboot. I understand which boot partition to boot is determined by the register EXT_CSD[179] which is set by using mmc partconf in uboot. Is there other way to hardcode the eMMC boot partition in uboot source code?

I found something in the /common/spl/Kconfig file.

config SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
	bool "MMC Raw mode: by partition"
	help
	  Use a partition for loading U-Boot when using MMC/SD in raw mode.

config SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION
	hex "Partition to use to load U-Boot from"
	depends on SYS_MMCSD_RAW_MODE_U_BOOT_USE_PARTITION
	default 1
	help
	  Partition on the MMC to load U-Boot from when the MMC is being
	  used in raw mode

config SUPPORT_EMMC_BOOT_OVERRIDE_PART_CONFIG
	bool "Override eMMC EXT_CSC_PART_CONFIG by user defined partition"
	depends on SUPPORT_EMMC_BOOT
	help
	  eMMC boot partition is normally configured by the bits of the EXT_CSD
	  register (EXT_CSC_PART_CONFIG), BOOT_PARTITION_ENABLE field. In some
	  cases it might be required in SPL to load the image from different
	  partition than the partition selected by EXT_CSC_PART_CONFIG register.
	  Enable this option if you intend to use an eMMC boot partition other
	  then selected via EXT_CSC_PART_CONFIG register and specify the custom
	  partition number by the CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
	  option.

config SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION
	int "Number of the eMMC boot partition to use"
	depends on SUPPORT_EMMC_BOOT_OVERRIDE_PART_CONFIG
	default 1
	help
	  eMMC boot partition number to use when the eMMC in raw mode and
	  the eMMC EXT_CSC_PART_CONFIG selection should be overridden in SPL
	  by user defined partition number.

I have enable both by defining in the r5 and a53 deconfig file. But how do I use this to set to eMMC boot partition #1 during board initialization? Also, I have set the primary boot mode to eMMC for the boot configuration switches.

Or is it possible to modify the register EXT_CSD[179] in the board initialization source code, then build it and flash into the board?

By the way, I have found the source code for the command mmc partconf in /cmd/mmc.c

static int do_mmc_partconf(struct cmd_tbl *cmdtp, int flag,
			   int argc, char *const argv[])
{
	int dev;
	struct mmc *mmc;
	u8 ack, part_num, access;

	if (argc != 2 && argc != 5)
		return CMD_RET_USAGE;

	dev = simple_strtoul(argv[1], NULL, 10);

	mmc = init_mmc_device(dev, false);
	if (!mmc)
		return CMD_RET_FAILURE;

	if (IS_SD(mmc)) {
		puts("PARTITION_CONFIG only exists on eMMC\n");
		return CMD_RET_FAILURE;
	}

	if (argc == 2)
		return mmc_partconf_print(mmc);

	ack = simple_strtoul(argv[2], NULL, 10);
	part_num = simple_strtoul(argv[3], NULL, 10);
	access = simple_strtoul(argv[4], NULL, 10);

	/* acknowledge to be sent during boot operation */
	return mmc_set_part_conf(mmc, ack, part_num, access);
}

From the code, it will call another function to set part conf and this function is in /drivers/mmc/mmc_boot.c

/*
 * Modify EXT_CSD[179] which is PARTITION_CONFIG (formerly BOOT_CONFIG)
 * based on the passed in values for BOOT_ACK, BOOT_PARTITION_ENABLE and
 * PARTITION_ACCESS.
 *
 * Returns 0 on success.
 */
int mmc_set_part_conf(struct mmc *mmc, u8 ack, u8 part_num, u8 access)
{
	int ret;
	u8 part_conf;
	
	part_conf = EXT_CSD_BOOT_ACK(ack) |
		    EXT_CSD_BOOT_PART_NUM(part_num) |
		    EXT_CSD_PARTITION_ACCESS(access);

	ret = mmc_switch(mmc, EXT_CSD_CMD_SET_NORMAL, EXT_CSD_PART_CONF,
			 part_conf);
	if (!ret)
		mmc->part_config = part_conf;

	return ret;
}

If I hardcode this, it will not take effect upon initialization, but will only take effect when you use the command in uboot.

In other words, is it possible to configure the register EXT_CSD[179] without configuring in u-boot or kernel?

Thanks.

  • Hello Chee,
    Let me expand a bit on my reply in this e2e
    e2e.ti.com/.../4506162
    >>>>
    A1. MMC/eMMC port is determined by BOOTMODE pins, and from which eMMC partition (boot1/boot2/UDA) R5-SPL boots from is solely by eMMC EXTCSD[179]
    A2. tispl.bin (ATF + OPTEE + A53-SPL) booting media is determined in R5-SPL as listed below, and essentially by BOOTMODE pins, but changeable by user as needed.
    git.ti.com/gitweb
    >>>>
    A1.
    After R5-SPL is flashed to eMMC boot1, eMMC EXTCSD[179] needs to programmed/configured, one example @u-boot
    => mmc partconf 0 1 1 1
    => mmc bootbus 0 2 0 0

    A2.
    After R5-SPL starts to run, the next stage tispl.bin (ATF + OPTEE + A53-SPL) booting media is "by default" is the same boot media as R5-SPL, i.e. eMMC. The code snippet is listed below. But in theory, the boot media can be changed to any other boot media by user.
    git.ti.com/gitweb

    Further on refer to the code snippet below, where eMMC boot1 is selected by default.
    Again, this can be customized by user, similar functionality as using "mmc dev [dev] [part] [mode]" @u-boot.
    git.ti.com/gitweb
    Best,
    -Hong

  • Hi Hong,

    A1. MMC/eMMC port is determined by BOOTMODE pins, and from which eMMC partition (boot1/boot2/UDA) R5-SPL boots from is solely by eMMC EXTCSD[179]

    I have conducted 4 "experiments" to understand more about the eMMC boot process. Can you help explain these 4 experiments because the results are conflicting with what you said. From the results, it seems like if the switches are set to eMMC boot (not UDA), the mmc partconf determines the R5 SPL boot. On the other hand, if the switches are set to eMMC UDA, the R5 SPL is determined by the switch and the rest are determined by mmc partconf.

    Experiment 1
    BOOTMODE switch -> MMCSD boot (eMMC UDA raw)
    mmc partconf 0 1 1 1 (boot partition #1)
    UDA contain boot binary files
    Boot partition #1 empty
    -> stuck at R5 SPL boot

    Experiment 2
    BOOTMODE switch -> MMCSD boot (eMMC UDA raw)
    mmc partconf 0 1 1 1 (boot partition #1)
    UDA contain boot binary files built at 13:36
    Boot partition #1 contain boot binary files built at 13:16
    -> R5 SPL boot from UDA and the rest boot from boot partition #1. The first SPL shows 13:36 which is from UDA. The second SPL and u-boot shows 13:16 which is from boot partition #1. I built two different boot binary files (tiboot3.bin, tispl.bin, u-boot.img) separately at different times and flashed them individually.

    Experiment 3
    BOOTMODE switch -> eMMC boot
    mmc partconf 0 1 7 1 (UDA)
    Boot partition #1 contain boot binary files
    UDA empty
    -> nothing happens when I power on the board.

    Experiment 4
    BOOTMODE switch -> eMMC boot
    mmc partconf 0 1 7 1 (UDA)
    Boot partition #1 contain boot binary files
    UDA contain boot binary files
    -> nothing happens when I power on the board.

    Let me explain what does the experiment mean

    Eg. experiment 1

    I set the BOOTMODE switch on the board to boot from eMMC UDA raw mode. But in uboot I have preconfigure the EXT_CSD[179] to boot from boot partition #1. Then I flashed the boot files into UDA and leave boot partition #1 empty. Thus, the result is the console shows only the first SPL boot and stuck there.

  • Hello Chee,
    Thanks for running various test cases on your setup.
    From one of your tests, i.e., #2 booting up to u-boot prompt, can you capture "md.l 0x43000030 1"?
    Best,
    -Hong

  • Hi Hong,

    This is the output for the command.

    => md.l 0x43000030 1
    43000030: 000000c3                               ....

    Can you tell me what actually happened in those tests that I ran above, especially in test #2. Can you also breakdown the boot process? Thanks.

  • Hi Lit Zhi

    Is this still open?

    Regards

    Muku

  • Hi Mukul,

    Sorry for the late reply.

    Yes, now I'm replace Lit Zhi and continue to solve this issue.

    Regards

    Hong

  • Hello,
    Have you got chance to look at my early reply?
    e2e.ti.com/.../4512593
    It outlined the eMMC boot flow in general, and you might need to do some customizations for your user case.
    Best,
    -Hong