Skip to content

tropicsquare/libtropic-stm32

libtropic-stm32

About

This repository contains examples of libtropic's usage on ST Microelectronic's development boards.

Contributors, please follow guidelines.

Currently supported boards are:

Debug messages are transmitted over devboard's USB ACM serial port, they can be received by opening a serial port on PC.

More info about wiring is in each project's own README.md file.

Dependencies

  • cmake
  • arm-none-eabi-gcc
  • openocd

Cloning

This repository must be cloned recursively, because it contains submodules - libtropic and target drivers:

git clone https://github.com/tropicsquare/libtropic-stm32.git
cd libtropic-stm32
git submodule update --init --recursive

Building and Running Examples

All available examples can be found here.

To build examples, switch to one of the platform directories (in this case, the NUCLEO_F439ZI), and do the following:

cd NUCLEO_F439ZI/
mkdir build
cd build
cmake -DLT_BUILD_EXAMPLES=1 ..
make

For each example, an ELF binary will be created in the build directory.

For a quick check of correct setup, all examples are already precompiled for all supported boards here (click on latest workflow run, scroll down to Artifacts and download an artifact for your board).

Important

When LT_BUILD_EXAMPLES are set, there has to be a way to define the SH0 private key for the TROPIC01's pairing key slot 0, because both the examples and the tests depend on it. For this purpose, the CMake variable LT_SH0_PRIV_PATH is used, which should hold the path to the file with the SH0 private key in PEM or DER format. By default, the path is set to the currently used lab batch package, found in libtropic/provisioning_data/<lab_batch_package_directory>/sh0_key_pair/. But it can be overriden by the user either from the command line when executing CMake (switch -DLT_SH0_PRIV_PATH=<path>), or from a child CMakeLists.txt.

Flashing

Connect NUCLEO devboard with usb, then execute in the NUCLEO_F439ZI/ directory:

./flash.sh build/<chosen_binary>

After this, output should be seen in the opened serial port.

For example, upon flashing the lt_ex_hello_world example as:

./flash.sh build/lt_ex_hello_world.elf

you should see some output similar to this:

INFO    [  21] ======================================
INFO    [  22] ==== TROPIC01 Hello World Example ====
INFO    [  23] ======================================
INFO    [  27] Initializing handle
INFO    [  35] Starting Secure Session with key 0
INFO    [  43] 	-------------------------------------------------
INFO    [  46] Sending Ping command with message:
INFO    [  47] 	"This is Hello World message from TROPIC01!!"
INFO    [  55] 	-------------------------------------------------
INFO    [  57] Message received from TROPIC01:
INFO    [  58] 	"This is Hello World message from TROPIC01!!"
INFO    [  59] 	-------------------------------------------------
INFO    [  61] Aborting Secure Session
INFO    [  69] Deinitializing handle

Building Functional Tests

All available functional tests can be found here.

Warning

Some tests make irreversible changes to the chip, such as writing pairing keys. Those irreversible tests contain _ire_ in their name. On the other hand, reversible tests are marked _rev_ and are generally safe to run, as they do only temporary changes and always do a clean up.

To build functional tests, switch to one of the platform directories (in this case, the NUCLEO_F439ZI), and do the following:

cd NUCLEO_F439ZI/
mkdir build
cd build
cmake -DLT_BUILD_TESTS=1 ..
make

For each test, an ELF binary will be created in the build directory.

Important

When LT_BUILD_TESTS are set, there has to be a way to define the SH0 private key for the TROPIC01's pairing key slot 0, because both the examples and the tests depend on it. For this purpose, the CMake variable LT_SH0_PRIV_PATH is used, which should hold the path to the file with the SH0 private key in PEM or DER format. By default, the path is set to the currently used lab batch package, found in libtropic/provisioning_data/<lab_batch_package_directory>/sh0_key_pair/. But it can be overriden by the user either from the command line when executing CMake (switch -DLT_SH0_PRIV_PATH=<path>), or from a child CMakeLists.txt.

Normally, we use CTest for handling the functional tests. They are executed using lt_test_runner on internal TS11 evaluation boards.

To launch all tests:

ctest

Tip

To see all output use --verbose.

To launch a selected test:

ctest -R test_name

To enumerate tests:

ctest -N

If you want to launch the tests without the platform, simply flash select binary manually and inspect the UART output. Note that a different UART is used for test output. This method is not officially supported.

Debugging in VS Code

For compiling in debug mode, pass -DCMAKE_BUILD_TYPE=Debug during cmake call.

Install dependencies:

  • cortex-debug extension
  • arm-none-eabi-gdb

Then place this launch.json file into .vscode folder:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "cortex-debug",
            "request": "attach",
            "name": "Debug (OpenOCD)",
            "servertype": "openocd",
            "cwd": "${workspaceRoot}",
            //"preLaunchTask": "cargo build",
            //"runToEntryPoint": "true",
            "executable": "./build/stm32_example.elf",
            "device": "STM32F429ZI",
            "configFiles": [
                "/usr/share/openocd/scripts/board/stm32f429discovery.cfg"
            ],
        }
    ]
}

Debugging should be enabled after restarting your VS Code.

Opening in STM32CubeIDE

  • Open File>New>STM32 Cmake Project
  • Set 'Project with existing CMake sources'
  • Choose apropriate name, set source directory to PATH_TO_THIS_EXAMPLE/<binary_name> and set the name of build directory
  • Define used MCU (Supported device is STM32F439ZITx and STM32L432KC)
  • Click on finish
  • Define transport layer by uncommenting an option in CMakeLists.txt
  • Click on Build, then on the left side click on binaries, right click on one of the built binaries and choose 'run as a stm32 Application'

License

See the LICENSE.md file in the root of this repository or consult license information at Tropic Square website.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •