Timesys Getting Started Guide for STMicroelectronics STM32MP135F-DK Board

$FILE


Contents

Introduction

This document will describe in detail the procedures for booting a Linux kernel image and mounting a root file system from an SD Card on the STM32MP135F-DK.

Prerequisites

Host Requirements

To properly boot the STM32MP135F-DK using software from Timesys, your host machine must meet the following requirements:

  • Modern GNU/Linux Distribution. Timesys recommends one of the following distributions:
    • Ubuntu (Most recent release or LTS)
    • Fedora (Most recent release)
  • Root or sudo permission on the Development Host.
  • A copy of the Linux Kernel (uImage-5.10.61-ts-armv7l), device tree file (stm32mp135f-dk.dtb) and Root File System (rootfs.tar.gz) for the Target Board downloaded from Factory. These are found in the output directory of your online build, or in the directory build_armv7l-timesys-linux-<libc>/images/ on the command line.
  • An available USB port on your Development Host.
  • A SD card slot or adapter on your Development Host.

Target Requirements

To boot the STM32MP135F-DK, you will need the following items:

  • STM32MP135F-DK
  • Micro SD Card
  • USB Type-C (power 5V-3A)
  • USB micro-B to a host PC that runs as Virtual COM port and debug port.

Once you have all of the necessary components, you should perform the following steps:

  1. Connect the USB micro-B serial cable to CN10. The following connections are relevant:
  2. Insert the SD card into your host machine. You will be loading your boot files onto this device.
  3. Connect the power supply to your board.

Preparing the Target

Configuring Serial Communication

The STM32MP135F-DK uses a serial debug port to communicate with the host machine. The commands discussed in this section are meant to be performed by a privileged user account. This requires the root login or prepending each command with sudo.

Using Minicom

  1. Start minicom on your host machine in configuration mode. As root:

    # minicom -o -s -w

  2. A menu of configuration should appear. Use the Down-arrow key to scroll down and select the Serial port setup option, and press Enter.
  3. Verify that the listed serial port is the same one that is connected to the target board. If it is not, press A, and enter the correct device. This is /dev/ttyACM0 on most Linux distributions.
  4. Set the Bps/Par/Bits option by pressing the letter E and using the next menu to set the appropriate values. You press the key that corresponds to the value 115200, then press Enter.
  5. Set Hardware flow control to No using the F key.
  6. Set Software flow control to No using the G key.
  7. Press Enter to return to the main configuration menu, and then press Esc to exit this menu.
  8. Reset the board, and wait for a moment. If you do not see output from the board, press Enter several times until you see the prompt. If you do not see any output from the board, and have verified that the serial terminal connection is setup correctly, contact your board vendor.

TIP: If you experience an error similar to Device /dev/ttyACM0 is locked when starting minicom, it usually means that another process is using the serial port (which is usually another instance of minicom). You can find the process that is currently using the serial port by executing the following:

# fuser /dev/ttyACM0
/dev/ttyACM0:         28358

# ps 28358
  PID TTY      STAT  TIME COMMAND
  28923 pts/0    S+    0:00 minicom

This process can also be killed directly with fuser as root. Please use this command with caution:

# fuser -k /dev/ttyACM0

Using GNU Screen

To quickly connect to a board using Gnu Screen, execute the following:

# screen /dev/ttyACM0 115200

For more information about using screen, please consult the man page, or view the manual online at http://www.gnu.org/software/screen/manual/screen.html

Preparing the Secure Digital Card

The STM32MP135F-DK boots from an SD card. Some kits may be shipped with one that contains a sample kernel and RFS preloaded. We will be replacing these with the kernel and RFS from Factory. If you are using a blank SD card or have trouble replacing the software on the preloaded one, see Partitioning the SD Card. Otherwise, skip directly to Writing Boot Files to the SD Card.

Before you begin, you should determine the name of your SD card on your host system. To do so:

  1. Connect the SD card to your host system. Many modern systems have SD card slots on the case, or you can purchase a USB SD Card Reader for around $15 US.
  2. Determine the device name of the SD Card. This can be done using dmesg. In the following example, the device is /dev/sdX, which contains one partition sdX1.

    $ dmesg | tail
    [88050.184080] sd 4:0:0:0: [sdX] 1990656 512-byte hardware sectors: (1.01 GB/972 MiB)
    [88050.184821] sd 4:0:0:0: [sdX] Write Protect is off
    [88050.184824] sd 4:0:0:0: [sdX] Mode Sense: 03 00 00 00
    [88050.184827] sd 4:0:0:0: [sdX] Assuming drive cache: write through
    [88050.185575] sd 4:0:0:0: [sdX] 1990656 512-byte hardware sectors: (1.01 GB/972 MiB)
    [88050.186323] sd 4:0:0:0: [sdX] Write Protect is off
    [88050.186325] sd 4:0:0:0: [sdX] Mode Sense: 03 00 00 00
    [88050.186327] sd 4:0:0:0: [sdX] Assuming drive cache: write through
    [88050.186330]  sdX: sdX1

Partitioning the SD card

