3.7.3. Flash Linux to eMMC¶
This section describes how to install a full Linux system to eMMC so that Linux can boot completely from eMMC.
The procedures below are all to be performed on the EVM through the Linux prompt. These steps assume that Linux has already booted properly from another memory device such as SD card or any supported interface. There are three steps to flash Linux to eMMC:
Flash U-Boot to eMMC boot0 partition
Flash Linux kernel, device tree and root filesystem to eMMC user partition
Change boot mode and U-Boot Env so that Linux boots from eMMC
The following sections will describe each of these steps in detail.
3.7.3.1. Flash U-Boot to eMMC¶
First, verify that eMMC is available on the EVM and
determine the mmc device number for eMMC. This can be done by checking the mmc
devices with command ls /dev/mmcblk*
. Both eMMC and SD card are mmc
devices, so we need to figure out which mmc device is the eMMC.
If Linux is booted without an SD card, command ls /dev/mmcblk*
will list only the eMMC:
# ls -l /dev/mmcblk*
brw-rw---- 1 root disk 179, 32 Nov 16 01:52 /dev/mmcblk0
brw-rw---- 1 root disk 179, 64 Nov 16 02:01 /dev/mmcblk0boot0
brw-rw---- 1 root disk 179, 96 Nov 16 01:44 /dev/mmcblk0boot1
crw------- 1 root root 237, 0 Nov 16 01:44 /dev/mmcblk0rpmb
On the other hand, if Linux is booted from the SD card, ls /dev/mmcblk*
will list
both the eMMC and the SD card. Whichever device has boot0 and boot1 partitions is the eMMC.
The example below shows mmcblk0 is the eMMC:
# ls -l /dev/mmcblk*
brw-rw---- 1 root disk 179, 32 Nov 18 18:55 /dev/mmcblk0
brw-rw---- 1 root disk 179, 64 Aug 10 22:07 /dev/mmcblk0boot0
brw-rw---- 1 root disk 179, 96 Aug 10 22:07 /dev/mmcblk0boot1
crw------- 1 root root 237, 0 Aug 10 22:07 /dev/mmcblk0rpmb
brw-rw---- 1 root disk 179, 0 Aug 10 22:07 /dev/mmcblk1
brw-rw---- 1 root disk 179, 1 Aug 10 22:07 /dev/mmcblk1p1
brw-rw---- 1 root disk 179, 2 Aug 10 22:07 /dev/mmcblk1p2
Now that the eMMC device is identified, U-Boot firmware can be written to the boot0 partition on the eMMC. First, we need to enable write access to the boot0 partition. Please refer to the Linux kernel documentation. Use the command below to enable write access:
# echo 0 > /sys/block/mmcblk0boot0/force_ro
Once write access is enabled, U-Boot firmware can be written to the eMMC boot0 partition. First, copy the U-Boot binaries from the host to the EVM (the binaries are located at <Processor SDK installation foder>board-supportprebuilt-images):
tiboot3.bin
tispl.bin
u-boot-<EVM name>.img
Then, use command dd
to write the binaries to eMMC boot0. Please refer to
eMMC layout
to determine the offset numbers for the dd
command. For example, to write
tispl.bin to offset 0x400 (1024), we need to use option seek = 1024
. Write all U-Boot
binaries to boot0 as below:
# dd if=tiboot3.bin of=/dev/mmcblk0boot0 seek=0
# dd if=tispl.bin of=/dev/mmcblk0boot0 seek=1024
# dd if=u-boot.img of=/dev/mmcblk0boot0 seek=5120
3.7.3.2. Flash Kernel, Device Tree and Root Filesystem to eMMC¶
While U-Boot is programmed to the eMMC boot0 partition, the Linux kernel, device
tree, and root filesystem need to be written to the eMMC user partition. First,
an ext4 partition needs to be created in the user partition. This can be done
with the fdisk
command:
# fdisk /dev/mmcblk0
Use the following options for this interactive command to delete existing partitions and create a new one:
Enter “p” to display current partitions
Enter “n” to create a new partition (or enter “d” first to delete existing partitions)
Use default for all subsequent options
Enter “w” to write the partition table to disk and exit
After a new partition is created, ls /dev/mmcblk*
should show the new partition in eMMC.
For example, if eMMC is mmcblk0, the newly created partition would be mmcblk0p1
:
# ls -l /dev/mmcblk0*
brw-rw---- 1 root disk 179, 32 Nov 16 02:02 /dev/mmcblk0
brw-rw---- 1 root disk 179, 64 Nov 16 02:01 /dev/mmcblk0boot0
brw-rw---- 1 root disk 179, 96 Nov 16 01:44 /dev/mmcblk0boot1
brw-rw---- 1 root disk 179, 33 Nov 16 02:02 /dev/mmcblk0p1
crw------- 1 root root 237, 0 Nov 16 01:44 /dev/mmcblk0rpmb
An ext4 filesystem needs to be created in the new partition:
# mkfs.ext4 /dev/mmcblk0p1
Now that an ext4 partition is created, the Linux kernel, device tree, and root filesystem can be written to this partition. Copy the Linux image from the host to the EVM. For example, the default image for AM64x:
tisdk-default-image-am64xx-evm.tar.xz
Please refer to Root Filesystem regarding Linux images from the Processor SDK.
Untar this image to the newly created eMMC partition. Below is an example on how
this can be done, assuming the Linux image has been copied to /home/root
folder on the EVM.
# mkdir -p /mnt/temp
# mount -t ext4 /dev/mmcblk0p1 /mnt/temp
# cd /mnt/temp
# tar xf <Linux image file copied from the host>
# cd ..
# umount temp
3.7.3.3. Change Boot Mode and U-Boot Env¶
Now that the complete Linux system has been installed to the eMMC, the final step is to set the EVM boot mode and change the U-Boot environment so that Linux will boot from eMMC.
Reboot the EVM and stop the autoboot to go to U-Boot prompt. Issue the following commands to give ROM access to the eMMC boot partition (this only needs to be done once):
=> mmc partconf 0 1 1 1
=> mmc bootbus 0 2 0 0
Next switch to eMMC boot mode. Please refer to EVM Boot Mode Switches for how to set the EVM bootmode switches to boot from eMMC.
Power cycle the EVM to boot to U-Boot prompt again, then issue the following commands to change the U-Boot environment variables for eMMC boot:
=> setenv mmcdev 0
=> setenv bootpart 0
=> saveenv
Now reset or power cycle the EVM, Linux should boot from the eMMC.