5. Secure memory management (SMM)

5.1 Introduction

STM32H750xB and STM32H753xl microcontrollers offer a first set of protection mechanisms, which are similar to other STM32 Series:

A detailed description of these protection mechanisms is given in Section 4: Embedded flash memory (FLASH) .

STM32H750xB and STM32H753xl also offer an additional enhanced protection mode, the Secure access mode, that makes possible the development of user-defined secure services (e.g. secure firmware update or secure boot) and guarantees of a safe execution and protection of both code and data. This mechanism is described in details in Section 5.3: Secure access mode , Section 5.4: Root secure services (RSS) and Section 5.5: Secure user software .

The secure memory management unit is contained inside the D1 domain.

5.2 Glossary

The following terms will be used in herein:

Table 29. List of preferred terms

TermDescription
Device Security Level
Standard modeDevice state which allows the access to the user Flash memory, the option bytes and the bootloader area.
Secure access modeDevice state which allows the access to all the memory areas of the device.
Memory areas
System memoryST reserved memory area used to store ST ROM code.
User flash memoryFlash memory area used to store user code and data.
Secure user memory/area (1)This area can be configured to be accessed once after reset and be hidden for the firmware stored in the user flash memory after the code stored in this area is executed.

Table 29. List of preferred terms (continued)

TermDescription
Software services
BootloaderSTMicroelectronics software executed at reset which allows the download of firmware from regular communication ports.
Root secure services (RSS)STMicroelectronics software which allows the access to secure services.
Secure user softwareUser software executed once after reset, which can be used to implement secure boot and secure firmware update (SFU).
Secure user software is located in secure user memory.
  1. 1. Secure user memory/areas are also named secure-hide protected (HDP) memory/areas.

5.3 Secure access mode

Some sensitive functions require safe execution from potential malicious software attacks. Secure firmware update (SFU) software is a good example of code that requires a high level of protection since it handles secret data (such as cryptographic keys) that shall not be retrieved by other processes.

STM32H750xB and STM32H753xl microcontrollers feature secure memory areas with restricted access. They allow building secure services that will be executed prior to any user application. These secure areas, together with the software they contain, are only accessible when configuring the device in Secure access mode.

Figure 15 gives an overview of flash memory areas and services in Standard and Secure access modes.

Figure 15. Flash memory areas and services in Standard and Secure access modes

Diagram illustrating flash memory areas and services in Standard and Secure access modes. The diagram is split into two columns: 'Standard mode' and 'Secure access mode'. In 'Standard mode', the top section is 'System memory' containing 'Option bytes (Bank 1 only)' and 'Bootloader'. The bottom section is 'User memory' containing 'User software'. In 'Secure access mode', the top section is 'Secure bootloader' containing 'Option bytes (Bank 1 only)', 'Bootloader', and 'RSS' (Root Secure Services). The middle section is 'Secure user memory' containing 'Secure user software'. The bottom section is 'User software'. Arrows on the left indicate the boundaries for 'System memory' and 'User memory' in standard mode. A label 'MSv43701V3' is in the bottom right corner.
Diagram illustrating flash memory areas and services in Standard and Secure access modes. The diagram is split into two columns: 'Standard mode' and 'Secure access mode'. In 'Standard mode', the top section is 'System memory' containing 'Option bytes (Bank 1 only)' and 'Bootloader'. The bottom section is 'User memory' containing 'User software'. In 'Secure access mode', the top section is 'Secure bootloader' containing 'Option bytes (Bank 1 only)', 'Bootloader', and 'RSS' (Root Secure Services). The middle section is 'Secure user memory' containing 'Secure user software'. The bottom section is 'User software'. Arrows on the left indicate the boundaries for 'System memory' and 'User memory' in standard mode. A label 'MSv43701V3' is in the bottom right corner.
  1. 1. The protected areas that can only be accessed in Secure access mode are shown in blue.
  2. 2. A single secure user area can be defined for each bank.

5.3.1 Associated features

The Secure access mode can be configured through option bytes. When it is set, it enables access to:

For a summary of access rights for each core, refer to Section 5.6: Summary of flash protection mechanisms .

5.3.2 Boot state machine

In Secure access mode, booting is forced in the RSS whatever the boot configuration (boot pins and boot addresses). The RSS can either set a secure user memory area if one has been requested (see Section 5.5.2: Setting secure user memory areas ) or jump directly to the existing secure user memory. The code located in secure user memory is executed before the main user application and the bootloader. If no service is required and no secure area is defined, the RSS jumps to the boot address selected by BOOT0 pin value.

Figure 16 shows the boot state machine.

Figure 16. Bootloader state machine in Secure access mode

