BSP Manual - phyCORE-STM32MP15x (L-876e.A0)

Table of Contents

BSP Manual - phyCORE-STM32MP15x (L-876e.A0)
Document TitleBSP Manual - phyCORE-STM32MP15x (L-876e.A0)
Document TypeBSP Manual
Article NumberL-876e.A0
Release Date23.09.2020
Is Branch ofBSP Manual - phyCORE-STM32MP15x (L-876e.Ax) Head

Compatible BSP'SBSP Release TypeBSP Release DateBSP Status
PD20.1.0Major Release18.09.2020Released

Yocto Introduction

The meta-yogurt layer cannot be used for the OpenSTLinux BSP. Refer to the ST documentation for more information:https://wiki.st.com/stm32mpu/wiki/OpenSTLinux_distribution

PHYTEC Documentation

PHYTEC will provide a variety of hardware and software documentation for all of our products. This includes any or all of the following:

  • Quickstart Guide: A short guide on how to set up and boot a phyCORE board along with brief information on building a BSP, the device tree, and accessing peripherals.
  • Hardware Manual:  A detailed description of the System on Module and accompanying carrier board. 
  • Yocto Guide:  A comprehensive guide for the Yocto version the phyCORE uses. This guide contains an overview of Yocto; introducing, installing, and customizing the PHYTEC BSP; how to work with programs like Poky and Bitbake; and much more.
  • BSP Manual:  A manual specific to the BSP version of the phyCORE. Information such as how to build the BSP, booting, updating software, device tree, and accessing peripherals can be found here.
  • Development Environment Guide:  This guide shows how to work with the Virtual Machine (VM) Host PHYTEC has developed and prepared to run various Development Environments. There are detailed step-by-step instructions for Eclipse and Qt Creator, which are included in the VM. There are instructions for running demo projects for these programs on a phyCORE product as well. Information on how to build a Linux host PC yourself is also a part of this guide.
  • Pin Muxing Table:  phyCORE SOMs have an accompanying pin table (in Excel format). This table will show the complete default signal path, from processor to carrier board. The default device tree muxing option will also be included. This gives a developer all the information needed in one location to make muxing changes and design options when developing a specialized carrier board or adapting a PHYTEC phyCORE SOM to an application. 

On top of these standard manuals and guides, PHYTEC will also provide Product Change Notifications, Application Notes, and Technical Notes. These will be done on a case by case basis. Most of the documentation can be found in the applicable download page of our products.

Warning

Be aware that not all of the above documentation will be available for the phyBOARD-Sargas. To find all PHYTEC documentation, go to https://www.phytec.de/produkt/system-on-modules/phycore-stm32mp1-download/ or https://www.phytec.eu/product-eu/system-on-modules/phycore-stm32mp1-download/

BSP Introduction

Supported Hardware

This BSP supports the phyCORE-STM32MP1 SOM with phyBOARD-Sargas SBC. Visit our web page at:
https://www.phytec.de/produkt/system-on-modules/phycore-stm32mp1-download/
or
https://www.phytec.eu/product-eu/system-on-modules/phycore-stm32mp1-download/

Click the corresponding BSP release and look for the article number of your module in the column "Article Number". Finally, look for the correct machine name in the corresponding cell under "Machine Name".

Software and Software Requirements

  • A modern Linux operating host system either natively or via a Virtual Machine.
  • Ubuntu 18.04 LTS or 16.04 LTS (64-bit).
  • VMWare Player and VirtualBox are possible solutions if you want to use a Virtual Machine. 

Virtual Machine (VM) configured for this BSP build environment can be downloaded at:  https://www.phytec.de/produkt/system-on-modules/phycore-stm32mp15x-download/#vm

  • Root access to your Linux host PC. Some commands in this guide will not work if you do not have sudo access (e.g. package installation, formatting an SD card).
  • At least 8GB of RAM (16GB or more is recommended).
  • At least 100 GB of free space on the build partition of the host PC.
  • An SD card reader operational under Linux.
  • An active internet connection.

For more details concerning Linux PC configuration, please refer to: https://wiki.st.com/stm32mpu/wiki/PC_prerequisites

Getting Started with the Included SD Card

This section is designed to get the board up and running with the SD Card included in the kit, which has been prepared with pre-built images.

Booting from the SD Card

This section describes how to boot the phyBOARD-Sargas with the pre-built images on the included SD card.

  • Insert the micro SD card into the SD card slot of the board.
  • Check that the S7 DIP switch is in the default position (boot from SD):

  • Plug the USB cable into the USB debug on the board (X13) and your host PC. You should see two new devices appear: /dev/ttyUSB0 and /devttyUSB1. A Linux terminal will be accessible on /dev/ttyUSB0. 
  • Start your favorite terminal software (e.g. Minicom or Tera Term) on your host PC and configure it for 115200 baud, 8 data bits, no parity, and 1 stop bit (8n1) with no handshake.
  • Example to launch minicom on /dev/ttyUSB0:
host:~$sudo minicom -D /dev/ttyUSB0 
  • Connect the power supply to the power connector.

The RGB LED (D11) will begin blinking BLUE as the board begins booting into Linux. The console output can be viewed in your terminal window. If everything was done correctly, the login prompt will be shown at the end of the booting process:

ST OpenSTLinux - Weston - (A Yocto Project Based Distro) 2.6-snapshot phycore-stm32mp1-3 ttySTM0
phycore-stm32mp1-3 login: root (automatic login)
root@phycore-stm32mp1-3:~#

Log in is done automatically as root (no password is required).

Building the BSP

This section will guide you through the general build process of the STM32MP1 BSP using the repo tool.

Our BSP is based on OpenSTLinux Distribution: https://wiki.st.com/stm32mpu/wiki/STM32MP15_OpenSTLinux_release_note

To adapt the OpenSTLinux distribution to our board, we added our own yocto layer, "meta-phytec". You can find our specific meta-phytec layer for stm32mp in:

https://git.phytec.de/meta-phytec/tree/dynamic-layers/stm-st-stm32mp

In this meta-phytec yocto layer, we have added some extra features and patches to U-boot and Linux Kernel.

Get the BSP

  • Create a fresh project directory:
host:~$ mkdir ~/PHYTEC_STM32MP1_BSP
  • Initialize repo in the current directory:
host:~$ cd ~/PHYTEC_STM32MP1_BSP
host:~/PHYTEC_STM32MP1_BSPx$ repo init -u git://git.phytec.de/phy2octo -b stm32mp1 -m PD-BSP-Yocto-OpenSTLinux-STM32MP1-PD20.1.0.xml --reference=/home/share/repo_reference
  • Synchronize the local project directories with the remote repositories specified in the manifest:
host:~/PHYTEC_STM32MP1_BSP$ repo sync

Tip

"ERROR 404" may appear during "repo init" command without any impact on the process.

Basic Set-Up

There are a few important steps that have to be done before the main build process.

Finding the Right Software Platform

The STM32MP1 BSP is a unified BSP, which means in the future it supports a set of different PHYTEC carrier boards (CB) with different Systems on Module (SOMs). These hardware sets are called MACHINE.

If you need to figure out the corresponding machine name of your board, go to https://www.phytec.de/produkt/system-on-modules/phycore-stm32mp15x-download/#software and click on the corresponding BSP release, or refer to the files in the source folder of the BSP, where you can find the platform name to the corresponding product IDs:

host:~/PHYTEC_STM32MP1_BSP/layers$ meta-phytec/conf/machine/phycore-stm32mp-*.conf

For our examples in this manual, we will use: <MACHINE>= phycore-stm32mp-3

Choose a BSP OpenSTLinux Distribution

The phyCORE-STM32MP1 BSP is based on OpenSTLinux which offers different distributions (DISTRO). When building the BSP, you have to choose one of them. The choice will depend on the features you want to get on your final application.

The available DISTROs are:

DISTRODescription
openstlinux-eglfs

OpenSTLinux featuring EGLFS (no X11, no Wayland).

EGLFS is a platform plugin for running Qt5 applications on top of EGL and OpenGL ES 2.0, without an actual windowing system like X11 or Wayland.

openstlinux-westonOpenSTLinux featuring Weston/Wayland display server protocol.
openstlinux-tiny

Distribution customized by PHYTEC for SOM equipped with small Flash memory size (128MB). It is based on OpenSTLinux distro with the following differences :

  • no X11, no Wayland, no eglfs
  • no uninative support
  • SysVinit instead of systemd
  • following features removed: alsa, wifi, nfs, bluetooth, bluez5

NOTE: currently, only BSP images proposed as an example only can be built with this DISTRO (no ST/PHYTEC support on this)

openstlinux-x11

OpenSTLinux featuring X11 display server protocol.

NOTE: currently only BSP images proposed as an example only can be built with this DISTRO (no ST/PHYTEC support on this)

For more details on the OpenSTLinux distributions, please refer to https://wiki.st.com/stm32mpu/index.php/OpenSTLinux_distribution#Distros

For our examples in this document we will use: <DISTRO>= openstlinux-weston

Choose a BSP Image to be Build and Deployed

Once you have chosen a DISTRO, you have to choose a BSP Image to build and deploy on target. The available images depend on the DISTRO that has been chosen before.

BSP ImageDescriptionRequired DISTRO MACHINE minimal FLASH memory size

st-image-weston

OpenSTLinux Weston image with basic Wayland support - OpenSTLinux official image

It comes with a graphical application demo that will show up on a Screen  (if one display is connected to the carrier board). This is the image that is delivered by default with our standard evaluation kit.

openstlinux-weston

>= 1GB

st-image-core

OpenSTLinux core image (without Weston or any GUI framework) - OpenSTLinux supported image

any openstlinux DISTRO

(except openstlinux-tiny)

>= 512MB

st-example-image-qt

OpenSTLinux example of image based on QT framework - proposed as an example only

openstlinux-eglfs

>= 1GB

st-example-image-x11OpenSTLinux example of image based on X11 - not tested - proposed as an example onlyopenstlinux-x11

>= 1GB

st-example-image-xfceOpenSTLinux example of image based on XFCE framework - proposed as an example onlyopenstlinux-x11

>= 1GB

st-image-core-minimal

PHYTEC OpenSTLinux core minimal image (PHYTEC custom image)  - proposed as an example only

It is based on st-image-core, but without :

  • framework for display and multimedia
  • framework tools base components (core, kernel, network, audio, ui, python2, python3)
  • package management system
openstlinux-tiny>= 128MB
st-example-image-qt-minimal

PHYTEC OpenSTLinux example of image based on Qt minimal framework (PHYTEC custom image)  - proposed as an example only
It is based on st-example-image-qt with fewer features and QT packages to decrease the image size.

openstlinux-eglfs>= 512MB

For more information regarding OpenSTLinux images and how to create your own image, please refer to: https://wiki.st.com/stm32mpu/wiki/How_to_create_your_own_image

For our examples in this document we will use: <BSP_IMAGE>=st-image-weston

OpenEmbedded Environment Setup

  • Select the correct MACHINE and DISTRO and initialize the OpenEmbedded build environment:
host:~/PHYTEC_STM32MP1_BSP$ DISTRO=openstlinux-weston MACHINE=phycore-stm32mp1-3 BSP_DEPENDENCY=layers/meta-phytec source layers/meta-phytec/scripts/envsetup.sh
  • The BSP for STM32MP1 depends on packages and firmware which are covered by a software license agreement (SLA). You will be asked to read and to accept this EULA:

Note

It is mandatory to accept this EULA to be able to use the internal STM32MP1 GPU.

  • After accepting the EULA, you should now be in a sub-folder named '~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>'

Warning

Warning

The OpenEmbedded environment setup script must be run once in each new working terminal (to be able to use bitbake). As DISTRO, MACHINE, and BSP_DEPENDENCY are now set in 'build-<DISTRO>-<MACHINE>'/conf/local.conf, you can directly use the following command:

host:~/PHYTEC_STM32MP1_BSP$ source layers/meta-phytec/scripts/envsetup.sh

Build Process

Now you should be in a sub-folder named '~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>' and you can start the first build process, using the following command:

host:~/PHYTEC_STM32MP1_BSP/build-openstlinuxweston-phycore-stm32mp1-3$ bitbake <BSP_IMAGE>

Example to build the "st-image-weston":

host:~/PHYTEC_STM32MP1_BSP/build-openstlinuxweston-phycore-stm32mp1-3$ bitbake st-image-weston

Generated BSP Image Binaries

All images generated by Bitbake are deployed to ~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>/tmp-glibc/deploy/images/<MACHINE>. The following list shows the generated files used for flashing the phycore-stm32mp1:

Binary file nameDescription
tf-a-<MACHINE>-trusted.stm32TF-A binary for FSBL partition (trusted boot chain)

u-boot-<MACHINE>-trusted.stm32

U-Boot binary for SSBL partition (trusted boot chain)

st-image-bootfs-<DISTRO>-<MACHINE>.ext4

Binary for bootfs partition on eMMC and microSD card devices

st-image-vendorfs-<DISTRO>-<MACHINE>.ext4

Binary for vendorfs partition on eMMC and microSD card devices

<BSP_IMAGE>-<DISTRO>-<MACHINE>.ext4

Binary for rootfs partition on eMMC and microSD card devices

st-image-userfs-<DISTRO>-<MACHINE>.ext4

Binary for userfs partition on eMMC and microSD card devices
<BSP_IMAGE>-<DISTRO>-<MACHINE>_multivolume.ubiBinary for bootfs, vendorfs, rootfs, and userfs partitions on NAND device

Using STM32CubeProgrammer to Flash the BSP

In this section, we explain how to use the STM32MPCubeProgrammer tool to flash the NOR, eMMC, NAND, or SD Card.

Install STM32CubeProgrammer Tool

When using the PHYTEC Virtual Machine preconfigured for the phyCORE-STM32MP1 BSP, this tool is already installed. Otherwise, refer to https://wiki.st.com/stm32mpu/wiki/STM32CubeProgrammer for information on installing the STM32CubeProgrammer.

To download the BSP via DFU link, change the BOOT mode to UART/USB boot mode

  • Switch OFF the board
  • Change the S7 DIP switch to UART/USB boot mode:

  • Switch ON the board => The RED LED on the SOM must start blinking RED.
  • Connect a USB micro-AB (OTG) to X12 and to the host PC that contains the downloaded image => The RED led should stop blinking.

Using STM32CubeProgrammer

  • Go to the directory that contains the binaries and the flash layout files: 
host:~$ cd ~/PHYTEC_STM32MP1_BSP/build-openstlinuxweston-stm32mp1/tmp-glibc/deploy/images/phycore-stm32mp1-3
  • Get the device port location for the USB link:
$ STM32_Programmer_CLI -l usb
      -------------------------------------------------------------------
                        STM32CubeProgrammer <tool version>                  
      -------------------------------------------------------------------

=====  DFU Interface   =====

Total number of available STM32 device in DFU mode: 1

  Device Index           : USB1
  USB Bus Number         : 001
  USB Address Number     : 001
  Product ID             : DFU in HS Mode @Device ID /0x500, @Revision ID /0x0000
  Serial number          : 003C00283338510C34383330
  Firmware version       : 0x0110
  Device ID              : 0x0500
  • Use the flashing command:
$ STM32_Programmer_CLI -c port=<DEVICE_PORT_LOCATION> -w [<file.tsv>]
where 
 w:
     Write
 <file.tsv>:PathToFlashlayout/flashlayout.tsv file
         if Flashlayout and binaries are not in the same directory, then the path to the Flashlayout files must be precised.
 <DEVICE_PORT_LOCATION>:
         e.g. usb1 (case sensitive)

Flashing the SD Card

To flash the SD Card with STM32CubeProgrammer:

  • If not already done, insert an SD Card in the SD Card connector (X14).
  • Use the flashing command with the following Flashlayout file: /flashlayout_st-image-weston/FlashLayout_sdcard_phycore-stm32mp1-3-trusted.tsv
$ STM32_Programmer_CLI -c port=usb1 -w flashlayout_st-image-weston/FlashLayout_sdcard_phycore-stm32mp1-3-trusted.tsv

This operation takes several minutes (mainly depending on the rootfs size). A successful flashing outputs the following message:

Flashing service completed successfully

Flashing the Target

Flashing the NOR and eMMC (Boot from NOR)

  • Use the flashing command with the following Flashlayout file: /flashlayout_<BSP_IMAGE>/FlashLayout_nor-emmc_<MACHINE>-trusted.tsv

Tip

With this FlashLayout file, the ST Trusted Firmware and U-boot are downloaded into the NOR Flash. The kernel and rootfs files are downloaded into eMMC. This enables booting from NOR Flash and running Linux on the eMMC.


$ STM32_Programmer_CLI -c port=usb1 -w flashlayout_st-image-weston/FlashLayout_nor-emmc_phycore-stm32mp1-3-trusted.tsv

This operation takes several minutes (mainly depending on the rootfs size). A successful flashing outputs the following message:

Flashing service completed successfully

Flashing eMMC (Boot from eMMC)

  • Use the flashing command with the following Flashlayout file: /flashlayout_<BSP_IMAGE>/FlashLayout_emmc_<MACHINE>-trusted.tsv
$ STM32_Programmer_CLI -c port=usb1 -w flashlayout_st-image-weston/FlashLayout_emmc_phycore-stm32mp1-3-trusted.tsv

This operation takes several minutes (mainly depending on the rootfs size). A successful flashing outputs the following message:

Flashing service completed successfully

Flashing NAND (Boot from NAND)

  • Use the flashing command with the following Flashlayout file: /flashlayout_<BSP_IMAGE>/FlashLayout_nand_<MACHINE>-trusted.tsv
$ STM32_Programmer_CLI -c port=usb1 -w flashlayout_st-image-weston/FlashLayout_nand-2-256_phycore-stm32mp1-3-trusted.tsv

This operation takes several minutes (mainly depending on the rootfs size). A successful flashing outputs the following message:

Flashing service completed successfully

System Booting

The phyCORE-STM32MP1 can boot from the following devices:

  • eMMC
  • NOR
  • NAND (when populated instead of eMMC)
  • UART 
  • USB
  • SD-Card

The boot source is chosen by setting the S7 DIP switch.

Booting from SD Card

Booting from the SD Card is useful in several situations (for example when the bootloader in Flash memory has crashed).

To boot from the SD card, set the S7 DIP switch as follow: 

There are two ways to create a bootable SD card. You can either use:

Create an SD card image (with PC Host SD card reader)

To boot from SD, the first possibility is to create an SD Card image that contains all BSP binary files in correctly preformatted partitions. This image can be copied to the SD card easily using the single Linux command dd. Use the script create_sdcard_from_flashlayout.sh with the <FlashLayout file> = FlashLayout_sdcard_phycore-stm32mp1-3-trusted.tsv:

host:~$ cd build-<DISTRO>-<MACHINE>/tmp-glibc/deploy/images/<MACHINE>/scripts
host:~$ ./create_sdcard_from_flashlayout.sh ../flashlayout_<built-image>/<FlashLayout file>

