Booting Linux from eMMC Print

Use the procedure documented below to install the U-Boot firmware, Linux kernel and filesystem images to the eMMC on the STM32MP1 module. Having completed the installation, the STM32MP1 SOM will boot to Linux from the eMMC on next reset / power on.

Note that the installation procedure requires a bootable SD card that will be used for the initial boot. Refer to Booting Linux from SD Card for information on how to create a bootable SD card. Note also that the procedure will erase all data previously present on the eMMC.

Here is the installation procedure:

  1. Insert a USB Flash into the Linux development host. Download the tarball with the prebuilt bootable Linux images from the Emcraft site, and unpack it into the USB Flash:
  2. $ mkdir -p /media/emcraft/5B4E/mfg_images
    $ tar xvfj images-stm32mp1-<version>.tar.bz2 -C /media/emcraft/5B4E/mfg_images

  3. Insert the USB Flash into the SOM-BSB carrier board and boot the STM32MP1 SOM. Refer to Booting Linux from SD Card.
  4. If the USB Flash device is not mounted automatically, use the following command:
  5. $ mount /dev/sda1 /media/sda1

  6. In the Linux command prompt, unmount the eMMC (if it is mounted) in order to make sure it is ready for the partitioning:
  7. $ umount -f /dev/mmcblk1*

  8. Erase the previous partition table that might be present if the eMMC has been used earlier:
  9. $ wipefs --all /dev/mmcblk1

  10. Create a new GPT partition table on the eMMC using gdisk as shown below:
  11. root@stm32mp1-som:~# gdisk -l /dev/mmcblk1 GPT fdisk (gdisk) version 1.0.3 [ 121.572170] mmcblk1: p1 p2 p3 p4 p5 Partition table scan: MBR: protective BSD: not present APM: not present GPT: present Found valid GPT with protective MBR; using GPT. Disk /dev/mmcblk1: 7471104 sectors, 3.6 GiB Sector size (logical/physical): 512/512 bytes Disk identifier (GUID): 0B727674-919F-4603-8853-36FA9D72465F Partition table holds up to 128 entries Main partition table begins at sector 2 and ends at sector 33 First usable sector is 34, last usable sector is 7471070 Partitions will be aligned on 1024-sector boundaries Total free space is 990 sectors (495.0 KiB) Number Start (sector) End (sector) Size Code Name 1 1024 5119 2.0 MiB 0700 ssbl 2 5120 136191 64.0 MiB 8300 bootfs 3 136192 168959 16.0 MiB 8300 vendorfs 4 168960 6460415 3.0 GiB 8300 rootfs 5 6460416 7471070 493.5 MiB 8300 userfs root@stm32mp1-som:~#

  12. Install the U-Boot image file (u-boot-stm32mp1-som-trusted.stm32) to the eMMC:
  13. $ dd if=/media/sda1/mfg_images/u-boot-stm32mp1-som-trusted.stm32 of=/dev/mmcblk1p1 bs=1M conv=fdatasync

  14. Install the ARM Trusted Firmware images to the eMMC:
  15. $ echo 0 > /sys/class/block/mmcblk1boot0/force_ro
    $ echo 0 > /sys/class/block/mmcblk1boot1/force_ro
    $ dd if=/media/sda1/mfg_images/tf-a-stm32mp1-som-trusted.stm32 of=/dev/mmcblk1boot0 bs=1M conv=fdatasync
    $ dd if=/media/sda1/mfg_images/tf-a-stm32mp1-som-trusted.stm32 of=/dev/mmcblk1boot1 bs=1M conv=fdatasync

  16. Create the filesystems on the eMMC:
  17. $ mkfs.ext4 -F /dev/mmcblk1p2
    $ mkfs.ext4 -F /dev/mmcblk1p3
    $ mkfs.ext4 -F /dev/mmcblk1p4
    $ mkfs.ext4 -F /dev/mmcblk1p5

  18. Mount the eMMC partitions:
  19. $ mkdir -p /media/mmcblk1p2
    $ mkdir -p /media/mmcblk1p3
    $ mkdir -p /media/mmcblk1p4
    $ mkdir -p /media/mmcblk1p5
    $ mount /dev/mmcblk1p2 /media/mmcblk1p2
    $ mount /dev/mmcblk1p3 /media/mmcblk1p3
    $ mount /dev/mmcblk1p4 /media/mmcblk1p4
    $ mount /dev/mmcblk1p5 /media/mmcblk1p5

  20. Copy the Linux kernel and DTB images to the mmcblk1p2 eMMC partition:
  21. $ cd /media/mmcblk1p2
    $ tar xf /media/sda1/mfg_images/st-image-bootfs-openstlinux-weston-stm32mp1-som.tar.xz
    $ cp /media/sda1/mfg_images/{uImage,*.dtb} .

  22. Install the filesystem images:
  23. $ cd /media/mmcblk1p3
    $ tar xf /media/sda1/mfg_images/st-image-vendorfs-openstlinux-weston-stm32mp1-som.tar.xz
    $ cd /media/mmcblk1p4
    $ tar xf /media/sda1/mfg_images/emcraft-rootfs-openstlinux-weston-stm32mp1-som.tar.xz
    $ cd /media/mmcblk1p5
    $ tar xf /media/sda1/mfg_images/st-image-userfs-openstlinux-weston-stm32mp1-som.tar.xz

  24. Reboot the system and stop at the U-Boot prompt by pressing any key:
  25. $ reboot
    U-Boot 2018.09-stm32mp-r2-2.8.0 (Feb 14 2019 - 15:13:06 +0000) ... Hit any key to stop autoboot: 0 STM32MP1-SOM>

  26. Configure the eMMC internal partition table for booting:
  27. STM32MP1-SOM> mmc partconf 1 1 2 0
    STM32MP1-SOM> mmc partconf 1
    BOOT_ACK: 0x1

  28. Remove the SD card from the slot, power off the SOM-BSB board, and prepare it for booting from the eMMC by setting the S4 DIP switch boot selection as described in Selecting Boot Device.
  29. Re-apply the power and boot the system to the shell prompt:
  30. U-Boot 2018.09-stm32mp-r2-2.8.0 (Feb 14 2019 - 15:13:06 +0000) CPU: STM32MP15x.B Model: Emcraft STM32MP1 SOM Rev 1A, Board: stm32mp1 in trusted mode Watchdog enabled DRAM: 1 GiB Clocks: - MPU : 650 MHz - MCU : 196.608 MHz - AXI : 266.500 MHz - PER : 24 MHz MMC: STM32 SDMMC2: 0, STM32 SDMMC2: 1 In: serial Out: vidconsole Err: vidconsole Model: Emcraft STM32MP1 SOM Rev 1A, Board: stm32mp1 in trusted mode Error: 16 bit/pixel mode, but BMP has 24 bit/pixel Net: eth0: ethernet@5800a000 Boot over mmc1! Hit any key to stop autoboot: 0 ... Emcraft STM32MP1-SOM Release Distro (ST OpenSTLinux 2.4-snapshot-20190213) stm32mp1-som ttyS3 stm32mp1-som login: root (automatic login) root@stm32mp1-som:~#