Flowchart of the Bootloader state machine in Secure access mode. The process starts with a System Reset, which can lead to either Secure access mode or Standard mode. In Secure access mode, it checks if 'resetAndInitializeSecureArea' is requested and no secure area is set. If yes, it sets the secure area(s) and resets. If no, it checks if any secure area is set. If no, it boots at the current address. If yes, it checks if bank swapping is on. If on, it checks the number of secure areas (1 or 2). If 1, it swaps banks off and resets. If 2, it sets the secure boot address to the user area of Bank 1. If bank swapping is off, it checks the number of secure areas (1 or 2). If 1, it sets the secure boot address to the user area of Bank 1 or 2. If 2, it sets the secure boot address to the user area closer to the current boot address. All secure boot addresses lead to a jump to the secure boot address, which then leads to the Secure User Area 1 or 2, and finally exits to the user application. Standard mode leads directly to booting at the current address.
graph TD
    SR[System Reset] -- Secure access mode --> RSS[ ]
    SR -- Standard mode --> Boot[Boot @]
    subgraph RSS [RSS]
        RSS --> Q1{resetAndInitializeSecureArea
as service requested & no
secure area already set?} Q1 -- yes --> Set[Set secure area(s)] Set --> Reset[Reset] Q1 -- No --> Q2{Any secure area is
set?} Q2 -- No --> Boot Q2 -- Yes --> Q3{Bank swapping
on?} Q3 -- Yes --> Q4{Number of
Secure area} Q3 -- No --> Q5{Number of
Secure area} Q4 -- 1 --> Swap[Bank
swapping off] Swap --> Reset Q4 -- 2 --> BootAddr1[Secure boot@=
Secure User area of
Bank 1] Q5 -- 1 --> BootAddr2[Secure boot@=
Secure User area of
Bank 1 or 2] Q5 -- 2 --> BootAddr3[Secure boot@=
Secure User area closer
to current boot @] BootAddr1 --> Jump[Jump to Secure boot @] BootAddr2 --> Jump BootAddr3 --> Jump end Jump --> UserArea[Secure User Area 1 or 2] UserArea --> Exit[exitSecureArea (User
application @)] Exit --> App[User application] style RSS fill:#f9f,stroke:#333,stroke-width:1px style SR fill:#fff,stroke:#333,stroke-width:1px style Boot fill:#fff,stroke:#333,stroke-width:1px style App fill:#fff,stroke:#333,stroke-width:1px style Exit fill:#fff,stroke:#333,stroke-width:1px style UserArea fill:#fff,stroke:#333,stroke-width:1px style Jump fill:#fff,stroke:#333,stroke-width:1px style BootAddr1 fill:#fff,stroke:#333,stroke-width:1px style BootAddr2 fill:#fff,stroke:#333,stroke-width:1px style BootAddr3 fill:#fff,stroke:#333,stroke-width:1px style Q4 fill:#fff,stroke:#333,stroke-width:1px style Q5 fill:#fff,stroke:#333,stroke-width:1px style Q3 fill:#fff,stroke:#333,stroke-width:1px style Q2 fill:#fff,stroke:#333,stroke-width:1px style Q1 fill:#fff,stroke:#333,stroke-width:1px style Set fill:#fff,stroke:#333,stroke-width:1px style Reset fill:#fff,stroke:#333,stroke-width:1px style Swap fill:#fff,stroke:#333,stroke-width:1px

MSv50671V1

Flowchart of the Bootloader state machine in Secure access mode. The process starts with a System Reset, which can lead to either Secure access mode or Standard mode. In Secure access mode, it checks if 'resetAndInitializeSecureArea' is requested and no secure area is set. If yes, it sets the secure area(s) and resets. If no, it checks if any secure area is set. If no, it boots at the current address. If yes, it checks if bank swapping is on. If on, it checks the number of secure areas (1 or 2). If 1, it swaps banks off and resets. If 2, it sets the secure boot address to the user area of Bank 1. If bank swapping is off, it checks the number of secure areas (1 or 2). If 1, it sets the secure boot address to the user area of Bank 1 or 2. If 2, it sets the secure boot address to the user area closer to the current boot address. All secure boot addresses lead to a jump to the secure boot address, which then leads to the Secure User Area 1 or 2, and finally exits to the user application. Standard mode leads directly to booting at the current address.

1. On STM32H750xB devices, only Bank 1 secure user area is applicable and bank swapping is not available.

1.

5.3.3 Secure access mode configuration

Enabling Secure access mode

There is no restriction on how to activate Secure access mode on the device. It is configured through the SECURITY option bit in FLASH_OPTSR_CUR register (see Section 4.9.8: FLASH option status register (FLASH_OPTSR_CUR) ).

The Secure access mode becomes active after a system reset.

Disabling Secure access mode

Disabling Secure access mode is a more sensitive task as it can only be done if no more protected code exists on the device. As a result, to come back to Standard mode, secure user memories and PCROP/execute-only areas shall be removed before clearing the SECURITY option bit in the FLASH_OPTSR_CUR register.

