STMicroelectronics STM32Cube User Manual

UM2043

User manual

Getting started with the STM32Cube function pack for IoT sensor node with telemetry and device management applications for Microsoft Azure cloud

Introduction

FP-CLD-AZURE1 is an STM32Cube function pack which lets you safely connect a B-L475E-IOT01A or STEVAL-STWINKT1B node to Microsoft Azure IoT, transmit sensor data and receive commands from Azure IoT Central PnP.

It fully supports Azure device management primitives and includes a sample implementation for firmware update over the air (FOTA).

The package also contains a sample application for data telemetry/device management and firmware update to be connected to Azure IoT Central PnP application.

This software, together with the suggested combination of STM32 and ST devices, can be used, for example, to develop sensor-to-cloud applications for a broad range of use cases, such as smart home or smart industry.

The software runs on the STM32 microcontroller and includes drivers for the Wi-Fi connectivity, and motion and environmental sensors.

RELATED LINKS

Visit the STM32Cube ecosystem web page on www.st.com for further information

UM2043 - Rev 9 - March 2021

www.st.com

For further information contact your local STMicroelectronics sales office.

 

 

 

UM2043

Acronyms and abbreviations

1Acronyms and abbreviations

 

Table 1. List of acronyms

 

 

Acronym

Description

 

 

AP

Access point

 

 

BSP

Base support package

 

 

FOTA

Firmware update over-the-air

 

 

DICE

Device identifier composition engine

 

 

DPS

Device provisioning system

 

 

GPIO

General purpose input/output

 

 

HAL

Hardware abstraction layer

 

 

HTML

Hypertext markup language

 

 

HTTP

Hypertext transfer protocol

 

 

IDE

Integrated development environment

 

 

IoT

Internet of things

 

 

I²C

Inter-integrated circuit

 

 

MCU

Microcontroller unit

 

 

MEMS

Micro electro-mechanical systems

 

 

ODE

Open development environment

 

 

 

 

PnP

IoT Central Plug and Play

 

 

REST API

Representational state tranfer apis

 

 

RIoT

Robust Intenet of Things

 

 

SDK

Software development kit

 

 

SMD

Surface mount device

 

 

SSID

Service set identifier

 

 

 

 

STM32UID

STM32 unique device ID

 

 

UART

Universal asynchronous receiver/transmitter

 

 

URL

Uniform resource locator

 

 

Wi-Fi

Wireless LAN based on IEEE 802.11

 

 

WLAN

Wireless local area network

 

 

UM2043 - Rev 9

page 2/25

 

 

UM2043

FP-CLD-AZURE1 software description

2FP-CLD-AZURE1 software description

2.1Overview

The package features:

Complete firmware to safely connect a node with sensors to Microsoft Azure IoT using Wi-Fi communication technology

A sample application for data telemetry/device management to be connected to Azure IoT Central PnP application

Middleware libraries featuring Microsoft Azure IoT software development, transport-level security (mbedTLS) and meta-data management

Ready-to-use binaries to connect the node to Azure IoT Central PnP application for sensor data visualization and device management (FOTA)

Sample implementations available for STM32L4 Discovery Kit for IoT node (B-L475E-IOT01A) and for STWIN SensorTile Wireless Industrial Node development kit (STEVAL-STWINKT1B)

Easy portability across different MCU families, thanks to STM32Cube

Free, user-friendly license terms

2.2Architecture

The software layers used by the application to access and use the STM32 microcontroller and the Wi-Fi and sensors are:

STM32Cube HAL driver layer: a simple, generic, multi-instance set of APIs (application programming interfaces) to interact with the upper layer applications, libraries and stacks. The APIs are based on a common framework so that overlying software like middleware can implement functions and routines without specific microcontroller unit (MCU) hardware configurations. This structure improves library code reusability and guarantees easy portability across other devices.

Board support package (BSP) layer: drives the STM32 Nucleo board peripherals like the LED, user button, etc. (not the MCU), with a specific set of APIs. This interface also helps in identifying the specific board version.

