Skip to content

3. Hello, World! Example Tutorial

This example demonstrates the basic Libtropic API and can be used to verify that the chip works correctly. In this example, you will learn about the following functions:

  • lt_init(): function used to initialize context for communication with the TROPIC01,
  • lt_verify_chip_and_start_secure_session(): helper function to start Secure Session and allow L3 communication,
  • lt_ping(): L3 command to verify communication with the TROPIC01,
  • lt_session_abort(): L3 command to abort Secure Session,
  • lt_deinit(): function used to deinitialize context.

Build and Run

Building and running the example

Go to the example's project directory:

cd examples/stm32/<your_board>/hello_world/

Create a build/ directory and switch to it:

mkdir build/
cd build/

Open your STM32's serial port using your preferred serial monitor with configuration 8-N-1 and baudrate set to 115200. By default, the serial port is mapped to /dev/ttyACM0. For example, using GTKTerm:

gtkterm -p /dev/ttyACM0 -s 115200

Warning

Make sure only one serial monitor has the STM32's serial port open, otherwise your output may appear mangled.

And finally, build and run the example:

cmake ..
make
make flash

TBA

TBA

After this, you should see an output in your serial monitor.

Configuration

In addition to the Libtropic CMake options used to configure Libtropic, this example provides the following CMake options:

  • STLINK_SERIAL_NUMBER (default: none, OpenOCD looks for any STLink programming interface) specifies the serial number of the STLink device used for flashing. This is needed only when you have multiple STM32s connected via built-in STLink or when OpenOCD autodetection does not work:

    Configuring STLink serial number
    cmake -DSTLINK_SERIAL_NUMBER=<stlink_serial_number> ..
    make
    make flash
    

    TBA

    TBA

  • LT_SH0_KEYS (default: "prod0") selects which pairing keys in slot 0 are used. Switch to engineering-sample pairing keys if your TROPIC01 is provisioned with them:

    Switching to engineering sample pairing keys
    cmake -DLT_SH0_KEYS="eng_sample" ..
    make
    make flash
    

    TBA

    TBA

    Additionally, see Default Pairing Keys for a Secure Channel Handshake for more information.