Example:

host:~$ cd build-openstlinuxweston-phycore-stm32mp1-3/tmp-glibc/deploy/images/phycore-stm32mp1-3/scripts
host:~$ ./create_sdcard_from_flashlayout.sh ../flashlayout_st-image-weston/FlashLayout_sdcard_phycore-stm32mp1-3-trusted.tsv 

The script will generate the following SD Card image (raw file): in the binaries directory: .../flashlayout_<BSP_IMAGE>_FlashLayout_sdcard_<MACHINE>-trusted.raw

Example : flashlayout_st-image-weston_FlashLayout_sdcard_phycore-stm32mp1-3-trusted.raw (in build-openstlinuxweston-phycore-stm32mp1-3/tmp-glibc/deploy/images/phycore-stm32mp1-3)

Use this raw file to populate the SD Card with dd command:

  • Insert the uSD Card in the PC Host
  • Umount all the partitions associated with uSD Card
  • Populate microSD card with dd command:
host:~$ cd build-openstlinuxweston-phycore-stm32mp1-3/tmp-glibc/deploy/images/phycore-stm32mp1-3
host:~$ sudo dd if=flashlayout_st-image-weston_FlashLayout_sdcard_phycore-stm32mp1-3-trusted.raw of=/dev/mmcblk0 bs=8MB conv=fdatasync

More details can be found here: https://wiki.st.com/stm32mpu/wiki/How_to_populate_the_SD_card_with_dd_command

Warning

To create your bootable SD Card with the dd command, you must have root privileges. Because of this, you must be very careful when selecting the destination device for the dd command! All files on the selected destination device will be erased immediately without any further query! Consequently, having selected the wrong device can also erase your hard drive!

Booting from eMMC Flash

  • When powering the board again, the system will boot from eMMC.

Booting from NOR Flash

  • When powering the board again, the system will boot from NOR.

Booting from NAND Flash

  • When powering the board again, the system will boot from NAND.

Accessing Peripherals (in Linux userspace)

The following sections provide an overview of the supported hardware components and their operating system drivers on the STM32 platform.

UARTs (tty)

The STM32MP15x SoC provides up to 4 x UART and 4 x USART. phyCORE-STM32MP1 and carrier board is configured by default with 4 UARTs:

UART interfaceLinux DeviceFunction on Carrier BoardRTS/CTS
UART4/dev/ttySTM0

USB debug (X13) - 1st FTDI serial port (Linux Terminal)
optionally available on Expansion connector (X33)

no
USART3/dev/ttySTM1

USB debug (X13) - 2nd FTDI serial port
optionally available on:

  • Arduino Shields connector (X3)
  • Expansion connector (X33)
no
USART1/dev/ttySTM2

UART available on:

  • RS232/RS485 (X35)
  • Arduino Shields connector (X3)
  • Raspberry Pi HAT connector (X7)
yes

Below are some Linux userspace commands to test the UART on target:

  • Sending a message on USART3:
target$ echo "test" > /dev/ttySTM1
  • Receiving a message on USART3:
target$ cat /dev/ttySTM1
  • Be sure that the baud rate is set correctly on the host and target. In order to get the currently configured baud rate, you can use the command stty on the target.

Command to get tty help:

target$ tty --help

FD CAN Bus

For an overview of the Linux Controller Area Network (CAN) framework, please refer to https://wiki.st.com/stm32mpu/wiki/CAN_overview

Below are some examples on how to send or receive data on a SocketCAN interface using the can-utils package with the cansend and candump command:

Prerequisite: At least two nodes are required to communicate on a CAN network.

  • Initialize CAN0 Link with 1Mbit/s:
target$ ip link set can0 up type can bitrate 1000000
  • The command below allows you to get details on the created link:
target$ ip -details link show can0
2: can0: <NOARP,UP,LOWER_UP,ECHO> mtu 16 qdisc fq_codel state UNKNOWN mode DEFAULT group default qlen 10
    link/can  promiscuity 0 
    can state ERROR-ACTIVE (berr-counter tx 0 rx 0) restart-ms 0 
          bitrate 992063 sample-point 0.761
          tq 48 prop-seg 7 phase-seg1 8 phase-seg2 5 sjw 1
          m_can: tseg1 2..256 tseg2 1..128 sjw 1..128 brp 1..512 brp-inc 1
          m_can: dtseg1 1..32 dtseg2 1..16 dsjw 1..16 dbrp 1..32 dbrp-inc 1
          clock 62500000numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535
  • To send a single frame, use the cansend utility (cansend <device> <can_frame>):
target$ cansend can0 123#1122334455667788                                                                                                                                                   
  • To receive CAN message, use the candump utility:
target$ candump can0                                                                                                                                                     
  can0  123   [8]  00 11 22 33 44 55 66 77
  can0  123   [8]  00 11 22 33 44 55 66 77
  • To print help on candump utility, use: "candump -h"

Network

A gigabit Ethernet is provided by our module and board. The interfaces offer a standard Linux network port that can be programmed using theBSD socket interface. The BSP contains different Network tools that allow for the configuration and testing of the Ethernet connection.

For information about these different tools and how to use it, please refer to: https://wiki.st.com/stm32mpu/wiki/Network_tools

Example on how to assign a given IP address to an Ethernet ETH0 interface:

ifconfig eth0 10.48.1.324

SD Card

The phyBOARD-Sargas supports a slot for Secure Digital Cards to be used as general-purpose block devices. These devices can be used in the same way as any other block device.

Warning

These kinds of devices are hot-pluggable. Nevertheless, you must ensure not to unplug the device while it is still mounted. This may result in data loss!

After inserting an SD/MMC card, the kernel will generate new device nodes in /dev. The full device can be reached via its /dev/mmcblk0 device node. SD/MMC card partitions will show up in the following way:

/dev/mmcblk0p<Y>

<Y> counts as the partition number starting from 1 to the max count of partitions on this device. The partitions can be formatted with any kind of file system and also handled in a standard manner, e.g. the mount and umount command work as expected.

GPIOs

The phyBOARD-Sargas carrier board has a set of pins specifically dedicated as user I/Os. Those pins are connected directly to STM32MP15x balls and are muxed as GPIOs. Accessing GPIOs from userspace can be done using the libgpiod.

To see how to access the GPIOs, please refer to: https://wiki.st.com/stm32mpu/wiki/How_to_control_a_GPIO_in_userspace 

Warning

Most of the CPU IOs are used for special functions. Before using a user IO, refer to the schematic or the hardware manual of your board to ensure that it is not already in use.

Keys

With gpio-keys driver, the Linux kernel can interpret GPIO signals as virtual keyboard events. The carrier board has 2 buttons (S4 and S5), which can be used with the gpio-keys driver. 

To display the key events in ASCII format, use evtest.

  • To show the available input devices, run:
target$ evtest
  • You will get, for example:
No device specified, trying to scan all of /dev/input/event*
Available devices:
/dev/input/event0:      pmic_onkey
/dev/input/event1:      gpio-keys
Select the device event number [0-1]:
  • Select input device event number 1 for gpio-keys:
Select the device event number [0-1]: 1
Input driver version is 1.0.1
Input device ID: bus 0x19 vendor 0x1 product 0x1 version 0x100
Input device name: "gpio-keys"
Supported events:
  Event type 0 (EV_SYN)
  Event type 1 (EV_KEY)
    Event code 28 (KEY_ENTER)
    Event code 102 (KEY_HOME)
Properties:
Testing ... (interrupt to exit)
  • Now you will see every hit on push buttons S4 (KEY_HOME) or S5 (KEY_ENTER):
Event: time 1570639195.409061, type 1 (EV_KEY), code 102 (KEY_HOME), value 1
Event: time 1570639195.409061, -------------- SYN_REPORT ------------
Event: time 1570639195.569047, type 1 (EV_KEY), code 102 (KEY_HOME), value 0
Event: time 1570639195.569047, -------------- SYN_REPORT ------------
Event: time 1570639196.809052, type 1 (EV_KEY), code 28 (KEY_ENTER), value 1
Event: time 1570639196.809052, -------------- SYN_REPORT ------------
Event: time 1570639197.009031, type 1 (EV_KEY), code 28 (KEY_ENTER), value 0
Event: time 1570639197.009031, -------------- SYN_REPORT ------------
  • You can exit evtest with Ctrl+C
  • Listening to the device with cat will print the raw output:
target$ cat /dev/input/event1
root@phycore-stm32mp1-3:/sys/class# cat /dev/input/event1 
F
�]��fF
�]��F
�]BfF
�]B

LEDs

If any LEDs are connected to GPIOs, you have the possibility to access them by a special LED driver interface instead of the general GPIO interface (section GPIOs). You will then access them using /sys/class/leds/ instead of /sys/class/gpio/. The maximum brightness of the LEDs can be read from the max_brightness file. The brightness file will set the brightness of the LED (taking a value from 0 up to max_brightness). Most LEDs do not have hardware brightness support and therefore, will just be turned on by all non-zero brightness settings.

Here is a simple example:

  • To get all LEDs available, type:
target$ ls /sys/class/leds
blue-power  pca:green:power  pca:red:power

Here the LEDs are the three possible colors from RGB lED driven by a LED dimmer present on the carrier board. By default, the RGB LED blinks blue (it is the "Linux Heartbeat" shows that the Linux Kernel is running). But this RGB LED can also be used as a "user LED".

  • Example to toggle the RGB LED Blue color OFF:
target$ cd /sys/class/leds
target$ echo 0 >  blue-power/brightness
  • Example to toggle RGB LED Blue color ON with a brightness=10:
target$ echo 10 >  blue-power/brightness
  • Example to toggle RGB LED Green color ON with a brightness=20:
target$ echo 20 >  pca\:green\:power/brightness

I2C Bus

The STM32MP15x SoC provides up to 6 I²C FM (Fast-Mode). The phyCORE-STM32MP1 is configured with two Fast-Mode I²C modules called I2C4 and I2C1.

  • I2C4 is reserved for the I²C devices on the module (PMIC, RTC, EEPROM).
  • I2C1 is reserved for the carrier board which provides plenty of different I²C devices connected I²C1 bus of the STM32MP15x.

This section will describe the basic device usage.

EEPROM

It is possible to read and write directly to the device:

/sys/class/i2c-dev/i2c-1/device/1-0050/eeprom
  • To read and print the first 1024 bytes of the EEPROM as a hex number, execute:
target$ dd if=/sys/class/i2c-dev/i2c-1/device/1-0050/eeprom bs=1 count=1024  | od -x
  • To fill the whole EEPROM with zeros, use:
target$ dd if=/dev/zero of=/sys/class/i2c-dev/i2c-1/device/1-0050/eeprom bs=4096 count=1

This operation takes some time as the EEPROM is relatively slow.

RTC

RTCs can be accessed via /dev/rtc*. 

  • Check the available RTC:
target$ ls /sys/class/rtc
target$ rtc0  rtc1

Tip

This will list all RTCs including the non-I²C RTCs.

  • To find the name of the RTC devices, you can read its sysfs entry with:
target$ cat /sys/class/rtc/rtc*/name
rtc-rv3028 1-0052
stm32_rtc 5c004000.rtc
RTC devicesNameDescription
/dev/RTC0rtc-rv3028 1-0052External RTC RV-3028 (on the SOM). It is the Default RTC used by Linux Timing System.

/dev/RTC1

stm32_rtc 5c004000.rtc

Internal RTC of the CPU

As time is set according to the value of rtc0 during system boot, rtc0 should always be the RTC that is being backed up. 

  • Date and time can be manipulated with the date command and the hwclock tool. Example to set the date on /dev/RTC0:
target$ date 1010123119
Thu Oct 10 12:31:00 UTC 2019
target$ hwclock -w


Tip

As the VBACKUP pin of the external RTC component RV-3028 (on the SOM) is connected to a Gold Cap (on the carrier board), the date and time stored in the RTC are kept even if the board is switched off.

SPI Bus

The STM32MP1 SoC provides up to 6 SPI interfaces. The phyCORE-STM32MP1 is configured with 1 SPI called SPI16 (configured as SPI1 or SPI6).

By default, the Linux SPI driver used in the BSP is spidev.

SPI interfaceLinux Device

SPI1 (or SPI6)

/dev/spidev0.0

USB Host and OTG

Both USB Host and OTG use the same framework.

To learn about the Linux USB framework and how to use it, please refer to the USB framework: https://wiki.st.com/stm32mpu/wiki/USB_overview

For more software details about the OTG internal peripheral, please refer to: https://wiki.st.com/stm32mpu/wiki/OTG_internal_peripheral

For more software details about the USBH internal peripheral, please refer to: https://wiki.st.com/stm32mpu/wiki/USBH_internal_peripheral

Create an SSH Connection with USB OTG

When the target is running on Linux, you can create an SSH connection with Ethernet or USB OTG.

To create an SSH connection over USB OTG, proceed as follow: 

  • Plug a USB-A male to USB Micro B between the carrier board (X12) and the PC Host.
  • On your host PC, with your network manager or using "ifconfig" on a terminal, check that there is a new network interface (ex: new interface called "enp0s20f0u2u3").
  • Check the IP address of the USB OTG device of the target (usb0).
target$ ifconfig 
eth0      Link encap:Ethernet  HWaddr 8E:C5:2C:68:CF:75  
          inet6 addr: fe80::8cc5:2cff:fe68:cf75/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:35 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:7597 (7.4 KiB)
          Interrupt:61 Base address:0x2000 

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:264 errors:0 dropped:0 overruns:0 frame:0
          TX packets:264 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:16800 (16.4 KiB)  TX bytes:16800 (16.4 KiB)

usb0      Link encap:Ethernet  HWaddr BA:15:19:D5:BC:01  
          inet addr:192.168.7.1  Bcast:192.168.7.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  • On your host PC, with your network manager or with ifconfig command, check that there is a new network interface (ex: new interface called "enp0s20f0u2u3"). Then , configure the IP that matches with the usb0 target interface (192.168.7.1). Example with ifconfig:
host:~$ sudo ifconfig enp0s20f0u2u3 192.168.7.2
  • Connect to the target (to create a new remote terminal through SSH):
host:~$ ssh [email protected]
  • You can also copy any file from host to the target with following command:
host:~$ scp ~/myFile [email protected]:/home/root

The same procedure can be applied with an Ethernet connection.

Audio

On the phyCORE-STM32MP1, we use the TI TLV320AIC3007 audio codec. Audio support is done via the SAI2 interface and controlled via I2C.

  • To check if your sound card driver is loaded correctly and to check which audio output device is available:
target$ aplay -L
  • You will get output similar toː
null
      Discard all samples (playback) or generate zero samples (capture)
pulse
      PulseAudio Sound Server
default
      Default ALSA Output (currently PulseAudio Sound Server)
sysdefault:CARD=STM32MP1PHYCORE
      STM32MP1-PHYCORE, 
       Default Audio Device
  • To test Audio Playback:
target$ aplay -D plughw:CARD=STM32MP1PHYCORE /usr/share/sounds/alsa/Front_Center.wav
  • To list audio capture devices:
target$ arecord -l
**** List of CAPTURE Hardware Devices ****card 0: STM32MP1PHYCORE [STM32MP1-PHYCORE], device 1: 4400b004.audio-controller-tlv320aic3x-hifi tlv320aic3x-hifi-1 [] 
Subdevices: 1/1 Subdevice #0: subdevice #0
  • Run speaker-test to identify channel numbers (Left, Right...). Example to check right and left channel (2 channels):
target$ speaker-test -c 2 -t wav
  • You may have to select the audio device:
target$ speaker-test -c 2 -t wav -D plughw:CARD=STM32MP1PHYCORE
  • To inspect your sound cards capabilities, call:
target$ alsamixer -c STM32MP1PHYCORE

You should see a lot of options as the audio-ICs has many features you can play with. It might be better to open alsamixer via ssh (see Create an SSH Connection with USB OTG) instead of the serial console, as the console graphical effects are better.

Audio Sources and Sinks

The phyBOARD-Sargas carrier board has three jacks: headphone (X28), line in (X27), line out (X26); and one Mono speaker output connector (X5). Enabling and disabling input and output channels can be done with the alsamixer program.

With the Tabulator key, you can switch between the following screens:  Screen Playback; Screen Capture. To enable or disable switchable controls, press m (mute). With the cursor keys left and right, you can step through the different channels.  You can leave alsamixer by pressing the ESC key. The settings are saved automatically on shutdown and restored on boot by the systemd service alsa-restore. If you want to save the mixer settings manually, you can execute alsactl store. The settings are saved in /var/lib/alsa/asound.state.

Playback

To playback simple audio streams, you can use aplay. For example:

target$ aplay /usr/share/sounds/alsa/Front_Center.wav
#OR you may have to select the audio device:
target$ aplay -D plughw:CARD=STM32MP1PHYCORE /usr/share/sounds/alsa/Front_Center.wav

Capture

arecord is a command-line tool for capturing audio streams that uses Line In as the default input source. The following example captures the current stereo input source with a sample rate of 48000 Hz and creates an audio file in WAV format (signed 16 bit per channel, 32 bit per sample):

target$ arecord -t wav -c 2 -r 48000 -f S16_LE test.wav
#OR :
target$ arecord -t wav -c 2 -f dat test.wav
#OR you may have to select the audio device:
target$ arecord -t wav -c 2 -f dat test.wav -D hw:0,1

Capturing can be stopped using CTRL-C. You can also specify the capture duration with the -d option.

  • To play the recorded file: 
target$ aplay test.wav

Texas Instruments TLV320AIC3007

The TI chip has a lot of mixing features as you will notice when opening alsamixer. To get an idea of the possibilities, refer to the datasheet from TI. One important feature is the analog mixing capability. You can route input channels to output channels, either active or passive, without transferring data back and forth to the SoC. This is usually known as zero-latency monitoring in terms of PC Audio cards. To control this feature, open alsamixer and go to Playback section (F3). There will be one group of selectors for each output channel, e.g. Right Line Mixer. For most of the input paths, you can select between "passive through" or you can activate a programmable gain signal path. To route the line input to the line output, activate both "Right Line Mixer PGAR Bypass" and "Left Line Mixer PGAL Bypass". You should now hear the input signal at the line-out.

As an example application, we can route the audio stream through the whole system. First, we deactivate the direct loop from line-in to line-out in alsamixer and activate the ADC for the analog input mixer and the DAC for the analog output mixer. We can now close the signal path in the user space by using a pipe and the ALSA tools:

target$ arecord -c 2 -r 48000 -f S16_LE | aplay
#OR
target$ arecord -c 2 -r 48000 -f S16_LE -D hw:0,1 | aplay -D plughw:CARD=STM32MP1PHYCORE

We created the following audio routing path:

analog in -> ADC -> STM32MP1 -> kernel -> (userspace -> kernel -> )* DAC -> analog out

