4.3.1. How to flash eMMC and boot with eMMC Boot

4.3.1.1. Overview

This how to guide allows to prepare and flash the eMMC device to boot using eMMC boot, that is, to boot from Boot0 or Boot1 eMMC hardware partitions and boot the rootfs from eMMC UDA.

Note

This process will require a working SD card that can boot the device to Linux kernel.

4.3.1.2. eMMC layout

+----------------------------------+0x0      +-------------------------+0x0
|      tiboot3.bin (1 MB)          |         |                         |
+----------------------------------+0x800    |                         |
|       tispl.bin (2 MB)           |         |        rootfs           |
+----------------------------------+0x1800   |                         |
|       u-boot.img (4 MB)          |         |                         |
+----------------------------------+0x3800   |                         |
|      environment (128 KB)        |         |                         |
+----------------------------------+0x3900   |                         |
|   backup environment (128 KB)    |         |                         |
+----------------------------------+0x3A00   +-------------------------+
             Boot0 (8 MB)                              UDA

4.3.1.3. Flash bootloader binaries to eMMC

To boot with eMMC boot the eMMC needs to be prepared before hand. The recommended process is to flash an SD card with TI SDK image, copy the bootlader binaries that will be flashed to eMMC in the SD card “boot” partition in emmc/ folder, boot the board with MMCSD boot from SD (FS mode), and proceed to flash the eMMC from either u-boot or linux.

Erase eMMC

In u-boot we can optionally erase boot0 or boot1 with mmc erase command, where the general syntax is:

$ mmc erase blk# cnt

The following example, shows how to find the largest block number for boot0 and erase boot0. To erase boot1, replace mmc dev 0 1 with mmc dev 0 2.

=> mmc dev 0 1
switch to partitions #1, OK
mmc0(part 1) is current device
=> mmc read ${loadaddr} 0xfffffffff 1
MMC read: dev # 0, block # -1, count 1 ... MMC: block number 0x100000000 exceeds max(0xfc00)
0 blocks read: ERROR
=> mmc erase 0 0xfc00
MMC erase: dev # 0, block # 0, count 64512 ... 64512 blocks erased: OK

Flash from u-boot

Stop at u-boot prompt and flash eMMC using fatload and mmc write commands to load binaries from SD card and flash them to eMMC Boot0.

In this example, eMMC device is dev 0, to find which device is eMMC, refer to this. section. To flash to eMMC Boot1 instead, replace mmc dev 0 1 with mmc dev 0 2.

=> mmc dev 0 1
=> fatload mmc 1 ${loadaddr} emmc/tiboot3.bin
=> mmc write ${loadaddr} 0x0 0x800
=> fatload mmc 1 ${loadaddr} emmc/tispl.bin
=> mmc write ${loadaddr} 0x800 0x1000
=> fatload mmc 1 ${loadaddr} emmc/u-boot.img
=> mmc write ${loadaddr} 0x1800 0x2000

Flash from linux

At linux prompt, flash eMMC using cp and dd commands to load binaries from SD card and flash them to eMMC Boot0.

In this example, eMMC is /dev/mmcblk0* and SD /dev/mmcblk1* to find which device is eMMC, refer to this. section. To flash to eMMC Boot1 instead, replace mmcblk0boot0 with mmcblk0boot1.

# Enable write access to the Boot0 partition
root@<machine>:~# echo 0 > /sys/block/mmcblk0boot0/force_ro
root@<machine>:~# mkdir /mnt/sdboot && mount /dev/mmcblk1p1 /mnt/sdboot && cd /mnt/sdboot
root@<machine>:~# dd if=emmc/tiboot3.bin of=/dev/mmcblk0boot0 seek=0 bs=512
root@<machine>:~# dd if=emmc/tispl.bin of=/dev/mmcblk0boot0 seek=1024 bs=512
root@<machine>:~# dd if=emmc/u-boot.img of=/dev/mmcblk0boot0 seek=5120 bs=512

Where seek is the eMMC offset converted to decimal type. For example, for seek=1024, we are flashing to offset 0x400. Please refer here for the offsets in eMMC when flashing bootloader files.

4.3.1.4. Flash rootfs to eMMC

To boot the rootfs from eMMC UDA, the eMMC needs to be prepared before hand. It is not possible to format a partition to ext4 in U-Boot, so the recommended process is to flash an SD card with TI SDK image, boot the device with SD card boot to linux kernel prompt, and prepre eMMC UDA from Linux.

First create a “root” partition to flash the rootfs as shown here. The new disk partition should be formatted as ext4 type as shown here. Mount the new partition and flash the rootfs as shown here. The Linux kernel Image and DT file are expected to be in the /boot folder of the “root” partition in order for u-boot to find and load them.

4.3.1.5. eMMC boot configuration

Now that we have flashed the eMMC device, reboot the board and stop at u-boot prompt to set configuration for eMMC boot.

Enable boot from HW partition

After flashing binaries to eMMC flash, the eMMC device Extended CSD register fields: BUS_WIDTH and PARTITION_CONFIG must be set so ROM will use the correct configuration for eMMC boot. Set using the mmc bootbus and mmc partconf commands. Go to Boot from Boot0 if booting for eMMC boot0. Alternatively, Boot from Boot1 if booting from eMMC boot1.

  • The mmc bootbus command sets the BOOT_BUS_WIDTH field where mmc bootbus 0 2 0 0 selects x8 (sdr/ddr) buswidth in boot operation mode.

  • The mmc partconf command can be used to configure what hardware partition to boot from. The general syntax is:

$ mmc partconf <dev> [[varname] | [<boot_ack> <boot_partition> <partition_access>]]

Where <dev> is MMC device index.

  • For more information on these commands, please go here.

Boot from Boot0

=> mmc partconf 0 1 1 1
=> mmc bootbus 0 2 0 0

Boot from Boot1

=> mmc partconf 0 1 2 1
=> mmc bootbus 0 2 0 0

Enable warm reset

On eMMC devices, warm reset will not work if EXT_CSD[162] bit is unset since the reset input signal will be ignored. Warm reset is required to be enabled in order for the eMMC to be in a “clean state” on power-on reset so that ROM can do a clean enumeration. To set the EXT_CSD[162] bit, stop at u-boot prompt and execute the following command:

=> mmc rst-function 0 1

Warning

This is a write-once field. For more information, please refer to the u-boot doc found here.

U-boot environment

The command saveenv is no longer used in TI SDK, thus, the following environment workarounds must be implemented to boot from eMMC.

At u-boot prompt, run the following commands to boot Linux from eMMC UDA:

=> setenv mmcdev 0
=> setenv bootpart 0
=> boot

Or change the u-boot environment for eMMC boot to boot completely from eMMC.

First apply the following change in u-boot for any SoC.

diff --git a/board/ti/<soc>/<soc>.env b/board/ti/<soc>/<soc>.env
index 82b9f0741bb..73d59ac425c 100644
--- a/board/ti/<soc>/<soc>.env
+++ b/board/ti/<soc>/<soc>.env
@@ -17,8 +17,8 @@ run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}

 boot_targets=mmc1 mmc0 usb pxe dhcp
 boot=mmc
-mmcdev=1
-bootpart=1:2
+mmcdev=0
+bootpart=0:1
 bootdir=/boot
 rd_spec=-

Re-build bootloader binaries and copy build outputs to the SD card “boot” partition and emmc/ folder. Proceed to flash eMMC with these binaries as shown in this step-by-step guide.

4.3.1.6. Boot from eMMC boot partition

Finally we can proceed to change boot mode pins to eMMC boot as per specific TRM, under: Initialization/Boot Mode Pins and power cycle the board.