STM32 IOT01A example

This example application runs out of the box on the STM32 IOT01A development kits.

It uses the on board peripherals such as WiFi and the temperature sensor to send data to Drogue Cloud, and retrieve firmware updates if available.

There are multiple variants of this kit, so the example must be compiled and run using feature flags.

Prerequisites

Hardware

  • STM32 IOT01A development kit

Software

  • To build the example, you need to have rustup.

  • To flash the example on the device, you need probe-run installed (cargo install probe-run).

  • A Drogue Cloud instance. See drogue-cloud for how to run that, or use the sandbox (requires TLS).

Configuring

Credentials for your local WiFi network will come from these entries in ~/.drogue/config.toml:

wifi-ssid = "..."
wifi-password = "..."

HTTP authentication will come from these entries in ~/.drogue/config.toml:

username = "..."
password = "..."

For Drogue Cloud, the username/password is stored in this form: device_id@application.

The example config.toml file for connecting to public Drogue cloud sandbox application could look like this:

hostname = "http.sandbox.drogue.cloud" # Replace with your own Drogue Cloud instance if you are not using the sandbox
port = "443"
wifi-ssid = "..."                      # The WiFi network SSID
wifi-password = "..."                  # The WiFi network pre-shared key
username = "device1@wifi-workshop"
password = "mysecretpassword"

Just enter your wifi details and you should be ready to go.

If you have the B-L4S5I-IOT01A board, set the following environment variables:

export CHIP=STM32L4S5VI CHIP_FEATURE=l4s5i

If you have the B-475E-IOT01A board, use the following settings instead:

export CHIP=STM32L475VGTx CHIP_FEATURE=l475e

Running

For this step, we need to flash a bootloader as well as the application. The example is configured to enable firmware updates using Drogue Cloud sandbox.

Flashing the bootloader

To flash the bootloader for a given chip:

cargo flash --manifest-path ../boot/Cargo.toml --release --features ${CHIP_FEATURE} --no-default-features --chip ${CHIP}

Running the application

To run the application using a given chip:

PROBE_RUN_CHIP=${CHIP} cargo run --release --features ${CHIP_FEATURE},debug --no-default-features

Once flashed, the device will reset and attempt to join the WiFi network as before, in addition to polling the Drogue Cloud for firmware update commands.

Troubleshooting

If you’re experiencing problems, try setting the VID:PID values to that of your probe (you can find that from lsusb once your board is powered).

<ENV> cargo run <ARGS> -- --probe <VID>:<PID>

Additionally, the B-L4S5I-IOT01A board can have issues with running probe multiple times, leading to errors like

Error: An error with the usage of the probe occured

Caused by:
    Operation timed out

If you experience that, the best way to restore the board is to reconnect it and use st-flash utility to write any binary to it, like

st-flash write ../target/thumbv7em-none-eabihf/release/iot01a-wifi.d 0x8000000

After reconnecting the board again, you should be able to use cargo run again.