STM32MP1 - johnosbb/Automation GitHub Wiki

Build Environment for STM32MP1

Introduction

The STM32MP1 series is a family of microprocessors developed by STMicroelectronics, designed to provide high-performance processing along with real-time control. The STM32MP1 series combines both Cortex-A7 application processors and a Cortex-M4 microcontroller, making it ideal for applications that require both complex operating systems (like Linux) and real-time, low-power embedded processing.

Key Features of the STM32MP1 Series

Dual-Core Architecture

Cortex-A7 (Single/Dual Core):
  • These cores are designed for running high-level operating systems like Linux or Android.
  • Suitable for complex application processing tasks such as user interfaces, multimedia, networking, etc.
Cortex-M4
  • This is an embedded microcontroller core that handles real-time tasks.
  • Typically runs an RTOS (Real-Time Operating System) or bare-metal applications for managing real-time control in industrial, IoT, or automotive systems.
  • Can operate independently of the Cortex-A7 cores for tasks that require low power and deterministic performance.

Heterogeneous Processing

  • The STM32MP1 allows both cores to work simultaneously but independently, enabling powerful combinations of Linux-based applications on the Cortex-A7 and real-time control on the Cortex-M4 core.

Operating System Support:

Cortex-A7
  • The main operating system for the Cortex-A7 core is Linux. STMicroelectronics provides OpenSTLinux, a Yocto Project-based distribution optimized for the STM32MP1. It supports drivers, bootloaders, middleware, and user-space applications.
Cortex-M4
  • This core typically runs FreeRTOS or other embedded RTOS platforms for real-time tasks. It's also capable of running bare-metal applications without an OS.

Power Management

  • The STM32MP1 series includes advanced power management features, allowing the system to optimize power consumption by enabling or disabling specific cores or peripherals depending on the workload. For instance, the Cortex-M4 core can operate independently in low-power modes while the Cortex-A7 cores are powered down.

Rich Peripherals

  • STM32MP1 comes with a broad set of peripherals commonly found in microcontrollers:
    • USB, UART, SPI, I2C, CAN, SDMMC, Ethernet, ADC/DAC, etc.
  • GPU (Graphics Processing Unit): Some STM32MP1 models include a 3D GPU (Vivante) that can handle graphics acceleration for user interfaces.
  • LCD and Camera Interfaces: Designed for devices that require display and imaging capabilities.

Security

  • STM32MP1 features security mechanisms including:
  • TrustZone for secure execution on the Cortex-A7.
  • Cryptographic hardware accelerators.
  • Secure boot and secure firmware updates.

Flexible Memory Options

  • The STM32MP1 supports external DDR (up to DDR3L/LPDDR2/LPDDR3), as well as QSPI Flash, eMMC, and NAND/NOR Flash, giving developers flexibility in terms of memory configuration.

STM32MP1 Use Cases

  • The STM32MP1 series is suitable for applications that combine high-performance processing with real-time control and low-power consumption, such as:
  • Industrial automation and control systems like IoT gateways, edge computing devices, Smart home devices, Human-machine interfaces (HMI) and touch-screen applications.

Buildroot Setup

git clone -b st/2024.02.3 https://github.com/bootlin/buildroot.git
git clone -b st/2024.02.3 https://github.com/bootlin/buildroot-external-st.git
cd buildroot
make BR2_EXTERNAL=../buildroot-external-st st_stm32mp157d_dk1_defconfig

If you are in a Conda environment do a conda deactivate to unset any environment variables

You can now run make or make menuconfig in the buildroot ( not the buildroot-external-st ) directory.

Serial Access

use ST-Link CN11 for serial link for terminal

image

image

image

login: root and no password on default build

SSH Access

Use IP 192.168.1.203 with a login of root similar password.

Make sure ssh access is set up in /etc/ssh/sshd_config

PermitRootLogin yes
PasswordAuthentication yes

To make this change permanent, add a cusomized sshd_config file to the overlay:

/mnt/500GB/STM32MP157D/buildroot-external-st/board/stmicroelectronics/stm32mp1/overlay/etc/ssh

Programming SDCard

#!/bin/bash

# Specify the path to the SD card image
IMAGE_FILE="sdcard.img"

# Function to display usage
usage() {
    echo "Usage: $0 /dev/sdX"
    echo "Where /dev/sdX is the device path of the SD card (e.g., /dev/sdb)"
    exit 1
}

# Check if an argument is provided
if [ "$#" -ne 1 ]; then
    usage
fi

# Get the SD card device
SD_CARD="$1"

# Check if the SD card device exists
if [ ! -b "$SD_CARD" ]; then
    echo "Error: $SD_CARD does not exist or is not a block device."
    exit 1
fi

# Check the size of the SD card
SD_CARD_SIZE=$(lsblk -b -n -o SIZE "$SD_CARD")
IMAGE_SIZE=$(stat -c %s "$IMAGE_FILE")

# Convert sizes to human-readable format
SD_CARD_SIZE_HR=$(numfmt --to=iec-i --suffix=B "$SD_CARD_SIZE")
IMAGE_SIZE_HR=$(numfmt --to=iec-i --suffix=B "$IMAGE_SIZE")

# Display sizes
echo "SD Card Size: $SD_CARD_SIZE_HR"
echo "Image Size: $IMAGE_SIZE_HR"

# Check if the SD card is large enough
if [ "$SD_CARD_SIZE" -lt "$IMAGE_SIZE" ]; then
    echo "Error: SD card size ($SD_CARD_SIZE bytes) is smaller than the image size ($IMAGE_SIZE bytes)."
    exit 1
fi

# Confirm with the user before proceeding
echo "This will write $IMAGE_FILE to $SD_CARD. All data on the card will be lost!"
read -p "Are you sure you want to continue? (y/n): " CONFIRM

if [ "$CONFIRM" != "y" ](/johnosbb/Automation/wiki/-"$CONFIRM"-!=-"y"-); then
    echo "Operation canceled."
    exit 0
fi

# Unmount the SD card if it is mounted
umount "$SD_CARD"* 2>/dev/null

# Write the image to the SD card
echo "Writing $IMAGE_FILE to $SD_CARD..."
sudo dd if="$IMAGE_FILE" of="$SD_CARD" bs=4M status=progress

# Sync to ensure all data is written
sync

echo "Done! $IMAGE_FILE has been written to $SD_CARD."

Adding a Data PArtition to the Card

Using GParted, proceed as shown below:

image

image

image

image

GPIO

Arduino connectors

Connectors CN13, CN14, CN16, CN17 are female connectors on the back side of the board. They are compatible in pin-out and form-factor with the Arduino connector:

image

Section 7.16 of the board user manual documents the pin-out for these connectors. There is one I2C bus available as well in CN13, through the I2C5_SDA (pin 9) and I2C5_SCL (pin 10) signals.

image

According to the block diagram in Figure 3 of the board user manual, the I2C1 bus is already used to connect the touchscreen, the USB hub, the audio codec and the HDMI transceiver. However, I2C5 doesn’t seem to be used at all. In addition, with the screen mounted on the Discovery board, the CN2 connector is beneath the screen, which makes it a bit more difficult to use than the Arduino connectors on the back side.

We can use the I2C5 bus, through the Arduino connector CN13. Pin 9 can be used to connect the data signal of a sensor, and pin 10 can be used to connect the clock signal of a sensor.

image

References