STM32CubeMX

Table Of Contents

- STM32CubeMX documentation
- CubeMX User Manual
  - 1 STM32Cube overview
  - 2 Getting started with STM32CubeMX
  - 3 Installing and running STM32CubeMX
  - 4 STM32CubeMX user interface
  - 5 STM32CubeMX tools
  - 6 STM32CubeMX C Code generation overview
  - 7 Code generation for dual-core MCUs (STM32H7 dual-core product lines only)
  - 8 Code generation with TrustZone enabled (STM32L5 series only)
  - 9 Device tree generation (STM32MPUs only)
  - 10 Support of additional software components using CMSIS-Pack standard
  - 11 Tutorial 1: From pinout to project C code generation using an MCU of the STM32F4 series
  - 12 Tutorial 2 - Example of FatFs on an SD card using STM32429I-EVAL evaluation board
  - 13 Tutorial 3 - Using the Power Consumption Calculator to optimize the embedded application consumption and more
  - 14 Tutorial 4 - Example of UART communications with an STM32L053xx Nucleo board
  - 15 Tutorial 5: Exporting current project configuration to a compatible MCU
  - 16 Tutorial 6 - Adding embedded software packs to user projects
  - 17 Tutorial 7 - Using the X-Cube-BLE1 software pack
  - 18 Creating LPBAM projects
  - Appendix A STM32CubeMX pin assignment rules
  - Appendix B STM32CubeMX C code generation design choices and limitations
  - Appendix C STM32 microcontrollers power consumption parameters
  - Appendix D STM32Cube embedded software packages
  - Revision history
- Release Notes
  - Release details
  - Release fixes
  - Known limitations
    - Miscellaneous
    - 2.1. When selecting microcontrollers in the STM32C0 series
    - 2.2. When selecting microcontrollers in the STM32G0 series
    - 2.3. When selecting microcontrollers in the STM32G4 series
    - 2.4. When selecting microcontrollers in the STM32H5 series
    - 2.5. When selecting microcontrollers in the STM32H7 series
    - 2.6. When selecting dual-core microcontrollers in the STM32H7 series
    - 2.7. When selecting microcontrollers in the STM32L5 series
    - 3.4. How to improve the wake-up from Stop sequences without relying on the global SystemClock_Config()
    - 3.3. List pinout-compatible microcontrollers
    - 3.2. DDR binaries for the STM32MP1 boards
    - 3.1. Command line authentication required
    - 2.21. Symbolic links on Ubuntu
    - 2.20. User manual
    - 2.19. DDR test suite
    - 2.18. STM32CubeIDE toolchain
    - 2.13. When selecting microcontrollers in the STM32WL series
    - 2.11. When selecting microcontrollers in the STM32WB series
    - 2.17. When using additional software packs
    - 2.16. When using the Example Selector
    - 2.15. When using the Memory Management Tool
    - 2.14. When selecting microprocessors in the STM32MP1 series
    - 2.11.1. When selecting microcontrollers in the STM32WB0 product lines
    - 2.12. When selecting microcontrollers in the STM32WBA series
    - 2.13.1. When selecting microcontrollers in the STM32WL33 product lines
    - 2.10. When selecting microcontrollers in the STM32U5 series
    - 2.9. When selecting microcontrollers in the STM32U3 series
    - 2.8. When selecting microcontrollers in the STM32N6 series
- Running STM32CubeMX in command-line mode
- FAQ
- Community

# 5 STM32CubeMX tools

Figure 423. Tooltip

In this example, on the Pinout & Configuration panel, CORTEX_M33, FLASH, and GTZC are set, and correspond to the region configuration on the Memory Management Tool. They are grayed out, as they cannot be modified.

When an IP is under MMT control, a tooltip provides the info shown in Figure 425.

Figure 425. IP under control

Apply Application Regions settings to linker files

When this button is on, the linker scripts for the secure and non secure applications are generated, taking into account the configuration.

Figure 426. Linker files update

This example uses the FMC. Go to the Pinout & Configuration window (see Figure 427) and enable the IP.

Figure 427. Configure an external memory

When going back to the MMT, a new region corresponding to the added FMC is created.

Figure 428. New region created

Add a new region by pressing the plus button appearing in the white space when hovering with the mouse.

To add another external memory, go to the Pinout & Configuration view, and add OCTOSPI1 to Cortex-M33 Secure. Choose Single SPI, and specify Device Size and Device Type.

Figure 430. Adding a new memory

On the MMT there is now a new entry with OCTOSPI1.

• For our example, we need half of the available 128 Mbytes.

• Press the “+” button, set a name for the region (for instance: MyExternalRAM), and put 64 MB for its size.

Figure 431. Memory assignment

Configuring a memory region using the left panel

With the left panel (see Figure 432) you can adjust items such as starting position and size. In this example, the added region must be adjusted: we want it to be allocated to the non secure project, and to start in the middle of the RAM. By adjusting those values, the expected results appear (see Figure 433). The color is now pink (nonsecure), and the region starts in the middle of the RAM (OctoSPI1).

Figure 432. Left panel configuration

Figure 433. Allocating a region

Setting up a middleware memory location

The application needs ThreadX. Go back to the “Pinout & Configuration” tab. Choose ThreadX, then use the Use Dynamic Allocation under Memory Configuration.

Figure 434. Middleware memory allocation

To finish the configuration, go back to MMT. We want ThreadX to use a dedicated application region for its heap memory allocation. To do so, simply click the RAM region, and reduce its size to 17 Kbytes using the left panel. We then add a new region to the newly freed space, and call it MyThreadXHeap.

As ThreadX has been selected, on the Pinout & Configuration you can see a tick box called ThreadX Heap section. When this box is selected, the tool ensures that ThreadX memory allocation happens only in that particular region.

Figure 435. Middleware heap configuration

For performance reasons, part of the application must run on the internal memory (much faster than the external memory). To do so, remap the added external RAM to an available internal memory region:

• Go to the Pinout & Configuration tab

• Enable ICACHE, select the Memory address remap tick box

• Select a region and set the memory size to 64 Mbytes

• Change the Remap address to 0x9000 0000

Figure 436. Remapping the memory

• Go back to the MMT tab. Region 0x9000 0000 is named with Remapped, with the amount of RAM previously selected.

Figure 437. Remapped region is renamed

• There is also a Remap – External RAM(OCTOSPI1) added at address 0x0000 0000.

Figure 438. Remapped start address

• Add a new region named “MyRemappedRAM” at that address.

Figure 439. New region remapped

The default regions cannot be removed, but can be resized. As an example, the FLASH is where the application code is hosted. You cannot untick the Default Region.

Figure 440. Resizing default region

Changing the security of an application region mapped on aliased RAM or FLASH moves it in an aliased RAM or FLASH corresponding to the new security setting. Graphically, the region moves up and down, depending on the area it will go, as the same physical memory is seen by the core at different locations.

Code generation

• Go to the project manager, set a name to your project, Choose CubeIDE as a toolchain and press GENERATE CODE

• Navigate to the generated Secure Project and open the linker definition file. Under the Memories definition you will see the defined memories with their start address and

length. This file shows only the secure regions in green. Open the nonsecure linker file and check the same location for the memory regions allocated to the nonsecure area.

Figure 442. Memory map in linker file

5.5.3 STM32H7 single core and STM32U5 without TrustZone activated

Feature: MMT usage, pinout, and configuration user interface

When the first toggle button is ON, Cortex-M33 (MPU for STM32U5) and Cortex-M7 (MPU for STM32H7) are under MMT control (see, respectively, Figure 443 and Figure 444): modes and parameters become read-only.

The middle panel (see, respectively, Figure 445 and Figure 446 for STM32U5 and STM32H7) represents the memory, split into two columns: the left one is the memory seen by the core(s), the right one the memory set-up for the application.

For the new project created under STM32CubeMX the tool creates the default application region to generate a valid project.

Figure 443. MMT usage (STM32U5)

Figure 444. MMT usage (STM32H7 single core)

Figure 445. MMT view for U5 without TrustZone

The middle panel represents the memory, split into two columns: the left one is the memory seen by the core(s), the right one the memory set-up for the application.

For the new project created under STM32CubeMX the tool creates the default application region to generate a valid project. The default data region can be updated by the user to choose another region as RAM, but there must always be a default data region ( Figure 447).

Figure 447. Default data region

FMC impact on MMT

When activating FMC and SDRAM Bank1, a tab mapping (see Figure 448) is displayed, with three options:

1. Default mapping (see Figure 449): MMT initializes as default position of SDRAM Bank1, SDRAM Bank2, and NOR PSRAM (default viewer of MMT)

2. NOR/PSRAM bank and SDRAM Bank1/2 are swapped: MMT swaps the position of SDRAM Bank1 and NOR PSRAM Bank1 (see Figure 450 and Figure 451)

3. SDRAM Bank2 remapped on FMC Bank2 and still accessible at default mapping: MMT updates the position of SDRAM Bank1 to be remapped on position of FMC Bank2 (see Figure 452 and Figure 453)

Figure 453. After remapping

ETH impact on MMT for STM32H7 single core

An example of MMT configuration of the ETH IP on the STM32H723VETx MCU

1. Activate the IP ETH:

– MMT creates three application regions within the MMT view.

– To change the start address and the size of each region, update the ETH parameters.

2. Press the radio button “Apply Application region Settings to Peripherals ON”, ETH will be partially under MMT control.

3. Press the Generate Code button to generate code for both applications.

– Apply Application Regions settings to linker files:

4. When this button is on, the linker scripts are generated, considering the configuration.

5. After the code generation, navigate to the generated folder:

– Open the linker definition file.

– Under the Memories definition you can see the memories with their start address and length, according to the configuration made in STM32CubeMX.

Figure 454. ETH MMT regions

Figure 455. ETH configuration for STM32H723VETx MCU

5.5.4 STM32WBxx

Feature: MMT usage, pinout, and configuration user interface

When the first toggle button is ON, Cortex-M33 is under MMT control: its modes and parameters become read-only (see Figure 457).

The user must select the core and the STM32Cube firmware from a list. It is possible to choose any STM32Cube firmware version (see Figure 458).

The list proposed to user contains only the firmwares found in

STM32Cube_FW_WB_Vx/Projects / STM32_Copro_Wireless_Binaries/STM32WBxx (all .bin files). Firmware Update Service (FUS) and SafeBoot firmware are not proposed, so they are not in the MMT list.

This example is based on an STM32WB5x MCU, so the list must contain only stm32wb5x_x binaries. The button “Refresh” is used to refresh the binaries list version in the repository of STM32Cube firmware (see Figure 459).

Figure 459. MMT configuration for STM32WB5x

After selecting the binary firmware, the MMT view is displayed and the reserved regions of Cortex M0+ are created.

The middle panel represents the memory, split into two columns: the left one is the memory seen by the core(s) Cortex-M4, the right one the memory set-up for the application.

For the new project created under STM32CubeMX the tool creates the default application region to generate a valid project.

5.5.5 STM32H7 Dual-core without Trust Zone activated

Feature: MMT usage, pinout, and user interface configuration

When the first toggle button is ON, Cortex-M7_BOOT (MPU) and Cortex-M7_APPLI (MPU) are under MMT control: their modes and parameters become read-only.

Figure 460. Cortex_M7 mode and configuration

Feature: MMT usage and linker script

When the two radio buttons are activated, the memory management parameters are available, and the linker file content is generated according to the configuration of application regions.

There are two possible configurations of the application regions for the code generation:

• First configuration:

• Second configuration:

The Cortex-M7 and Cortex-M4 contexts are managed by the MMT. Each context has its own application region (AppReg0 and AppReg1, respectively).

User interface

Figure 462. Default settings

The middle panel represents the memory, split into three columns: the left one is the memory seen by the cores (CM7 and CM4), the middle one the memory set-up for the application in Context Cortex-M7, the right one the memory set-up for the application in the Context Cortex-M4.

For the new project created under STM32CubeMX, the tool creates the default application region to generate a valid project.

Region information

Clicking on a particular region in the Application Regions column shows the associated details on the left hand side.

STM32CubeMX automatically adds a 4 Gbytes region for the system core, even if you are not planning to use the MMT.

An example of MMT configuration of the OPENAMP Middleware on the STM32H755XIH6TR MCU

Below are the steps for configuring the MMT with OPENAMP activated on the STM32H755XIH6TR MCU.

1. Choose a supported MCU.

Figure 463. Choose an STM32H7 dual-core product

2. Click on the Start Project button, then choose Yes on the “Memory Protection Unit for Cortex-M7” dialog box.

Figure 464. Region 0 added

Note: STM32CubeMX applies the default configuration, then adds a 4 Gbytes region called “Region 0” under the Cortex_M7 parameters. The new parameters can be checked using the Pinout and Configuration tab.

3. Select “Tools” in the toolbar

– Choose Memory Management.

– Activate the Memory Management Tool support by clicking the button “Apply Application Regions Settings to Peripherals”.

Figure 465. Activate Memory Management support

The default application regions are in exclusive mode (context sharing is unselected). A reserved region in the other context is created and mentioned as “Mx non-shared region”.

Figure 466. Default setting for new application region

4. Add a new region by pressing the “+” button that appears in the white space when hovering with the mouse.

5. Select “Context sharing (M7, M4)”, automatically another region is created with the same name, start address, and size.

6. Select the Project Manager tab.

7. Give a name to the project and press the Generate Code button.

8. OPENAMP activation

– Configure the NVIC1 and 2 and select their related HSEM global interrupts. – Activate the Middleware OPENAMP_M4.

– MMT creates two application regions for each core. The Master regions are defined by attribute mode.

