How to compile the device tree with the Distribution Package



1. Introduction[edit source]

This article is reserved to Yocto experts or at least people who have already practiced with the Yocto environmment.

This section describes all steps to create and configure a layer for demo with DeviceTree files coming from STM32CubeMX tool and to add and configure a machine that is similar to those that the OpenSTLinux Distribution Package already supports.
Mainly the machine delivered inside the existing STM32MP BSP layer 'addons'.
For reminder this addons layer is deployed here in our delivery : <path of OpenSTLinux distribution delivery>/layers/meta-st/meta-st-stm32mp-addons/

2. Create a new open embedded layer for your demo[edit source]

First you need to create a new layer, take a look at the latest How to create a new open embedded layer

After the creation you will have here <path of OpenSTLinux distribution delivery>/layers/meta-st/:


$ tree meta-my-demo-layer
meta-my-demo-layer
├── conf
│   └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
    └── example
        └── example.bb

3 directories, 4 files

2.1. Update layer.conf file[edit source]

Open layer.conf file and add the lines below for the licenses, the demo layer path and the dependency with the STM32MP BSP layer 'addons' :

EULA_FILE_ST_stm32mpcommondemomotor = "${LAYERDIR}/conf/eula/${MACHINE}"
EULA_FILE_ST_MD5SUM_stm32mpcommondemomotor = "8b505090fb679839cefbcc784afe8ce9"

#Inform bitbake for adding another location to search for licenses
LICENSE_PATH += "${LAYERDIR}/files/licenses"

# Set a variable to get the STM32MP MX BSP location
STM32MP_DEMO_MOTOR_BASE = "${LAYERDIR}"

# This should only be incremented on significant changes that will
# cause compatibility issues with other layers
LAYERVERSION_meta-my-demo-layer = "1"

LAYERDEPENDS_meta-my-demo-layer = "stm-st-stm32mp-mx"

2.2. Create the machine for your demo[edit source]

Copy the machine delivered inside the existing STM32MP BSP layer 'addons' into your layer for demo

$ cp <path of OpenSTLinux distribution delivery>/layers/meta-st/meta-st-stm32mp-addons/conf/machine/stm32mp1-mx.conf <path of OpenSTLinux distribution delivery>/layers/meta-st/meta-my-demo-layer/conf/machine/stm32mp1-demo.conf

Update this line with the highlighted part :

  1. @NEEDED_BSPLAYERS: layers/meta-openembedded/meta-oe layers/meta-openembedded/meta-python layers/meta-st/meta-st-stm32mp-addons

Replace these lines

CUBEMX_DTB_PATH_pn-tf-a-stm32mp   = "${STM32MP_MX_BASE}/mx/${CUBEMX_PROJECT}/tf-a"
CUBEMX_DTB_PATH_pn-u-boot-stm32mp = "${STM32MP_MX_BASE}/mx/${CUBEMX_PROJECT}/u-boot"
CUBEMX_DTB_PATH_pn-linux-stm32mp  = "${STM32MP_MX_BASE}/mx/${CUBEMX_PROJECT}/kernel"
CUBEMX_DTB_PATH_pn-optee-os-stm32mp  = "${STM32MP_MX_BASE}/mx/${CUBEMX_PROJECT}/optee-os"

by these ones

CUBEMX_DTB_PATH_pn-tf-a-stm32mp   = "${STM32MP_DEMO_MOTOR_BASE}/mx/${CUBEMX_PROJECT}/tf-a"
CUBEMX_DTB_PATH_pn-u-boot-stm32mp = "${STM32MP_DEMO_MOTOR_BASE}/mx/${CUBEMX_PROJECT}/u-boot"
CUBEMX_DTB_PATH_pn-linux-stm32mp  = "${STM32MP_DEMO_MOTOR_BASE}/mx/${CUBEMX_PROJECT}/kernel"
CUBEMX_DTB_PATH_pn-optee-os-stm32mp  = "${STM32MP_DEMO_MOTOR_BASE}/mx/${CUBEMX_PROJECT}/optee-os"

Then add these lines and modify variables based on your own needs and demo naming:

# Define specific common machine name
MACHINEOVERRIDES .= ":stm32mpcommondemomotor"

# Boot Mode Choice
# =========================================================================
# boot scheme (basic or trusted or optee) 
# =========================================================================
BOOTSCHEME_LABELS = "trusted"

# Boot Device Choice
# =========================================================================
# flashlayout 
# DISCO : sdcard
# EVAL : sdcard or emmc or nand-4-256 or nor-sdcard or nor-emmc or nor-nand-4-256
# =========================================================================
# Define the config labels to use to generate flashlayout file
FLASHLAYOUT_CONFIG_LABELS = "sdcard"

# Board Type Choice
# =========================================================================
# Assign CubeMX Board DT and project name
CUBEMX_DTB = "stm32mp157c-demo-motor-ev1-mx"
CUBEMX_PROJECT = "STM32MP157C-EV1/demo-motor-ev1/DeviceTree/demo-motor-ev1"
# Define the original board devicetree : stm32mp157a-dk1 or stm32mp157c-dk2 or stm32mp157c-ev1 
CUBEMX_DT_FILE_BASE = "stm32mp157c-ev1"

2.3. Associate EULA with the new demo machine[edit source]

Copy the eula folder delivered inside the existing STM32MP BSP layer 'addons' into your layer for demo

$ cp -rf <path of OpenSTLinux distribution delivery>/layers/meta-st/meta-st-stm32mp-addons/conf/eula/ <path of OpenSTLinux distribution delivery>/layers/meta-st/meta-my-demo-layer/conf/.

And replace the existing symbolic link with your machine for demo

$ rm stm32mp1-mx
$ ln -s ST_EULA_SLA stm32mp1-demo

2.4. Move DeviceTree files and project coming from STM32CubeMX tool[edit source]

The principle is that the user generates devicetree files from the STM32CubeMX tool for the targetted demo.

Warning white.png Warning
Most of the time, generated devicetree files, mainly user sections, must be reworked by end user for compilation and functional purpose, each demo is delivered with an Application Note which will describe changes applied on STM32CubeMX devicetree files

Then these files are moved inside “mx” folder created into your demo layer  : <path of OpenSTLinux distribution delivery>/layers/meta-st/meta-my-demo-layer/mx/

sub-folders are created and populated with generated devicetree files :

mx/${CUBEMX_PROJECT}/kernel
mx/${CUBEMX_PROJECT}/u-boot
mx/${CUBEMX_PROJECT}/tf-a
mx/${CUBEMX_PROJECT}/optee-os

With CUBEMX_PROJECT is equal to the value defined inside the machine for the demo.

2.5. Update README file[edit source]

Please update the README with the needed information for building and executing the demo

2.6. Clean up useless content[edit source]

You can delete the content of recipes-example folder created by create-layer command

3. Add specific recipes and content necessary for your demo[edit source]

More add-on component examples:

  • recipes for installing distro-specific configuration files
  • any image recipes specific to user distribution
  • a psplash append file for a branded splash screen
  • any other append files to make custom changes

Some other added components (*bb) are more specific: images, system services, ... (non-exhaustive list shown below):

  • recipes-core for psplash screen, systemd services
  • recipes-samples for example images

...