If you want to use a different SD card or its contents become corrupted, you can use the sgdisk tool to create four partitions on your SD card. Please note that all data on the card will be lost upon completion of these steps.
  1. The minimal partitions requirements for boot are:
  2. A partitions "fsbl1" size at least 256KiB.The size of fip or ssbl partition must be enough for the associated binary file, 4MB and 2MB are default values.
  3. A partitions "fsbl2" size at least 256KiB.The size of fip or ssbl partition must be enough for the associated binary file, 4MB and 2MB are default values.
  4. one partition named "fip" for FIP or U-Boot (TF-A [Trusted Firmware-A ]search the "fip" partition and SPL search the 3th partition.Without FIP support in TF-A, a 3rd partition "fip" for u-boot.stm32 must be named "ssbl".
  5. The 4th, 5th partition are marked as bootable..
  6. As root, run the sgdisk utility on the drive for Delete the existing partition table.
    $ export DISK=/dev/sdb
    $ sudo dd if=/dev/zero of=$DISK bs=1M count=10
    $ sudo sgdisk -o $DISK
  7. In sgdisk, create a new partition table.

    sudo sgdisk –resize-table=128 -a 1 \
    -n 1:34:545 -c 1:fsbl1 \
    -n 2:546:1057 -c 2:fsbl2 \
    -n 3:1058:9249 -c 3:fip \
    -n 4:9250:413695 -c 4:bootfs -a 4 -A 4:set:2 \
    -n 5:413696: -c 5:rootfs -a 5 -A 5:set:2 \
    -p $DISK

  8. Format the 4th, 5th partition using an ext4 filesystem using the mkfs.ext4 tool.

    $ sudo mkfs.ext4 -L bootfs $DISK4
    $ sudo mkfs.ext4 -L rootfs $DISK5

Writing Boot Files to the SD Card

Once you have a properly partitioned SD card, you can then populate it with the boot files generated by Factory.

  1. The partitions are usually automounted under /media, but if not, you can use the mount command to mount the partition to an arbitrary location.

    $ sudo mount $DISK4 /media/timesys/bootfs
    $ sudo mount $DISK5 /media/timesys/rootfs

  2. copy the tf-a-stm32mp135f-dk.stm32 file to the SD card.


    $ sudo dd if=tf-a-stm32mp157f-dk2.stm32 of=$DISK1 conv=fdatasync
    $ sudo dd if=tf-a-stm32mp157f-dk2.stm32 of=$DISK2 conv=fdatasync

  3. To create a file with no data but with required size A file with all zero written on it.

    $ sudo dd if=/dev/zero of=$DISK3 conv=fdatasync

  4. Copy fip.bin to the SD card.

    $ sudo dd if=fip.bin of=$DISK3 conv=fdatasync

  5. As root, extract the rootfs.tar.gz archive to the card.

    $ sudo tar -xvf rootfs.tar.gz -C /media/timesys/rootfs/

  6. As root, copy the uImage file, uImage, to the boot directory on the RFS partition of the card.

    $ sudo cp uImage-5.10-ts-armv7l /media/timesys/bootfs/

  7. Copy the dtbfile, stm32mp135f-dk.dtb into the boot partition.

    $ sudo cp  stm32mp135f-dk.dtb /media/timesys/bootfs/

  8. To utilise factory Distro boot feature follow the steps bellow As root, copy the extlinux.conf file to the ext4 partition.

    $ sudo mkdir -p /media/timesys/bootfs/extlinux
    $ sudo cp extlinux.conf /media/timesys/bootfs/extlinux
    NOTE: Board will automatically boot by utilizing the environment variables specified in "extlinux.conf" file.
  9. Unmount all partitions.

    $ sudo umount $DISK*

  10. Remove the card from the host machine, and insert it into the SD card slot on the STM32MP135F-DK.

  11. Power on or press B5 to reset the board.

Preparing the Host

No additional host setup is required to boot from SD.

Booting the Board

STM32MP135F-DK Boot related switches

Image STM32MP135F-DK-boot-combination

Image STM32MP135F-DK-boot-img

Set Environment Variables

You must set a few environment variables in order to boot the board from the SD card. This is done with the setenv and saveenv commands in U-Boot.

On the target, set the following environment variables:

Variable Value          
bootargs console=ttySTM0,115200 root=/dev/mmcblk0p5 rw rootwait earlyprintk          
load_kernel ext4load mmc 0:5 0xc2000000 uImage-5.10.61-ts-armv7l          
load_dtb ext4load mmc 0:5 0xc4000000 stm32mp135f-dk.dtb          
bootcmd mmc rescan\; run load_kernel load_dtb\; bootm 0xc2000000 - 0xc4000000          

Example

> setenv bootargs console=ttySTM0,115200 root=/dev/mmcblk0p5 rw rootwait earlyprintk
> setenv load_kernel ext4load mmc 0:5 0xc2000000 uImage-5.10.61-ts-armv7l
> setenv load_dtb ext4load mmc 0:5 0xc4000000 stm32mp135f-dk.dtb
> setenv bootcmd mmc rescan\; run load_kernel load_dtb\; bootm 0xc2000000 - 0xc4000000
> saveenv

Load The Kernel

You can use the mmc subsystem to load the kernel from the SD card.

Example

> mmc rescan
> ext4load mmc 0:5 0xc2000000 uImage-5.10.61-ts-armv7l
reading uImage-5.10.61-ts-armv7l

3008612 bytes read

Load The Device Tree

You can use the mmc subsystem to load the device tree file (dtb) from the SD card.

Example

> mmc rescan
> ext4load mmc 0:5 0xc4000000 stm32mp135f-dk.dtb
reading stm32mp135f-dk.dtb

24612 bytes read

Boot the Kernel

The bootm command is used to boot the kernel. It loads the file that was previously loaded using the ext4load command.

Example

> bootm 0xc2000000 - 0xc4000000
## Booting kernel from Legacy Image at 0xc2000000 ..
   Image Name:   Linux-5.10.61
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    3008548 Bytes =  2.9 MB
   Load Address: 80008000
   Entry Point:  80008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK
## Flattened Device Tree blob at 0xc4000000
   Booting using the fdt blob at 0xc4000000
   Loading Kernel Image ... OK
OK

Additional Information

Factory Documentation