Figure 468. Configure NVIC1 and NVIC2, and select their HSEM global interrupt

Figure 470. OPENAMP_M4 parameters settings

> 9. Press the Generate Code button to generate the code for both applications.

Apply Application Regions settings to linker files

When the second radio button is on, the linker scripts for the CM7 and CM4 projects are generated considering the configuration.

Figure 472. Linker files update (stm32h755xxx_flash_cm4.icf)

The middleware can be enabled or disabled:

• If disabled, it automatically chooses the configured memory along with the associated driver and sets the execution memory location in the linker file.

• If enabled, the two regions and corresponding ‘export symbol’ must be added in the generated linker file.

After the code generation, navigate to the generated folder to check the linker file updates.

Example of MMT configuration of the ETH on STM32H755XIH6TR MCU

1. Activate the IP ETH: MMT creates three application regions for each core. To change the start address and the size of each region, update the ETH parameters.

Figure 474. Configuration of ETH IP

2. Press the radio button “Apply Application region Settings to Peripherals ON”, ETH will be partially under MMT control.

3. Press the Generate Code button to generate code for both applications.

Figure 476. IP configuration

Apply Application Regions settings to linker files:

4. When this button is on, the linker scripts for the CM7 project and CM4 project are generated, considering the configuration.

5. After the code generation, navigate to the generated folder:

– Under the CM7 Project, open the linker definition file.

– Under the Memories definition you can see the defined memories with their start address and length, according to the configuration made in STM32CubeMX.

Figure 477. Defined memories under the linker file (Cortex-M7)

Figure 478. Defined memories under the linker file (Cortex-M4)

Feature: MMT usage, pinout, and configuration user interface

When the first toggle button is ON, Cortex-M7_BOOT (MPU) and Cortex-M7_APPLI (MPU) are under MMT control: their modes and parameters become read-only.

Figure 479. MMT usage

Linker files content is generated according to the configuration of application regions.

Only “Boot” and “Appli” contexts are managed by the MMT. Each context has its own application region (AppReg0 and AppReg1, respectively).

User interface

Figure 480. Default settings

The middle panel represents the memory, split into three columns: the left one is the memory seen by the core(s), the middle one the memory set-up for the application in Context Boot, the right one the memory set-up for the application in the Context Appli.

For the new project created under STM32CubeMX, the tool creates the default application region to generate a valid project.

Region information

Clicking on a particular region in the Application Regions column shows the associated details on the left hand side.

STM32CubeMX automatically adds a 4-Gbyte region for the system core, even if you are not planning to use the MMT.

1. Choose a supported MCU (the following example is based on STM32H7R3A8I6).

Figure 481. Choose an STM32H7R product

2. Click on the Start Project button, then choose “Yes” on the “Memory Protection Unit for Cortex-M7” dialog box.

STM32CubeMX applies the default configuration, then adds a 4-Gbyte region called

“Region 0” under the CORTEX_M7_BOOT parameters, and a 4-Gbyte region called “Region 0” under the CORTEX_M7_APPLI parameters. The two regions start at the same address, adjust it to avoid overlap.

The new parameters can be checked using the Pinout and Configuration tab.

Figure 483. Region0 added

3. Select the Tools tab:

a) Choose Memory Management

b) Activate the Memory Management Tool support by clicking on “Apply Application

Regions Settings to Peripherals”

Figure 484. Activate Memory Management support

4. Select the Project Manager tab

5. Give a name to the project and press the Generate Code button: a warning message is displayed.

The flash region overlap issue can be solved in different ways, the preferred one goes through the following steps:

a) Select the Pinout and configuration tab

b) Enable XSPI1 for the boot context and choose the ‘Single SPI’ mode

Figure 486. Configure the XSPI

c) Activate the Middleware EXTMEM_MANAGER for the boot context:

> > MMT solves the issue

> Press the Generate Code button to generate code for both applications. The overlap message does not appear any longer.

Figure 487. EXT_MEM_MANAGER

Code generation configuration

The application regions settings can be applied to peripherals on the left-hand side of the screen. The concerned peripherals are shown on the associated tooltip. This can impact their availability on the pinout screen configuration.

Figure 488. Tooltip

In this example, on the Pinout & Configuration panel, Cortex-M7_BOOT (MPU) and Cortex-M7_APPLI (MPU) are set and correspond to the region configuration on the Memory Management Tool. They are grayed out, as they cannot be modified.

Figure 489. IP configuration

Apply Application Regions settings to linker files

When this button is on, the linker scripts for the Boot project and Appli project are generated, taking into account the configuration.

Figure 490. Linker files update

Figure 491. Memory assignment for context Boot H7RS

