Project

General

Profile

Programming the eMMC Through U-Boot

The MitySBC-A5E can be ordered with an on-board eMMC (U26) in addition to the microSD socket (J5). Both hang off the same HPS SDMMC controller through a TXS02612 port expander (U25), so only one of them is visible at a time and both enumerate as U-Boot device mmc 0. The expander's select line, SDMMC_SELECT, is driven by HPS GPIO0_IO10, with jumper J20 setting the default when the GPIO is not driven.

Select J20 U-Boot Device on mmc 0
microSD card (J5) pins 1-2 (factory default) gpio clear 10 SD card
eMMC (U26) pins 2-3 gpio set 10 eMMC

This page copies a reference microSD card onto the eMMC block for block, using only U-Boot. The reference filesystem image is 1 GB, so the whole thing fits in DDR and can be staged in RAM in a single pass. Nothing has to be unplugged or moved to make the copy.

Before you start: the eMMC is an option, not standard equipment, and its size is encoded in the model number. In the third group of the model number (the C88 in A5ED-B64-C88-RC-SBC) the first character is the eMMC size, where X means no eMMC is fitted and C means 64 GB. The last character of that group is the HPS DDR size (8 = 8 GB LPDDR4). Check your model number against the MitySBC-A5E model numbering scheme before working through this page, and adjust the capacities quoted below to match your board.

1. Boot to the U-Boot prompt

Install the reference microSD card in J5 and power on the board. Press any key to stop the autoboot countdown.

Hit any key to stop autoboot:  0
MITYSOM_A5E #

2. Confirm the microSD card is selected

MITYSOM_A5E # mmc dev 0
switch to partitions #0, OK
mmc0 is current device
MITYSOM_A5E # mmc info
Device: mmc0@10808000
Manufacturer ID: 3
OEM: 5344
Name: SA08G
Bus Speed: 50000000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 7.4 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes

SD version 3.0 confirms the card and not the eMMC is on the bus. The name and capacity reported are simply whatever card is fitted in J5 and will differ from the example above. It is the reference image that is 1 GB, not necessarily the card carrying it.

3. Read the card into RAM

mmc read takes a DDR address, a starting block, and a block count, all in hex. Starting at block 0 captures the partition table along with both partitions.

MITYSOM_A5E # mmc read 0x90000000 0 0x200000
MMC read: dev # 0, block # 0, count 2097152 ... 2097152 blocks read: OK

0x200000 blocks is 1 GiB, which covers the reference image. mmc part shows why: the second partition ends at sector 2,095,105. If you have repartitioned the card, check mmc part and size the copy to the end of the last partition. Do not ask for more blocks than the card physically holds, or the transfer fails.

Load at 0x90000000. U-Boot's own load addresses on this platform are 0x81000000 for the boot script, 0x82000000 for the kernel and 0x86000000 for the device tree, and U-Boot itself relocates to the top of the first DDR bank, so a 1 GiB buffer at 0x90000000 stays clear of all of them.

4. Switch the SDMMC mux to the eMMC

MITYSOM_A5E # gpio set 10
gpio: pin 10 (gpio 10) value is 1
MITYSOM_A5E # mmc rescan
MITYSOM_A5E # mmc info
Device: mmc0@10808000
Manufacturer ID: 13
OEM: 4e
Name: G1M15M
Bus Speed: 50000000
Mode: MMC High Speed (52MHz)
Rd Block Len: 512
MMC version 5.1
High Capacity: Yes
Capacity: 59.3 GiB
Bus Width: 4-bit
Erase Group Size: 512 KiB

MMC version 5.1 and the 59.3 GiB capacity confirm the eMMC is now on the bus. Do not continue until mmc info reports the eMMC, or the next step will write over the card you just read.

Notes and Tips

- The mmc rescan is required. Without it U-Boot keeps using the card data it probed for the microSD and every transfer to the eMMC errors out.
- Moving the jumper on J20 from pins 1-2 to pins 2-3 selects the eMMC the same way and is an equally valid alternative here. Note that the two methods do not mix within one session: once either gpio set 10 or gpio clear 10 has been issued, U-Boot drives the select line and the jumper has no effect until the next reset.

5. Write the image to the eMMC

Same address, same starting block, same block count as the read in step 3. Writing 1 GiB takes roughly 45 seconds.

MITYSOM_A5E # mmc write 0x90000000 0 0x200000
MMC write: dev # 0, block # 0, count 2097152 ... 2097152 blocks written: OK

6. Verify the copy

mmc part should now report the same partition table as the microSD card, including the same partition UUIDs, and the FAT partition should hold the boot files.

MITYSOM_A5E # mmc part

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

Part    Start Sector    Num Sectors    UUID        Type
  1    8192          524289        91f0f3d1-01    0b
  2    532481        1562624       91f0f3d1-02    83
MITYSOM_A5E # fatls mmc 0:1
   805760   u-boot.itb
      959   boot.scr

2 file(s), 0 dir(s)

The eMMC is now programmed. If all you wanted was to program it, gpio clear 10 followed by mmc rescan puts the microSD card back on the bus.

7. Boot from the eMMC

There are two ways to do this, depending on whether you want the change to stick.

Boot the eMMC once, from the current U-Boot session

The mux is already pointed at the eMMC from step 4, so boot picks up the boot script, kernel and root filesystem from the eMMC.

MITYSOM_A5E # boot

Make the eMMC the permanent boot device

Move the jumper on J20 to short pins 2-3, then power cycle. J20 is what selects the boot device out of reset, so this is what makes the setting survive. The microSD card can stay in J5; it is ignored while J20 is in the eMMC position.

Notes and Tips

- gpio set 10 only lasts until the next reset. On the following boot GPIO0_IO10 is released and J20 decides which device the expander selects, so a reset without moving the jumper goes back to the microSD card.
- Only the first 1 GB of the eMMC is written, so the root partition is sized for the reference image and the rest of the device is unallocated. Grow the partition and the filesystem from Linux afterwards if you want the extra space.