* actually twice for the pipe

You should now hear the input signal at the line output again. But this time, the routing through the entire system added a latency of 750 ms to the signal. The line mixer on the other side will only add about 4 μs delay.

This pipe routing is a crude example of how to use audio. If you need good audio performance, you should use an audio server. There are two prominent choices available, pulseaudio and jack.

As a third option, you can route the audio from line-in to the internal ADC. But instead of taking the signal path through the complete system, you can use the internal digital mixer of the TLV to directly route the signal back to the DAC and then to the output analog mixer and line-out. This signal path is record-only. You do not have the option of full-duplex playback in this mode. You can, however, use all the available DSP features of the TLV, the automatic gain, the high-pass filter, EQ, and de-emphasis filters for the record path. To activate this mode, you have to use the TI Windows tool to look up the specific I²C commands. The software can be found on the TI webpage and is called TLV320AIC3107EVM-K - GUI software. The 3107 is register compatible with all available features to the 3007. The software is used for both chips.

Displays

Three different kinds of displays are currently supported:

  • HDMI monitor => with PEB-AV-01 PHYTEC addon connected on Audio/Video connectors X24/X25
  • AC158 7" EDT capacitive LCD screen => with PEB-AV-02 PHYTEC addon connected on Audio/Video connectors X24/X25
  • MB1407 MIPI DSI screen (from STMicroelectronics : https://wiki.st.com/stm32mpu/wiki/MB1407) => connected on MIPI DSI connector X41
  • Official Raspberry Pi Touch 7" Display => connected on MIPI DSI connector X41

By default, the PHYTEC BSP is configured for the AC158 LCD parallel display (with PEB-AV-02 expansion).

To switch between the 3 different configurations, the device tree has to be rebuilt.

Changing the BSP Display Configuration

Prerequisite: Building the BSP must have been done.

Build a new image enabling/disabling one of the following Linux Kernel device tree files:

  • phyboard-stm32mp1-peb-av01-hdmi.dtsi
  • phyboard-stm32mp1-peb-av02-lcd.dtsi
  • phyboard-stm32mp1-dsi-lcd-mb1407.dtsi
  • phyboard-stm32mp1-dsi-rpi-official-display.dtsi

By default, phyboard-stm32mp1-peb-av02-lcd.dtsi is enabled.

  • To enable/disable one of these device tree expansions, comment (line begin with //) or uncomment the corresponding line in the phycore-stm32mp1-1.dtsi kernel device tree file (at the end of file).  Only one display expansion can be enabled at a time.
  • To modify and re-build the Linux Kernel device tree, please refer to section BSP Customization.
  • Once you have built and deployed your new BSP image on target, you can check that the display configuration is correct with the following command:
target$ modetest -M stm -c
Connectors:
id      encoder status          name            size (mm)       modes   encoders
29      28      connected       HDMI-A-1        520x290         2       28
  modes:
        name refresh (Hz) hdisp hss hse htot vdisp vss vse vtot)
  1024x768 70 1024 1048 1184 1328 768 771 777 806 75000 flags: nhsync, nvsync; type: driver
  800x600 72 800 856 976 1040 600 637 643 666 50000 flags: phsync, pvsync; type: driver
  props:
        1 EDID:
                flags: immutable blob
                blobs:

                value:
                        00ffffffffffff005a6330b701010101
                        201a010380341d782e0bd5a25750a128
                        0f5054bfef80b300a940a9c095009040
                        8180814081c0023a801871382d40582c
                        450009252100001e000000ff0055454a
                        3136333232313038340a000000fd0032
                        4b185213000a202020202020000000fc
                        00564132343635205345524945530081
        2 DPMS:
                flags: enum
                enums: On=0 Standby=1 Suspend=2 Off=3
                value: 0
        5 link-status:
                flags: enum
                enums: Good=0 Bad=1
                value: 0
        6 non-desktop:
                flags: immutable range
                values: 0 1
                value: 0
        19 CRTC_ID:
                flags: object
                value: 32

This command allows the user to check the display connectors and their status.

The '-c' modetest option displays only the connectors. To check all the Linux DRM display parameters, use the command: 

$modetest -M stm

To get more information about the modetest command and the Linux DRM/KMS display, graphic and composition framework, please refer to: https://wiki.st.com/stm32mpu/wiki/DRM_KMS_overview#Show_display_overall_status

  • The result seen above is for HDMI configuration: connector name = "HDMI-A-1" with status ="connected" (when PEB-AV-01 connected)
  • For a parallel LCD configuration: connector name = "DPI-1" with status ="connected" (when  PEB-AV-02 connected)
  • For MIPI DSI display configuration: connector name = " "DSI-1"  with status ="connected" (when MIPI-DSI screen connected)

Selecting the HDMI Monitor Video Modes

To get the supported video modes (resolutions and refresh frequencies) of an HDMI monitor connected to the phyCORE-STM32MP platform, please refer to: https://wiki.st.com/stm32mpu/wiki/How_to_display_on_HDMI#Video_modes and https://wiki.st.com/stm32mpu/wiki/How_to_display_on_HDMI#FAQ

In case all video modes supported by the monitor are rejected by the phyCORE-STM32MP platform, you will not be able to use the monitor. One solution, in this case, is to use Linux kernel DRM KMS Helper with EDID Firmware files to be able to get more video modes possibilities and choose the HDMI resolution to apply.

To do this, you have to build a new BSP image applying the following changes:

  • Modify the following file: /build-<DISTRO>-<MACHINE>/conf/local.conf uncommenting the two following lines:
IMAGE_INSTALL_append = " linux-firmware-edid"

HDMI_EDID_KERNEL_ARGS = "drm_kms_helper.edid_firmware=HDMI-A-1:edid/1280x720.bin"
  • On the second line, replace "1280x720" by the resolution that you want.

Possible resolutions are listed in layers/meta-phytec/dynamic-layers/stm-st-stm32mp/recipes-kernel/linux-firmware/linux-firmware-edid/linux-firmware-edid_20171024.tar.gz

  • Rebuild the BSP image:
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake <BSP_IMAGE>
  • Deploy the newly generated image on the target.

WLAN / Bluetooth Module Expansion

Two different WLAN / Bluetooth modules are supported :

  • Laird Stering-LWB 2.4GHz from Laird™ => with PEB-WLBT-05 PHYTEC addon connected on Expansion connector X33
  • AMPAK AP6212A => with the Raspberry PI HAT "RedBear IoT pHAT v1.0" connected on Raspberry Pi connector X7

By default, the PHYTEC BSP is configured without any Wifi/Bluetooth module activated in the device tree.

To enable one of these two modules, the Linux Kernel device tree has to be rebuilt.

Enabling WLAN / Bluetooth Module on a Device Tree

Prerequisite: Building the BSP must have been done.

With this PEB-WLBT-05 expansion, WLAN and Bluetooth device tree can be activated separately, so it is possible to use WLAN only, Bluetooth only, or both enabled.

  • Build a new image enabling the following Linux Kernel device tree files:
Expansion

FunctionKernel device tree expansion

PEB-WLBT-05[1]

Bluetooth[2]

on USART1

phyboard-stm32mp1-peb-wlbt-05-bluetooth-usart1.dtsi

on USART3phyboard-stm32mp1-peb-wlbt-05-bluetooth-usart3.dtsi
WLAN

phyboard-stm32mp1-peb-wlbt-05-wlan.dtsi

RedBear IoT pHAT v1.0WLAN and Bluetoothphyboard-stm32mp1-pi-hat-redbear.dtsi

1.

With PEB-WLBT-05, WLAN and Bluetooth expansion device tree files can be both enabled or only one can be enabled, so it is possible to use WLAN only, Bluetooth only, or both.

2.

With PEB-WLBT-05, for Bluetooth, enabled the device tree corresponding to the UART interface that should be used by the module (refer to the Application Note of this module to configure the phyBOARD-Sargas correctly).


  • To enable/disable those Kernel device tree expansions, comment (line begin with //) or uncomment the corresponding line in the phyboard-stm32mp1.dtsi kernel device tree file (at the end of file). 
  • To modify and re-build the device tree, please refer to section BSP Customization.

Tip

Watchdog

The STM32MP includes a Watchdog circuit called "IWDG" (Independent WatchDoG) that is able to reset the board when the system hangs (due to software or hardware failures). The IWDG is clocked by an independent clock, and stays active even if the main clock fails. In addition the watchdog function is performed in the VDD voltage domain, allowing the IWDG to remain functional even in low-power modes.

Two independent watchdogs (IWDG1 and IWDG2) are dedicated to MPU:

  • IWGG1 can only be allocated to the Cortex-A7 secure (to be used in the secure context by the customer application: this instance is not supported in OpenSTLinux distribution).
  • IWDG2 can be allocated to the Cortex-A7 non-secure to be used with Linux Watchdog Timer (WDT) framework.

How to enable the IWDG2 and configure its timeout value

The IWDG2 watchdog is enabled by default in the phycore-stm32mp157cac-som.dtsi kernel device tree with a custom timeout value in seconds (timeout-sec):

&iwdg2 {
timeout-sec = <32>;
status = "okay";
};

By default, the Watchdog Timer Linux framework support and the IWDG support is activated in the Linux kernel. This configuration can be changed through the Menuconfig tool (Configure the kernel through Menuconfig):

Device Drivers --->
[*] Watchdog Timer Support --->
[*] Disable watchdog shutdown on close
[*] Update boot-enabled watchdog until userspace takes over
<*> STM32 Independent WatchDoG (IWDG) support

With the option  "Update boot-enabled watchdog until userspace takes over" (enabled by default),  the kernel will ping the watchdog as long as an application opens the /dev/watchdog file (used by systemd).

How to use the watchdog in Linux using systemd

systemd is able to use the Hardware wathdog to check for system hangs (when system is running or during reboot). This feature is enabled by default, with the RuntimeWatchdogSec= option in the file system.conf in /etc/systemd/  :

RuntimeWatchdogSec=30s
ShutdownWatchdogSec=10min

When RuntimeWatchdogSec is not set or equal to 0, the Watchdog is not use. Setting this option to a different value allow to use it.

RuntimeWatchdogSec defines the timeout value of the watchdog, while ShutdownWatchdogSec defines the timeout when the system is rebooted. For more detailed information about hardware watchdogs under systemd refer to http://0pointer.de/blog/projects/watchdog.html.

To get more information on the IWDG internal peripheral please refer to:

https://wiki.st.com/stm32mpu/wiki/IWDG_internal_peripheral

https://wiki.st.com/stm32mpu/wiki/IWDG_device_tree_configuration

To get more information on the IWDG Linux Kernel support and how to use and trace/debug the WDT framework, please refer to:

https://wiki.st.com/stm32mpu/wiki/Watchdog_overview

Special Connectors Pinout Configuration

The following special connectors are available on the phyCORE-Sargas:

  • Raspberry PI HAT
  • Arduino Shields
  • Motor Control

Those special connectors pinout can be configured in the Linux Kernel device tree with the following dts files:

  • phyboard-stm32mp1-pi-hat-extension.dtsi
  • phyboard-stm32mp1-uno-r3-extension.dtsi
  • phyboard-stm32mp1-motor-control.dtsi

By default, only phyboard-stm32mp1-pi-hat-extension.dtsi is enabled.

  • To enable/disable those Kernel device tree files, comment (line begins with //) or uncomment the corresponding line in the phyboard-stm32mp1-1.dtsi device tree file (at the end of file).
  • To modify and rebuild the device tree, please refer to section BSP Customization.

Prerequisite: Building the BSP must have been done.

Rapsberry PI HAT Connector (X7)

This connector is compatible with the pinout of the standard Raspberry Pi HAT connector (https://pinout.xyz/). The pinout can be configured by pin muxing in the following device tree file: phyboard-stm32mp1-pi-hat-extension.dtsi

Please refer to the phyCORE-STM32MP1 Hardware Manual section Raspberry Pi HAT Connector (X7) for the pinout of this connector.

Arduino Shields Connector (X3)

This connector is compatible with the standard Arduino pinout connector (https://www.arduino.cc/en/reference/board). The pinout can be configured by pin muxing in the following device tree file: phyboard-stm32mp1-uno-r3-extension.dtsi

Please refer to the phyCORE-STM32MP1 Hardware Manual section Arduino Shields Connector (X3) for the pinout of this connector.

Motor Control Connector (X38)

This connector is compatible with the pinout of STM32 standard motor control power boards. It is also possible to connect X-NUCLEO-IHMx STM32 motor control expansions using X-NUCLEO-IHM09M1 adaptor: https://www.st.com/en/ecosystems/x-nucleo-ihm09m1.html. The pinout can be configured by pin muxing in the following device tree file: phyboard-stm32mp1-motor-control.dtsi or phyboard-stm32mp1-motor-control-m4.dtsi.

phyboard-stm32mp1-motor-control-m4.dtsi is an example of device tree configuration when signals are used by the Cortex-M4 MCU.

Please refer to the phyCORE-STM32MP1 Hardware Manual section Motor Control Connector (X38) for the pinout of this connector.

Warning

By default phyboard-stm32mp1-motor-control.dtsi and phyboard-stm32mp1-motor-control-m4.dtsi are not included in the SRC_URI of the linux-stm32mp yocto recipe. So, to be able to compile them, you first have to modify this recipe to add the corresponding SRC_URI. Please refer to Modify the Kernel Device Tree to know how to do this.

BSP Customization

STM32MP1 BSP Device Tree Concept

All device tree documentation can be found under:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>/tmp-glibc/work/<MACHINE>-<DISTRO>-linux-gnueabi/linux-stm32mp/<x.y>-r0/<x.y>/<x.y.z>/Documentation/devicetree/bindings

<x.y> and <x.y.z> in the above path have to be replaced by the Linux Kernel version number (ex: 4.19-r0/4.19/4.19.94/).

An introduction of the device tree usage can be found in the Linux kernel: linux/Documentation/devicetree/usage-model.txt. The device tree files are used during boot time by the Trusted Firmware (TF-A), the Bootloader (U-Boot), by the Linux kernel.

STM32MP documentation about the STM32MP1 Device Tree can be found at:

Note that in this ST documentation, the device tree files name concerning the boards do not correspond to our PHYTEC boards but the concept is exactly the same. The device tree files for our boards start with "phycore" or "phyboard". Refer to the next section for the phyCORE and phyBOARD device tree files list.

Tip

When customizing the BSP, device tree files can also be automatically generated thanks to the STM32CubeMX tool (The STM32CubeMX tool)

STM32MP1 Pin Muxing

The STM32MP1 SoC contains many peripheral interfaces. In order to reduce package size and lower overall system cost while maintaining maximum functionality, many of the STM32MP1 terminals can multiplex up to 16 signal functions. The STM32MP1 BSP is based on the pin controller Linux kernel framework (pinctrl) with a specific pinctrl-stm32 driver. The configuration is performed in the device tree (dts).

Please refer to ST documentation to learn about pinctrl and how to configure it in the device tree:

Below is the list of STM32MP1 PHYTEC custom device tree files (dts) under each source's directory (Linux Kernel, U-Boot, and TF-A). To know how to modify those sources, refer to the sections below.

Sourcesdts files pathphyCORE dts filesphyBOARD dts files

Internal peripherals config

PinctrlInternal peripherals configPinctrl

Linux

Kernel

arch/arm/boot/dts/

(original files are stored under the meta-phytec Yocto layer)

phycore-stm32mp1-x.dts

phycore-stm32mp157cac-som.dtsi


phycore-stm32mp157cac-pinctrl.dtsi
phycore-stm32mp157-pinctrl.dtsi

phyboard-stm32mp1.dtsi
phyboard-stm32mp1-peb-av01-hdmi.dtsi
phyboard-stm32mp1-peb-av02-lcd.dtsi
phyboard-stm32mp1-peb-av02-lcd-res.dtsi

phyboard-stm32mp1-dsi-lcd-mb1407.dtsi

phyboard-stm32mp1-dsi-rpi-official-display.dtsi

phyboard-stm32mp1-pi-hat-extension.dtsi

phyboard-stm32mp1-peb-wlbt-05-bluetooth-usart1.dtsi
phyboard-stm32mp1-peb-wlbt-05-bluetooth-usart3.dtsi
phyboard-stm32mp1-peb-wlbt-05-wlan.dtsi
phyboard-stm32mp1-pi-hat-redbear.dtsi

phyboard-stm32mp1-pinctrl.dtsi

phyboard-stm32mp1-motor-control.dtsi

phyboard-stm32mp1-motor-control-m4.dtsi
phyboard-stm32mp1-uno-r3-extension.dtsi

U-Bootarch/arm/dts

same dts file names as kernel

+phycore-stm32mp1-x-u-boot.dtsi

+phycore-stm32mp157fac-som.dtsi

same dts file names as kernel

same dts file names as kernel

same dts file names as kernel

TF-Afdts

phycore-stm32mp1-x.dts
phycore-stm32mp157cac-som.dtsi

phycore-stm32mp157fac-som.dtsi

phycore-stm32mp157cac-pinctrl.dtsi

phycore-stm32mp157-pinctrl.dtsi

-

-

Tip

For more details on the phyCORE-STM32MP1 and phyBOARD-Sargas pin muxing configuration on the BSP, you can refer to the Hardware Manual and the Pinmuxing Excel file that can be downloaded at https://www.phytec.de/produkt/system-on-modules/phycore-stm32mp1-download/

Modify the Kernel Device Tree

Modifying the kernel device tree is necessary when enabling/disabling dts expansions (for example when enabling one display interface or expansion boards).  It is also necessary when customizing your own application/baseboard. To simplify the kernel device tree modifications, the phyCORE-STM32MP and phyBOARD-Sargas device tree files are located into the meta-phytec Yocto layer, under:

host:~/PHYTEC_STM32MP1_BSP/layers/meta-phytec/dynamic-layers/stm-st-stm32mp/recipes-kernel/linux/linux-stm32mp/<x.y>/<x.y.z>/dts$
  • Modify the dts files with your favorite code editor.
  • In case that you create new dtsi files (ex: phyboard-stm32mp1-custom.dtsi that you include in phyboard-stm32mp1.dtsi) under this directory (for new Hardware expansions for example), the SRC_URI variable of the linux-stm32mp_<x.y>.bbappend recipe of the meta-phytec layer must be "append" (so that your new dtsi file will be added to the device tree sources directory).

To do this, edit the file linux-stm32mp_<x.y>.bbappend and add the following line, replacing <x.y.z> by the kernel version (ex: 4.19.94):

SRC_URI += "file://${LINUX_VERSION}/<x.y.z>/dts/phyboard-stm32mp1-custom.dtsi"

linux-stm32mp_<x.y>.bbappend is located in meta-phytec under : dynamic-layers/stm-st-stm32mp/recipes-kernel/linux/

Configure the kernel through Menuconfig

The process of building a kernel has two parts: configuring the kernel options and building the source with those options. For you BSP customization, you may have to change the kernel options. This section describes how to do it.

  • Start the Linux kernel configuration menu:
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp -c menuconfig
  • Navigate forwards or backwards directly between feature
    • un/select, modify feature(s) you want
    • When the configuration is OK : exit and save the new configuration

Tip

useful Menuconfig keys to know:
enter: enter in config subdirectory
space: hit several times to either select [*], select in module [m] or unselect [ ] 
/: to search for a keyword, this is usefull to navigate in tree
?: to have more information on selected line

  • After saving et exiting the menuconfig, the kernel the modifcations made are only temporary. Only the kernel configuration file (.config) in the kernel build directory is updated. It is located under:
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>/tmp-glibc/work/<MACHINE>-ostl-linux-gnueabi/linux-stm32mp/<x.y>-r0/build/
  • Your modifications will be taken into account if the kernel is rebuild from this point (without clean), but it will not be permanent (not in the Linux Kernel source directory). To save it, create a new configuration fragment that will contains only your configuration changes:
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp -c diffconfig
  • The fragment is generated under:
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>/tmp-glibc/work/phycore_stm32mp1_x-ostl-linux-gnueabi/linux-stm32mp/<x.y>-r0/fragment.cfg
  • You can tamporary save and rename this frament to your home folder (for example):
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ cp tmp-glibc/work/phycore_stm32mp1_x-ostl-linux-gnueabi/linux-stm32mp/<x.y>-r0/fragment.cfg ~/<custom-fragment>.cfg
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp -c cleansstate

With this clean, when using bitbake diffconfig command again, it will genarate a new fragment comparing the new changes made from the default Linux Kernel configuration. 

Updating the kernel/device tree on running target (temporary method)

After modifying the device tree kernel and/or kernel configuration, you can test your modifications on your running target with the following quick but temporary method (to use for prootyping only).

  • Rebuild kernel / device tree:
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp

This command will generate a new Kernel Image (uImage) and new device tree blob (<MACHINE>.dtb) under the binaries folder (tmp-glibc/deploy/images/<MACHINE>)

  • Create a SSH connection between your PC and the running board with Ethernet or USB OTG (see Create an SSH Connection with USB OTG)
  • For device tree update: copy the new device tree blob to the /boot directory of the target:
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ scp tmp-glibc/deploy/images/<MACHINE>/<MACHINE>.dtb root@<Target_IP>:/boot

Example:

host:~/PHYTEC_STM32MP1_BSP/build-openstlinuxweston-phycore-stm32mp$ scp tmp-glibc/deploy/images/phycore-stm32mp-3/phycore-stm32mp-3.dtb [email protected]:/boot
  • For kernel update: copy the new kenel image (uImage) to the /boot directory of the target:
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ scp tmp-glibc/deploy/images/<MACHINE>/uImage root@<Target_IP>:/boot

Example:

host:~/PHYTEC_STM32MP1_BSP/build-openstlinuxweston-phycore-stm32mp$ scp tmp-glibc/deploy/images/phycore-stm32mp-3/uImage [email protected]:/boot
  • Reboot the board with following commands on Target:
root@phycore-stm32mp1-3:~# cd /boot; sync; systemctl reboot

Creating Custom Yocto Layer

Creating your layer should be one of the first tasks when customizing the BSP. In the following chapter, we have an embedded project called "racer" which we will implement using the OpenSTLinux distribution. First, we need to create a new layer. Yocto provides a script for that. If you set up the BSP and the shell is ready, type:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake-layers create-layer meta-racer

The default options are fine for now. Move the layer to the source directory:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ mv meta-racer ../layers/

Create a Git repository in this layer to track your changes:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ cd ../layers/meta-racer
host:~/PHYTEC_STM32MP1_BSP/layers/meta-racer$ git init && git add . && git commit -s -m "create meta-racer"

Now you can add the layer directly to your build-<DISTRO>-<MACHINE>/conf/bblayers.conf:

BBLAYERS += "${OEROOT}/layers/meta-racer"

or with a script provided by Yocto:

host:~/PHYTEC_STM32MP1_BSP/layers/meta-racer$ cd ../../build-<DISTRO>-<MACHINE>
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake-layers add-layer ../layers/meta-racer

Patch Kernel, Bootloader, or Trusted Firmware

Modify the Sources with devtool

Instead of using the standard PHYTEC versions of kernel, bootloader, or trusted firmware which are provided in the Yocto recipes, you can modify the source code to build your customized BSP. For example, it is necessary when you have to modify the pin muxing (configured in device tree files).

Tip

For the kernel phyCORE and phyBOARD device tree only, you don't necessarily have to use devtool as you can modify the files directly in the meta-phytec Yocto layer (see the previous section:  Modify the Kernel Device Tree). But for all other kernel source files and for u-boot and tf-a-stm32mp modifications, devtool should be used.

Devtool is a set of helper scripts to enhance the user workflow of Yocto. It is available as soon as you set up your shell environment. Devtool can be used to:

  • modify existing sources
  • integrate software projects into your build setup
  • build software and deploy software modifications to your target

Devtool command to modify an existing recipe:

devtool modify -x <recipename> <directory> 

The corresponding recipe names for kernel, bootloader, or trusted firmware are: 

Trusted Firmwaretf-a-stm32mp
Bootloaderu-boot-stm32mp
Kernellinux-stm32mp

Example for modifying the kernel:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ devtool modify -x linux-stm32mp sources/linux-stm32mp

Devtool will create a new Yocto layer in /build-openstlinuxweston-<MACHINE>/workspace where you can see all modifications done by devtool. It will extract the sources corresponding to the recipe to the specified directory. In this example kernel sources will be extracted on the following local git directory: /build-openstlinuxweston-<MACHINE>/sources/linux-stm32mp

A bbappend file will be created in the workspace directing the SRC_URI to this directory. Building an image with Bitbake will now use the sources in this directory. Now you can do your kernel, u-boot, or trusted-firmware modifications.

Example of modifying a kernel device tree file:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ vim sources/linux-stm32mp/arch/arm/boot/dts/phycore-stm32mp1-3.dtsi

Make a change in the dts file with your favorite code editor. When it is done, refer to the next section for re-building the BSP (example for re-building the kernel).

If you want to store your code changes permanently, it is advisable to create a patch from the changes, then store and backup only the patch. You can go into the linux-stm32mp directory and create a patch with the method described in the section Creating Patches.

Rebuilding the Kernel, Bootloader, or Trusted Firmware

Launch the following command to re-start the BSP image build process (only the modules that have been modified will be re-generated; the kernel for example).

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake <BSP_IMAGE>

For quick build tests, you may also want to build only the module you have modified (kernel, bootloader, or trusted firmware), as described in the following sections.

Tip

We recommend rebuilding the entire BSP image as described above, so that all necessary BSP binaries are generated, before flashing the target.

Rebuild the Kernel

To rebuild the kernel only, launch the following command:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp

Rebuild the Bootloader

To rebuild the bootloader only, launch the following command:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake u-boot-stm3mp

Rebuild the Trusted Firmware

To rebuild the trusted firmware only, launch the following command:

host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake tf-a-stm32mp

Creating Patches

You have to create the patch from the local git directory containing the modified source code (directory created by devtool).

Example to Create a Kernel Patch

  • Enter to the <local git directory>:
host:~/PHYTEC_STM32MP1_BSP/build-openstlinuxweston-phycore-stm32mp1-3$ cd sources/linux-stm32mp 
host:<local git directory>$ cd sources/linux-stm32mp
host:<local git directory>$ git status                        # Show changes files
host:<local git directory>$ git diff                          # Show all the changes made compared to the previous commit
host:<local git directory>$ git add .                         # Add all modified file to the staging area
host:<local git directory>$ git commit -m "DTS modification"  # Creates a commit with a not so useful commit message
host:<local git directory>$ git format-patch -1 -o ~/         # Creates a patch of the last commit and saves it in you home directory
/home/<user>/0001-DTS-modification.patch

The created patch is the home directory: host:~/0001-DTS-modification.patch.

Applying Patches

The created patches can be used once you have validated your device tree modifications (using devtool for example) and you want to customize the BSP adding a custom Yocto layer (how to create a Yocto layer is described in Creating Custom Yocto Layer). 

Tip

It is possible to add your patches directly in the meta-phytec layer, but it is not recommended to do this, as it is easier to maintain your custom BSP if you have your own Yocto layer (particulary when we deliver BSP updates).


Warning

Before being able to apply any patch to a recipe, the recipe must be removed from the devtool workspace. To do that, use the following command (example for linux-stm32mp recipe):

devtool reset linux-stm32mp

This will remove the linux-stm32mp.bbappend file created by devtool in ../build-<DISTRO>-<MACHINE>/workspace/appends

Then clean the recipe build

bitbake linux-stm32mp -c cleansstate
bitbake st-image-bootfs -c cleansstate

After you have created the kernel patch, you must create a .bbappend file in your custom layer. The locations for the append recipes are:

recipe (.bb) to append.bbappend file path in custom layer to create
linux-stm32mp.bblayers/<custom_layer>/recipes-kernel/linux/linux-stm32mp_%.bbappend
u-boot-stm32mp.bblayers/<custom_layer>/recipes-bsp/u-boot-stm32mp/u-boot-stm32mp_%.bbappend
tf-a-stm32mp.bblayers/<custom_layer>/recipes-bsp/trusted-firmware-a/tf-a-stm32mp_%.bbappend

The following example is for the linux-stm32mp recipe. You have to adjust the paths:

  • Create the folders and move the patch into it. Then create the bbappend file:
host:~/PHYTEC_STM32MP1_BSP/$ mkdir -p layers/meta-custom/recipes-kernel/linux/features                          # create the directories
host:~/PHYTEC_STM32MP1_BSP/$ cp ~/0001-DTS-modification.patch layers/meta-custom/recipes-kernel/linux/features  # copy patch in the features directory
host:~/PHYTEC_STM32MP1_BSP/$ touch layers/meta-custom/recipes-kernel/linux/linux-stm32mp_%.bbappend             # create a bbappend file

Warning

Pay attention to your current work directory. You have to execute the above commands in the BSP top-level directory. Not in the build directory!

  • Use your favorite editor to add the following lines into the bbappend file (layers/meta-custom/recipes-kernel/linux/linux-stm32mp_%.bbappend):
FILESEXTRAPATHS_prepend := "${THISDIR}/features:"
SRC_URI_append = " \
file://0001-DTS-modification.patch \
"
  • Save the file, go back to the build directory and rebuild the kernel recipe with:
host:~/PHYTEC_STM32MP1_BSP/$ cd build-<DISTRO>-<MACHINE>
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp -c clean
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp
  • If the build is successful, you can then rebuild the st-image-bootfs partition (containing the kernel and device tree) or the entire image (st-image-weston for example).

Adding Kernel configuration fragment

After creating one or more kernel configuration file (.cfg) with menuconfig and diffconfig bitbake commands (Configure the kernel through Menuconfig), you have to add them in the linux-stm32mp_%.bbappend recipe of your customer Yocto layer, so that it will be included in the final generated Kernel configuration file (.config file in the Kernel build directory).

Tip

It is possible to add your kernel config fragment files directly in the meta-phytec layer, but it is no recommended to do this, as it is easier to maintain your custom BSP if you have your own Yocto layer (particulary when we deliver BSP updates).

  • If not already done, you must create a linux-stm32mp_%.bbappend file in your custom layer:

Replace <x.y> below with the kernel version x.y (ex: 4.19).

host:~/PHYTEC_STM32MP1_BSP/$ mkdir -p layers/meta-custom/recipes-kernel/linux/features/<x.y>                     # create the directories
host:~/PHYTEC_STM32MP1_BSP/$ touch layers/meta-custom/recipes-kernel/linux/linux-stm32mp_%.bbappend             # create a bbappend file

  • Copy your config fragment file (<custom-fragment>.cfg) into the features/<x.y> directory (ex: features/4.19):
host:~/PHYTEC_STM32MP1_BSP/$ cp ~/<custom-fragment>.cfg layers/meta-custom/recipes-kernel/linux/features/<x.y>  # copy fragment in the features directory

Warning

Pay attention to your current work directory. You have to execute the above commands in the BSP top-level directory. Not in the build directory!

  • Use your favorite editor to add the following lines into the bbappend file (layers/meta-custom/recipes-kernel/linux/linux-stm32mp_%.bbappend):
FILESEXTRAPATHS_prepend := "${THISDIR}/features:"

SRC_URI += "file://${LINUX_VERSION}/custom-fragment.cfg;subdir=fragments"
KERNEL_CONFIG_FRAGMENTS += "${WORKDIR}/fragments/${LINUX_VERSION}/custom-fragment.cfg"
  • Save the file, go back to the build directory and rebuild the kernel recipe with:
host:~/PHYTEC_STM32MP1_BSP/$ cd build-<DISTRO>-<MACHINE>
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp -c clean
host:~/PHYTEC_STM32MP1_BSP/build-<DISTRO>-<MACHINE>$ bitbake linux-stm32mp
  • If the build is successful, you can then rebuild the st-image-bootfs partition (containing the kernel and device tree) or the entire image (st-image-weston for example).

The STM32CubeMX tool

STM32CubeMX is an official STMicroelectronics graphical software configuration tool that tool allows, among others features, to:

  • configure pin assignments, the clock tree, or internal peripherals
  • generate the device tree for a Linux kernel, TF-A, and U-Boot firmware for Cortex-A7
  • generate HAL initialization code for Cortex-M4

For more details on these and other features, go to: https://wiki.st.com/stm32mpu/wiki/STM32CubeMX

To install the tool and get the user manual: https://www.st.com/en/development-tools/stm32cubemx.html

Tip

PHYTEC provides STM32CubeMX project files customized for the phyCORE-STM32MP1 SOM. Those project can be download at https://www.phytec.de/produkt/system-on-modules/phycore-stm32mp15x-download/#CubeMX

How to Use the Cortex-M4 MCU

The Arm® Cortex®-M4 coprocessor and its peripherals are directly inherited from the STM32 MCU family. STM32Cube™ environment that is usually used for STM32 MCU is also used for the STM32MP1.

STM32Cube™ provides comprehensive embedded software libraries and tools, significantly reducing development effort, time, and cost. It is fully integrated in the STM32MPU Embedded Software distribution (https://wiki.st.com/stm32mpu/wiki/STM32MPU_Embedded_Software_distribution) thanks to the STM32CubeMP1 Firmware Package and tools such as  STM32CubeMX, STM32CubeIDE or STM32CubeProgrammer.

STM32CubeMP1‎ Overview

STM32CubeMP1‎ is the embedded software part of STM32Cube™, running on the Arm® Cortex®-M4 processor. It is based on the STM32Cube MCU package but has been adapted to a Linux Framework (OpenSTLinux).

To get an overview of this package, use the following links:

https://wiki.st.com/stm32mpu/wiki/STM32CubeMP1_Package

https://wiki.st.com/stm32mpu/wiki/STM32CubeMP1_architecture

Coprocessor Management with STM32Cube‎MP1 and Linux

In order to manage the coprocessor system, services are proposed relying on the open-source Linux RemoteProc framework and the RPMsg frameworks.

Overview

For and Overview, go to https://wiki.st.com/stm32mpu/wiki/Coprocessor_management_overview.

Linux Coprocessor Management

Information on the Linux coprocessor management software frameworks such as mailbox and RPMsg:

https://wiki.st.com/stm32mpu/wiki/Linux_Mailbox_framework_overview

https://wiki.st.com/stm32mpu/wiki/Linux_remoteproc_framework_overview

https://wiki.st.com/stm32mpu/wiki/Linux_RPMsg_framework_overview

Others Coprocessor Management Information

https://wiki.st.com/stm32mpu/wiki/Coprocessor_management_troubleshooting_grid

https://wiki.st.com/stm32mpu/wiki/Coprocessor_power_management

https://wiki.st.com/stm32mpu/wiki/Coprocessor_resource_table

https://wiki.st.com/stm32mpu/wiki/Exchanging_buffers_with_the_coprocessor

https://wiki.st.com/stm32mpu/wiki/Resource_manager_for_coprocessing

STM32CubeIDE Development Tool

STM32CubeIDE is an advanced C/C++ development platform with peripheral configuration, code generation, code compilation, and debug features for STM32 microcontrollers and microprocessors. To know how to install and use this tool please refer to: https://wiki.st.com/stm32mpu/wiki/STM32CubeIDE

Specific Tool Configuration for the phyBOARD-Sargas

Use external JTAG

As the phyBOARD-Sargas is not equipped with STLINK serial link / debug feature, a STLINK external JTAG (STLINK/V2 or STLINK-V3SET) or SEGGER J-LINK connected to the JTAG connector (X8) must be used.

Configure the MPU Serial Device

As the phyBOARD-Sargas is equipped with an FDTI usb/serial device, the "MPU serial device" parameter of the tool must be modified as follow (on Linux computer):

  • Connect your phyBOARD serial console to your computer (X13 connector)
  • Open the "Preferences" menu : "Window" => "Preferences"
  • In "Preferences" menu, open the submenu "STM32Cube"/"MPU Serial"
  • And configure the MPU serial as below ("/dev/ttyUSB0" should be in the "Prefered device" list):

image2020-8-7_11-24-24.png

Specific Board Configuration for the phyBOARD-Sargas

Two modes can be used to debug Arm® Cortex®-M firmware on STM32 MPU device: "Engineering mode" or "Production mode".

  • To use the Production mode, the board must be booted with the "classic" procedure ( boot mode is SD CARD / eMMC / NOR / NAND for Linux booting).

In this mode, Cortex-M4 firmware is loaded from an ssh connection and started with the remoteproc service running on the Cortex-A7.

  • To use the Engineering mode, the board must be booted in a specific way called "Engineering boot Mode". In this mode, only Cortex-M is started and Firmware is loaded via JTAG/SWD into its dedicated RAM. 

On phyBOARD-Sargas, set the S7 DIP switch as follow before powering or resetting the board to enter the Engineering mode:


STM32CubeMP1‎ Development Guidelines

https://wiki.st.com/stm32mpu/wiki/STM32CubeMP1_development_guidelines

https://wiki.st.com/stm32mpu/wiki/How_to_assign_an_internal_peripheral_to_a_runtime_context

https://wiki.st.com/stm32mpu/wiki/How_to_configure_system_resources

https://wiki.st.com/stm32mpu/wiki/How_to_exchange_large_data_buffers_with_the_coprocessor_-_principle

https://wiki.st.com/stm32mpu/wiki/How_to_retrieve_Cortex-M4_logs_after_crash

https://wiki.st.com/stm32mpu/wiki/How_to_start_the_coprocessor_from_the_bootloader

Revision History

VersionChangesDateAuthor
L-876e.AxPreliminary Edition11.09.2020C. Parant