STM32 Cube WLGetting Started
STM32 Cube WLGetting Started
User manual
Introduction
STM32Cube is an STMicroelectronics original initiative to significantly improve developer productivity by reducing development
effort, time and cost. STM32Cube covers the whole STM32 portfolio.
STM32Cube includes:
• A set of user-friendly software development tools to cover project development from the design to the production, among
which:
– STM32CubeMX, a graphical software configuration tool that allows the automatic generation of C initialization code
using graphical wizards.
– STM32CubeProgrammer (STM32CubeProg), a programming tool available with both graphical and command-line
interfaces.
– STM32CubeMonitor-Power (STM32CubeMonPwr), a monitoring tool to measure and to help optimizing the MCU
power consumption.
– STM32CubeMonitor, a versatile monitoring tool with a dedicated add-on to perform RF tests with STM32WL
(dynamic packet transmission/reception, PER measurements) with a graphical representation of RF performance
over time.
• A comprehensive embedded software platform, delivered per series (such as STM32CubeWL for STM32WL Series):
– The STM32Cube HAL, STM32 abstraction layer embedded software ensuring maximized portability across STM32
portfolio.
– Low-layer APIs (LL) offering a fast light-weight expert-oriented layer which is closer to the hardware than the HAL.
LL APIs are available only for a set of peripherals.
– A consistent set of middleware components such as FatFS, FreeRTOS™, LoRaWAN®, SubGHz_Phy, Sigfox™,
KMS, SE and mbed-crypto.
– All embedded software utilities coming with a full set of examples.
The STM32CubeWL runs on STM32WL Series microcontrollers based on the Arm® Cortex®-M processor.
Note: Arm is a registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
STM32CubeWL gathers, in a single package, all the generic embedded software components required to develop
an application on STM32WL microcontrollers. In line with the STM32Cube initiative, this set of components is
highly portable, not only within the STM32WL Series but also to other STM32 Series.
STM32CubeWL is fully compatible with the STM32CubeMX code generator that allows generating initialization
code. The package includes low-layer (LL) and hardware abstraction layer (HAL) APIs. These APIs cover the
microcontroller hardware, together with an extensive set of examples running on the STMicroelectronics boards.
The HAL and LL APIs are available in open-source BSD license for user convenience.
STM32CubeWL MCU Package also contains a set of middleware components with the corresponding examples.
They come in free user-friendly license terms:
• CMSIS-RTOS implementation with FreeRTOS™ open source solution
• FAT file system based on open source FatFS solution
SubGHZ_Phy mbed-crypto
Middleware level (1) Utilities
Board support package (BSP) Low-layer APIs (LL) Hardware abstraction layer APIs (HAL)
The STM32CubeWL firmware solution is built around three independent levels that easily interact as described in
Figure 2.
Applications
Level 1
Library and protocol based components
(for example FatFS, FreeRTOS™ or LoRaWAN®)
Examples
DT64432V1
HAL
2.1 Level 0
This level is divided into three sub-layers:
• Board support package (BSP)
• Hardware abstraction layer (HAL)
– HAL peripheral drivers
– Low-layer drivers
• Basic peripheral usage examples
The BSP is based on a modular architecture allowing an easy porting on any hardware by just implementing the
low-level routines.
• Each target configuration has its own option settings: target device, linker options, RO, RW zones,
preprocessor symbols (CORE_CM0PLUS) so that user code can be compiled, linked and programmed
separately for each core. The compilation results in two binaries: CM4 binary and CM0+ binary.
2.2 Level 1
This level is divided into two sub-layers:
• Middleware components
• Examples based on the middleware components
• LoRaWAN®
– It offers a very compelling mix of long range, low power consumption, and secure data transmission.
Public and private networks using this technology can provide coverage that is greater in range
compared to that of existing cellular networks. It is easy to plug into the existing infrastructure and
offers a solution to serve battery-operated IoT applications.
• SubGHz_Phy
– It implements the PHY layer for sub-gigahertz protocol. Although specialized for LoRaWAN® MAC
it can interface most sub-gigahertz protocol. It provides an abstraction layer managing transmission,
radio reception handlers and timeouts. With its unique radio API, it also implements several radio
drivers for other I-CUBE-LRAWAN
• Sigfox™
– It implements the Sigfox™ protocol library compliant with the Sigfox™ protocol Network. It is also
including the RF test protocol library to test against RF Sigfox™ tools.
• SE
– The secure engine middleware (SE) provides a protected environment to manage all critical data
and operations (such as cryptography operations accessing firmware encryption key and others).
Protected code and data are accessible through a single entry point (called gate mechanism) and it is
therefore not possible to run or access any SE code or data without passing through it, otherwise, a
system reset is generated.
• KMS
– The key management services middleware (KMS) provides cryptographic services to the user
application through the PKCS #11 APIs (KEY ID-based APIs). Security is insured by locating KMS in
the secure enclave. User application keys are stored in the secure enclave and can be updated in a
secure way (authenticity check, decryption, and integrity check before the update).
• mbed-crypto
– mbed-crypto middleware is delivered as open source code. This middleware provides a PSA
cryptography API implementation.
STM32CubeWL features a rich set of examples and applications at all levels making it easy to understand and
use any HAL driver and/or middleware components. These examples run on the STMicroelectronics boards listed
in Table 1.
Supported boards
Sub-GHz Middleware
(Phy Layer and MAC
layers)
Set of examples, applications and
demonstration organized by boards
and provided with preconfigured
projects
DT64435V2
Attention: The user must not modify the components files. Only the \Projects sources are eligible to changes by the user.
For NUCLEO-WL55JC1, NUCLEO-WL55JC2 and B-WL5M-SUBG1 boards, a set of examples are provided with
preconfigured projects for EWARM, MDK-ARM, and STM32CubeIDE toolchains.
Figure 5 shows the project structure for the STM32CubeWL MCU Package.
The examples are classified depending on the STM32Cube level they apply to, and are named as explained
below:
• Level 0 examples are called Examples, Examples_LL and Examples_MIX. They use respectively HAL
drivers, LL drivers and a mix of HAL and LL drivers without any middleware component.
• Level 1 examples are called Applications. They provide typical use cases of each middleware component.
Templates projects available in the Templates and Templates_LL directories permit to quickly build any firmware
application on a given board. Two projects are available in each template directory: single core for all STM32WL
lines and dual core projects for STM32WL5x (dual core) line.
Single core examples have the same structure:
• \Inc folder that contains all header files.
For developing a custom project in the STM32CubeMX, follow the step-by-step process:
1. Select the STM32 microcontroller that matches the required set of peripherals.
2. Configure all the required embedded software using a pinout-conflict solver, a clock-tree setting helper, a
power consumption calculator, and the utility performing MCU peripheral configuration (such as GPIO or
USART) and middleware stacks (such as USB).
3. Generate the initialization C code based on the selected configuration. This code is ready to use within
several development environments. The user code is kept at the next code generation.
For more information about STM32CubeMX, refer to the STM32CubeMX for STM32 configuration and
initialization C code generation (UM1718).
For a list of the available example projects for the STM32CubeWL, refer to the STM32Cube firmware examples
for STM32WL Series application note (AN5409).
4.2.2.2 LL application
This section describes the steps needed to create your own LL application using STM32CubeWL.
1. Create your project
To create a new project you either start from the Templates_LL project provided for
each board under \Projects\<STM32xxx_yyy>\Templates_LL or from any available project under
\Projects\<STM32xxy_yyy>\Examples_LL (<STM32xxx_yyy> refers to the board name, such as NUCLEO-
WL55JC).
The Template project provides an empty main loop function, however it is a good starting point to get
familiar with project settings for STM32CubeWL.
Template main characteristics are the following:
– It contains the source codes of the LL and CMSIS drivers which are the minimal components needed
to develop code on a given board.
– It contains the include paths for all the required firmware components.
– It selects the supported STM32WL device and allows to configure the CMSIS and LL drivers
accordingly.
– It provides ready-to-use user files, that are pre-configured as follows:
main.h: LED & USER_BUTTON definition abstraction layer.
main.c: System clock configuration for maximum frequency.
2. Port an existing project to another board
To port an existing project to another target board, start from the Templates_LL project provided for each
board and available under \Projects\<STM32xxx_yyy>\Templates_LL:
a. Select a LL example
To find the board on which LL examples are deployed, refer to the list of LL examples
STM32CubeProjectsList.html.
b. Port the LL example
◦ Copy/paste the Templates_LL folder - to keep the initial source - or directly update existing
Templates_LL project.
◦ Then porting consists principally in replacing Templates_LL files by the Examples_LL targeted
project.
◦ Keep all board specific parts. For reasons of clarity, board specific parts have been flagged
with specific tags:
/* ============== BOARD SPECIFIC CONFIGURATION CODE BEGIN ============== */
/* ============== BOARD SPECIFIC CONFIGURATION CODE END ============== */
Caution: Regeneration of dual core template with CubeMX (file .ioc) would overwrite the code migrated previously
Optionally, CubeMX configuration of the dual core template (file .ioc) can be updated to match the example
migrated to CPU2.
4.2.4 RF applications
Three types of RF application are available in the package. They are listed below:
LoRaWAN® examples are LoRaWAN® examples implementing a LoRaWAN® device exercising the LoRaWAN®
stack and the SubGHz_Phy RF driver. They are located in Projects\NUCLEO-WL55JC\Applications\ and
Projects\B-WL5M-SUBG1\Applications\.
• LoRaWAN\LoRaWAN_AT_Slave implements a LoRaWAN® modem that is controlled through AT command
interface over UART by an external host. This application is available in single core and dual core format
with and without KMS (key management system). More information can be found in AN5406 and AN5481.
LoRaWAN_AT_Slave devices can be connected to STM32CubeMonitor to send AT commands to the
device, perform packet error rate measurement and more.
• LoRaWAN\LoRaWAN_End_Node implements a LoRaWAN® application device sending sensor data to
LoRaWAN® network server. This application is available in single core, dual core with optionally FreeRTOS
and KMS. More information can be found in the application note AN5406 : How to build a LoRa®
application with STM32CubeWL.
• LoRaWAN_FUOTA_DualCore implements a dual core LoRaWAN® application device sending sensor data
to LoRaWAN® network server. Moreover, the LoRaWAN® application and stack can be updated over-the-
air from a LoRaWAN® network server using the SBSFU as a secure boot and secure firmware update
framework. As well, the LoRaWAN_FUOTA example is fully secured using isolation features provided
by the STM32WL55. More information is provided in the application note AN5554: LoRaWAN® firmware
update over the air with STM32CubeWL.
• LoRaWAN_FUOTA implements a single core LoRaWAN® application device sending sensor data to
LoRaWAN® network server. Moreover, the LoRaWAN® application and stack can be updated over-the-air
from a LoRaWAN® network server using the BFU as a boot and firmware update framework.
• LoRaWAN_SBSFU_1_Slot_DualCore implements a dual core Secure LoRaWAN® application device
sending sensor data to LoRaWAN® network server. This application is secured with security environment
offered by secure boot (SB) and secure engine. The application can also be updated with local loader
Y-modem (SFU).
4.2.5 RF demonstration
The local network demonstration features a non LoRaWAN® local network with one concentrator and up
to 14 sensors that can connect and send sensor data to the concentrator. More information is provided in
UM2786. Local network projects are located under Projects\NUCLEO-WL55JC\Demonstrations\LocalNetwork
and Projects\B-WL5M-SUBG1\Demonstrations\LocalNetwork_Sensor.
• One concentrator project flashed into STM32WLxx_Nucleo board implements a concentrator sending one
beacon frame and one sync frame every 16 seconds to administrate a network of up to 14 sensors and
receives each connected sensor data. The concentrator can be connected to the STM32CubeMonitor to
configure the geographical area and display the list of sensors detected and connected sensor data.
• Two sensor projects that implement:
– Sensor sending data (based on the Internal Temperature Sensor and VBat information on the
NUCLEO-WL55JC board) to the demo concentrator
– Sensor sending data (based on all sensors available on the B-WL5M-SUBG1 board) to the demo
concentrator.
5 FAQ
5.3 Are any examples provided with the ready-to-use toolset projects?
Yes. STM32CubeWL provides a rich set of examples and applications. They come with the pre-configured
projects for IAR™-based toolchain.
5.5 Does the HAL layer take benefit from interrupts or DMA? How can this be
controlled?
Yes. The HAL layer supports three API programming models: polling, interrupt and DMA (with or without interrupt
generation).
5.9 Can I use HAL and LL drivers together? If yes, what are the constraints?
It is possible to use both HAL and LL drivers. One handles the peripheral initialization phase with HAL and then
manages the I/O operations with LL drivers.
The major difference between HAL and LL is that HAL drivers require to create and use handles for operation
management while LL drivers operate directly on peripheral registers. Mixing HAL and LL is illustrated in
Examples_MIX example.
5.10 Are there any LL APIs which are not available with HAL?
Yes, there are.
A few Cortex® APIs have been added in stm32wlxx_ll_cortex.h , for instance for accessing SCB or SysTick
registers.
5.14 How to get regular updates on the latest STM32CubeWL MCU Package
releases?
Refer to Section 4.2.6 .
Revision history
Table 3. Document revision history
11-
1 Initial release.
Dec-2019
Updated Section Introduction.
Updated Section 1 STM32CubeWL main features.
Updated Figure 1. STM32CubeWL firmware components.
Updated Section 2.1.2 Hardware abstraction layer (HAL) and low-layer (LL).
Updated Section 2.1.3 Basic peripheral usage examples.
Updated Section 3 STM32CubeWL firmware package overview.
12- Updated Section 4.1 Running your first example.
2
Oct-2020
Added Section 4.2.1 Using STM32CubeMX to develop or update your application.
Reorganized Section 4.2.2 Drivers applications.
Added Section 4.2.2.3 How to migrate a single core example from CPU1 to CPU2.
Updated Section 5.1 What is the license scheme for the STM32CubeWL firmware?.
Added Section 5.13 How can STM32CubeMX generate code based on embedded software?.
Added Section 5.14 How to get regular updates on the latest STM32CubeWL MCU Package
releases?.
16-
3 Replaced STM32CubeMonitor-RF by STM32CubeMonitor in Section Introduction.
Mar-2021
Updated Figure 5. Overview of STM32CubeWL examples.
07-
4 Updated Section 4.2.3.2 SBSFU applications
Jun-2021
Updated Section 4.2.4 RF applications
Updated Table 2. Boards for STM32WL Series.
27- Updated Section 3.2 Firmware package overview inlcuding Figure 4. STM32CubeWL firmware
5
Jan-2022 package structure and Figure 5. Overview of STM32CubeWL examples.
Updated Section 4.2.4 RF applications.
Updated Section 1 STM32CubeWL main features to streamline product names.
Updated Section 2 STM32CubeWL architecture overview to streamline product names.
Updated Section 3.1 Supported STM32WL devices and hardware to add STM32WL5MO devices in
table 1; to add the B-WL5M-SUBG1 board in table 2.
Updated Section 3.2 Firmware package overview : Edited figure 4 to add the B-WL5M-SUBG1
board. Edited figure 5 to add the STM32CubeWL MCU Package information. Added B-WL5M-
03-
6 SUBG1 information and EWARM, MDK-ARM and STM32CubeIDE toolchains.
Nov-2022
Updated Section 4.2.4 RF applications to streamline product names; to add B-WL5M-SUBG1
information; and to add LoRaWAN_FUOTA_DualCore_ExtFlash application information;
Updated Section 4.2.5 RF demonstration to add the B-WL5M-SUBG1 project path; and to add the
two sensor project information.
Updated Section 5.2 What boards are supported by the STM32CubeWL firmware package? with
information about the NUCLEO-WL55JC1, NUCLEO-WL55JC2 and B-WL5M-SUBG1 boards.
Contents
1 STM32CubeWL main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 STM32CubeWL architecture overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1 Level 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.1 Board support package (BSP). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.1.2 Hardware abstraction layer (HAL) and low-layer (LL) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.1.3 Basic peripheral usage examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.2 Level 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.1 Middleware components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.2 Examples based on the middleware components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3 STM32CubeWL firmware package overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1 Supported STM32WL devices and hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2 Firmware package overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4 Getting started with STM32CubeWL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
4.1 Running your first example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2 Developing your own application. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.2.1 Using STM32CubeMX to develop or update your application . . . . . . . . . . . . . . . . . . . . . . 11
4.2.2 Drivers applications. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.2.3 Security applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.2.4 RF applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.2.5 RF demonstration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.2.6 Getting STM32CubeWL release updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18
5.1 What is the license scheme for the STM32CubeWL firmware? . . . . . . . . . . . . . . . . . . . . . . . 18
5.2 What boards are supported by the STM32CubeWL firmware package? . . . . . . . . . . . . . . . . 18
5.3 Are any examples provided with the ready-to-use toolset projects?. . . . . . . . . . . . . . . . . . . . 18
5.4 Is there any link with standard peripheral libraries? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.5 Does the HAL layer take benefit from interrupts or DMA? How can this be controlled? . . . 18
5.6 How are the product/peripheral specific features managed?. . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.7 When should I use HAL versus LL drivers? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.8 How can I include LL drivers in my environment? Is there any LL configuration file as for
HAL?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.9 Can I use HAL and LL drivers together? If yes, what are the constraints? . . . . . . . . . . . . . . 19
5.10 Are there any LL APIs which are not available with HAL? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.11 Why are SysTick interrupts not enabled on LL drivers? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
5.12 How are LL initialization APIs enabled? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
List of tables
Table 1. Macros for STM32WL Series. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 2. Boards for STM32WL Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Table 3. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
List of figures
Figure 1. STM32CubeWL firmware components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Figure 2. STM32CubeWL firmware architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Figure 3. Dual core project architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 4. STM32CubeWL firmware package structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 5. Overview of STM32CubeWL examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9