STM32CubeU5GettingStarted
STM32CubeU5GettingStarted
User manual
Introduction
STM32Cube is an STMicroelectronics original initiative to significantly improve designer's 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 conception to realization, among which
are:
– STM32CubeMX, a graphical software configuration tool that allows the automatic generation of C initialization code
using graphical wizards
– STM32CubeIDE, an all-in-one development tool with peripheral configuration, code generation, code compilation, and
debug features
– STM32CubeProgrammer (STM32CubeProg), a programming tool available in graphical and command-line versions
– STM32CubeMonitor (STM32CubeMonitor, STM32CubeMonPwr, STM32CubeMonRF, STM32CubeMonUCPD
powerful monitoring tools to fine-tune the behavior and performance of STM32 applications in real-time
• STM32CubeU5 comprehensive embedded-software platforms specific to STM32U5 Series microcontrollers), which
include:
– STM32Cube hardware abstraction layer (HAL), ensuring maximized portability across the STM32 portfolio
– STM32Cube low-layer APIs, ensuring the best performance and footprints with a high degree of user control over
hardware
– A consistent set of middleware components such as FAT file system, RTOS, USB Host and Device, Touch library, and
Graphics
– All embedded software utilities with full sets of peripheral and applicative examples
• STM32Cube Expansion packages, which contain embedded software components that complement the functionalities of
the STM32Cube MCU and MPU packages with:
– Middleware extensions and applicative layers
– Examples running on some specific STMicroelectronics development boards
This user manual describes how to get started with the STM32CubeU5 MCU package.
Section 2 describes the main features of the STM32CubeU5 MCU package. Section 3 and Section 4 provide an overview of the
STM32CubeU5 architecture and MCU package structure.
1 General information
The STM32Cube MCU package runs on STM32 32-bit microcontrollers based on the Arm® Cortex®-M33
processor with Arm® TrustZone® and FPU.
Note: Arm and TrustZone are registered trademark of Arm Limited (or its subsidiaries) in the US and/or elsewhere.
The STM32CubeU5 MCU package runs on STM32 32-bit microcontrollers based on the Arm® Cortex®-M33
processor with Arm® TrustZone® and FPU.
The STM32CubeU5 gathers, in a single package, all the generic embedded software components required to
develop an application for the STM32U5 Series microcontrollers. In line with the STM32Cube initiative, this set
of components is highly portable, not only within the STM32U5 Series microcontrollers but also to other STM32
series.
The STM32CubeU5 is fully compatible with the STM32CubeMX code generator for generating initialization code.
The package includes low-layer (LL) and hardware abstraction layer (HAL) APIs that cover the microcontroller
hardware, together with an extensive set of examples running on STMicroelectronics boards. The HAL and LL
APIs are available in open-source BSD license for user convenience.
The STM32CubeU5 MCU package also contains a comprehensive middleware components constructed around
Microsoft® Azure® RTOS middleware and other in-house and open source stacks, with the corresponding
examples.
They come with free user-friendly license terms:
• Integrated and full featured RTOS: ThreadX
• CMSIS-RTOS implementation with ThreadX
• USB Host and Device stacks coming with many classes: USBX
• Advanced file system and Flash translation layer: FileX / LevelX
• Industrial grade networking stack: optimized for performance coming with many IoT protocols: NetX Duo
• USB PD library
• Open bootloader
• Arm Trusted Firmware-M (TF-M) integration solution
• MCU boot
• mbed-crypto libraries
• ST network library
• STMTouch touch sensing library solution.
Several applications and demonstrations implementing all these middleware components are also provided in the
STM32CubeU5 MCU package.
The STM32CubeU5 MCU package component layout is illustrated in Figure 1.
The STM32CubeU5 MCU package 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 FS, RTOS™, USB PD)
Examples
HAL
3.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
• BSP driver
It allows linking the component drivers to a specific board and provides a set of user-friendly APIs. The API
naming rule is BSP_FUNCT_Action().
Example: BSP_LED_Init(), BSP_LED_On()
The BSP is based on a modular architecture allowing an easy porting on any hardware by just implementing the
low-level routines.
3.2 Level 1
This level is divided into two sub-layers:
• Middleware components
• Examples based on the middleware components
• ThreadX:
– A real-time operating system (RTOS), designed for embedded systems with two functional modes:
– Common mode: common RTOS functionalities such as thread management and synchronization,
memory pool management, messaging, and event handling
– Module mode: an advanced usage mode that allows loading and unloading of pre-linked ThreadX
modules on-the-fly through a module manager.
• NetX duo
– Industrial grade networking stack: optimized for performance coming with many IoT protocols.
• FileX / levelX
– Advanced Flash file system (FS) / Flash translation layer (FTL): fully featured to support NAND/NOR
Flash memories
• USBX
– USB Host and Device stacks coming with many classes
• USB PD Device and Core libraries
– new USB type C power delivery service. Implementing a dedicated protocol for the management
of power management in this evolution of the USB.org specification. (Refer to http://www.usb.org/
developers/powerdelivery/ for more details)
– PD3 specifications (support of source / sink / dual role)
– Fast role swap
– Dead battery
– Use of configuration files to change the core and the library configuration without changing the library
code (read only)
– RTOS and standalone operation.
– Link with low-level driver through an abstraction layer using the configuration file to avoid any
dependency between the Library and the low-level drivers.
• Open bootloader
– provides an open source bootloader with exactly the same features as STM32 system bootloader and
with the same tools used for system bootloader
• Arm trusted firmware-M (TF-M)
– Reference implementation of the Arm platform security architecture (PSA) for TrustZone
– Secure services are:
◦ Secure storage service
◦ Attestation
◦ Crypto service
◦ TF-M audit log
◦ Platform service
Note: An example of TF-M application is available in the STM32CubeU5 firmware package under
\Projects\B-U585I-IOT02A\Applications\TFM.
• MCU boot
• mbed-crypto
– Open source cryptography library that supports a wide range of cryptographic operations, including:
◦ Key management
◦ Hashing
◦ Symmetric cryptography
◦ Asymmetric cryptography
◦ Message authentication (MAC)
◦ Key generation and derivation
◦ Authenticated encryption with associated data (AEAD).
• Network Library
– provides network services on STM32 devices. It
– provides a socket API (BSD like style) with support of secure or non secure connection and an API to
control the lifecycle of the network adapters.
– Three classes of network adapters are supported WIFI, Ethernet and Cellular. Different WIFI modules
are supported from third party vendors.
• STM32 Touch sensing library:
– Robust STMTouch capacitive touch sensing solution supporting proximity, touchkey, linear and rotary
touch sensors. It is based a proven surface charge transfer acquisition principle.
3.3 Level 2
This level is composed of a single layer which consist in a global real-time and graphical demonstration based on
the middleware service layer, the low-level abstraction layer and the basic peripheral usage applications for board
based features.
3.4 Utilities
Alike all STM32Cube firmware packages, the STM32CubeU5 provides a set of utilities that offer miscellaneous
software and additional system resources services that can be used by either the application or the different
STM32Cube Firmware intrinsic middleware and components.
• The second level of abstraction is a hardware agnostic layer named Advanced LPBAM layer. It provides a
predefined scenario (set of elementary nodes) that can be customized and concatenated to build an end
user application.
• The Platform layer contains device specific constants to be used by the applicative side.
• The LL LPBAM layer (low level) is used by the Basic and the Advanced LPBAM layers. It contains the
device specific mechanisms for each supported peripheral.
Macro defined in
STM32U5 devices
stm32u5xx.h
STM32CubeU5 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 2.
NUCLEO-U575ZI-Q STM32U575ZIT6Q
STM32U575I-EV STM32U575AII6Q
B-U585I-IOT02A STM32U585AII6Q
The STM32CubeU5 MCU package is able to run on any compatible hardware. The user simply updates the BSP
drivers to port the provided examples on his own board, if the latter has the same hardware features (such as
LED, LCD display, buttons).
STMTouch library
USB power delivery
libraries
Miscellaneous utilities
STM32CubeU5 firmware
package release note and
license
1. The component files must not be modified by the user. Only the \Projects sources are editable by the user.
For each board, a set of examples are provided with pre-configured projects for EWARM, MDK-ARM, and
STM32CubeIDE toolchains.
Figure 5 shows the project structure for the NUCLEO-U575ZI-Q board.
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.
Any firmware application for a given board can be quickly build thanks to template projects available in the
Templates and Templates_LL directories.
The STM32CubeU5 firmware package provides default memory partitioning in the partition_<device>.h files
available under:
\Drivers\CMSIS\Device\ST\STM32U5xx\Include\Templates.
In these partition files, the SAU is disabled by default. Consequently, the IDAU memory mapping is used for
security attribution (refer to Figure 3 in Reference Manual)
If SAU is enabled by the user, a default SAU region configuration is pre-defined in partition files as follows:
• SAU region 0: 0x0C0FE000 - 0x0C0FFFFF (secure, non-secure callable)
• SAU region 1: 0x08100000 - 0x081FFFFF (non-secure Flash memory Bank2 (1024 Kbytes))
• SAU region 2: 0x20040000 - 0x200BFFFF (non-secure SRAM3 (512 Kbytes)))
• SAU region 3: 0x40000000-0x4FFFFFFF (non-secure peripheral mapped memory)
• SAU region 4: 0x60000000-0x9FFFFFFF (non-secure external memories)
• SAU region 5: 0x0BF90000-0x0BFA8FFF (non-secure system memory)
To match the default partitioning, the STM32U5xx Series devices must have the following user option bytes set:
• TZEN=1 (TrustZone-enabled device)
• SECWM1_PSTRT=0x0 SECWM1_PEND=0x7F (all 128 pages of Flash memory Bank1 set as secure)
• SECWM2_PSTRT=0x1 SECWM2_PEND=0x0 (no page of Flash memory Bank2 set as secure, hence Bank2 is
non-secure).
Note: The internal Flash memory is fully secure by default in TZEN=1 and user option bytes SECWM1_PSTRT/
SECWM1_PEND and SECWM2_PSTRT/SECWM2_PEND must be set according to the application memory
configuration (SAU regions (if SAU is enabled) and secure/non-secure applications project linker files must be
aligned too).
All examples have the same structure:
• \Inc folder that contains all header files.
• \Src folder for the sources code.
• \EWARM, \MDK-ARM, and \STM32CubeIDE folders containing the pre-configured project for each toolchain.
• readme.txt describing the example behavior and needed environment to make it work
• *.ioc file that allows users to open most of firmware examples within STM32CubeMX
Table 3 gives the number of projects available for each board.
Templates_LL 1 1 1 3
Templates 2 2 2 6
Examples_MIX 0 0 5 5
Examples_LL 0 0 41 41
Examples 23 27 85 135
Demonstrations 1 1 0 2
Applications 16 2 38 56
Total 43 35 172 250
• MDK-ARM
1. Open the MDK-ARM toolchain
2. Open Multi-projects workspace file Project.uvmpw
3. Select the xxxxx_s project as Active Project (Set as Active Project)
4. Build xxxxx_s project
5. Select the xxxxx_ns project as Active Project (Set as Active Project)
6. Build xxxxx_ns project
7. Load the non-secure binary (F8)
(this downloads the \MDK-ARM\xxxxx_ns\Exe\xxxxx_ns.axf to flash memory)
8. Select the Project_s project as Active Project (Set as Active Project)
9. Load the secure binary (F8)
(this downloads the \MDK-ARM\xxxxx_s\Exe\xxxxx_s.axf to flash memory)
10. Run the example
STM32CubeIDE
1. Open the STM32CubeIDE toolchain
2. Open Multi-projects workspace file .project
3. Rebuild xxxxx_Secure project
4. Rebuild xxxxx_NonSecure project
5. Launch Debug as STM32 Cortex-M C/C++ Application for the secure project.
6. In the Edit configuration window, select the Startup panel, and add load image and symbols of the
non-secure project.
7. Be careful, the non-secure project has to be loaded before the secure project.
8. Then click "OK".
9. Run the example on debug perspective.
• MDK-ARM
1. Under the example folder, open \MDK-ARM sub-folder
2. Launch the Project.uvprojx workspace
Note: The workspace name may change from one example to another.
3. Rebuild all files: Project → Rebuild all target files
4. Load project image: Debug → Start/Stop Debug Session
5. Run program: Debug → Run (F5).
• STM32CubeIDE
1. Open the STM32CubeIDE toolchain
2. Click File → Switch Workspace → Other and browse to the STM32CubeIDE workspace directory
3. Click File → Import, select General → Existing Projects into Workspace and then click Next
4. Browse to the STM32CubeIDE workspace directory and select the project
5. Rebuild all project files: select the project in the Project explorer window then click the Project →
build project menu
6. Run program: Run → Debug (F11)
1. Create a project
To create a new project, start either from the Template project provided for each
board under \Projects\<STM32xxx_yyy>\Templates or from any available project under
\Projects\<STM32xxy_yyy>\Examples or \Projects\<STM32xx_yyy>\Applications (where <STM32xxx_yyy>
refers to the board name, such as STM32CubeU5).
The Template project provides an empty main loop function, however it is a good starting point to understand
the STM32CubeU5 project settings. The template has the following characteristics:
– It contains the HAL source code, CMSIS and BSP drivers which are the minimum set of components
required to develop a code on a given board.
– It contains the include paths for all the firmware components.
– It defines the supported STM32U5 Series devices, allowing the CMSIS and HAL drivers to be
configured correctly.
– It provides read-to-use user files pre-configured as shown below:
HAL initialized with default time base with Arm core SysTick.
SysTick ISR implemented for HAL_Delay() purpose.
Note: When copying an existing project to another location, make sure all the include paths are updated.
2. Add the necessary middleware to user project (optional)
To identify the source files to be added to the project file list, refer to the documentation provided for each
middleware. Refer to the applications under \Projects\STM32xxx_yyy\Applications\<MW_Stack> (where
<MW_Stack> refers to the middleware stack, such as USBX) to know which source files and which include
paths must be added.
3. Configure the firmware components
The HAL and middleware components offer a set of build time configuration options using macros #define
declared in a header file. A template configuration file is provided within each component which has to
be copied to the project folder (usually the configuration file is named xxx_conf_template.h, the word
‘_template’ needs to be removed when copying it to the project folder). The configuration file provides
enough information to understand the impact of each configuration option. More detailed information is
available in the documentation provided for each component.
4. Start the HAL Library
After jumping to the main program, the application code must call HAL_Init() API to initialize the HAL
Library, which carries out the following tasks:
a. Configuration of the Flash memory prefetch and SysTick interrupt priority (through macros defined in
stm32u5xx_hal_conf.h).
b. Configuration of the SysTick to generate an interrupt every millisecond at the SysTick interrupt priority
TICK_INT_PRIO defined in stm32u5xx_hal_conf.h, which is clocked by the MSI (at this stage, the
clock is not yet configured and thus the system is running from the 4 MHz MSI).
c. Setting of NVIC group priority to 0.
d. Call of HAL_MspInit() callback function defined in stm32u5xx_hal_msp.c user file to perform global
low-level hardware initializations.
5.2.3 LL application
This section describes the steps needed to create a custom LL application using STM32CubeU5.
1. Create a project
To create a new project, 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-
U575ZI-Q).
The template project provides an empty main loop function, which is a good starting point to understand the
project settings for STM32CubeU5. Template main characteristics are the following:
– It contains the source codes of the LL and CMSIS drivers which are the minimum set of components
needed to develop code on a given board.
– It contains the include paths for all the required firmware components.
– It selects the supported STM32U5 device and allows the correct configuration of the CMSIS and LL
drivers.
– 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.
3. 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:
6 FAQ
6.1 What is the license scheme for the STM32CubeU5 MCU package?
The HAL is distributed under a non-restrictive BSD (berkeley software distribution) license.
The middleware stacks made by STMicroelectronics (ex: USBPD library) come with a licensing model allowing
easy reuse, provided it runs on an STMicroelectronics device.
The middleware based on well-known open-source solutions (TFM) have user-friendly license terms. For more
details, refer to the appropriate middleware license agreement.
6.3 Are any examples provided with the ready-to-use toolset projects?
Yes. STM32CubeU5 provides a rich set of examples and applications. They come with the pre-configured projects
for IAR Embedded Workbench®, Keil® and STM32CubeIDE.
6.10 Does the HAL layer take advantage of 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).
6.14 Can HAL and LL drivers be used together? If yes, what are the constraints?
It is possible to use both HAL and LL drivers. Use the HAL for the IP initialization phase and then manage 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 operates directly on peripheral registers. Mixing HAL and LL is illustrated in the
"Examples_MIX" example.
6.15 Are there any LL APIs which are not available with HAL?
Yes, there are. A few Cortex® APIs have been added in stm32u5xx_ll_cortex.h, for instance for accessing SCB or
SysTick registers.
6.19 How to get regular updates on the latest STM32CubeU5 MCU package
releases?
Refer to Section 5.3 .
6.21 Is the LPBAM based on DMA "tasks" used to configure the peripherals?
The LPBAM is based on DMA transfers stored on linked-list nodes to configure partially autonomous peripherals.
6.22 How are managed the priorities between LPBAM and others DMA transfer?
The LPBAM is based on DMA transfer, the same DMA channels priority arbitration principle applies.
Revision history
Contents
1 General information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 STM32CubeU5 main features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 STM32CubeU5 architecture overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1 Level 0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.1.1 Board support package (BSP). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3.2 Level 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.2.1 Middleware components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.3 Level 2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4 Utilities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.4.1 LPBAM Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
5.2.3 LL application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
6 FAQ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
6.1 What is the license scheme for the STM32CubeU5 MCU package? . . . . . . . . . . . . . . . . . . . 22
6.2 What boards are supported by the STM32CubeU5 MCU package? . . . . . . . . . . . . . . . . . . . 22
6.3 Are any examples provided with the ready-to-use toolset projects?. . . . . . . . . . . . . . . . . . . . 22
List of tables
Table 1. Macros for STM32U5 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 2. Boards for STM32U5 Series . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Table 3. Number of examples for each board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
Table 4. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
List of figures
Figure 1. STM32CubeU5 MCU package components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Figure 2. STM32CubeU5 MCU package architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 3. LPBAM Utility layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Figure 4. STM32CubeU5 MCU package structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 5. STM32CubeU5 examples overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 6. Secure and non-secure multi-projects structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14