Skip to main content

STM32MP157 Target Setup Guide

Before you Begin

Before starting with the setup guide, we recommend the following to get familiar with CGI-Studio:

  • Explore CGI-Studio
    Watch the Video Tutorials and read the Quick Start Guide
  • Learn to create SceneComposer Solutions
    The documentation provides instructions on how to create simple SceneComposer solutions. To access SceneComposer navigate to:
    <cgi-studio-installation-path>/bin/SceneComposer/\bin\SceneComposer\SceneComposer.exe
  •  Generate Assets for Simulation and Target Environments
    You can find guidance on generating assets from solutions (binary files containing solution information for the player) for both simulation and target environments in the documentation.

With this knowledge you should be fit to complete this guide.


Software Image Setup

Please note, that this chapter contains links to an external resource (e.g. ST image and wiki). These links were used by Candera for this guide in December 2024 and might have changed in the meanwhile.

Download the official ST target image from here:
STM32MP1Starter - STM32MP1 OpenSTLinux Starter Package - STMicroelectronics
ST Image version 3.1.0 must be used for the CGI Professional Edition 3.15 due some API changes in ST image version 4+.

drawing-7-1738913139.png

For the image and hardware setup please follow the official ST guide:
STM32MP15 Discovery kits - Starter Package - stm32mpu

Please be aware of the following potential issues while following the setup guide.

  1. During image flashing make sure to use the correct extensible FlashLayout file, specific to your hardware.

    STM32_Programmer_CLI -c port=usb1 -w flashlayout_st-image-weston/extensible/FlashLayout_sdcard_stm32mp157x-dk2-extensible.tsv

  2. During the flashing process, we encountered an issue that required us to copy specific files and folders from the extracted stm32mp1.tar archive into the flashlayout_st-image-weston/extensible folder. The following files and folders from the root folder (images\stm32mp1) were necessary in the extensible folder for successful SD card flashing:

    |- arm-trusted-firmware
    |- fip
    - st-image-bootfs-openstlinux-weston-stm32mp1.ext4
    - st-image-userfs-openstlinux-weston-stm32mp1.ext4
    - st-image-vendorfs-openstlinux-weston-stm32mp1.ext4
    - st-image-weston-openstlinux-weston-stm32mp1.ext4

After following the official setup, you should have a running target device with a terminal connection. This is required for the next steps. For the Python installation (needed for Python-based data binding) it is required to connect the target to the internet.

At Candera we have used Tera Term for the remote serial terminal connection and WinSCP for the transfer of files to the target device.


Blood Pressure Sample

The Blood Pressure device sample is a Scene Composer sample that demonstrates a blood pressure measurement device with exemplary scenes and animations. 

For the Professional Edition, the sample was extended with a data binding sample programmed in Python. The Python part of the sample relies on the Python-based player data binding library to interact with the data bindings of the scene.

In this section we will explain how to run the BloodPressureSample with our precompiled target player and with the PythonPlayer PlayerConnector.Connector Library.

For this chapter the completed “Image Setup” is required, and it is assumed that WinSCP is downloaded and installed.

Run Blood Pressure Sample with Target Player

Follow the steps given below to run the Blood Pressure sample on the target with our precompiled target player:

  • Connect to the target device with WinSCP
    Launch WinSCP, in the host name field enter the IP address of the target device, and for the username use“root”. Default values should be used for the remaining fields.
    Refer to the ST Setup Guide for information on obtaining the device’s IP address.
    drawing-7-1738913165.png

  • Transfer Files to the Target
    Use WinSCP to transfer the following files to the target device:
    • Target Player executable:
      <cgi-installation-path>/bin/TargetPlayer/Player
    • Solution asset binary file: The asset binary you wish to run.
      <cgi-installation-path>/bin/Player/PlayerConnector/Samples/BloodPressureDevice/BloodPressureDevice_Target.bin
  • Set Execution Permissions
    To set execution permissions before running the asset in the target player, execute the following command in the remote terminal.

    chmod +x Player
    
    
  • Run the Asset
    Execute the below command in remote terminal, to run the player and asset

    ./Player BloodPressureDevice_Target.bin
    
    
    The asset will be visible on the target device.
    drawing-7-1738913227.png

Run Blood Pressure Sample with Python

In this section, we explain how to execute the Blood Pressure sample including Python-based data binding with our PlayerConnectorPlayer Connector Library and how to install the required software on the target. The PlayerConnectorPlayer Connector Library allows the simple connection between CGI Studio Player and a Python-based script.
Please note that the “Blood Pressure sample with Python” has been prepared for integration with the Soundhound voice recognition service. For the sake of simplicity in this guide, we will not use this service. By running the sample, you will be presented with a start scene waiting for voice input. As the voice recognition service is not configured, it will not perform any action. To continue using the sample, simply press 'Start'.
For guidance on configuring the voice recognition service by utilizing our Soundhound integration, please refer to our CGI-Studio Documentation: Blood Pressure Sample