Middleware layer: contains the MetaDataManager to save Meta Data in the STM32 Flash memory, mbedTLS and the Microsoft Azure IoT device SDK (https://github.com/Azure/azure-iot-sdks) to facilitate the connection of STM32 Nucleo with Azure IoT services.

Figure 1. FP-CLD-AZURE1 software architecture

Applications

Azure1 PNP

BootLoader

 

 

 

 

 

 

 

mbedTLS

Meta Data Mgr

Middleware

Network Library

Azure IoT SDK Public Review

 

Hardware

STM32Cube Hardware Abstraction Layer (HAL)

Abstraction

 

 

 

 

 

 

 

 

Hardware

STEVAL-STWINKT1B

B-L475E-IOT01A

 

evaluation board

Discovery kit IoT node

 

 

 

UM2043 - Rev 9

page 3/25

 

 

UM2043

Folder structure

2.3Folder structure

Figure 2. Package folder structure

The following folders are included in the software package:

Documentation: with two compiled HTML files generated from the source code detailing the software components and APIs (one for each project).

Drivers: the HAL drivers and the board-specific drivers for each supported board or hardware platform, including those for the on-board components, and the CMSIS vendor-independent hardware abstraction layer for the ARM Cortex-M processor series.

Middlewares: the middleware interface for MetaDataManager, mbedTLS and the porting of Microsoft Azure IoT device SDK.

Utilities: contains BootLoader for B-L475E-IOT01A and for STEVAL-STWINKT1.

Projects contains:

the AzurePnP sample application (for B-L475E-IOT01A/STEVAL-STWINKT1B) to transmit sensor data and receive commands via a personal Azure account using IoT Central PnP accessible through the link in the documentation included in the source package that allows importing the application template used for this example

the BootLoader project used in FP-CLD-AZURE1 for the firmware update procedure

sample applications that can be compiled with IAR Embedded Workbench for ARM, RealView Microcontroller Development Kit (MDK-ARM-STM32) or STM32CubeIDE development environments

for each sample application, a configurable pre-compiled binary to connect devices to the Azure web dashboards

2.4Flash memory management

The sample application uses the Flash memory to:

1.save the Wi-Fi credentials and the IoT Central PnP information in the Meta Data Manager;

2.allow the Firmware-Over-The-Air update

To enable these features the Flash is divided in different regions (see Figure 3. Azure1 Flash structure for STM32L475VG):

1.the first region contains a custom boot loader (required for firmware update);

2.the second region contains the application firmware;

3.the third region is used in a firmware update procedure to store the new downloaded firmware before updating it, and to save data inside the Meta Data Manager.

The STEVAL-STWINKT1B embeds the STM32L4R9ZI microcontroller with 2 MBytes of Flash divided in pages of 4 KBytes. The B-L475E-IOT01A embeds the STM32L475VG microcontroller with 1 MByte of Flash divided in

pages of 2 KBytes. In this section the STM32L475VG is used as example, even if the STM32L4R9ZI has a similar Flash organization.

UM2043 - Rev 9

page 4/25

 

 

UM2043

The boot process for the firmware update over-the-air (FOTA) application

The Meta Data Manager is placed at the end of the Flash (0x080FF000 for STM32L475VG). For more information

on the Flash memory management, refer to RM0351: "STM32L4x5 and STM32L4x6 advanced Arm®-based 32-bit MCUs" on www.st.com.

Figure 3. Azure1 Flash structure for STM32L475VG

2.5The boot process for the firmware update over-the-air (FOTA) application

To enable the firmware update procedure, the Azure1 application binary cannot be flashed at the beginning of the Flash memory (address 0x08000000), and is therefore compiled to run from the beginning of the second Flash region (at 0x08004000).

To enable this procedure, a vector table offset is set in Src/system_stm32l4xx.c (for B-L475E-IOT01A or STEVALSTWINKT1): #define VECT_TAB_OFFSET 0x4000.

The linker script also requires changes; in this section, considering the B-L475E-IOT01A as example, the Linker script for Azure, compiled using IAR Embedded Workbench for ARM, is modified as follows:

UM2043 - Rev 9

page 5/25

 

 

UM2043

The installation process for the firmware update over-the-air (FOTA) application

/*-Specials-*/

define symbol __ICFEDIT_intvec_start__ = 0x08004000; /*-Memory Regions-*/

define symbol __ICFEDIT_region_ROM_start__ = 0x08004000; define symbol __ICFEDIT_region_ROM_end__ = 0x0807FFFF; define symbol __ICFEDIT_region_RAM_start__ = 0x20000000; define symbol __ICFEDIT_region_RAM_end__ = 0x20017FFF; define symbol __ICFEDIT_region_SRAM2_start__ = 0x10000000; define symbol __ICFEDIT_region_SRAM2_end__ = 0x10007FFF; /*-Sizes-*/ define symbol __ICFEDIT_size_cstack__ = 0x6000; define symbol __ICFEDIT_size_heap__ = 0x12000;

Using the above linker script, the maximum usable code size is fixed at 496 KB.

Before flashing the compiled Azure1 firmware, you must flash the appropriate bootloader binary for B-L475E- IOT01A, available in the Utilities\BootLoader folder, in the first Flash region (address 0x08000000).

Figure 4. BootLoader folder content

When the firmware update procedure is activated, the new firmware is downloaded and copied in the third Flash region.

After board reset, the following procedure applies:

if there is a new firmware downloaded in the third Flash region, the BootLoader overwrites the second Flash region (containing the current firmware), replaces its content with the new firmware and restarts the board;

if there is no new firmware downloaded, the BootLoader jumps to the firmware stored in region 2.

Figure 5. Azure1 boot sequence

2.6The installation process for the firmware update over-the-air (FOTA) application

The flashing procedure is simplified by a script available for each IDE (IAR/RealView/STM32CubeIDE).

UM2043 - Rev 9

page 6/25

 

 

UM2043

The installation process for the firmware update over-the-air (FOTA) application

The script uses the command line of STM32CubeProgrammer.

Figure 6. Project folder content example

In particular, the script:

erases the full Flash;

flashes the BootLoader at the correct position (0x08000000);

flashes the Azure1 firmware at the correct position (0x08004000).

UM2043 - Rev 9

page 7/25

 

 

STMicroelectronics STM32Cube User Manual

UM2043

The installation process for the firmware update over-the-air (FOTA) application

Figure 7. BootLoader and Azure installation

The same script also dumps a unique image file (containing the BootLoader and the Azure firmware) that can be directly flashed to the beginning of the Flash memory.

UM2043 - Rev 9

page 8/25

 

 

Loading...
+ 17 hidden pages