3.1.1.5. SD, eMMC and USB

The following guide shows how to flash and boot from storage media like the embedded multimedia card (eMMC), secure digital (SD) card, and USB storage devices. While this is a step-by-step guide, it is in no way extensive and does not cover all the per-platform corner-cases. For any issues/questions on this guide, please reach out to: Help e2e.

3.1.1.5.1. MMC

3.1.1.5.1.1. Listing MMC devices

Usually in all the platforms there will be one or two MMC instances of which one would be SD and the other would be eMMC. The index of them can vary from one class of platforms to the other. For a given platform, the device number: mmcdev=[0:1] can be found in the following way:

=> mmc list
OMAP SD/MMC: 0 (SD)

The device number “0” is for SD, here eMMC is not enumerated.

3.1.1.5.1.2. Selecting MMC device and paritions

To selct an MMC device in u-boot, the command: mmc dev could be used. The general syntax is:

=> mmc dev [dev] [partition]

The following lists examples and their explanation for each MMC device and partitions according to the example in: Listing MMC devices.

=> mmc dev 0 0 # select SD "boot" partition
=> mmc dev 0 1 # select SD "root" partition

Note

AM335x EVM does not carry a eMMC flash

3.1.1.5.1.3. View MMC partition contents

This section assumes an SD card or eMMC was prepared previously to boot the device.

Note

For eMMC, typically, the device ships without a partition table If there is a need to create a partition in UDA (to flash the rootfs), please go to: create partition in UDA and format the partition: formatting eMMC partition before proceeding to look at the eMMC partition contents.

To verify partitions in any MMC device from u-boot prompt, use the command: mmc part. If the partitions are formatted with a file system type that is supported by u-boot, you can view the contents of the MMC partition as show below:

=> ls mmc 0:1
   7700992   zImage
      112421   am437x-idk-evm.dtb
      118979   am437x-sk-evm.dtb
      122333   am43x-epos-evm.dtb
               extlinux/
      158859   MLO
      814184   u-boot.img
         717   uEnv.txt
      84299   am437x-gp-evm.dtb

   8 file(s), 1 dir(s)

=> ls mmc 0:2 boot
   <DIR>       4096 .
   <DIR>       4096 ..
   <DIR>       4096 dtb
            7700992 zImage

Where the general syntax is:

$ ls <interface> [<dev[:partition]> [directory]]

Note

AM335x EVM does not carry a eMMC flash

3.1.1.5.1.4. Flash and boot SPL from eMMC

In some cases it is desirable to write MLO and u-boot.img as raw images to the MMC device rather than load them from a filesystem. In that case, the command mmc write can be used to flash the MMC device.

In this example, mmc dev 0 selects an eMMC device that was enumerated. In the following example, flash the eMMC boot0 HW partition, loading the binaries from SD and assuming the files: MLO and u-boot.img exist on the SD card first (boot) partition:

=> mmc dev 0
=> mmc rescan
=> mmc dev 1 1
=> fatload mmc 0 ${loadaddr} MLO
=> mmc write ${loadaddr} 0x0 0x300
=> fatload mmc 0 ${loadaddr} u-boot.img
=> mmc write ${loadaddr} 0x300 0x400

To flash the eMMC boot0 HW partition from network tftp:

=> setenv autoload no
=> dhcp
=> mmc dev 1 1
=> tftp ${loadaddr} MLO
=> mmc write ${loadaddr} 0x0 0x300
=> tftp ${loadaddr} u-boot.img
=> mmc write ${loadaddr} 0x300 0x400

To flash the eMMC UDA HW partition from SD: Flash each binary at specific offsets chosen to not overwrite the partition table on the device. Assuming that the files exist on the SD card.

=> mmc dev 0
=> mmc rescan
=> mmc dev 1
=> fatload mmc 0 ${loadaddr} MLO
=> mmc write ${loadaddr} 0x100 0x100
=> mmc write ${loadaddr} 0x200 0x100
=> fatload mmc 0 ${loadaddr} u-boot.img
=> mmc write ${loadaddr} 0x300 0x400
=> fatload mmc 0 ${loadaddr} rootfs.ext4
=> mmc write ${loadaddr} 0x1000 ...rootfs.ext4 size in bytes divided by 512, in hex...

3.1.1.5.1.4.1. eMMC boot configuration

We also need to configure the eMMC to boot from boot0 HW partition using the bootbus and partconf commands. The bootbus command sets the eMMC into dual data rate mode with a bus width of 8 to match with the bus configuration supported by the Boot ROM. The partconf command gives access to the boot0 HW partition during boot operation. Note that these configurations are limited to boot operation and the eMMC can be set to its highest speed mode once boot operation is complete. All these are non-volatile configurations that need to be done once per eMMC/board .

=> mmc bootbus 1 2 0 2
=> mmc partconf 1 1 1 0
=> mmc rst-function 1 1

3.1.1.5.1.5. Flashing an MMC device using USB-DFU

To see the list of available places to write to (in DFU terms, altsettings) list the MMC partitions with mmc part command, run printenv dfu_alt_info_mmc or printenv dfu_alt_info_emmc to see how they are mapped and exposed to dfu-util.

=> mmc part

Partition Map for MMC device 0  --   Partition Type: DOS

Partition     Start Sector     Num Sectors     Type
   1                   63          144522       c Boot
   2               160650         1847475      83
   3              2024190         1815345      83
=> printenv dfu_alt_info_mmc
dfu_alt_info=boot part 0 1;rootfs part 0 2;MLO fat 0 1;u-boot.img fat 0 1;uEnv.txt fat 0 1"

Note

The above command: mmc part lists the partitions in the current selected device. Switch to a different MMC device with mmc dev, refer to Selecting MMC device and paritions.

This means that you can tell dfu-util to write anything to any of:

  • boot

  • rootfs

  • MLO

  • u-boot.img

  • uEnv.txt

And that the MLO, u-boot.img and uEnv.txt files are to be written to a FAT filesystem.

To start DFU on the target on the first MMC device:

=> setenv dfu_alt_info ${dfu_alt_info_mmc}
=> dfu 0 mmc 0

On boards like AM57x GP EVM or BeagleBoard x15, where the second USB instance is used as USB client, the dfu command becomes:

=> dfu 1 mmc 0

Then on the host PC to write MLO to an existing boot partition:

$ sudo dfu-util -D MLO -a MLO

On the host PC to overwrite the current boot partition contents with a new created on the host FAT filesystem image:

$ sudo dfu-util -D fat.img -a boot

3.1.1.5.1.6. Flashing an SD card from a host PC

This section assumes that you have flashed an SD card using the script “create-sdcard.sh” packaged in the installer or have made a compatible layout manually. In this case, you will need to copy the boot images:

  • MLO

  • u-boot.img

to the SD card boot partition. At this point, the device can boot to u-boot prompt.

3.1.1.5.2. USB

3.1.1.5.2.1. Configuring USB in Host Mode

Configuring USB in host mode documentation is pending for AM335x devices, please reach out to: Help e2e for additional information.

3.1.1.5.2.2. Flash and boot SPL from USB storage

Boot SPL from USB storage documentation is pending for AM335x devices, please reach out to: Help e2e for additional information.

3.1.1.5.2.3. Boot Linux from USB storage

Booting Linux from USB storage documentation is pending for AM335x devices, please reach out to: Help e2e for additional information.