Skip to content
Tomasz Zeman edited this page May 16, 2021 · 24 revisions

openwrt-stm32mp wiki

This repository demonstrates how to setup OpenWRT on STM32MP1 DK2 board.

I would like to thank Thomas Petazzoni who implemented Building a linux system for the stm32mp1 basic system using Buildroot build system. I am following his footsteps here but using OpenWRT.

I did want to use OpenWRT because it is easy to customise, debug, and add own packages. The way OpenWRT is using GNU Make to drive the processing of the build is easy to follow, and can be quickly customised to a specific solution.

In the above some may question: how can one easyly debug the subsystems. When I have a moment I will create sample wiki showing how to use VisualGDB do debug uci processing. That is using Windows 10 as interface, Mint as host build system and STM32MP1-DK2 as target.

Toolchain

Every build system requires toolchain to produce binaries that can execute on target system. Normally, the target system is of different architecture to the hosting environment, and care must be taken to select one that works.

Some would use ready to download toolchain like GNU Embedded Toolchain for Arm, other would build their own with crosstool-NG. I have used OpenWRT to build for me the toolchain, glibc, and all required tools.

To start with I just create new target in my OpenWRT snapshot, I will call this directory stm32mp1. This directory may contain all device variation that can be produced using this MCU. The Makefile in this directory contains the recipe for building toolchain.

CPU_TYPE:=cortex-a7
CPU_SUBTYPE:=neon-vfpv4

This information is taken from ST document titled stm32mp157c.pdf. Once OpenWRT has this information it can start downloading and building the toolchain.

This process unfortunately is connected with Linux kernel ARM architecture headers, as it requires kernel headers.

Linux kernel

Modified Linux kernel for STM32MP1 is kindly maintained by ST under STM32MP1 Linux Kernel v5.4. We just have to tell OpenWRT where to find it. This if done via CONFIG_KERNEL_GIT_CLONE_URI configuration item. We tell what branch name to use, and OpenWRT will download this repository and place tar in dl directory for faster rebuilds.

In my build I have introduces CONFIG_KERNEL_GIT_REF_DESC configuration item, which is not compulsory. It allows to rename the directory, and everything that descends from it, to be named as I wish.

For: 4.19-stm32mp-r2

CONFIG_KERNEL_GIT_CLONE_URI="[email protected]:STMicroelectronics/linux.git"
CONFIG_KERNEL_GIT_REF="v4.19-stm32mp-r2"
CONFIG_KERNEL_GIT_REF_DESC="4.19.49-stm32mp-r2"

For: v5.4-stm32mp

CONFIG_KERNEL_GIT_CLONE_URI="https://github.com/namezis/linux-stm32mp.git"
CONFIG_KERNEL_GIT_REF="st-v5.4-stm32mp-r1"
CONFIG_KERNEL_GIT_REF_DESC="5.4.56-stm32mp"


NOTE

I have squashed the changes for kernel 5.4.56, and I placed the result in my repository. The build system is modified to faster retrieve the single branch.


ARM Trusted Firmware for STM32MP1

Some notes about TF-A:

Initially the STM32MP1 was widly booted by using U-boot-SPL (Secondary Program Loader).

In STM32MP15 ecosystem release note - v2.0.0 it has been announced that U-BOOT-SPL is no longer supported and the preferred way to boot is TF-A as FSBL. This is TF-A version 2.2.

Moreover, in STM32MP15 ecosystem release note - v3.0.0 it has been announced that TF-A BL2 requires stm32 headers for the ROM Code authentication and other bootloader binaries are embedded in the FIP (Firmware Image Package) container. This is TF-A version 2.4.

This means that the STM32MP1 now requires to build the TF-A and its FIP image. Appropriate build steps have been provided.

For more technical information please read ST TF-A repository and in it diff between branch v2.4-stm32mp and v2.2-stm32mp, path arm-trusted-firmware/docs/plat/stm32mp1.rst

OpenWRT configuration

The sample OpenWRT config is located in config_stm32mp1_dk2.

This will allow to complete building the host tools and the toolchain.

One can start the build definition preparation by invoking:

$ ./fixup.sh

Select your configuration with SPACE and press ENTER. The build definition will be prepared for you. After that one can invoke the build.

Once finished an SD card image will be created in binary target output. For example in: ./bin/targets/stm32mp1/generic

Then one can flash the sdcard with:

sudo dd if=./sdcard.bin of=/dev/sda bs=8M conv=fdatasync status=progress
Clone this wiki locally