Protected areas can be removed by performing a flash mass erase (refer to Section 4.3.10: FLASH erase operations for more details on mass erase sequence).

5.4 Root secure services (RSS)

The root secure services (RSS) are STMicroelectronics ROM code stored on the device. They are part of the security features. These firmware services are available in Secure access mode (see Section 4.5.5: Secure access mode ).

Table 30 gives the addresses of the application programming interface (API) described in the following sections.

Table 30. RSS API addresses

RSSRSS API address
RSS_getVersion0x1FF0 9500
RSS_exitSecureArea0x1FF0 9514
RSS_resetAndInitializeSecureAreas0x1FF0 9518

5.4.1 Secure area setting service

STMicroelectronics provides a service to perform the initialization of secure areas. This service can be called only once. It is executed after a system reset in Secure access mode prior to any other software stored in the device.

Caution: RSS software cannot be accessed (read, write, execute and debug) when the STM32H750xB and STM32H753xl operate in Standard mode. The service can be automatically accessed with ST programming tool, STM32CubeProgrammer, or called through a direct call to the resetAndInitializeSecureAreas function defined below.

resetAndInitializeSecureAreas

Prototypevoid resetAndInitializeSecureAreas(RSS_SecureArea_t area)
ArgumentsSecure user areas start and end addresses. One or two secure user areas can be set.
This service sets secure user area boundaries, following the values stored in the option byte registers:
Description
  • – SEC_AREA_START1 and SEC_AREA_END1 for bank 1
  • – SEC_AREA_START2 and SEC_AREA_END2 for bank 2
This service can be used only when a secure area is set for the first time.
A system reset is triggered after service completion.

5.4.2 Secure area exiting service

The RSS also provides the exitSecureArea service. This service must be called to jump to user application. It allows closing safely the secure user area to guarantee that its content can no more be accessed.

Contrary to the resetAndInitializeSecureAreas service, it does not trigger any system reset. exitSecureArea function is defined below:

exitSecureArea
Prototypevoid exitSecureArea (unsigned int vectors)
ArgumentsAddress of application vectors where to jump after exit
DescriptionThis service is used to exit from secure user software and jump to user main application.
There is no system reset triggered by this service

5.5 Secure user software

A secure user software is a trusted piece of code that is executed after device power-on or after a system reset. It allows building secure applications such as:

5.5.1 Access rules

Only accessible in Secure access mode, the secure user software is stored in the secure memory areas.

Only one user secure area can be configured per bank. If two secure areas are defined, the secure software that is executed is the one closer to current boot address.

After secure user software execution, the code shall jump to the main user application and prevent access to the secure user area. This is done by calling exitSecureAreas secure service with the application code address given as parameter.

Once in the application code, any access to the secure user area triggers a flash error.

5.5.2 Setting secure user memory areas

One secure area of configurable size can be set in each bank. The size of each area can be set from 512 bytes to full bank with a granularity of 256 bytes:

Note: If the secure area start address is equal to the secure area end address, the whole bank is considered as secure protected.

The above option bits can only be initialized through exitAndInitializeSecureAreas service.

If a secure area already exists, the secure user area code can update its own secure user area size or create a new one in the other bank.

5.6 Summary of flash protection mechanisms

Figure 17 and Table 31 summarize the access rights of the different flash memory areas, both in Secure access and Standard modes.

Figure 17. Core access to flash memory areas

Diagram showing the layout of flash memory areas. At the top is the RSS (Root Secure Services) block, followed by the Bootloader. Below are two banks, Bank 1 and Bank 2. Each bank contains a 'Secure user memory' block (labeled 'Secure user memory 1' and 'Secure user memory 2') and a 'User Memory' block (labeled 'User Memory 1' and 'User Memory 2'). The 'User Memory' blocks are preceded by a 'PCROP' (Protection) block. A legend at the bottom indicates that the blue color represents 'Secure access mode only'.
Diagram showing the layout of flash memory areas. At the top is the RSS (Root Secure Services) block, followed by the Bootloader. Below are two banks, Bank 1 and Bank 2. Each bank contains a 'Secure user memory' block (labeled 'Secure user memory 1' and 'Secure user memory 2') and a 'User Memory' block (labeled 'User Memory 1' and 'User Memory 2'). The 'User Memory' blocks are preceded by a 'PCROP' (Protection) block. A legend at the bottom indicates that the blue color represents 'Secure access mode only'.

Table 31. Summary of flash protected areas access rights

Access typeSoftware areaSecurity modeAccess
ExecutionPCROPAny
Secure user softwareSecure access(1)
Root secure servicesSecure access(1)
Read accessPCROPAnyNo
Secure user softwareSecure access(1)
Root secure servicesSecure access(1)
Debug accessPCROPAnyNo
Secure user softwareSecure accessNo
Root secure servicesSecure accessNo
  1. 1. Access rights granted after reset until code completion only.