EXTMEM_MANAGER when using H7Rx/H7Sx

The middleware can be used with the “Select boot code generation” disabled or enabled.

If disabled, MMT automatically chooses the configured memory along with the associated driver, and sets the execution memory location in the linker file. This is the most straightforward way of configuring an external memory.

If enabled, by activating the “Select boot code generation” you can choose “Execute in Place” or “Load and Run”

• Execute in Place chooses and configures the memory zones

• Load and Run lets the user choose source, destination memory, and addresses to jump to. The configuration is translated into the linker file. The user must provide the source and destination addresses.

Figure 492. EXTMEM_MANAGER “Select boot code generation” disabled

After the code generation, navigate to the generated folder.

• Under the boot Project, open the linker definition file. • Under the Memories definition you can see the defined memories with their start address and length, according to the configuration made in STM32CubeMX.

Figure 497. Linker files

Three option bytes can be used to configure the regions in the MMT. To see them, activate the IP FLASH on the Pinout and Configuration tab.

Figure 498. Flash option bytes

The option bytes interacting with the MMT are:

• ECC_ON_SRAM:

– Linked to the AXI SRAM4 region on the MMT

– When value is “disable” or “no update”, the AXI SRAM4 region size is set to 72 KB

– When value is set to “enable” the AXI SRAM4 region is removed

• DTCM_AXI_SHARED:

– Linked to the AXI SRAM3 region on the MMT

– When set to 0 or 3, the AXI SRAM3 region size is set to 128 KB, and the size of region named DTCM is set to 64 KB

– When set to 1, the AXI SRAM3 region size is set to 64 KB, and the size of region named DTCM is set to 128 KB

– When set to 2, the AXI SRAM3 region is removed, and the size of region named DTCM is set to 192 KB

• ITCM_AXI_SHARED:

– Linked to the AXI SRAM1 region on the MMT

– When set to 0 or 3, the AXI SRAM1 region size is set to 128 KB

– When set to 1, the AXI SRAM1 region size is set to 64 KB

– When set to 2, the AXI SRAM1 region size is removed

Figure 499. ECC_ON_SRAM enabled and DTCM_AXI_SHARED set to 2

ETH impact on MMT when using H7RS/H7SX

An example of MMT configuration of the ETH IP on the STM32H7R3A8Ix MCU

1. Activate the IP ETH:

– MMT creates three application regions for each context.

– To change the start address and the size of each region, update the ETH parameters.

2. Press the radio button “Apply Application region Settings to Peripherals ON”, ETH will be partially under MMT control.

3. Press the Generate Code button to generate code for both applications.

– Apply Application Regions settings to linker files:

4. When this button is on, the linker scripts are generated, considering the configuration.

5. After the code generation, navigate to the generated folder:

– Open the linker definition file.

– Under the Memories definition you can see the memories with their start address and length, according to the configuration made in STM32CubeMX.

Figure 500. ETH MMT regions for STM32H7R3A8Ix

Figure 501. ETH configuration for STM32H7R3A8Ix

Figure 503. Defined memory regions under the linker file of the application context

Feature: MMT usage, pinout, and configuration user interface

When the first toggle button is ON, Cortex-M0+ (MPU) is under MMT control: its modes and parameters become read-only (see Figure 504).

Figure 504. MMT usage

The middle panel represents the memory, split into two columns: the left one is the memory seen by the core Cortex-M0+, the right one the memory set-up for the application.

Figure 505. User interface

For a new project created under STM32CubeMX, the MMT creates the default application region to generate a valid project.

Apply Application Regions settings to linker files

When this button is on, the linker scripts for the project are generated, considering the configuration.

• The REGION_ROM is a default code region used in linker.

• The linker file copies the STM32Cube firmware linkers files and only MMT region is updated or added.

• OTA tag is not managed by MMT and usually exists in the linker file.

Figure 506. Linker files update

Impact on STM32WB09 RADIO

When this IP is activated, a reserved region “Blue Core Config” calculated by value of CFG_NUM_RADIO_TASKS, which varies from 1 to 128, is added.

Figure 507. Impact on RADIO (STM32WB09)

MMT usage, pinout, and configuration of the user interface

MMT interaction with peripherals starts from the moment the user enters their interfaces:

• Checks their settings

• Updates other peripherals involved in the memory map configuration

The peripherals are updated only when the first toggle button is “ON” in the panel Memory Management (under STM32CubeMx Tools).

MMT updates the scripts only when the second toggle button is ON. The linker file content is generated according to the configuration of the application regions.

The applicative regions are saved in the user project even if the first toggle button is OFF.

Feature under MMT control for secure and nonsecure domains

