Target setup for STM32MP157

This is a setup guide for the CGI Studio Professional Edition on the STM32MP157 with a Wayland display server. It covers the preparation of the target image and environment, the installation of CGI Studio player and the creation of a simple solution including the data binding script.

This target setup guide does not cover the optional SoundHound integration, which is used by the BloodPressureSample for voice interaction. Please check the Blood Pressure Sample for further information about it.

STM32MP157 Target Setup Guide

Before you Begin

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

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


Software Image Setup

Flashing the Target Device

Download the prepared image provided by Candera:
FlashLayout_sdcard_stm32mp157f-dk2-opteemin.raw

To flash the image to a micro SD card with minimum size of 8GB, use a tool such as Etcher.io. After the flashing process is complete, insert the SD card into the STM32MP157 Discovery Kit, then power on the device to boot from the SD card.
Please check that your boot settings are correctly set to boot from the SD card according to the official guide.

After booting, connect to the target device via a serial terminal (e.g. Tera Term) or SSH and run the following setup script to complete the installation of required packages and configuration:

cd /opt/cgistudio/PlayerConnector
./install.sh

At Candera we have used WinSCP to transfer additional files to the target device as needed.

After this step, your target system will be prepared to run Python-based data binding examples or any assets using the CGI-Studio runtime environment.

To change the location of the Weston taskbar (which is positioned at the bottom by default) or to remove it entirely you can use our set_weston_panel.sh script located in /opt/cgistudio/PlayerConnector/set_weston_panel.sh.


Blood Pressure Sample

We have prepared several samples to demonstrate the capabilities of CGI-Studio on the target image. These samples are located at:
/opt/cgistudio/PlayerConnector/Samples/ on the target image and in <cgi-studio-installation-path>\bin\ProfessionalEdition\Python\Samples on the host computer.

We will use the Blood Pressure Sample as an example to demonstrate how to run our samples. The Blood Pressure device sample is a Scene Composer sample that showcases 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 Player Connector Library. For this chapter the completed “Image Setup” is required.

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:

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 Player Connector Library. The Player Connector Library allows the simple connection between CGI Studio Player and a Python-based script.

Python Script

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

This script can also be found in /opt/cgistudio/PlayerConnector/Samples/BloodPressureDevice/BloodPressureDevice.py on the image.

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 Player Connector Library and additional required libraries.

    import argparse
    import time
    import signal
    from CanderaAppConnector import CanderaAppConnector, Logger
    from Generated.BindingSourceEnum import BindingSourceItem
    
    
  2. Constructing the library with the Player Connector 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()
      if SoundhoundCommandClient is not None:
        SoundhoundCommandClient.destroy()
    
    exit()
    
    

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

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

To run the Python-based data binding in the simulation environment (on the host computer) execute the steps below on the host computer:

Run Blood Pressure Sample with Player 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) connection is established and the setup script /opt/cgistudio/PlayerConnector/install.sh was executed successfully.


Empty Solution with Slider and Gauge Control

This chapter shows how you can create your own solution with Python data binding through a simple use case, and how to run it on host and target. 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 reading 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.


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.