Python Installation

Python is required for the PlayerConnector,Player Connector Library, to enable Python-based data binding for CGI-Studio. The target device needs to have an internet connection for installing python. 

This section only covers the Python installation on the target device. In the host environment pythonPython can be installed with the help of the python download guide on the pythonPython webpage. We have used pythonPython version 3.12.6, but the latest version is supported.

To install Python on the target device, follow these steps on the target:

  • Update Packages and Install Python.
    Run the following commands on the target device with remote terminal:

    apt-get update && apt-get upgrade
    apt-get install python3
    
    
  • If pip is not installed by default run

    python3 -m ensurepip –-upgrade
    
    
  • Verify the installation of pip3 by using the command “pip3”.
Python Script

Before we proceed with executing the script, let's first take a moment to review the key components of the PythonPlayer PlayerConnectorConnector Library script, which can be found at the following location:
<cgi-studio-installation-path>\bin\Player\PlayerConnector\Samples\BloodPressureDevice\BloodPressureDevice.py

Understanding the structure and the key steps of the script will help you execute and modify it effectively. Below are the key sections of the script:


  1. Import the Python Player Connector libraryLibrary and additional required libraries.

    import argparse
    import time
    import signal
    from SoundhoundCommandClient import SoundhoundCommandClient
    from CanderaAppConnector import CanderaAppConnector, Logger
    from Generated.BindingSourceEnum import BindingSourceItem
    
    
  2. Constructing the library with the connectorPlayer libraryConnector Library binary contained in the delivered package (PlayerConnectorLibrary)

    #Getting an instance of the CanderaAppConnector Python class
    App = CanderaAppConnector(args.LibraryBinaryPath)
    
    
  3. Initializing the library with the asset binary

    #initializing the player with the asset
    App.Init(args.AssetBinaryPath)
    
    
  4. Set or get databinding values.

    #Initializing binding values for back communication
    App.SetBoolValue(BindingSourceItem.SOURCE2ITEM1, False)
    App.SetBoolValue(BindingSourceItem.SOURCE2ITEM2, False)
    App.SetStringValue(BindingSourceItem.SOURCE1ITEM5, TRANSCRIPTION_DEFAULT_STRING)
    
    
  5. Optionally register data binding callbacks

    def BindingCallback(SourceItem, Value):
        global menuSceneActive, valueSceneActive
    ...
    
    
    #Registering databinding callback method 
    App.RegisterCallback(BindingCallback
    
    
  6. Continuously calling step to invoke the render loop and internal message delivery

    #Looping until sig int
    try:
        while not sigintCaptured:
        ...
        App.Step()
    
        
  7. Interact with data bindings. Note that internally, changes to the data bindings are reflected on the view when App.step() is called

    App.SetFloatValue(BindingSourceItem.SOURCE1ITEM1,
    normalizedProgress * 100.0)
    
    
  8. Shutdown library and gracefully exit program

    except KeyboardInterrupt:
        logger.info("Caught KeyboardInterrupt from Python")
    finally:
        App.ShutDown()
        SoundhoundCommandClient.destroy()
    
    exit()
    
    

More information on the capabilities of our library can be found here.

Run Blood Pressure Sample with PlayerConnectorPlayer Connector Library in Simulation Environment (Host)

To run the python-Python-based data binding in the simulation environment (on the host computer) execute the steps below on the host computer:
Please make sure to create a clean copy of the <cgi-studio-installation-path>\bin\Player\PlayerConnector folder before creating the pythonPython environment, since this folder is required in its original form for the target.

  • Open a command line interface in
    <cgi-studio-installation-path>\bin\Player\PlayerConnector\Samples\BloodPressureDevice

  • Create and activate a Python environment:
    It is recommended to create your own Python environment to keep dependencies isolated. To do this, run in the command line:

    python -m venv .
    Script\activate
    
    
  • Install libraries:
    In order to install the PlayerConnectorPlayer librariesConnector Library and other required libraries you need to execute

    pip install -r requirements.txt
    
  • Run Blood Pressure Sample Simulation Asset with Python-based Data Binding
    By running the sample, you will be presented with a start scene waiting for voice input. As the voice recognition service is not configured, it will not perform any action. To continue using the sample, simply press 'Start'.

    python BloodPressureDevice.py
    -lbp  ..\..\PlayerConnectorLibrary.dll
    -abp BloodPressureSample_Simulation.bin
    
    
    The asset is displayed in host environment.
    drawing-7-1738913335.png
Run Blood Pressure Sample with PlayerConnectorPlayer Connector Library in Target Environment

The following steps are required to run the asset on the target.
It’s assumed that a remote terminal (Tera Term) and WinSCP connection is established.

  • Copy required files
    Copy the listed folder to the target using using WinSCP.
    • PlayerConnector:Player Connector Library: <cgi-studio-installation-path>/bin/Player/PlayerConnector (all files from this folder are necessary)

  • Navigate to the BloodPressureDevice folder

    cd <path-to-PlayerConnector-folder>/Samples/BloodPressureDevice

  • Create and Activate a pythonPython environment:
    It is recommended to create and activate a pythonPython environment by running the following in the remote console:

    python3 -m venv .
    source bin/activate
    
    
  • Install libraries:
    In order to install the PlayerConnector libraryLibrary and additional required libraries on the target run this command

    pip3 install -r requirements.txt
    
    
  • Run asset with Python-based Data Binding
    By running the sample, you will be presented with a start scene waiting for voice input. As the voice recognition service is not configured, it will not perform any action. To continue using the sample, simply press 'Start'.

    python3 BloodPressureDevice.py -
    lbp ../../libPlayerConnectorLibrary.so -abp
    BloodPressureSample_Target.bin
    
    
    The asset and the configured databinding are running on the target.

Empty Solution with Slider and Gauge Control

This chapter shows how you can create your own solution with Python data binding on host and target with a simple use case. It is using a Gauge Control for HMI data output for the user and a Slider Control for HMI data input via user.

Before proceeding with the example, it is recommended to explore CGI-Studio by viewing the Video Tutorials and the Quick Start Guide, both of which are available in the CGI-Studio Documentation

The documentation also contains information on how to create simple SceneComposer solutions.

  • Start Scene Composer in <cgi-studio-installation-path>/bin/SceneComposer/\bin\SceneComposer\Scenecomposer.exe


  • Open Empty Solution by either double clicking the empty solution thumbnail or through the File > New Solution dialog.
    drawing-7-1738913524.png

  • In the Render Targets panel (on the right side of the SceneComposer), set the resolution of Display (0) to X Resolution (width) of 800 and Y Resolution (height) of 480.
    drawing-7-1738913629.png

  • Drag and drop a Slider Control and a Gauge Control from the Control section of the Toolbox (on the right side of the Scene Composer) into the Scene Editor.
    drawing-7-1738913876.png

  • You can move the controls in the Scene Editor by selecting the translation icon (the red square in the screenshot below) in the top left corner of the Scene Editor and then selecting the control which you want to move. Just select the item you want to move and drag it to a new location.
    drawing-7-1738913959.png

  • Select the Gauge Control in either the Scene Editor or the Scene Tree, navigate to the properties, and adjust the scale to ensure it fits comfortably within the display.
    drawing-7-1738914100.png

  • To set up a data binding for the Gauge value, first select the Gauge either in the Scene Editor or the Scene Tree. In the properties panel locate the Value property under the Control section and click the chain icon next to it to establish the binding.
    drawing-7-1738914200.png


    A "Define Data Binding" window will appear. In this window, select Item1 (under PredefinedBindingSource1). Finally, click OK at the bottom to confirm your selection.

    drawing-7-1738914285.png

  • To set a data binding for the Slider property, select the Slider control in either the Scene Editor or the Scene Tree. Then, click the chain icon next to the Value property in the Control section of the Properties panel. Next, choose Item2 (under PredefinedBindingSource1) from the available options.

  • Next, generate two asset libraries for both the target and simulation environments to run the solution in the player.
    • Save the solution, then go to File > Generate Asset Library
      drawing-7-1738914354.png

    • A popup window will appear each time, allowing you to generate the asset library. Choose your desired asset location, set the environment to “Simulation” for the first run and to “Target” for the next, then click “Generate” to create each asset library.
      drawing-7-1738914952.png

  • Next, create a Python script. You can use the provided Sample.py file in 
    <cgi-installation-path>/bin/Player/PlayerConnector/Samples/SliderAndGauge/\bin\Player\PlayerConnector\Samples\SliderAndGauge\Sample.py.
  • Run the asset in the simulation environment (Host):
    Do it analogous to the steps from chapter Run Asset with PythonPlayer PlayerConnectorConnector Library in Simulation Environment (Host).


    Important:
    a requirements.txt file is not necessary, since only the PlayerConnectorPlayer libraryConnector Library needs to be installed:

    pip install <cgi-studio-installation-path>\bin\Player\PlayerConnector
    
    
  • Run the asset on the target device:
    (ensure the device is set up correctly, following the official guide).
    Do it analogous to the steps from chapter Run Asset with PythonPlayer PlayerConnectorConnector Library in Target Environment.

    Important: Only the PlayerConnectorPlayer libraryConnector Library needs to be installed on the target:

    pip3 install <path-to-player-connector-folder>
    
    

Final comments

Congratulations you have successfully completed the Target Setup of CGI Studio Professional Edition on STM32MP157 development kit. With the completion of this guide, you can run an asset on the target with Python-based data binding and with Candera CGI Studio target player.

For more information on how to create brilliant HMI solutions with CGI Studio, please refer to the general documentation.