When the first toggle button is ON, the following features are controlled by MMT (their modes and parameters become read-only):

• CORTEXM55-FSBL (MPU)

• CORTEXM55_S (MPU)

• CORTEXM55_NS (MPU)

• SAU

• RIF (RISAF panel)

Figure 508. Feature under MMT control (secure and nonsecure domains)

Feature under MMT control for secure domains

When the first toggle button is ON the following features are controlled by MMT (their modes and parameters become read-only):

• CORTEXM55-FSBL (MPU)

• CORTEXM55_S (MPU)

• RIF (RISAF panel)

Figure 509. Feature under MMT control (secure domains only)

Application regions for secure and nonsecure domains

Only FSBL, CORTEX_M55_S, and CORTEX_M55_NS contexts are managed by the MMT. Each context has its own application region.

In the memory layout the CORTEX_M55_S and CORTEX_M55_NS use the same column for application regions.

Figure 510. Memory layout for secure and nonsecure domains

Application regions for secure domains

Only FSBL and CORTEX_M55_S contexts are managed by the MMT. Each context has its own application region.

Figure 511. Memory layout for secure domains

Description of the memory layout in STM32CubeMX user interface

The memory is split in three columns:

1. The left one is the memory seen by the core(s)

2. The middle one is the memory set-up for the application in FSBL context

3. The right one is the memory set-up for the application in the Context Appli

For the new project under STM32CubeMX, the tool creates the default application region to generate a valid project.

Region information

Clicking on a particular region in the Application Regions column shows the associated details on the left-hand side.

Figure 512. Details about the clicked region in the FSBL context

STM32CubeMX automatically adds a 4-Gbyte region for the system core, even if you are not planning to use the MMT. Each region in the memory layout has its own characteristics, detailed at the bottom of the STM32CubeMX interface.

Figure 513. Regions designation for secure and nonsecure domains

Example of using MMT with STM32N6 products

1. Choose an MCU that supports the MMT feature (the following example is based on STM32N657Z0HxQ).

Figure 515. Project creation with an STM32N6 product

2. Choose the project structure, then initiate the project creation by clicking Start Project. Upon display of the TrustZone feature available dialog box, specify the domain configuration as Secure and Non-Secure domains before confirming with OK ( Figure 516). Choose the second option if you intend to work exclusively within secure domains ( Figure 517). STM32CubeMX applies the default configuration (RAM and FLASH regions are created in the MMT view).

Figure 516. Choosing the project structure (secure and nonsecure domains)

Figure 517. Choosing the project structure (secure domains)

3. Configure the MMT

a) Click on the Tools tab

b) Choose Memory Management panel

c) Activate the Memory Management Tool support by clicking on “Apply Application

Regions Settings to Peripherals”

Figure 518. MMT configuration (secure and nonsecure domains)

Figure 519. MMT configuration (secure domains)

4. Select the Project Manager tab

5. Give a name to the project and press the Generate Code button

Changes in RIF resulting from MMT activation

By selecting “Apply Application region Settings to Peripherals ON,” the RISAF feature (located in RIF panel) is put partially under MMT.

The RAM and flash memory regions are configured with the same security, read/write, and privilege parameters. They are represented as a single RISAF region in the view corresponding to RISAF 2 (CPU AXI RAM0).

Figure 520. Mapping between MMT regions and RISAF memory configurations

Configuration of memory regions in RISAF2 (CPU AXI RAM0) tab (region 2)

Under the RISAF2 (CPU AXI RAM0) tab, region 2 has two groups of settings:

• Fixed fields (grayed out): Region ID, Region Name, Start address Offset, Region size, and Filtering are read-only and cannot be modified.

• Controllable fields (editable): The security and access parameters (Secure, Read, Write, and Privilege) are editable and are updated by the (MMT).

The values that MMT can set for the Read, Write, or Privilege fields are 2 (00000010b) and 0 (00000000b).

Figure 521. Setting up the memory region of RISAF2 (CPU AXI RAM0) tab

Setting up memory subregions for RISAF 2 (CPU AXI RAM0) region 2

The Sub-Region A has two groups of settings:

• Fixed fields (grayed out): RISAF Region ID, SubRegion name, Start address Offset, Region size, SubRegion CID (fixed to 1) are read-only and cannot be modified.

