Project

General

Profile

Boot EMMC

NOTE: The AM62x has multiple MMC interfaces. The EMMC is configured on MMC1

To boot the Dev Kit from EMMC using a CL supplied image, set the boot pins as follows:

B9 B8 B7 B6 B5 B4 B3
Port (0) Reserved (0) Fs/raw (1) 1 0 0 1

Boot mode switches for EMMC boot

Based on the TI wiki procedure ( https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/08_03_00_19/exports/docs/linux/Foundational_Components/U-Boot/UG-Memory.html )
Major difference was the block size used. The TI wiki instructions assume a 512 byte block size. The U-Boot image we have was using 1024 byte block size and therefore programming the SPL and UBoot at wrong addresses.

EMMC Layout

             boot0 partition (8 MB)                        user partition
     0x0+----------------------------------+      0x0+-------------------------+
        |      tiboot3.bin (512 KB)        |         |                         |
  0x8000+----------------------------------+         |                         |
        |        tispl.bin (2 MB)          |         |                         |
0x280000+----------------------------------+         |        rootfs           |
        |      u-boot.img (1.412 MB)       |         |                         |
0x3E1000+----------------------------------+         |                         |
        |      environment (124 KB)        |         |                         |
0x400000+----------------------------------+         +-------------------------+

Steps

  • generate 2 uuids (currently this must be done outside of u-boot... one needs to enable CONFIG_CMD_UUID if you want uuid generation in u-boot)
  • partition the eMMC device (can be done in u-boot as shown, or from linux using fdisk)
    U-Boot # printenv partitions
    uuid_disk=${uuid_gpt_disk};name=rootfs,start=2MiB,size=-,uuid=${uuid_gpt_rootfs}
    U-Boot # setenv uuid_gpt_disk ...first uuid...
    U-Boot # setenv uuid_gpt_rootfs ...second uuid...
    U-Boot # gpt write mmc 0 ${partitions} /* <device num> is device index obtained from mmc list for eMMC */
    
    U-Boot # reset /* required to reload partition data */
    
  • Boot into linux from SD card
  • Change dir to SD card boot partition
  • enable writing to the mmbblk0boot0 partition
    root@mitysom-am62x:~# echo 0 > /sys/block/mmcblk0boot0/force_ro
    
  • Copy the needed images from the SD card to the eMMC boot partition
    root@mitysom-am62x:~# dd if=tiboot3.bin of=/dev/mmcblk0boot0 bs=512 seek=0
    root@mitysom-am62x:~# dd if=tispl.bin of=/dev/mmcblk0boot0 bs=512 seek=1024
    root@mitysom-am62x:~# dd if=u-boot.img  of=/dev/mmcblk0boot0 bs=512 seek=5120
    Optional if you want to set the environment
    root@mitysom-am62x:~# dd if=<uboot env blob> of=/dev/mmcblk0boot0 bs=512 seek=7944
    
  • Enable the boot partition of the eMMC device
    From U-Boot
    U-Boot # mmc partconf 0 1 1 1
    U-Boot # mmc bootbus 0 2 0 0
    

    OR from Linux
    root@mitysom-am62x:~# mmc bootpart enable 1 1 /dev/mmcblk0
    root@mitysom-am62x:~# mmc bootbus set single_backward x1 x8 /dev/mmcblk0
    
  • Set the boot mode to boot from the eMMC
    BM0-7 = 11001xxx (SW1-4, SW1-7, SW-8 ON)
    BM8-15 = 00000000
    Boot mode switches for EMMC boot

SW1-4-7 set the boot mode to eMMC
SW1-8 sets RAW mode

This will get you to U-Boot. To boot to linux, you need to install linux on the eMMC UDA partition (created above) and tell U-Boot to boot the OS from the eMMC.
The eMMC is MMC device 0 and we want the first partition of it

U-Boot # setenv mmcdev 0
U-Boot # setenv bootpart 0
U-Boot # saveenv

One way to copy the linux rootfs...

Mount the SD card rootfs under /mnt and tar-copy it to the eMMC

root@mitysom-am62x:~# lsblk
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
...
mmcblk1      179:0    0   7.4G  0 disk
|-mmcblk1p1  179:1    0 132.6M  0 part /run/media/mmcblk1p1
`-mmcblk1p2  179:2    0   3.3G  0 part /
mmcblk0      179:32   0  59.3G  0 disk
`-mmcblk0p1  179:33   0  59.3G  0 part /run/media/mmcblk0p1
mmcblk0boot0 179:64   0  31.5M  1 disk
mmcblk0boot1 179:96   0  31.5M  1 disk

root@mitysom-am62x:~# mkdir -p /mnt/sd-rootfs
root@mitysom-am62x:~# mkdir -p /mnt/emmc-rootfs
root@mitysom-am62x:~# mount /dev/mmcblk1p2 /mnt/sd-rootfs
root@mitysom-em62x:~# umount /dev/mmcblk0p1
root@mitysom-am62x:~# mkfs.ext4 /dev/mmcblk0p1
mke2fs 1.45.7 (28-Jan-2021)

If there was an existing FS on the eMMC tell mkfs to erase it
/dev/mmcblk0p1 contains a ext3 file system labelled 'EMMC'
        last mounted on /tmp/mnt_EMMC on Mon Jan 16 13:56:15 2023
Proceed anyway? (y,N) y

Discarding device blocks: done
Creating filesystem with 15540096 4k blocks and 3891200 inodes
Filesystem UUID: f6975435-0bd3-425d-b2eb-57cd2c3eaaf2
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424

Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks): done
Writing superblocks and filesystem accounting information: done

root@mitysom-am62x:~# mount /dev/mmcblk0p1 /mnt/emmc-rootfs/
root@mitysom-am62x:~# tar -C /mnt/sd-rootfs/ -cf - . |tar -C /mnt/emmc-rootfs/ -xf -

Hardware Reset setting

NOTE: We enable hw reset in our factory test environment, setting this yourself should not be necessary.

The eMMC part ships with hardware reset disabled. This caused reset/reboot to hang when booting from the eMMC.
To fix this, the HW reset needs to be enabled in the part. This is done by writing a 1 to the RST_N_FUNCTION CSD register in the part.
THIS IS A ONE-TIME-PROGRAMMABLE VALUE
If you write a 2 to this register, you will permanently DISABLE reset and effectively prevent using the eMMC as a boot device.

From linux

root@mitysom-am62x:~# mmc hwreset enable /dev/mmcblk0

The state of this register can be checked using the extcsd read command
root@mitysom-am62x:~# mmc extcsd read /dev/mmcblk0 | grep RST
H/W reset function [RST_N_FUNCTION]: 0x01

From U-Boot

mmc rst-function 0 1

Go to top
Add picture from clipboard (Maximum size: 1 GB)