• Controllable fields (editable): the security and access parameters (Secure, Read, Write, and Privilege are editable and are updated by the MMT.

Figure 522. Setting up memory subregions of RISAF 2 (CPU AXI RAM0) tab

On RISAF1 (TCM) tab, when the user adds an application region in ITCM or DTCM ranges, MMT adds automatically memory regions in RISAF1 (TCM) with the same start address as in the MMT layout.

Figure 523. Setting up memory regions of RISAF1 (TCM) tab

|image467|

On RISAF 7 (FLEXRAM) tab, when the user adds an application region in ITCM or DTCM ranges MMT adds automatically in RISAF 7 (FLEXRAM) memory regions with the same start address as in the MMT layout.

Use the configuration shown in Figure 525 for the right mapping between MMT settings and RISAF 7 (FLEXRAM) memory regions.

Figure 525. Configurations needed for RAMCFG FLEXRAM

|image468|

When FLEXRAM (RAMCFG) is active, not utilizing its default settings, and the user adds an application region in ITCM or DTCM ranges, the memory split is specifically defined. Example of configurations:

• D-TCM is set to SYSCFG_DTCM_256K

• I-TCM is set to SYSCFG_ITCM_256K

When adding a 256 KB application region that overlaps the ITCM and DTCM ranges:

• The configuration of RISAF1 (TCM) remains consistent for its allocated portion.

• Any memory belonging to that region above 0x340020000 is automatically redirected

(or split) and configured under RISAF7 (FLEXRAM). This segment starts at 0x340020000 and is treated as the beginning 0x00000000 offset of the RISAF7 region.

Figure 526. Setting up memory regions of RISAF1 (TCM) and RISAF7 (FLEXRAM) tabs

|image469|

When the user applies a custom FLEXRAM configuration, such as:

• D-TCM to SYSCFG_DTCM_256K, I-TCM to SYSCFG_ITCM_64K, or

• D-TCM: SYSCFG_DTCM_256K, I-TCM: SYSCFG_ITCM_128K, or

• D-TCM: SYSCFG_DTCM_256K, I-TCM: SYSCFG_ITCM_256K

a warning appears, indicating that the flash memory region overlaps with the memory area reserved to FLEXRAM.

Figure 527. Overlap with FLEXRAM

|image470|

To avoid the warning, locate the flash memory region to another range, and update the configuration of FLEXRAM.

On RISAF4 (NPN master1), RISAF5 (NPN master2), and RISAF6 (CPU master) tabs RISAF4/5 are available.

Configuration: add two application regions:

• Region 1: start address 0x34200000, size 1792 KB in FSBL (S) context

• Region 2: start address 0x24200000, size 1792 KB in Appli NS context

Figure 528. Configurations of the application regions on the MMT view

|image471|

The MMT adds:

• Two RISAF regions in RISAF4 (secure region, nonsecure region), see Figure 529

• Two RISAF regions in RISAF5 (secure region, nonsecure region), see Figure 530

• Two RISAF regions in RISAF6 (CPU master), see Figure 531

Figure 529. Setting up memory regions of RISAF4 (NPU master 0)

|image472|

Figure 531. Setting up memory regions of RISAF6 (CPU master)

|image473|

The two secure regions in RISAF4 and RISAF5 are consolidated into a larger secure region, identified and managed in RISAF6. The two nonsecure regions in RISAF4 and RISAF5 are consolidated into a larger nonsecure region, identified and managed in RISAF6.

RISAF8(CACHEAXI):

• When the IP CACHEAXI is enabled, MMT must remove the address range shown in the figures below.

|image474|

• Add application region in CACHEAXI range (CACHEAXI must be disabled)

|image475|

• MMT add in RISAF 8(CACHEAXI) the regions with start offset like in MMT view RISAF9(VENCRAM):

- When the IP VENC is enabled MMT must delete the range illustrated in the figure below.

  > Figure 536. VENC enable

  > |image476|

  > Figure 537. MMT view for VENCRAM

  > |image477|

  > • Adding application region in VENCRAM range(user should disable VENC when it is activated)

  > Figure 538. Adding regions in VERCRAM

  > |image478|

  > Figure 539. RISAF9 VENCRAM

  > |image479|

  > • MMT add the regions in RISAF9 (VENCRAM) with start offset like in MMT view.

  > On RISAF14(FMC) tab the available FMC (Flexible Memory Controller) ranges include:

  > • FMC Bank 1

  > • FMC SDRAM Bank 1

  > • FMC SDRAM Bank 2

  > Configuration:

  > • Configure the FMC IP

  > • Add application regions in FMC ranges

  > Figure 540. Configurations of FMC added regions in MMT view

  > |image480|

  > MMT adds in RISAF14 (FMC) regions with the same start address as in MMT view (no offset).

  > Figure 541. Setting up the memory regions for the RISAF14 (FMC) tab

  > |image481|

  > EXTMEM_MANAGER

  > Code generation configuration

  > • The application regions settings can be applied to peripherals on the left-hand side of the screen. The concerned peripherals are shown on the associated tooltip.

  > • The MMT configuration may impact their availability on the pinout screen configuration.

  > • The EXTMEM_MANAGER can be used with the “Select boot code generation” parameter enabled or disabled.

  > – If disabled, MMT automatically chooses the configured memory along with the associated driver and sets the execution memory location in the linker file. This is the most straightforward way of configuring an external memory.

  > – If enabled, by activating the “Select boot code generation” you can choose “Execute in Place” or “Load and Run”

  > Figure 542. EXTMEM_MANAGER in the MMT view

  > |image482|

  > The activation of the EXMEM_MANAGER depends upon the XSPIx activation.

  > 1. Go to the Pinout and Configuration tab

  > 2. Enable XSPI1 for the FSBL context and choose “Single SPI” mode

  > 3. Activate the middleware EXTMEM_MANAGER in the FSBL context

  > 4. Activate XSPIM and XSPI instances (XSPI1/2/3) Figure 543. Setting up the XSPI feature

  > |image483|

  > Figure 544. Setting Select boot code generation parameter for EXTMEM_MANAGER

  > |image484|

  > For the selection of the boot system there are two possibilities:

  > 1. Execute In Place (Figure 545) chooses and configures the memory zones.

  > 2. Load and Run (Figure 547) lets the user choose source, destination memory, and addresses to jump to.The configuration is translated into the linker file. The user must provide the source and destination address.

  > Figure 545. Selection of the boot system - Execute In Place

  > |image485|

Figure 546. Configuration of the MMT view after enabling XIP

|image486|

Figure 548. Configuration of MMT view after choosing Load and Run as boot system

|image487|

Once the code is generated, follow these steps:

1. Navigate to the generated project folder.

2. In the boot Project directory, open the linker definition file (usually an .ld or .icf file).

3. In the Memories definition section you can review the memory blocks (start addresses and lengths) that reflect your configuration settings.

Figure 549. Defined linker script for XIP

|image488|

Figure 550. MMT linker file after choosing Load and Run as boot system

|image489|

Example of MMT configuration for the ETH IP on the STM32N645B0HxQ MCU

Configure the ETH:

> • For secure domains:

– Activate the ETH: MMT creates three application regions for each context Figure 551. ETH MMT regions for STM32N647L0HxQ

|image490|

– Update the start address and the size of each region, update the ETH parameters.

– Press the radio button “Apply Application region Settings to Peripherals ON”, to make ETH partially under MMT control ( Figure 552).

– Press the Generate Code button to generate code for both applications.

– Apply Application Regions settings to linker files:

Figure 552. MMT view after adding ETH memory regions

|image491|

When this button is on, the linker scripts are generated, considering the configuration. After the code generation, navigate to the generated folder:

– Open the linker definition file.

Figure 553. ETH linker file (fully secure domain only)

|image492|

Figure 554. ETH MMT regions (secure domains only)

|image493|

– Under the Memory definition you can see the memory parts with their start address and length, according to the configuration made in STM32CubeMX. If an application region overlaps an ETH region a warning is displayed in the MMT log.

Figure 555. Warning in case of overlap between application and ETH regions

|image494|

- The default parameters are used for the secure context, but if the selected context is nonsecure, other nonsecure parameters are displayed.

  > Impact of configuring the ETH memory regions with ETH on RISAF panels

  > Figure 556. RISAF 3 (CPU AXI RAM1) memory regions

  > |image495|

  > For secure and nonsecure domains ETH application regions are created for the selected contexts.

  > Figure 557. ETH application regions for secure and nonsecure domains (part 1)

  > |image496|

  > Figure 558. ETH application regions for secure and nonsecure domains (part 2)

  > |image497|

  > 5.5.9 Notification MMT/boot path (STM32H7RS and STM32H5)

  > After the activation of boot path and MMT, all regions of MMT are deleted and replaced by the regions of Boot path in Appli context.

  > In this example, we use the boot path OEM-iRoT for STM32H7RS and for STM32H5.

  > Figure 559. MMT/boot path (STM32H7RS)

  > |image498|

  > |image499|

  > The linker files are copied from STM32Cube firmware of boot path, and MMT integrates all added application regions (App_User).

  > • Open the linker files STM32H7S3I8KX_OEMiROT_Appli_app.ld or

  > STM32H523CETX_FLASH.ld (respectively, left or right side of Figure 561)

  > • Look at the memory definition: check the App_User declaration in the Appli project in case of an OEM-iRoT boot path (see Figure 562 and Figure 563).

  > Figure 561. Linker files location (STM32H7RS on the left, STM32H5 on the right)

  > |image500|