7. Embedded flash memory (FLASH)

7.1 Introduction

The embedded flash memory (FLASH) manages the accesses of any master to the up to 2 Mbytes of embedded nonvolatile memory. It implements read, program, and erase operations, error corrections, as well as various integrity and confidentiality protection mechanisms.

FLASH manages the automatic loading of nonvolatile user option bytes at power-on reset, and implements the dynamic update of these options. It also features a high-cycle data area, a one-time-programmable (OTP) area, a secure key storage area (OBKeys), and a read-only area configured by STMicroelectronics during manufacturing.

7.2 FLASH main features

7.3 FLASH functional description

7.3.1 FLASH block diagram

Figure 22 shows the embedded flash memory block diagram.

Figure 22. FLASH block diagram (simplified)

Figure 22: FLASH block diagram (simplified).

This block diagram illustrates the internal architecture of the FLASH memory system. At the top, a DEBUG block connects to the SBS (System Bus Security) block via dbg_en and Cert_ok signals. The SBS block is central, receiving addresses , Product state , HDPL , and OBK-HDPL . It interfaces with RCC (Reset and Clock Control) via po_rst and flash_rst , and with TAMP (Tamper) via tamper_in and tamper_out . The SAES (Secure AES) block receives keybus from Backup registers and provides Epoch and HWKEY to the SBS .

The main FLASH block contains two AHB interfaces. A 32-bit AHB bus connects to an AHB interface for the Configuration port , which leads to Register banks (including OB words ) and a Keyb i/f . A 128-bit AHB bus connects to another AHB interface for User, system flash access and read-only, OTP area, engi, user option and high-cycle data . Both interfaces connect to the Flash interface logic . The IRQ logic outputs a flash_it signal.

The Flash interface logic manages two memory banks: NVM Bank1 and NVM Bank2 . Each bank is connected via a 128 -bit data bus and control lines for ECC, redundancy and Control, Status . The entire system is labeled FLASH at the bottom right.

Figure 22: FLASH block diagram (simplified).

7.3.2 FLASH signals

The flash memory has two AHB connections, namely the flash AHB register interface and the main AHB interface.

Flash AHB register interface

Main AHB interface

The AHB data bus size is 128 bits. This interface is used to handle three different targets:

The main AHB interface is implemented as follows:

By default, all the AHB memory range is cacheable. For regions where caching is not practical (OTP, RO, data area), MPU must be used to disable local cacheability.

7.3.3 Flash memory architecture and usage

Flash memory architecture

Figure 23 shows the organization supported by the embedded flash memory. By default, all the AHB memory range is cacheable. For regions where caching is unpractical (OTP, read-only, data) use MPU to disable local cacheability.

Figure 23. Embedded flash memory organization (2-Mbyte devices)

Figure 23: Embedded flash memory organization (2-Mbyte devices). The diagram shows the internal architecture of the flash memory, divided into two banks (Bank1 and Bank2). Bank1 contains User main memory (128 sectors of 8 Kbytes each), System memory (8 sectors of 8 Kbytes each), High-cycle data area (8 sectors of 6 Kbytes each), and Option byte key storage (2 sectors of 8 Kbytes each). Bank2 contains User main memory (128 sectors of 8 Kbytes each), System memory (8 sectors of 8 Kbytes each), High-cycle data area (8 sectors of 6 Kbytes each), and Option bytes. The diagram also shows the Flash interface logic, Main AHB system bus, and AHB config port. Special regions like Read-only, OTP, and OBK are also indicated.

The diagram illustrates the internal organization of a 2-Mbyte embedded flash memory device. It is divided into two banks, Bank1 and Bank2, each containing different types of memory sectors. Bank1 includes user main memory (128 sectors of 8 Kbytes), system memory (8 sectors of 8 Kbytes), high-cycle data area (8 sectors of 6 Kbytes), and option byte key storage (2 sectors of 8 Kbytes). Bank2 includes user main memory (128 sectors of 8 Kbytes), system memory (8 sectors of 8 Kbytes), high-cycle data area (8 sectors of 6 Kbytes), and option bytes. The diagram also shows the Flash interface logic, Main AHB system bus, and AHB config port. Special regions like Read-only, OTP, and OBK are also indicated.

Figure 23: Embedded flash memory organization (2-Mbyte devices). The diagram shows the internal architecture of the flash memory, divided into two banks (Bank1 and Bank2). Bank1 contains User main memory (128 sectors of 8 Kbytes each), System memory (8 sectors of 8 Kbytes each), High-cycle data area (8 sectors of 6 Kbytes each), and Option byte key storage (2 sectors of 8 Kbytes each). Bank2 contains User main memory (128 sectors of 8 Kbytes each), System memory (8 sectors of 8 Kbytes each), High-cycle data area (8 sectors of 6 Kbytes each), and Option bytes. The diagram also shows the Flash interface logic, Main AHB system bus, and AHB config port. Special regions like Read-only, OTP, and OBK are also indicated.

The embedded flash nonvolatile memory is composed of:

The overall flash memory architecture and its corresponding access interface is summarized in Table 48 .

Partition usage

Figure 24 shows how the embedded flash memory is used by STMicroelectronics and by the application software.

Figure 24. Embedded flash memory usage

Figure 24. Embedded flash memory usage diagram showing memory partitioning for STM32 Standard mode, SWAP_BANK=0, SWAP_BANK=1, and STM32 Secure access mode. The diagram illustrates the layout of User memory, System memory, and various reserved and option areas, with a legend for Secure area, Bank limits, and Notable startup addresses.

The diagram illustrates the memory layout for different STM32 modes. The columns represent: STM32 Standard mode, SWAP_BANK=0, SWAP_BANK=1, and STM32 Secure access mode. The rows represent different memory sections: User memory (Application software, Reserved, Debug authentication, Reserved, Bootloader, Reserved, Read-only and OTP area, Option byte key storage, User option bytes, Reserved), System memory (Application secure software, Application software, RSS, Debug authentication, ST iRoT, Secure library, Bootloader), and Mapped on AHB configuration port (Reserved, Read-only and OTP area, Option byte key storage, User option bytes, Reserved). The diagram also shows Bank1 and Bank2 labels, a 'Jump' arrow, and a legend for Secure area, Bank limits, and Notable startup addresses. The code MSV68817V2 is visible in the bottom right corner.

Figure 24. Embedded flash memory usage diagram showing memory partitioning for STM32 Standard mode, SWAP_BANK=0, SWAP_BANK=1, and STM32 Secure access mode. The diagram illustrates the layout of User memory, System memory, and various reserved and option areas, with a legend for Secure area, Bank limits, and Notable startup addresses.

User and system memories are used differently, according to product state and other option bytes settings:

Note: For more information on option byte setup for boot, refer to Section 7.4.6 .

7.3.4 FLASH read operations

Read operation overview

Read access to main and system flash memory operates as follows:

Read access to OTP, RO and flash high-cycle data operates as follows:

  1. 1. Flash data word of 137 bits is read and stored in a temporary buffer.
  2. 2. The interface parses the 137-bit data word, and selects the 16- or 32-bit data requested.
  3. 3. While parsing the 137-bit data word, (two) wait states are added, and the AHB bus is stalled.
  4. 4. If the application reads an OTP data or flash high-cycle data not previously written, a double ECC error is reported and only a word full of set bits is returned (see Section 7.3.9 for details). The read data (in 16 bits) is stored in FLASH_ECCDR register, so that the user can identify if the double ECC error is due to a virgin data or a real ECC error.
  5. 5. Reading two times the same address triggers two reads in the flash memory.
  6. 6. For 8-bit accesses, an AHB bus error is generated.

Note: The embedded flash memory can perform single-error correction and double-error detection while read operations are being executed (see Section 7.3.8 ).

Instruction prefetch

The Cortex-M33 fetches instructions and literal pools (constants/data) over the C-Bus and through the instruction cache, if it is enabled. The prefetch block aims at increasing the efficiency of C-Bus accesses when the instruction cache is enabled, by reducing the cache refill latency.

Prefetch is efficient in case of sequential code; prefetch in the flash memory allows the next sequential instruction line to be read from the memory, while the current instruction line is being filled in instruction cache and executed by the CPU.

Prefetch is enabled by setting the PRFTEN bit in the FLASH access control register (FLASH_ACR). PRFTEN must be set only if at least one wait state is needed to access the flash memory.

Adjusting read timing constraints

The embedded clock must be enabled and running before reading data from a nonvolatile memory.

To correctly read data from the memory, the number of wait states (LATENCY) must be correctly programmed in the access control register (FLASH_ACR), according to the main AHB interface clock frequency, and the internal voltage range of the device ( \( V_{core} \) ).

Table 45 shows the correspondence between the number of wait states (LATENCY), the programming delay parameter (WRHIGHFREQ), the embedded flash memory clock frequency, and the supply voltage range.

Table 45. Recommended number of wait states and programming delay

Number of wait states (LATENCY)Programming delay (WRHIGHFREQ)Interface clock frequency vs. \( V_{CORE} \) range (1)
VOS3 range 0.95 to 1.05 VVOS2 range 1.05 to 1.15 VVOS1 range 1.15 to 1.26 VVOS0 range 1.30 to 1.40 V
0 WS
(1 FLASH clock cycle)
000 to 20 MHz0 to 30 MHz0 to 34 MHz0 to 42 MHz
1 WS
(2 FLASH clock cycles)
20 to 40 MHz30 to 60 MHz34 to 68 MHz42 to 84 MHz
2 WS
(3 FLASH clock cycles)
0140 to 60 MHz60 to 90 MHz68 to 102 MHz84 to 126 MHz
3 WS
(4 FLASH clock cycles)
60 to 80 MHz90 to 120 MHz102 to 136 MHz126 to 168 MHz
4 WS
(5 FLASH clock cycles)
1080 to 100 MHz120 to 150 MHz136 to 170 MHz168 to 210 MHz
5 WS
(6 FLASH clock cycles)
N/AN/A170 to 200 MHz210 to 250 MHz

1. Voltage range from 1.26 to 1.30 V is not supported.

Adjusting system frequency

After power-on, the embedded flash memory is clocked by the 64 MHz high-speed internal oscillator (HSI), with a voltage range set at a scaled value of VOS3: a conservative 3 wait-state latency is specified in FLASH_ACR register (see Table 45 ).

When changing the bus frequency, the application software must follow the sequence described below, to tune the number of wait states required to access the memory.

To increase the CPU frequency:

  1. 1. If necessary, program the LATENCY and WRHIGHFREQ bits to the right value in the FLASH_ACR register, as described in Table 45 .
  2. 2. Check that the new number of wait states is taken into account by reading back the FLASH_ACR register.
  3. 3. Modify the embedded flash memory clock source and/or the clock prescaler in the RCC_CFGR register of the reset and clock controller (RCC).
  4. 4. Check that the new embedded flash memory clock source and/or the new AHB clock prescaler value are taken in account by reading back the embedded flash memory clock source status and/or the prescaler value in the RCC_CFGR register of the reset and clock controller (RCC).

To decrease the CPU frequency:

  1. 1. Modify the embedded flash memory clock source and/or the clock prescaler in the RCC_CFGR register of reset and clock controller (RCC).
  2. 2. Check that the embedded flash memory new clock source and/or the new clock prescaler value are taken into account by reading back the embedded flash memory clock source status and/or the AHB interface prescaler value in the RCC_CFGR register of reset and clock controller (RCC).
  3. 3. If necessary, program the LATENCY and WRHIGHFREQ bits to the right value in FLASH_ACR register, as described in Table 45 .
  4. 4. Check that the new number of wait states has been taken into account by reading back the FLASH_ACR register.

Error code correction (ECC)

The memory embeds an error correction mechanism. Single-error correction and double-error detection are performed for each read operation. For more details, refer to Section 7.3.8 .

Read errors

When the ECC mechanism is unable to correct the read operation, the memory reports read errors, as described in Section 7.9.10 .

Read interrupts

See Section 7.10 for details.

7.3.5 FLASH program operations

Program operation overview

Program operation consists in issuing write commands. The memory supports the execution of only one write-command at a time. Write-while-write is not supported. Nothing prevents overwriting a non-virgin flash word, but this is not recommended. The result may lead to invalid data and inconsistent ECC code.

User flash, OBK storage and system flash memories sectors

For the user and system flash memories, 9-bit ECC is associated to each 128-bit data flash word. In this case, the embedded flash memory must always perform write operations to nonvolatile memory with a 128-bit word granularity. Once the write buffer is full (128 bits), the Busy flag is set, and a programming operation is triggered.

There is a write buffer common to Bank1 and 2, which supports multiple write-access types (128, 64, 32, 16 or 8 bits). The application can decide to write from 8 bits to 128 words. In this case, a force-write mechanism to the 128 bits + ECC is used (see FW bit of FLASH_NS/SECCR register).

When the write request is issued to the memory, any new write request stalls the main AHB bus. Moreover, while a write operation is ongoing, any new read request to the same bank stalls the main AHB bus.

OTP, RO, flash high-cycle data

When the target memory is OTP, RO and flash high-cycle data sectors, 6-bits ECC code is associated to each 16-bit data flash word. The embedded flash memory supports 16- or 32-bit write operations (8-bit write operations are not supported). For 8-bit accesses, write accesses are ignored. There is no write data buffer. Each write access triggers a write in the flash memory.

Note: The OTP area is typically write-protected on the final product, as described in Section 7.3.9 .

The write protection check is performed at the reception of the write request (during address phase). Write protection is not checked anymore at the output of the write buffer. If a write protection violation is detected, the write operation is canceled, and write protection error (WRPERR) is raised in FLASH_NS/SECSR register.

Note: For write protections of main flash, ICP, and OTP see Section 7.6 .

Monitoring ongoing write operations

The application software can use a status flag located in FLASH_NS/SECSR to monitor ongoing write operations. Since only one operation is possible at a time, this flag indicates if any operation (write, erase, option change) is ongoing, whatever the bank.

They are cleared when the current operation ends, or in case of error.

Note: If the memory is busy at the receipt of the AHB write request, the CPU execution is stalled.

Enabling write operations

Before programming the user flash memory in Bank1 or in Bank2, the application software must ensure that the PG bit is set to 1 in FLASH_NS/SECCR. If not, an unlock sequence must be used (see Section 7.6.7 ), and the PG bit must be set.

When an option byte or an option byte key must be modified, or a mass erase must be started, the application software must ensure that FLASH_OPTCR is unlocked. If this is not the case, an unlock sequence must be used (see Section 7.6.7 ).

A separate mechanism with similar use exists for FLASH_NS/SECOBKCFGR. The control register must be unlocked prior to the start of any OBKeys storage modification. Writing the correct sequence to the FLASH_NSOBKKEYR unlocks FLASH_NSOBKCFGR. FLASH_SECOBKKEYR is linked to FLASH_SECOBKCFGR, as described in Section 7.6.7 .

Note: The application software must not unlock an already unlocked register, otherwise this register remains locked until the next system reset.

If needed, the application software can update the programming delay, as described in Adjusting programming timing constraints .

Writing to the FLASH control register FLASH_NS/SECCR and FLASH_OPTCR

The FLASH_NS/SECCR, FLASH_OPTCR and FLASH_NS/SECOBKCFGR registers are not accessible in write mode when the BSY bit is set. Any attempt to write these registers while the BSY bits is set causes the AHB bus to stall until SEC/NSBSY bit is cleared.

Single-write sequence

The recommended single-write sequence is the following:

  1. 1. Make sure protection mechanism does not prevent programming
  2. 2. Check that no memory operations are ongoing by checking the BSY bit in the FLASH_NS/SECSR register and CDBNE bits in the FLASH_NS/SECSR register. Check that the write buffer is empty by checking the WBNE bit in the FLASH_NS/SECSR register
  3. 3. Check and clear all the error flags due to previous programming/erase operation
  4. 4. Unlock the FLASH_NS/SECCR register, as described in Section 7.6.7 (only if this register is not already unlocked)
  5. 5. Enable write operations by setting PG bit in the FLASH_NS/SECCR register
  6. 6. Write one flash-word at aligned address

Note: NS/SECWBNE flag indicates if the 128-bit write buffer is waiting for new data.

Note: No erase request, options change request, OBK operation is allowed between the first write and the completion of the write operation.

  1. 7. Wait for the BSY bit to be cleared in the corresponding FLASH_NS/SECSR register
  2. 8. Clear PG bit in FLASH_NS/SECCR register if there are not any more programming requests

If step 6 is executed incrementally (for example byte per byte), the write buffer can become partially filled. In this case the application software can decide to force-write what is stored in the write buffer by using FW bit in FLASH_NS/SECCR register. In this particular case, the unwritten bits are automatically set to 1. If no bit in the write buffer is cleared to 0, the FW bit has no effect.

Note: The usage of a force-write operation prevents the application from updating, in a later stage, the missing bits with a value different from 1. This can lead to unexpected or inconsistent data, or ECC.

Adjusting programming timing constraints

Program operation timing constraints depend of the memory clock frequency, which directly impacts the performance. If timing constraints are too tight, the nonvolatile memory does not operate correctly, if they are too lax, the programming speed is not optimal.

The user must therefore trim the optimal programming delay through the WRHIGHFREQ parameter in the FLASH_ACR register. Refer to Table 45 for the recommended programming delay, depending upon the memory clock frequency.

FLASH_ACR configuration register is common to both banks.

The application software must check that no program/erase operation is ongoing before modifying WRHIGHFREQ.

Caution: Modifying WRHIGHFREQ while programming/erasing the memory can corrupt its content.

Programming errors

When a program operation fails, an error is reported, as described in Section 7.9 .

Programming interrupts

See Section 7.10: FLASH interrupts for details.

7.3.6 FLASH erase operations

Erase operation overview

The memory can perform erase operations on 8-Kbyte user sectors, on one user flash memory bank, or on two user flash memory banks (for example mass erase). For more details in user flash memory, ICP, user options and OTP erase protection, see Section 7.6 .

Erase commands are issued through the AHB configuration interface. The memory supports one operation at a time, if it receives simultaneously a write and an erase request an error flag is raised, and both operations are canceled. See Section 7.9 for details.

After successful completion of erase, all the bytes in the erased flash sectors are set to the flash default 0xFF value.

Erase and WRP

If the application software attempts to erase a write-protected user sector, the sector erase operation is aborted, and the WRPERR flag is raised in the FLASH_NS/SECSR register, as described in Section 7.9.2 .

Flash busy

Busy signals is described in Monitoring ongoing write operations .

Writing to the FLASH control register FLASH_NS/SECCR and FLASH_OPTCR

Refer to Writing to the FLASH control register FLASH_NS/SECCR and FLASH_OPTCR .

Enabling erase operations

Before erasing a sector, the application software must make sure that FLASH_NS/SECCR is unlocked. If this is not the case, an unlock sequence must be used (see Section 7.6.7 ).

Note: The application software must not unlock a register that is already unlocked, otherwise this register remains locked until next system reset. This can be used to deliberately lock-out a register from further accesses.

Similar constraints apply to bank erase requests.

Standard flash sector erase sequence

To erase an 8- or 6-Kbyte data user sector without security protections, proceed as follows:

  1. 1. Make sure protection mechanism does not prevent sector erase (WRP, secure flag, HDP).
  2. 2. Check that no memory operations are ongoing by checking the BSY and DBNE bits in the FLASH_NSSR register, and that the write buffer is empty by checking the WBNE bit in the FLASH_NSSR register.
  3. 3. Check and clear all the non-secure error flags due to previous programming/erase operation. Refer to Section 7.9 for details.
  4. 4. Unlock the FLASH_NSCR register, as described in Section 7.6.7 (only if this register is not already unlocked).
  5. 5. Set the BKSEL bit, the SER bit and SNB bitfield in the FLASH_NSCR register. BKSEL indicates in which physical bank sector must be erased, then SER indicates a sector erase operation, while SNB contains the target sector number. In case of data sector, use the number of the corresponding regular sector.
  6. 6. Set the STRT bit in the FLASH_NSCR register.
  7. 7. Wait for the BSY bit to be cleared in the FLASH_NSSR register.
  8. 8. STRT bit is automatically cleared at the end of the sector erase, or in case of error.
  9. 9. Clear SER in FLASH_NSCR register if there are not anymore sector erase request to be issued.

Note: If another erase flag is requested simultaneously to the sector erase, a PGSERR error is generated.

Secure flash memory sector erase sequence

To erase an 8- or 6-Kbyte data secure configured user sector, proceed as follows:

  1. 1. Make sure write protection or HDP mechanism does not prevent sector erase.
  2. 2. Ensure that no memory operations are ongoing (by checking the BSY and DBNE bits in the FLASH_SECSR register), and that the write buffer is empty (by checking the WBNE bit in the FLASH_SECSR register).
  3. 3. Check and clear all the secure error flags due to previous programming/erase operations. Refer to Section 7.9 for details.
  4. 4. Unlock the FLASH_SECCR register, as described in Section 7.6.7 (only if this register is not already unlocked).
  5. 5. Set the BKSEL bit, the SER bit and SNB bitfield in the FLASH_SECCR register. BKSEL indicates in which physical bank sector must be erased, then SER indicates a sector erase operation, while SNB contains the target secure sector number. In case of data sector, use the number of the corresponding regular sector.
  1. 6. Set the STRT bit in the FLASH_SECCR register.
  2. 7. Wait for the BSY bit to be cleared in the FLASH_SECSR register.
  3. 8. STRT bit is automatically cleared at the end of the sector erase or in case of error.
  4. 9. Clear SER in FLASH_SECCR register if there are not any secure sector erase request to be issued.

Note: If another erase flag is requested simultaneously to the sector erase, a PGSERR error is generated.

Standard flash memory bank erase sequence

To erase bank where no sector is configured as secure:

  1. 1. Make sure protection mechanism does not prevent sector erase.
  2. 2. Check that no memory operations are ongoing by checking the BSY and DBNE bits in the FLASH_NSSR register and that the write buffer is empty by checking the WBNE bit in the same register.
  3. 3. Check and clear all the non-secure error flags due to previous programming/erase operation. Refer to Section 7.9 for details.
  4. 4. Unlock the FLASH_NSCR register, as described in Section 7.6.7 (only if this register is not already unlocked).
  5. 5. Set the BKSEL bit and the BER bit in the FLASH_NSCR register to the targeted physical bank (swap setting is ignored).
  6. 6. Set the STRT bit in the FLASH_NSCR register to start the bank erase operation. Then wait until the BSY bit is cleared in the FLASH_NSSR register.
  7. 7. STRT bit is automatically cleared at the end of erase sequence or in case of error.
  8. 8. Clear BER in FLASH_NSCR register if there is not other bank erase request to be issued.

Secure flash memory bank erase sequence

To erase bank where all sectors are configured with secure flag:

  1. 1. Make sure protection mechanism does not prevent sector erase (for mass erase the HDP is also considered, it cannot be fully executed from HDPL= 2, 3 if HDP is defined).
  2. 2. Check that no memory operations are ongoing by checking the BSY and DBNE bits in the FLASH_SECSR register and that the write buffer is empty by checking the WBNE bit in the same register.
  3. 3. Check and clear all the secure error flags due to previous programming/erase operation. Refer to Section 7.9 for details.
  4. 4. Unlock the FLASH_SECCR register, as described in Section 7.6.7 (only if this register is not already unlocked).
  5. 5. Set the BKSEL bit and the BER bit in the FLASH_SECCR register to the targeted physical bank (swap setting is ignored).
  6. 6. Set the STRT bit in the FLASH_SECCR register to start the bank erase operation. Then wait until the BSY bit is cleared in the FLASH_SECSR register.
  7. 7. STRT bit is automatically cleared at the end of erase sequence or in case of error.
  8. 8. Clear BER in FLASH_SECCR register if there is not other bank erase request to be issued.

Flash mass erase sequence

To erase all sectors of both banks, using non-secure access, all sectors must be configured as non-secure. The application software can set the MER bit to 1 in FLASH_NSCR register, as described below:

  1. 1. Make sure protection mechanisms do not prevent mass erase ( Section 7.6 ).
  2. 2. Check that no memory operations are ongoing by checking the BSY and DBNE bits in the FLASH_NSSR register and that the write buffer is empty by checking the WBNE bit in the FLASH_NSSR register.
  3. 3. Check and clear all the non-secure error flags due to previous programming/erase operation. Refer to Section 7.9 for details.
  4. 4. Unlock the FLASH_NSCR register as described in Section 7.6.7 (only if the registers are not already unlocked).
  5. 5. Set the MER bit to 1 in FLASH_NSCR register.
  6. 6. Set the STRT bit in the FLASH_NSCR register. Then wait until BSY bit is cleared in the FLASH_NSSR register.
  7. 7. STRT bit is cleared automatically at the end of the erase sequence, or in case of error.
  8. 8. Clear MER in FLASH_NSCR register.

Secure flash memory mass erase sequence

To erase all sectors of both banks simultaneously, using secure access, all sectors must be configured as secure. The application software can set the MER bit to 1 in FLASH_SECCR register, as described below:

  1. 1. Make sure protection mechanisms do not prevent mass erase ( Section 7.6 ).
  2. 2. Check that no memory operations are ongoing by checking the BSY and DBNE bits in the FLASH_SECSR register and that the write buffer is empty by checking the WBNE bit in the FLASH_SECSR register.
  3. 3. Check and clear all the secure error flags due to previous programming/erase operation. Refer to Section 7.9 for details.
  4. 4. Unlock the FLASH_SECCR register as described in Section 7.6.7 (only if the registers are not already unlocked).
  5. 5. Set the MER bit to 1 in FLASH_SECCR register.
  6. 6. Set the STRT bit in the FLASH_SECCR register. Then wait until BSY bit is cleared in the FLASH_SECSR register.
  7. 7. STRT bit is cleared automatically at the end of the erase sequence, or in case of error.
  8. 8. Clear MER in FLASH_SECCR register.

Note: Mass and bank erase also erase high-cycle data sectors aliased from the erased bank.

7.3.7 FLASH parallel operations

As the memory is divided into two independent banks, the embedded flash memory interface supports a read in one bank while a write (RWW: read while write) or an erase is executed in the other bank. It does not support write-while-write, nor read-while-read. Same is valid for the high-cycle data area, system flash libraries, or the OBK (located on Bank2).

In all cases, the sequences described in Section 7.3.4 , Section 7.3.5 and Section 7.3.6 apply.

7.3.8 FLASH error protections

Error correction codes (ECC)

The embedded flash memory supports an error correction code (ECC) mechanism, based on the SECDED algorithm, to correct single errors and detect double errors.

This mechanism uses nine ECC bits per 128-bit flash word, and applies to user and system memory. For read-only, OTP, flash high-cycle data, a stronger six ECC bits per 16-bit word is used. A double ECC error is generated for an OTP or flash high-cycle data virgin word (for example a word with 22 bits at 1). When this OTP or flash high-cycle data word is no more virgin, the ECC error disappears.

More specifically, during each read operation from a 128-bit flash word, the embedded flash memory retrieves the 9-bit ECC information, computes the ECC of the flash word, and compares the result with the reference value. If they do not match, the corresponding ECC error is raised, as described in Section 7.9.10 .

During each program operation, a 9-bit ECC code is associated to each 128-bit data flash word, and the resulting 137-bit flash word information is written in nonvolatile memory.

A similar mechanism applies to read-only and OTP areas, but with 6-bit ECC for 16-bit data.

7.3.9 OTP and RO memory access

OTP and RO memory are accessed through main AHB interface. The OTP is accessible at addresses 0x08FF_F000 to 0x08FF_F7FF, and the read-only section is accessible from 0x08FF_F800 to 0x08FF_FFFF.

FLASH one-time programmable area

The embedded flash memory offers a 2048-byte memory area dedicated to application non-confidential, one-time programmable data (OTP). This area is composed by 1024 words of 16 bits (plus 6 bits of ECC). It cannot be erased, and can be written only once. The OTP area can be accessed through the main AHB interface from address 0x08FF_F000 to 0x08FF_F7FE.

OTP data can be programmed by the application software by 16-bit chunks. Overwriting an already programmed 16-bit half-word can lead to data and ECC errors, and is therefore not supported.

Note: The OTP area is virgin when the device is delivered by STMicroelectronics.

When reading OTP data with a single error corrected or a double error detected, the embedded flash memory reports read errors, as described in Section 7.9.10 .

When reading OTP data not written by the application software (such as virgin OTP), the ECC correction reports a double-error detection (ECCD), and the data are to be found in the FLASH_ECCDR register. ECCD implies an NMI raised.

OTP write protection

OTP data are organized as 32 blocks of 32 OTP words, as shown in Table 46 . An entire OTP block can be protected (locked) from write accesses by setting the LOCKBLi bit (i = 0 to 31) corresponding to each OTP block in the FLASH_OTPBLR register. A block can be write-protected, if it has been programmed (even partially) or not.

The OTP block locking operation is irreversible, and independent from the product life state.

Note: The OTP area can be accessed only in read mode.

Table 46. Flash memory OTP organization

OTP blockAHB addressAHB wordLock bit
[31:16][15:0]
Block 00x08FF F000OTP001OTP000LOCKBL0
0x08FF F004OTP003OTP002
...
0x08FF F03COTP031OTP030
Block 10x08FF F040OTP033OTP032LOCKBL1
0x08FF F044OTP035OTP034
...
0x08FF F07COTP063OTP062
Block 20x08FF F080OTP065OTP064LOCKBL2
0x08FF F084OTP067OTP066
...
0x08FF F0BCOTP95OTP94
...
Block 310x08FF F7C0OTP993OTP992LOCKBL31
0x08FF F7C4OTP995OTP994
...
0x08FF F7FCOTP1023OTP1022

OTP write sequence

Follow the sequence below to write an OTP word:

  1. 1. Check that no memory operations are ongoing by checking the BSY bit in the FLASH_NSSR register and that the data buffer is empty by checking the DBNE bit in the FLASH_NSSR register.
  2. 2. Check and clear all the error flags due to previous programming/erase operation.
  3. 3. Set PG bit in the FLASH_NSCR register.
  4. 4. Check the protection status of the target OTP word (see Table 46 ). The corresponding LOCKBLi bit must not be set to 1.
  5. 5. Write two OTP words (32 bits) corresponding to the 4-byte aligned address shown in Table 46 . Alternatively, the application software can program separately the 16-bit MSB or 16-bit LSB. In this case the first 16-bit write operation starts immediately, without waiting for the second one.
  6. 6. Wait for the BSY bit to be cleared in the FLASH_NSSR register.
  7. 7. Clear PG bit in FLASH_NSCR register if there is not any programming request anymore in the bank.
  8. 8. Optionally, lock the OTP block using LOCKBLi to prevent further data changes.

Note: Do not write twice an OTP 16-bit word, otherwise an ECC error is generated.
Writing OTP data at byte level is not supported, and generates a bus error.
To avoid data corruption, it is important to complete the OTP write process (for example by reading back the OTP value), before starting an option change.

Flash read-only area

The embedded flash memory offers a 2-Kbyte area to store read-only data. This area can be accessed through the AHB main port, and is protected by a robust ECC scheme, as detailed in Section 7.3.8 .

The read-only information (programmed by STMicroelectronics) that can be used by the application software is detailed in Table 47 .

Table 47. Read-only public data organization

Read-only data nameAddressComment
Unique device ID0x08FF F800U_ID[31:0]
0x08FF F804U_ID[63:32]
0x08FF F808U_ID[96:64]
Flash memory size/ package0x08FF F80CFlash memory size[15:0] / Package code[15:0]
Reserved0x08FF F810 to 0x08FF FFFFReserved information

7.3.10 Flash high-cycle data

The embedded flash memory offers up to 96 Kbytes (maximum) memory area with high-cycling capability (100 kcycles) to store data and emulate EEPROM. It can be accessed through the AHB system port from address 0x0900_0000 to 0x0901_7FFF (see Figure 25 ). It is mapped in the 8 (or 4) last sectors of Bank 1 and 2. This area is protected by a robust 6-bit ECC, enabling a 16-bit read and write granularity, at the expense of having sector size shrunk to 6 Kbytes.

A threshold per bank (EDATA(1/2)_STRT) is programmable to determine the beginning of the data flash area. By default, the whole memory is used for code.

For example, if 48 Kbytes of data are needed in Bank 1, set EDATA1_EN to 1, and EDATA1_STRT to 7. If no data are needed in Bank2, set EDATA2_EN to 0. In this case the data are accessible from address 0x0900_0000 to 0x0900_BFFF for Bank 1.

For greater efficiency, it is recommended to use sector on the other bank for flash high-cycle data, so that the application benefits from RWW capability of the dual-bank arrangement.

When SWAP_BANK feature is enabled, the banks are swapped: the flash high-cycle data in Bank 2 are accessible from 0x0900_000 to 0x0900_BFFF, and the data in Bank 1 are accessible from 0x0900_C000 to 0x0901_7FFF.

A bus error is generated on:

Erasing the data area sector is possible by normal erase request for the corresponding user flash sector (120-127 for the STM32H562/563/573xx devices, 24-31 for the STM32H523/33xx devices).

Protections and security of high-cycle area are detailed in Section 7.6.9 .

Figure 25. Flash high-cycle data memory map on 2-Mbyte devices

Figure 25: Flash high-cycle data memory map on 2-Mbyte devices. The diagram shows two banks, Bank1 and Bank2, each with 128 sectors. Bank1 sectors 0-1 are 6 KB each, while sectors 2-127 are 8 KB each. Bank2 sectors 0-1 are 6 KB each, while sectors 2-127 are 8 KB each. The data memory map shows addresses from 0x0900_0000 to 0x0D00_0000 for Bank1 and 0x0900_C000 to 0x0D01_7FFF for Bank2. The code memory map shows addresses from 0x0800_0000 to 0x0C00_0000 for Bank1 and 0x0810_0000 to 0x0C10_0000 for Bank2. The EDATA1_STRT and EDATA2_STRT markers are shown between the banks.

The diagram illustrates the flash memory map for 2-Mbyte devices, divided into two banks, Bank1 and Bank2. Each bank contains 128 sectors. Bank1 sectors 0 and 1 have a size of 6 KB, while sectors 2 through 127 have a size of 8 KB. Bank2 sectors 0 and 1 have a size of 6 KB, while sectors 2 through 127 have a size of 8 KB. The data memory map for Bank1 starts at 0x0900_0000 and ends at 0x0D00_0000. The data memory map for Bank2 starts at 0x0900_C000 and ends at 0x0D01_7FFF. The code memory map for Bank1 starts at 0x0800_0000 and ends at 0x0C00_0000. The code memory map for Bank2 starts at 0x0810_0000 and ends at 0x0C10_0000. The EDATA1_STRT and EDATA2_STRT markers are indicated between the banks.

Figure 25: Flash high-cycle data memory map on 2-Mbyte devices. The diagram shows two banks, Bank1 and Bank2, each with 128 sectors. Bank1 sectors 0-1 are 6 KB each, while sectors 2-127 are 8 KB each. Bank2 sectors 0-1 are 6 KB each, while sectors 2-127 are 8 KB each. The data memory map shows addresses from 0x0900_0000 to 0x0D00_0000 for Bank1 and 0x0900_C000 to 0x0D01_7FFF for Bank2. The code memory map shows addresses from 0x0800_0000 to 0x0C00_0000 for Bank1 and 0x0810_0000 to 0x0C10_0000 for Bank2. The EDATA1_STRT and EDATA2_STRT markers are shown between the banks.

Figure 26. Flash high-cycle data memory map on 1-Mbyte devices

Figure 26: Flash high-cycle data memory map on 1-Mbyte devices. The diagram shows two banks, Bank1 and Bank2, each with 64 sectors. Bank1 sectors 0-1 are 6 KB each, while sectors 2-63 are 8 KB each. Bank2 sectors 0-1 are 6 KB each, while sectors 2-63 are 8 KB each. The data memory map shows addresses from 0x0900_0000 to 0x0D00_0000 for Bank1 and 0x0900_C000 to 0x0D01_7FFF for Bank2. The code memory map shows addresses from 0x0800_0000 to 0x0C00_0000 for Bank1 and 0x0808_0000 to 0x0C08_0000 for Bank2. The EDATA1_STRT and EDATA2_STRT markers are shown between the banks.

The diagram illustrates the flash memory map for 1-Mbyte devices, divided into two banks, Bank1 and Bank2. Each bank contains 64 sectors. Bank1 sectors 0 and 1 have a size of 6 KB, while sectors 2 through 63 have a size of 8 KB. Bank2 sectors 0 and 1 have a size of 6 KB, while sectors 2 through 63 have a size of 8 KB. The data memory map for Bank1 starts at 0x0900_0000 and ends at 0x0D00_0000. The data memory map for Bank2 starts at 0x0900_C000 and ends at 0x0D01_7FFF. The code memory map for Bank1 starts at 0x0800_0000 and ends at 0x0C00_0000. The code memory map for Bank2 starts at 0x0808_0000 and ends at 0x0C08_0000. The EDATA1_STRT and EDATA2_STRT markers are indicated between the banks.

Figure 26: Flash high-cycle data memory map on 1-Mbyte devices. The diagram shows two banks, Bank1 and Bank2, each with 64 sectors. Bank1 sectors 0-1 are 6 KB each, while sectors 2-63 are 8 KB each. Bank2 sectors 0-1 are 6 KB each, while sectors 2-63 are 8 KB each. The data memory map shows addresses from 0x0900_0000 to 0x0D00_0000 for Bank1 and 0x0900_C000 to 0x0D01_7FFF for Bank2. The code memory map shows addresses from 0x0800_0000 to 0x0C00_0000 for Bank1 and 0x0808_0000 to 0x0C08_0000 for Bank2. The EDATA1_STRT and EDATA2_STRT markers are shown between the banks.

Figure 27. Flash high-cycle data memory map on 512-Kbyte devices

Figure 27: Flash high-cycle data memory map on 512-Kbyte devices. The diagram shows two banks, Bank1 and Bank2. Bank1's code memory map (9-bit ECC) starts at 0x0800_0000 and ends at 0x0803_FFFF, with sectors 0-1 at the top and sectors 24-31 at the bottom. Bank2's code memory map (9-bit ECC) starts at 0x0804_0000 and ends at 0x0807_FFFF, also with sectors 0-1 at the top and sectors 24-31 at the bottom. Data memory maps (6-bit ECC) are shown on the far left and far right. On the left, it starts at 0x0900_0000 and ends at 0x0900_BFFF. On the right, it starts at 0x0900_C000 and ends at 0x0901_7FFF. Arrows labeled EDATA1_STRT and EDATA2_STRT point from the bottom of Bank1 and Bank2 respectively to the start of the data memory maps.
Figure 27: Flash high-cycle data memory map on 512-Kbyte devices. The diagram shows two banks, Bank1 and Bank2. Bank1's code memory map (9-bit ECC) starts at 0x0800_0000 and ends at 0x0803_FFFF, with sectors 0-1 at the top and sectors 24-31 at the bottom. Bank2's code memory map (9-bit ECC) starts at 0x0804_0000 and ends at 0x0807_FFFF, also with sectors 0-1 at the top and sectors 24-31 at the bottom. Data memory maps (6-bit ECC) are shown on the far left and far right. On the left, it starts at 0x0900_0000 and ends at 0x0900_BFFF. On the right, it starts at 0x0900_C000 and ends at 0x0901_7FFF. Arrows labeled EDATA1_STRT and EDATA2_STRT point from the bottom of Bank1 and Bank2 respectively to the start of the data memory maps.

Figure 28. Flash high-cycle data memory map on 256-Kbyte devices

Figure 28: Flash high-cycle data memory map on 256-Kbyte devices. The diagram shows two banks, Bank1 and Bank2. Bank1's code memory map (9-bit ECC) starts at 0x0800_0000 and ends at 0x0801_FFFF, with sectors 0-1 at the top and sector 15 at the bottom. Bank2's code memory map (9-bit ECC) starts at 0x0802_0000 and ends at 0x0803_FFFF, also with sectors 0-1 at the top and sector 15 at the bottom. Data memory maps (6-bit ECC) are shown on the far left and far right. On the left, it starts at 0x0900_0000 and ends at 0x0900_BFFF. On the right, it starts at 0x0900_C000 and ends at 0x0901_7FFF. Arrows labeled EDATA1_STRT and EDATA2_STRT point from the bottom of Bank1 and Bank2 respectively to the start of the data memory maps.
Figure 28: Flash high-cycle data memory map on 256-Kbyte devices. The diagram shows two banks, Bank1 and Bank2. Bank1's code memory map (9-bit ECC) starts at 0x0800_0000 and ends at 0x0801_FFFF, with sectors 0-1 at the top and sector 15 at the bottom. Bank2's code memory map (9-bit ECC) starts at 0x0802_0000 and ends at 0x0803_FFFF, also with sectors 0-1 at the top and sector 15 at the bottom. Data memory maps (6-bit ECC) are shown on the far left and far right. On the left, it starts at 0x0900_0000 and ends at 0x0900_BFFF. On the right, it starts at 0x0900_C000 and ends at 0x0901_7FFF. Arrows labeled EDATA1_STRT and EDATA2_STRT point from the bottom of Bank1 and Bank2 respectively to the start of the data memory maps.

Note: When flash high-cycle data area on Bank1 is enabled, the code memory map is not continuous from Bank1 to Bank2 on 2M- and 512K-byte devices.

7.3.11 Flash bank swapping

Bank1 and Bank2 can be swapped for the user flash. This feature can be used after a firmware upgrade to restart the device on the new firmware. Bank swapping is an user option byte flag controlled by the SWAP_BANK bit of the FLASH_OPTCR register.

Bank specific settings for data area and security attributes follow the original bank and its contents. Control bit BKSEL always refers to physical bank, not the SWAP_BANK setting.

Table 48 shows the accessible memory, depending upon the SWAP_BANK bit value.

Table 48. Memory map and swapping options (STM32H562/563/573xx devices)

AreaCorresponding bankStart addressEnd addressSize (bytes)Region name
SWAP_BANK = 0SWAP_BANK = 1
User main memoryBank1Bank20x0800 00000x0800 1FFF8 KSector 0
0x0800 20000x0800 3FFF8 KSector 1
............
0x080F E0000x080F FFFF8 KSector 127
Bank2Bank10x0810 00000x0810 1FFF8 KSector 0
0x0810 20000x0810 3FFF8 KSector 1
............
0x081F E0000x081F FFFF8 KSector 127
System memoryBank10x0BF8 00000x0BF8 1FFF8 KSystem 1 Sector 0
0x0BF8 20000x0BF8 3FFF8 KSystem 1 Sector 1
............
0x0BF8 E0000x0BF8 FFFF8 KSystem 1 Sector 7
Bank20x0BF9 00000x0BF9 1FFF8 KSystem 2 Sector 0
0x0BF9 20000x0BF9 3FFF8 KSystem 2 Sector 1
............
0x0BF9 E0000x0BF9 FFFF8 KSystem 2 Sector 7

Table 49. Memory map and swapping options (STM32H523/533xx devices)

AreaCorresponding bankStart addressEnd addressSize (bytes)Region name
SWAP_BANK = 0SWAP_BANK = 1
User main memoryBank1Bank20x0800 00000x0800 1FFF8 KSector 0
0x0800 20000x0800 3FFF8 KSector 1
0x0803 E0000x0803 FFFF8 KSector 31
Bank2Bank10x0804 00000x0804 1FFF8 KSector 0
0x0804 20000x0804 3FFF8 KSector 1
0x0807 E0000x0807 FFFF8 KSector 31

Table 49. Memory map and swapping options (STM32H523/533xx devices) (continued)

AreaCorresponding bankStart addressEnd addressSize (bytes)Region name
SWAP_BANK = 0SWAP_BANK = 1
System memoryBank10x0BF8 00000x0BF8 1FFF8 KSystem 1 Sector 0
0x0BF8 20000x0BF8 3FFF8 KSystem 1 Sector 1
............
0x0BF8 E0000x0BF8 FFFF8 KSystem 1 Sector 7
Bank20x0BF9 00000x0BF9 1FFF8 KSystem 2 Sector 0
0x0BF9 00000x0BF9 3FFF8 KSystem 2 Sector 1
............
0x0BF9 E0000x0BF9 FFFF8 KSystem 2 Sector 7

The SWAP_BANK bit in FLASH_OPTCR register is loaded from the SWAP_BANK option bit only after system reset or POR.

To change the SWAP_BANK bit (for example to apply a new firmware update), follow the sequence below:

  1. 1. Check that no memory operations are ongoing by checking the BSY and DBNE bits in the FLASH_NS/SECSR register and that the write buffer is empty by checking the WBNE bit in the FLASH_NS/SECSR register.
  2. 2. Clear all error flags due to a previous operation.
  3. 3. Unlock OPTLOCK bit, if not already unlocked.
  4. 4. Set the new desired SWAP_BANK value in the FLASH_OPTSR_PRG register.
  5. 5. Start the option byte change sequence by setting the OPTSTRT bit in the FLASH_OPTCR register.
  6. 6. Once the option byte change has completed, FLASH_OPTSR_CUR contains the expected SWAP_BANK value, but SWAP_BANK bit in FLASH_OPTCR has not yet been modified and the bank swapping is not yet effective.
  7. 7. Force a system reset or a POR. When the reset rises up, the bank swapping is effective (SWAP_BANK value updated in FLASH_OPTCR) and the new firmware shall be executed.

Note: The SWAP_BANK bit in FLASH_OPTCR is read-only, and cannot be modified by the application software.

The SWAP_BANK option bit in FLASH_OPTSR_PRG can be modified whatever the product state. Instead of being locked by PRODUCT_STATE, it is locked by (NS/SEC)BOOT_LOCK User OB.

Figure 29 gives an overview of the bank swapping sequence.

Figure 29. Flash bank swapping sequence

Flowchart of the flash bank swapping sequence. The sequence starts with 'Begin', followed by 'Update new firmware in user Flash bank 1/2', 'Set/unset SWAP_BANK_OPT option bit in FLASH_OPTSR_PRG', and 'Write OPTSTRT bit in FLASH_OPTCR to start option byte change sequence'. A 'System reset' separates the first three steps from the rest. After the reset, 'SWAP_BANK of FLASH_OPTSR_CUR is copied to SWAP_BANK_OPT bit in FLASH_OPTCR', leading to 'End' and 'Execution of new firmware'. Register diagrams show FLASH_OPTSR_PRG (yellow), FLASH_OPTSR_CUR (pink), and FLASH_OPTCR (blue) being updated. Arrows show 'Option byte programming' to Non-volatile memory, 'Option byte reload' from Non-volatile memory to FLASH_OPTSR_CUR, and 'System reset option byte reload' to FLASH_OPTCR. Post-reset, 'New swap policy effective' leads to 'User flash memory SWAP logic' connected to 'Non-volatile memory Bank1' and 'Non-volatile memory Bank2' via an 'AHB bus'.
graph TD
    Begin([Begin]) --> Step1[Update new firmware in user Flash bank 1/2]
    Step1 --> Step2[Set/unset SWAP_BANK_OPT option bit in FLASH_OPTSR_PRG]
    Step2 --> Step3[Write OPTSTRT bit in FLASH_OPTCR to start option byte change sequence]
    Step3 --> Reset[System reset]
    Reset -.-> Step4[SWAP_BANK of FLASH_OPTSR_CUR is copied to SWAP_BANK_OPT bit in FLASH_OPTCR]
    Step4 --> End([End])
    End --> Firmware[Execution of new firmware]

    subgraph Registers
        PRG[FLASH_OPTSR_PRG: SWAP BANK OPT]
        CUR[FLASH_OPTSR_CUR: SWAP BANK OPT]
        CR[FLASH_OPTCR: SWAP BANK]
    end

    Step2 -- "Option byte programming" --> NV[Non-volatile memory]
    NV -- "Option byte reload" --> CUR
    Reset -- "System reset option byte reload" --> CR
    CR -- "New swap policy effective" --> Logic[User flash memory SWAP logic]
    Logic --> Bank1[Non-volatile memory Bank1]
    Logic --> Bank2[Non-volatile memory Bank2]
    Bus[AHB bus] --> Logic
  

MSv68819V2

Flowchart of the flash bank swapping sequence. The sequence starts with 'Begin', followed by 'Update new firmware in user Flash bank 1/2', 'Set/unset SWAP_BANK_OPT option bit in FLASH_OPTSR_PRG', and 'Write OPTSTRT bit in FLASH_OPTCR to start option byte change sequence'. A 'System reset' separates the first three steps from the rest. After the reset, 'SWAP_BANK of FLASH_OPTSR_CUR is copied to SWAP_BANK_OPT bit in FLASH_OPTCR', leading to 'End' and 'Execution of new firmware'. Register diagrams show FLASH_OPTSR_PRG (yellow), FLASH_OPTSR_CUR (pink), and FLASH_OPTCR (blue) being updated. Arrows show 'Option byte programming' to Non-volatile memory, 'Option byte reload' from Non-volatile memory to FLASH_OPTSR_CUR, and 'System reset option byte reload' to FLASH_OPTCR. Post-reset, 'New swap policy effective' leads to 'User flash memory SWAP logic' connected to 'Non-volatile memory Bank1' and 'Non-volatile memory Bank2' via an 'AHB bus'.

7.3.12 FLASH reset and clocks

Reset management

The embedded flash memory can be reset by a core domain reset, driven by the reset and clock control (RCC). The main effects of this reset are the following:

The memory can be reset by a power-on core domain reset, driven by the reset and clock control (RCC). When the reset falls, all option byte registers are reset. When the reset rises up, the option bytes are loaded, potentially applying new features. During this loading sequence, the device remains under reset, and the memory is not accessible.

The reset signal can have a critical impact on the memory: the content is not guaranteed if a device reset occurs during a write or erase operation.

Reset occurring during flash operation

If a reset occurs during a flash operation (programming, erase or option change), the content of the memory is not guaranteed. It is mandatory for integrity to restart the operation. The status register FLASH_OPSR gives information about operations interrupted by a reset.

FLASH_OPSR.CODE_OP gives opcode of operation. Table 50 indicates how to use FLASH_OPSR, and which operation is required.

Table 50. Recommended reactions to FLASH_OPSR contents

CODE_OPOperation interruptedOTP_OPSYSF_OPBK_OPDATA_OPFlash areaADDR_OP minADDR_OP maxRecommended action
0x000No operation ongoing while reset0000_( 1 )--No extra action
0x001Write operation000/10User flash0x00000xFFFFErase sector and rewrite
010/10System flash0x00000x0FFF
1000OTP0x06000x07FF
1010OBKeys (2)0x00000x03FF
000/11Data area (3)0xF0000xFFFF
0x010OBK alternate sector erase0010OBKeys00Relaunch the alternate sector erase
0x011Sector erase (4)000/10User flash0x00000xFFFFRelaunch sector erase
010/10System flash0x00000x0FFF
0x100Bank erase000/10User flash--Relaunch bank erase
0x101Mass erase0000--Relaunch mass erase
0x110Option change0000User configuration--New attempt on option change
0x111OBK swap sector0010OBKeys--Erase alternate sector, reprogram new OBKeys and relaunch swap

1. Dash represents "does not matter".

2. Depends on current OBK sector.

3. Depends on EDATA setting in the OB.

4. Addresses indicated are aligned to sector start, data area sectors are erased by erase request to corresponding user flash memory sector.

Clock management

The memory uses the microcontroller system clock (sys_ck), here the AHB interface clock.

7.4 FLASH option bytes

7.4.1 About option bytes

The memory includes a set of nonvolatile option bytes. They are loaded at power-on reset and can be read and modified only through configuration registers. This section details:

7.4.2 Option bytes loading

There are multiple ways of loading the option bytes:

When the device is first powered, the embedded flash memory automatically loads all the option bytes. During the option byte loading sequence, the device remains under reset and the embedded flash memory cannot be accessed.

When the core power domain, which contains the embedded flash memory, is switched from Standby mode to Run mode, the embedded flash memory behaves as during a power-on sequence. During loading time the device is not under reset, unlike power-on sequence.

When the user application successfully modifies the option byte content through the memory registers, the nonvolatile option bytes are programmed and the memory automatically reloads all option bytes to update the option registers.

Note: The option byte read sequence is protected by error correction code. In case of error, the option bytes are loaded with default values (see Section 7.4.3 ), different from the initial values (user default configuration), and more restrictive.

7.4.3 Option bytes modification

Changing user option bytes

A user option byte change operation can be used to modify the configuration and the protection settings saved in the nonvolatile option byte area.

There are several rules enforced when attempting to change a user option byte, they are summarized in Section 7.4.7 . Failing to stick to those rules usually results in errors, described in Section 7.9.12 .

The embedded flash memory features two sets of option byte registers:

When the OPTLOCK bit in FLASH_OPTCR register is set, it is not possible to modify the FLASH_XXX_PRG registers.

When OPTSTRT bit is set to 1, the memory checks the programming sequence (PGSERR) and the conditions described in Section 7.4.7 (OPTCHANGEERR). If no error has been detected (PGSERR/OPTCHANGEERR), the flash interface launches the option byte modification, and updates the option byte registers with _CUR extension.

If one of the condition described in Section 7.4.7 , Section 7.9.12 or Section 7.9.5 , alternatively Section 7.9.4 is not respected, the memory aborts the option byte change operation. In this case, the FLASH_XXX_PRG registers are not overwritten by the current option value. The user application can check what was wrong in their configuration.

Unlocking the option byte modification

After reset, the OPTLOCK bit is set to 1 and the FLASH_OPTCR is locked. As a result, the application software must unlock the option configuration register before attempting to change the option bytes. The FLASH_OPTCR unlock sequence is described in Section 7.6.7 .

Option bytes modification sequence

To modify user option bytes, follow the sequence below:

  1. 1. Check that no memory operations are ongoing by checking the BSY bit in the FLASH_NS/SECSR register and that the write buffer is empty by checking the WBNE bit in the FLASH_NS/SECSR register.
  2. 2. Check the data buffer is empty (DBNE = 0) in FLASH_NS/SECSR register.
  3. 3. Clear all error flags due to a previous operation.
  4. 4. Unlock FLASH_OPTCR register as described in Section 7.6.7 , unless the register is already unlocked.
  5. 5. Write the desired new option byte values in the corresponding option registers (FLASH_XXX_PRG).
  6. 6. Set the option byte start change OPTSTRT bit to 1 in the FLASH_OPTCR register.
  7. 7. Wait until BSY bit is cleared in FLASH_NS/SECSR register.
  8. 8. OPTSTRT bit is cleared automatically at the end of the sequence (or in case of error).
  9. 9. Reset the device. This step is always recommended, becomes mandatory when one of the following option bytes is impacted:
    1. a) SECBOOTADDR
    2. b) NSBOOTADDR
    3. c) TZEN
    4. d) BOOT_UBE

Note: If a reset or a power-down occurs while the option byte modification is ongoing, the original option byte value is kept. A new option byte modification sequence is required to program it.

Option bytes overview

Table 51 lists all the user option bytes managed through the memory registers, as well as the initial values before the first option byte change (user default configuration).

Table 51. Option bytes organization

Register313029282726252423222120191817161514131211109876543210
FLASH_OPTSRSWAP BANKBOOT_UBEIWDG_STDBYIWDG_STOPRes.Res.IO_VDDIO2_HSLVIO_VDD_HSLVPRODUCT_STATENRST_STDBYNRST_STOPRes.WWDG_SWIWDG_SWBORH_ENBOR_LEV
00101101001100001110110111011000
FLASH_OPTSR2TZENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.USBPD_DISRes.SRAM2_ECCSRAM3_ECCBKPRAM_ECCSRAM2_RSTSRAM13_RSTRes.Res.
11000011000000000000000101111100
FLASH_BOOTRSECBOOTADD[23:8]SECBOOTADD[7:0]SECBOOT_LOCK
0x0C000x000xC3
FLASH_NSBOOTRNSBOOTADD[23:8]NSBOOTADD[7:0]NSBOOT_LOCK
0x08000x000xC3
FLASH_SECWM1RRes.Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_ENDRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_STRT
00000000000000000000000000111111
FLASH_SECWM2RRes.Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_ENDRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT
00000000000000000000000000111111
FLASH_WRPSGN1RWRPSG[127:124]WRPSG[123:120]...WRPSG[71:68]WRPSG[67:64]WRPSG[63:60]WRPSG[59:56]...WRPSG[7:4]WRPSG[3:0]
11111111111111111111111111111111
FLASH_WRPSGN2RWRPSG[127:124]WRPSG[123:120]...WRPSG[71:68]WRPSG[67:64]WRPSG[63:60]WRPSG[59:56]...WRPSG[7:4]WRPSG[3:0]
11111111111111111111111111111111

Table 51. Option bytes organization (continued)

Register313029282726252423222120191817161514131211109876543210
FLASH_OTPBLRLOCKBL
00000000000000000000000000000000
FLASH_EDATA1RRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DATA_EN1Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SECTOR_START_1
00000000000000000000000000000000
FLASH_EDATA2RRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DATA_EN1Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SECTOR_START_2
00000000000000000000000000000000
FLASH_NSEPOCHRRes.Res.Res.Res.Res.Res.Res.Res.Res.NS_EPOCH1
00000000000000000000000000000001
FLASH_SECEPOCHRRes.Res.Res.Res.Res.Res.Res.Res.Res.SEC_EPOCH1
00000000000000000000000000000001
FLASH_HDP1RRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP1_ENDHDP1_STRT1
00000000000000000000000000000001
FLASH_HDP2RRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_ENDHDP2_STRT1
00000000000000000000000000000001

7.4.4 Description of user and system option bytes

The general-purpose option bytes that can be used by the application are listed below:

Note: If the hardware watchdog “control selection” feature is enabled (set to 0), the watchdog is automatically enabled at power-on, thus generating a reset unless the watchdog key register is written to or the down-counter is reloaded before the end-of-count is reached. Depending on the configuration of IWDG_STOP and IWDG_STDBY options, the IWDG can continue counting (1) or not (0) when the device is, respectively, in Stop or Standby mode.

When the IWDG is kept running during Stop or Standby mode, it can wake up the device from these modes.

Note: Whenever a Standby (Stop) mode entry sequence is successfully executed, the device is reset instead of entering Standby (Stop) mode if NRST_STDBY (NRST_STOP) is cleared to 0.

At delivery, the values programmed in the user option bytes are the following:

Refer to Section 7.11 for details.

7.4.5 Description of data protection option bytes

The option bytes that can be used to enhance data protection are listed below:

programming, to actually use TZ features, reset is required to set the TZ_STATE in SBS.

When TZEN is activated, secure watermark settings and secure boot address can be reset to default to prevent a deadlock in case the previous values were not correct.

When factory programmed values of the data protection option bytes are the following:

Refer to Section 7.11 for details.

7.4.6 Description of boot address option bytes

Below the list of option bytes that can be used to configure the appropriate boot address for an application:

When STMicroelectronics delivers the device, the PRODUCT_STATE is Open, BOOT_LOCK is not set (0xC3) and the BOOT_UBE is set to user flash (0xB4). Addresses are SECBOOTADD = 0x0C00 0000, NSBOOTADD = 0x0800 0000.

Refer to Section 7.11 for details.

7.4.7 Specific rules for modifying option bytes

On top of OPTLOCK bit and register access rules, there are other protections for selected security-sensitive option byte fields.

Different option bytes can be modified simultaneously, but if they rely on each other for protection, both states are checked. For example, when trying to modify PRODUCT_STATE and TZEN simultaneously, resulting state must be coherent with the rules. With few exceptions, listed in this section, failing to uphold the rules results in raising OPTCHANGEERR flag ( Section 7.9.12 for additional details).

Table 52. Specific modifying rules

Option byteHDPLTZ secureValueProduct state
PRODUCT_STATE1 (1)Some values only when TZ is enabledSet of possible transitionsSet of possible transitions ( Table 45 )
HDP1 (2)(3)-Refer to Table 53
TZEN---Regression, Open or Provisioning
EPOCH--PRG > CURRegression
EPOCH_NS--PRG > CURNS-Regression, Regression
SECWM-Secure mode only (2)-Refer to Table 53
BOOT_UBE---Open or Provisioning, SECBOOT_LOCK disabled
SECBOOTADD-Secure mode only (2)-
NSBOOTADD---Open or Provisioning, NSBOOT_LOCK disabled
LOCKBL--One way switch (2)-
SWAP_BANK-Fixed if BOOT_LOCK corresponding to TZEN is set--
SECBOOT_LOCK-Secure mode only (2)-Open, Regression or Provisioning to unlock
NSBOOT_LOCK---
  1. 1. Most transitions are possible regardless of HDPL, only a few require specific HDPL, see text below.
  2. 2. No OPTCHANGEERR raised in violation of this.
  3. 3. Dash means there is no limitation from this side.

Even in the closed PRODUCT_STATE progression, some OBs can still be modified, if all the other constraints are satisfied. An overview is presented in Table 53 .

Table 53. OB modifiable in closed product

PRODUCT_STATEOBs that can be modified
TZ-ClosedSWAP_BANK, LOCKBL, PRODUCT_STATE, SECWM, HDP
ClosedSWAP_BANK, LOCKBL, PRODUCT_STATE
LockedSWAP_BANK, LOCKBL

Specific rules must be respected to update the following OB:

PRODUCT_STATE transitions follow a state machine with two types of transitions. Locking down the product is allowed without restriction. Opening the product is possible only using a debug interface and following a digital signature verification. The regression to a less secure state results in the erase of the protected content. More details are given in Section 7.6.11 .

Summary: Selected changes are possible only in HDPL1. Some states are accessible only when TZEN is enabled.

Note: For all user option bytes above: default values are loaded and Tamper is signaled when a double ECC error occurs during OBL.

7.5 Option bytes key (OBK) management

This section describes the key storage tied with SAES and OBK-HDPL value set by the SBS (refer to Section 14.3.7: SBS hardware secure storage control ). The OBKs are stored in 128 bits and protected by 9-bit ECC (SEC/DED). They are written alternatively in two sectors.

7.5.1 OBK loading

OBKs are memory mapped, and accessible through the main AHB bus (C-Bus), starting from address 0x0FFD 0000. A 9-bit ECC is associated to each 128-bit data flash word.

Note: Read access is allowed in the current and alternate sector, except for the last address of the current and alternate sector. In case of read access, no error is reported but the read data is always 0x0 (see Section 7.6.12 ).

7.5.2 OBK access per HDPL level

Table 54 describes the option byte key areas. The key storage is not dedicated to a particular key, and the usage is defined by the application.

An option byte key can be accessed only if the OBK-HDPL (set in SBS) matches the HDPL associated to the storage offset, indicated below (refer to Section 14.3.7: SBS hardware secure storage control ). If this is not the case, an OBKERR error is raised.

Table 54. Option bytes key area

OBK-HDPLAddress offset startAddress offset endComment
-0x00000x00FFReserved
10x01000x08FFOEM iRoT keys
20x09000x0BFFuRoT, OS or secure application
30x0C000x17FFHDPL 3 secure keys
30x18000x1FEFHDPL 3 non-secure keys

7.5.3 OBK programming sequence

The sequence to write OBK is the same as a write to main flash except that the “alternate sector” (ALT_SECT) bit must be set to write in the alternate OBK sector. The ALT_SECT bit is checked each time a write access is received. If it does not match the one stored in the write buffer, an error is raised.

Note: Before writing in the alternate OBK sector the user must ensure that the whole key space (128, 256, or 512 bits) is free, by reading the alternate OBK sector.
If the alternate sector is not free, erase the sector using the command ALT_SECT_ERASE.

Secure programming method

Using the secure register if TrustZone is active (TZ_STATE = 0xB4):

  1. 1. Program the ALT_SECT bit.
  2. 2. Make sure protection mechanism does not prevent programming (TZ, PRIV and OBK-HDPL).
  3. 3. Check that no memory operations are ongoing by checking the BSY and DBNE bits in the FLASH_SECSR register and that the write buffer is empty by checking the WBNE bit in the FLASH_SECSR register.
  4. 4. Check and clear all the secure error flags due to previous operation.
  5. 5. Unlock the FLASH_SECCR register only if this register is not already unlocked, as described in Section 7.6.7 .
  6. 6. Enable write operations by setting the SECPG bit in the FLASH_SECCR register.
  7. 7. Write one flash-word corresponding to 16-byte data starting at 16-byte aligned address.

Note: WBNE flag indicates if the 128-bit write buffer is waiting for new data.

Note: No erase request, options change request, OBK swap sector or OBK alternate sector erase is allowed between first write and the completion of flash write operation.

  1. 8. Wait for the BSY bit to be cleared in the corresponding FLASH_SECSR register.
  2. 9. Clear PG bit in FLASH_SECCR register if there is not any programming request anymore in the bank.

If step 7 is executed incrementally (byte per byte), the write buffer can become partially filled. In this case the application software can decide to force-write what is stored in the write buffer by using FW bit in FLASH_SECCR register. In this particular case, the unwritten bits are automatically set to 1. If no bit in the write buffer is cleared to 0, the FW bit has no effect.

Figure 30. OBK protection checks

Flowchart for OBK protection checks. The process starts at 'Idle', proceeds to 'Write access of any type: 128, 64, 32, 16, 8 bit length', then checks buffer address (128-bit range), buffer address (not written twice), protection (TZ/Priv), OBK-HDPL value, stores data in 128-bit buffer, checks if buffer is full or SECFW=1, and finally checks if it's the same sector request (ALT_SECT=0). Depending on these checks, it either calls OBK Write (same sector), OBK Write (alternate sector), or OBK Swap sector. Errors like OBK error, Protection error, Strobe error, and Inconsistency error are also shown.
graph TD
    Idle([Idle]) --> Write[Write access of any type:
type: 128, 64, 32, 16,
8 bit length] Write --> Check1{Check buffer
address (inside same
128-bit address range)} Check1 --> Check2{Check buffer
address : same addr
is not written twice} Check2 --> Check3{Check protection
(TZ/Priv)} Check3 --> Check4{Check OBK-
HDPL value*} Check4 --> Store[Store date in
128-bit Write
buffer] Store --> Check5{128-bit buffer full
or SECFW=1} Check5 --> Check6{Same sector request
ALT_SECT=0?} Check1 --> Inconsistency((Inconsistency
error INCERR)) Check2 --> Strobe((Strobe error
STRBERR)) Check3 --> Protection((Protection error
( WI, ILAFM,
WRPERR))) Check4 --> OBKError((OBK error
OBKERR)) Check5 --> OBKError Check6 --> WriteSame[Call OBK
Write
(same
sector)] Check6 --> WriteAlt[Call OBK
Write
(alternate
sector)] OBKCR1[OBKCR register
ALT_SECT: same
or new sector] --> Check6 Idle --> OBKCR2[OBKCR register
Set SWAP_SECT_REQ
and SWAP_OFFSET] OBKCR2 --> Swap[Call OBK
Swap
sector] WriteSame --> Idle WriteAlt --> Idle Swap --> Idle Inconsistency --> Idle Strobe --> Idle Protection --> Idle OBKError --> Idle
Flowchart for OBK protection checks. The process starts at 'Idle', proceeds to 'Write access of any type: 128, 64, 32, 16, 8 bit length', then checks buffer address (128-bit range), buffer address (not written twice), protection (TZ/Priv), OBK-HDPL value, stores data in 128-bit buffer, checks if buffer is full or SECFW=1, and finally checks if it's the same sector request (ALT_SECT=0). Depending on these checks, it either calls OBK Write (same sector), OBK Write (alternate sector), or OBK Swap sector. Errors like OBK error, Protection error, Strobe error, and Inconsistency error are also shown.

7.5.4 OBK programming finite state machine

When the OBK write buffer is filled, the OBK programming is launched automatically in the current OBK sector or in the alternate OBK sector, depending upon the ALT_SECT bit.

If the address is not virgin, the OBKWRERR is raised.

Figure 31. Key writing flow

Flowchart illustrating the Key writing flow for two cases: Same sector (current sector = S1) and Alternate sector (current sector = S1).
graph TD
    subgraph SameSector [Same sector (current sector = S1)]
        S1_1([OBK write request
Same sector
(current sector = S1)]) --> S1_2[Read data @ key index S1] S1_2 --> S1_3{Is data =
0xFF..FF} S1_3 -- Yes --> S1_4[Write data] S1_3 -- No --> S1_5[Signal OBK Write error
OBKWRERR] S1_4 --> S1_6([End]) S1_5 --> S1_6 end subgraph AlternateSector [Alternate sector (current sector = S1)] S2_1([OBK write request
Alternate sector
(current sector = S1)]) --> S2_2[Read data @ key index S2] S2_2 --> S2_3{Is data =
0xFF..FF} S2_3 -- Yes --> S2_4[Write data] S2_3 -- No --> S2_5[Signal OBK Write error
OBKWRERR] S2_4 --> S2_6([End]) S2_5 --> S2_6 end

The flowchart shows two parallel paths for key writing. The left path is for a 'Same sector (current sector = S1)' request, which involves reading data at key index S1, checking if it equals 0xFF..FF, and then either writing data or signaling an error. The right path is for an 'Alternate sector (current sector = S1)' request, which involves reading data at key index S2, checking if it equals 0xFF..FF, and then either writing data or signaling an error. Both paths end at an 'End' state. A small code 'MSv68821V4' is visible in the bottom right corner of the diagram.

Flowchart illustrating the Key writing flow for two cases: Same sector (current sector = S1) and Alternate sector (current sector = S1).

7.5.5 OBK swap sector

The user can request a swap of the option byte keys by setting the bit SWAP_SECT_REQ in the NS/SECOBKCFGR register. The number of keys swapped is defined by the SWAP_OFFSET in NS/SECOBKCFGR register.

Swap is limited by OBK-HDPL value, the following SWAP_OFFSET values are permitted:

The programming sequence is the following:

  1. 1. Check that no memory operations are ongoing by checking the BSY and DBNE bit in the FLASH_SEC/NSSR register and that the write buffer is empty by checking the WBNE bit in the FLASH_SEC/NSSR register.
  2. 2. Check and clear all the secure/non-secure error flags due to previous operation.
  3. 3. Unlock NS/SECOBKCFGR register if not unlocked already thanks to FLASH_NS/SECOBKKEYR.
  1. 4. Define the numbers of keys to be swapped thanks to SWAP_OFFSET field in NS/SECOBKCFGR. SWAP_OFFSET must be equal to or greater than OBK_HDPL<N-1>_OFFSET.
  2. 5. Set bit SWAP_SECT_REQ in NS/SECOBKCFGR.
  3. 6. Wait for BSY bit to be cleared. In case of error OBKERR flag is set.
  4. 7. SWAP_SECT_REQ is cleared automatically at the end of the operation or in case of error.

Figure 32. Swap workflow

Flowchart of the swap workflow. It starts with 'OBK swap page request (current page = S1)', followed by a decision 'SWAP_OFFSET > 1'. If 'Yes', it sets 'Addr index = 0', then enters a loop: 'Read data @ S2 (addr index)' -> 'Is data = 0xFF..FF'. If 'Yes', it 'Copy data S1(addr index) -> S2(addr index)'. If 'No', it skips to 'Increment addr index'. After 'Increment addr index', it checks 'Addr index = SWAP_OFFSET?'. If 'Yes', it 'Set current page = S2' and 'Erase page 1', then 'End'. If 'No', it loops back to 'Read data @ S2 (addr index)'. A note indicates SWAP_OFFSET is set in OBKCR register.
graph TD; Start([OBK swap page request
(current page = S1)]) --> Decision1{SWAP_OFFSET > 1}; Decision1 -- Yes --> Init[Addr index = 0]; Init --> Read[Read data @ S2
(addr index)]; Read --> Decision2{Is data = 0xFF..FF}; Decision2 -- Yes --> Copy[Copy data S1(addr index) -> S2(addr index)]; Copy --> Increment[Increment addr index]; Decision2 -- No --> Increment; Increment --> Decision3{Addr index = SWAP_OFFSET?}; Decision3 -- Yes --> EndPage[Set current page = S2
Erase page 1]; EndPage --> End([End]); Decision3 -- No --> Read; Note[①SWAP_OFFSET is set in OBKCR register. It indicates the numbers of data to swap.]
Flowchart of the swap workflow. It starts with 'OBK swap page request (current page = S1)', followed by a decision 'SWAP_OFFSET > 1'. If 'Yes', it sets 'Addr index = 0', then enters a loop: 'Read data @ S2 (addr index)' -> 'Is data = 0xFF..FF'. If 'Yes', it 'Copy data S1(addr index) -> S2(addr index)'. If 'No', it skips to 'Increment addr index'. After 'Increment addr index', it checks 'Addr index = SWAP_OFFSET?'. If 'Yes', it 'Set current page = S2' and 'Erase page 1', then 'End'. If 'No', it loops back to 'Read data @ S2 (addr index)'. A note indicates SWAP_OFFSET is set in OBKCR register.

While the OBK SWAP operation is ongoing, the BSY flag is set and no other operation (write, erase, user opt change) can be launched in parallel.

7.5.6 OBK alternate sector erase

The user can request the erase of the alternate OBK sector by setting the bit ALT_SECT_ERASE in the FLASH_NS/SECOBKCFGR register.

The programming sequence must be:

  1. 1. Check that no memory operations are ongoing by checking the BSY and DBNE bits in the FLASH_SEC/NSSR register and that the write buffer is empty by checking the WBNE bit in the FLASH_SEC/NSSR register.
  2. 2. Check and clear all the secure/non-secure error flags due to previous operation.
  3. 3. Set bit ALT_SECT_ERASE in NS/SECOBKCFGR.
  4. 4. Wait for BSY bit to be cleared.
  5. 5. ALT_SECT_ERASE is cleared automatically at the end of the operation or in case of error.

7.6 FLASH security and protections

To protect sensitive information against unwanted operations (such as reading confidential areas, illegal programming of immutable sectors, or malicious flash memory erasing), the FLASH implements the following protection mechanisms:

The microcontroller can have TrustZone active (TZ_STATE = 0xB4) or not (TZ_STATE = 0xC3).

While TrustZone is active the flash memory can be accessed in four basic modes:

While TrustZone is disabled, only two modes are possible:

The flash interface evaluates the access restrictions in the following order:

  1. 1. TrustZone security
  2. 2. Write protection (for write access)
  3. 3. HDP
  4. 4. Privilege

7.6.1 TrustZone security protection

The global TrustZone system security is activated by setting the TZEN option in the FLASH_OPTSR2_PRG register. The actual state of TZ is however determined by the SBS and the setting of TZ_STATE (refer to Section 14.3.5: SBS boot control ).

When TrustZone is active (TZ_STATE = 0xB4), additional security features are available:

Activating TrustZone security

When the TrustZone is activated (TZ_STATE = 0xB4), the SECBOOTADD and the secure watermark areas are set to a secure default value. Default settings are also used in case of corrupted configuration. In this default state, user flash memory is secure (see Table 55 ).

Table 55. Default secure watermark

Secure watermark in case of configuration errorSecurity attribute
SECWMx_STRT = 0
SECWMx_END = 0x7F (1)
All flash memory is secure

1. Default and maximum values depend upon the total number of sectors in the user flash memory.

Illegal access generation

A non-secure access to a secure flash memory area is RAZ/WI, it generates an illegal access event. An illegal access interrupt is generated if the FLASHIE illegal access interrupt is enabled in the TZIC_IER2 register.

A non-secure access to a secure flash register generates an illegal access event. An illegal access interrupt is generated if the FLASH_REGIE illegal access interrupt is enabled in the TZIC_IER2 register.

Table 56. Flash memory TZ protection summary

TZ protection
(TZ_STATE = 0xB4)
Main flash
Non-secure sectorSecure sector
SecureFetchBUS ERROROK
ReadRAZ, ILAFM
WriteWI, WRPERR, ILAFMIf not WRP: OK
else: WI, WRPERR
Erase

Table 56. Flash memory TZ protection summary (continued)

TZ protection
(TZ_STATE = 0xB4)
Main flash
Non-secure sectorSecure sector
Non-secureFetchOKBUS ERROR
ReadRAZ, ILAFM
WriteIf not WRP: OK
else: WI, WRPERR
WI, WRPERR, ILAFM
Erase

Table 57. TZ protection and bank or mass erase summary

TZ protection
(TZ_STATE = 0xB4)
Main flash
Non-secure flashSecure flashMix of secure and non-secure
MESWI, WRPERR, ILAFMOKWI, WRPERR, ILAFM
MENSOKWI, WRPERR, ILAFMWI, WRPERR, ILAFM

Deactivate TrustZone security

Reversing of the TZ setting in OB (TZEN) is possible when the product state is ST-RoT-Ready or Provisioning. Deactivating TZEN from other states requires full regression (Regression state).

When the TrustZone is deactivated (TZ_STATE = 0xC3) after option bytes loading, the following security features are deactivated:

Watermark-based secure flash area protection

When TrustZone security is active (TZ_STATE = 0xB4), a part of the flash memory can be protected against non-secure read and write accesses. Up to two different nonvolatile secure areas can be defined by option bytes and can be read or written by a secure access only: one area per bank can be selected with a sector granularity.

The secure areas are defined by a start sector offset and end sector offset using the SECWMx_STRT and SECWMx_END option bytes. These offsets are defined in the secure watermark registers address registers FLASH security watermark for Bank1 (FLASH_SECWM1R_CUR) , FLASH security watermark for Bank2 (FLASH_SECWM2R_CUR) and modified by corresponding FLASH_XXX_PRG registers.

The SECWMx_STRT and SECWMx_END option bytes can be modified only by secure firmware.

Table 58. Secure watermark-based area

Secure watermark option bytes values (x = 1, 2)Secure watermark protection area
SECWMx_STRT > SECWMx_ENDNonsecure area
SECWMx_STRT = SECWMx_ENDOne sector defined by SECWMx_STRT is secure watermark-based protected
SECWMx_STRT < SECWMx_ENDThe area between SECWMx_STRT and SECWMx_END is secure watermark-based protected

Caution: Switching a memory area from secure to nonsecure does not erase its content. The user secure software must perform the needed operation to erase the secure area before switching an area to non-secure attribute whenever is needed. It is also recommended to flush the instruction cache.

7.6.2 Hide protection (HDP)

The HDP area is independent of the flash watermark-based secure area. One nonvolatile secure hide protection (HDP) area per bank can be defined with a sector granularity. Access to the hide protection area can be denied by progressing the HDPL level in the SBS.

When the HDPL = 1, no user flash is protected by the HDP. With HDPL \( \geq \) 2 the user OB defined HDP area in each bank is closed. No read, write, fetch or erase is allowed in the HDP area.

The HDP area can be extended, the extension setting is only a register value, not stored in OB. With HDPL = 3 the HDP area remains activated and the extension is added. If extension is added while the base user OB defined area is not active, the extension covers one more sector, because HDPx_END sector is also protected.

The HDPL level can be only cleared by a system reset, there is no means to deactivate the HDP area.

The protected HDP area is defined by setting its size using start and end sectors in a similar way as the secure watermark.

The size of the inaccessible area can be extended using register FLASH_HDPEXTR values HDPx_EXT, representing the number of sectors added to the HDP area (past the HDPx_END sector). The volatile HDPx_EXT value can be increased, but cannot decrement.

If HDPx_STRT > HDPx_END the extension covers (HDPx_EXT + 1) size area between sectors marked by HDPx_END and HDPx_END + HDPx_EXT.

By default HDPx_END is set to 0 and HDPx_STRT is set to 1. This means that the HDP area in user flash has a 0 size, and extends from the flash start address (first sector).

For example, to protect area by HDP from the address 0x0801 4000 (included) to the address 0x0804 FFFF (included):

Figure 33. HDP (a) in user flash memory (STM32H563/573xx devices) Diagram of a Flash bank showing HDP protection. The bank is divided into sectors from Sector 0 to Sector 127. The protection area is defined by PSTART = 0x0A and PEND = 0x27. The HDP1 - HDPL1 closes at Sector 0, and the HDP_EXT = 0x1D extension area is shown. The diagram is labeled MSv68823V2.
Diagram of a Flash bank showing HDP protection. The bank is divided into sectors from Sector 0 to Sector 127. The protection area is defined by PSTART = 0x0A and PEND = 0x27. The HDP1 - HDPL1 closes at Sector 0, and the HDP_EXT = 0x1D extension area is shown. The diagram is labeled MSv68823V2.

Note: For more details on the bank swapping mechanism, refer to Section 7.6.6 . The values have an upper limit, 127 for STM32H562/63/73xx devices, 31 for STM32H523/33xx devices.

Table 59. Secure hide protection

HDPx watermark option byte values
(x = 1, 2)
Hide protection area
HDPL ≤ 1-No inaccessible HDP area in user flash memory
HDPL = 2HDPx_END < HDPx_STRTNo inaccessible HDP area in user flash memory
HDPx_END = HDPx_STRTExactly one sector is protected by HDP
HDPx_END > HDPx_STRTThe area between HDPx_STRT and HDPx_END is HDP protected.
HDPL = 3HDPx_END < HDPx_STRT
and HDPx_EXT = 0
No inaccessible HDP area in user flash memory
HDPx_END ≥ HDPx_STRT
or HDPx_EXT > 0
The area between min (HDPx_STRT, HDPx_END) and (HDPx_END + HDPx_EXT) is HDP protected

a. The HDP works analogically, the number of sectors is the only differentiator.

Table 60. HDP protections summary

HDP protectionUser flash
Access to OB HDP areaAccess to EXT HDP area
HDPL 2 or 3HDPL1HDPL3HDPL1 or HDPL 2
FetchBUS ERROROKBUS ERROROK
ReadRAZRAZ
WriteWI, WRPERRIf not WRP: OK
Else: WI, WRPERR
WI, WRPERRIf not WRP: OK
Else: WI, WRPERR
Erase (mass erase)

7.6.3 Block-based secure flash memory area protection

Any sector can be programmed on-the-fly as secure or non-secure using the block-based configuration registers. FLASH_SECB1x/FLASH_SECB2x registers are used to configure the security attribute for, respectively, sectors in Bank1/Bank2.

When the sector security attribute bit SECBByx[i] is set, the security attribute is the same as the secure watermark-based area. The secure sector is accessible only by a secure access.

If the SECBBy[i] bit is set or reset for a sector already included in a secure watermark-based area, the sector keeps the watermark-based protection security attributes.

To modify a block-based sector security attribute, it is recommended to:

Caution: Switching a sector from secure to non-secure does not erase the content of the associated sector. User secure software must perform the needed operations before switching to non-secure attribute:

Note: For SECBByx[i] access control, refer to Table 61.

Execute protection for S-Bus (AHB register bus) is done in AHB decoder, not in flash memory interface itself.

Table 61. Secure configuration block-based registers access conditions

AccessCorresponding sector privilege statusSector setting in SECBByx
FetchSecure/
non-secure
Privilege/
unprivilege
-BUS ERROR
Read-OK
WriteSecurePrivilege-OK
Unprivilege0OK
1WI
Non-securePrivilege/
unprivilege
-WI, ILAP

7.6.4 Block-based privileged flash memory area protection

Any sector can be programmed on-the-fly as privileged or unprivileged using the block-based configuration registers. FLASH_PRIVBB1x and FLASH_PRIVBB2x registers are used to configure the privilege attribute for, respectively, sectors in Bank1 and Bank2.

When the sector privilege attribute PRIVBBx[i] bit is set, the sector is accessible only by a privileged access. An unprivileged sector is accessible by a privileged or unprivileged access.

To modify a block-based privilege attribution, it is recommended to:

Caution: Switching a sector from privileged to unprivileged does not erase the content of the associated sector.

Table 62. Privilege protection summary

Access (TZ not relevant)Main flash
Unprivileged sectorPrivileged sector
PrivilegeFetchOK
Read
Write
Erase
UnprivilegeFetchOKRAZ
Read
WriteWI, WRPERR
Erase

Table 63. Privilege and mass or bank erase

Access
(TZ state not relevant)
Main flash
Unprivileged FLASHPrivileged FLASHMix unprivileged and privileged FLASH
MEPOK
MENPOKWI, WRPERR

Note: For PRIVBBx[i] access control, refer to Table 64 and Table 65.

Table 64. Privilege configuration register access conditions (TZ enabled)

AccessCorresponding sector secure status (1)Sector setting access in PRIVBBx
FetchPrivileged/
unprivileged
Secure/
non-secure
-BUS ERROR
Read-OK (all sectors)
Table 64. Privilege configuration register access conditions (TZ enabled) (continued)
AccessCorresponding sector secure status (1)Sector setting access in PRIVBBxy
WritePrivilegedSecure-OK (all sectors)
Non-secureNSOK (only the sector corresponding to the bit)
SWI (only the sector corresponding to the bit)
UnprivilegedSecure/non-secure-WI

1. Either watermark or block-based.

Table 65. Privilege configuration register access conditions (TZ disabled)
AccessSector setting access in PRIVBBRxy
FetchPrivileged/unprivilegedBUS ERROR
ReadOK
WritePrivilegedOK
UnprivilegedWI

7.6.5 Flash memory register privileged and unprivileged modes

The flash registers can be read and written by privileged and unprivileged accesses depending on the SPRIV and NSPRIV bits in FLASH privilege configuration register (FLASH_PRIVCFGR) :

The registers related to key storage (FLASH_NSOBKCFGR, FLASH_SECOBKCFGR, FLASH_NSOBKKEYR, FLASH_SECOBKKEYR) are exceptions to this rule and can be only accessed in privilege, regardless of other settings.

The next table summarizes flash registers access control.

Table 66. Flash register accesses (1)
AccessNon-secure registerSecure register
NSPRIV = 1NSPRIV = 0SPRIV = 1SPRIV = 0
XSecure/non-securePrivileged/unprivilegedBus error
R/WSecurePrivilegedOK
R/WUnprivilegedRAZ, WIOKRAZ, WIOK
Table 66. Flash register accesses (1) (continued)
AccessNon-secure registerSecure register
NSPRIV = 1NSPRIV = 0SPRIV = 1SPRIV = 0
R/WNon-securePrivilegedOKRAZ, WI, ILAP
R/WUnprivilegedRAZ, WIOK

1. Some registers are privilege only, not configurable.

7.6.6 Flash memory banks attributes in case of bank swap

The SWAP_BANK option bit modifies the address of each bank in the memory map. When SWAP_BANK is reset, flash Bank1 is mapped at the lower address range. When SWAP_BANK is set, flash Bank1 is mapped at the higher address range. flash bank attributes follow their bank contents so there is no need to modify their setting registers when swapping banks:

The SWAP_BANK is rendered immutable by setting BOOT_LOCK in the user OB. If TZEN is enabled, then SECBOOT_LOCK locks the option. If TZEN is disabled, then NSBOOT_LOCK locks the SWAP_BANK option.

Note: The BK_ECC bit in the FLASH ECC detection register (FLASH_ECCDETR) and FLASH ECC correction register (FLASH_ECCCORR) , BKSEL bit in FLASH non-secure control register (FLASH_NSCR) and BKSEL bit in FLASH secure control register (FLASH_SECCR) always refers to Bank1 (respectively Bank2) when it is low (respectively high), regardless of the SWAP_BANK value.

Figure 34 shows how security attributes and protections behave in case of bank swap.

Figure 34. Protection attributes in case of bank swap illustration

Diagram illustrating the effect of a bank swap on flash memory protection attributes. The diagram shows two states: the initial state and the state after a SWAP_BANK operation. In the initial state, Bank 1 (top) contains HDP area, Secure watermark area, Bank 1, Write protection blocks, -, and Data area. Bank 2 (bottom) contains No protections defined. After the swap, Bank 1 (bottom) contains the same protection attributes as before, and Bank 2 (top) contains No protections defined. Memory addresses are shown on the left and right sides of the diagram.

The diagram illustrates the effect of a bank swap on flash memory protection attributes. It shows two states: the initial state and the state after a SWAP_BANK operation.

Initial State (Top):

Initial State (Bottom):

After SWAP_BANK operation:

A large 'X' with the label 'SWAP_BANK' is positioned between the two states, indicating the swap operation.

Diagram illustrating the effect of a bank swap on flash memory protection attributes. The diagram shows two states: the initial state and the state after a SWAP_BANK operation. In the initial state, Bank 1 (top) contains HDP area, Secure watermark area, Bank 1, Write protection blocks, -, and Data area. Bank 2 (bottom) contains No protections defined. After the swap, Bank 1 (bottom) contains the same protection attributes as before, and Bank 2 (top) contains No protections defined. Memory addresses are shown on the left and right sides of the diagram.

7.6.7 Flash memory configuration protection

The memory uses hardware mechanisms to protect the following assets against unwanted or spurious modifications (such as software bugs):

The memory configuration registers protection is summarized in Table 67 . Registers not present in this table are not protected by a key.

Table 67. Flash interface register protection summary

Register nameUnlocking registerProtected asset
FLASH_NSCRFLASH_NSKEYRWrite/erase control
FLASH_SECCRFLASH_SECKEYRSecure write/erase control
FLASH_OPTCR +
all_PRG registers
FLASH_OPTKEYRFlash bank option byte words change
FLASH_NSOBKFGRFLASH_NSOBKKEYRFlash OBKey storage manipulation
FLASH_SECOBKCFGRFLASH_SECOBKKEYR

7.6.8 Write protection

The purpose of the write protection is to prevent unwanted modifications to code and/or data.

Any group of four consecutive 8-Kbyte sectors can be independently write-protected or unprotected by clearing/setting the corresponding WRPSGn1/2 bit in the FLASH_WRPSG1/2 register (see FLASH write sector group protection for Bank1 (FLASH_WRP1R_CUR) and FLASH write sector group protection for Bank2 (FLASH_WRP2R_CUR) ).

A write-protected group of sectors cannot be erased nor programmed. As a result, a bank erase cannot be performed if one group of sectors is write-protected, unless a NVSTATE transition to OPEN is triggered (erasing the whole user flash memory).

Note: Write protection errors are documented in Section 7.9 .

7.6.9 Flash high-cycle data protections

The memory can be configured to have 96-Kbyte memory area with high-cycling capability (100 kcycles) to store data and emulate EEPROM, see Section 7.3.10 .

Option byte controlled security features for user flash memory prevent sectors from being used as high-cycle data area. No OPTCHANGEERR is raised in case of setting conflict, it only makes the sectors unusable. Details are listed in Table 68 .

Volatile settings using FLASH_SECBxx and FLASH_PRIVBBxx can be applied. In this case the security setting of user flash sector 127 applies to flash high-cycle data sector 0 and so on, as indicated in Figure 25 , Figure 26 , and Figure 29 .

Volatile settings of HDP extension that extends into sectors of data area cause the data area to be inaccessible.

Table 68. High-cycle area protection summary: access to data area address range

TZ protection (when
TZ_STATE = 0xB4) (1)
Data sector enabledData
sector
not
enabled
HDP
protected
OB
secure
area
SecBB protectedNS sector
16/32 bits
access
Other16/32 bits
access
Other
SecureFetchBUS ERRORBUS ERROR
ReadOKBUS
ERROR
RAZ, ILAC
WriteIf not WRP:
OK else WI,
WRPERR
WI, WRPERR, ILAFM
EraseSame protection as in corresponding classic user flash sector
Non-secureFetchBUS ERRORBUS ERROR
ReadRAZ, ILACOKBUS
ERROR
WriteWI, WRPERR, ILAFMIf not WRP:
OK else WI,
WRPERR
EraseSame protection as in corresponding classic user flash sector
  1. 1. If TZ_STATE = 0xC3, there is no secure state access, no SecBB, and no Secure Area. For HDP and NS access the rules remain the same.

Table 69. HDP protected definition

User flashOB HDP area enabledHDP extension enabled
HDPL1HDP protected = 0HDP protected = 0
HDPL2HDP protected = 1HDP protected = 0
HDPL3HDP protected = 1HDP protected = 1

Table 70. Privileged sectors and data area - Access to data area address range

AccessData area address range access
Unprivileged sectorPrivileged sector
PrivilegedFetchBUS ERROR
ReadOKOK
WriteOKOK
UnprivilegedFetchBUS ERROR
ReadOKRAZ, ILAC
WriteOKWI, WRPERR

7.6.10 Life cycle management

Non-volatile or debug states are determined by the product state set by user option bytes. Debug possibility and possibility to change selected security settings are related to it. While the state is stored in the OB, it is the SBS that controls the debug policy.

OBK storage access conditions are unaffected by the PRODUCT_STATE, but keys can be evicted in regression transitions.

HDP works regardless of the debug state. Even in debug the HDP area is hidden when HDPL increments.

The following states are defined:

Table 71. Product states, debug states and debug policy

PRODUCT_STATECode in OBDescription
Open0xEDUser flash open (TZ secure and non-secure open).
External access (debug) N and NS enabled (~RDP0).
Provisioning0x17Provisioning - Immutable root of trust is being installed.
Open if TZEN = 0xC3. The debug is opened in HDPL3-NS.
iROT-Provisioned0x2EThe immutable root of trust is installed (~RDP 0.5).
TZ-Closed0xC6State for debugging the NS application.
Debug is restrained to non-secure areas.
Closed0x72State for running a secure application.
Debug disabled, regression is possible.
Locked0x5CTransition to other state, policy change or debug not permitted (1) .
Regression0x9AThe temporary state initiated by the debug authentication system in transition to Open.
NS-Regression0xA3The temporary state initiated by the debug authentication system in transition to TZ-Closed.

1. The same situation is Closed state with incorrect or not defined debug certificates.

1. No debug protection

Read, program and erase operations into the flash main memory area are possible. Least restriction on the option bytes.

2. Non-secure debug only

All read and write operations (if no write protection is set) from/to the non-secure flash memory are possible. The debug access to secure area is prohibited. Debug access to non-secure area remains possible.

The following rules are enforced:

3. Full product protection

All debug features are disabled and following rules enforced:

7.6.11 Product state transitions

Progressing towards a more closed state is the normal product life cycle, that does not require security measures. Transition towards Open state is a regression, controlled by the debug authentication control. If debug unlock policy is set to “locked”, no regression is accepted. Locked state can be reinforced by invalidating the debug authentication certificates.

All transitions not listed in this chapter are invalid.

There is no restriction on reading the current product state.

Transitions in progress direction

Transition from Open to any of the closed states is matter of correct product configuration and provisioning. The transitions must be done in correct order.

The normal progression is:

Transition is managed either by a software running on the device, or directly, using a debug interface. Transitions from Closed are only possible by software running on the device. By software it is assumed that transitions are triggered by bootloader, or root-of-trust services, but generally any software running on the device can do a progress transition.

Transition to Open state

This transition is a full regression. The starting state is any except Open and Locked. The debug tools are used to authenticate debug regression access rights with the debug authentication library, running on the device in HDPL1 (refer to Section 14.3.6: SBS debug control ). After verifying the credentials, it puts the device into intermediate state Regression. From this state the device regresses securely in HDPL0 to Open.

The transition has the following consequence:

Transition from closed to closed-secure debug state

This transition opens the device to authorize the debug of the non-secure application software without compromising the security of the ROT functions.

The starting state is Closed. The debug tools are used to authenticate debug regression access rights with the debug authentication library, running on the device in the HDPL1 (refer to Section 14.3.6: SBS debug control ). After verifying the credentials, it puts the device into intermediate state NS-Regression. From this state, the device regresses securely in HDPL0 to Closed.

The transition has the following consequence:

Table 72. PRODUCT_STATE transitions

FromTo (1)
OpenProvisioningiROT-ProvisionedTZ-Closed (2)ClosedLockedRegressionNS-Regression (2)
Open-OKOKXXXXX
ProvisioningX-OKOKOKOKOK (HDPL1)X
iRoT-ProvisionedXX-OKOKOKOK (HDPL1)X
TZ-ClosedXXX-OKOKOK (HDPL1)X
ClosedXXXX-XOK (HDPL1)OK (HDPL1)
LockedXXXXX-XX

Table 72. PRODUCT_STATE transitions (continued)

FromTo (1)
OpenProvisioningiROT-ProvisionedTZ-Closed (2)ClosedLockedRegressionNS-Regression (2)
RegressionOK (HDPL0)XXXXX-X
NS-RegressionXXXOK (HDPL0)XXX-

1. X = transitions not permitted (OPTCHANGEERR raised), - = no change, OK = valid transitions.

2. To transition into this state, both the current and programmed values of TZEN must be enabled (TZEN = 0xB4), otherwise the change is ignored with OPTCHANGEERR.

In Table 72 , X indicates transitions that are not permitted, a dash indicates no change, OK indicates valid transitions. Some transitions are possible only in correct HDPL provided in parenthesis. Attempts to do an illegal transition result in OPTCHANGEERR.

Incorrect PRODUCT_STATE (no OBL) is interpreted as Locked.

7.6.12 OBK protection

At the receipt of an OBK access (read/write/execute), secure and privilege attributes are first checked, followed by OBK-HDPL. The OBK-HDPL value must exactly match the HDPL assigned to the key location, otherwise OBKERROR flag is raised. Flash interface response is described in Table 73 .

Table 73. TZ OBK protection summary

TZ protection
(when
TZ_STATE = 0xB4)
OBK accessTamper
No tamper
HDPL0/1/2/3OBK selector
XSBUS ERRORBUS ERRORRAZ, WI
RSOK if privilege, otherwise RAZRAZ
WSOK if privilege, otherwise WI, WRPERRWI, if not privilege also WRPERR
XNSBUS ERRORBUS ERROR
RNSRAZ, ILAFMRAZ, ILAFM
WNSWI, WRPERR, ILAFMWI, WRPERR, ILAFM
EraseNANANA

Table 74. OBK protection summary with TZ disabled

TZ protection
(when
TZ_STATE = 0xC3)
OBK accessTamper
No tamper
HDPL1/2/3OBK selector
XNSBUS ERRORBUS ERROR
RNSOK if privileged, otherwise RAZRAZRAZ,
WI
WNSOK if privilege, otherwise WI, WRPERRWI if privileged, otherwise WI, WRPERR
EraseNANANA

Note: Cacheable access is managed at system level and not in the flash interface. The MPU must be configured to disable cache where it is not desirable.

In case of tamper, all keys are read as 0x00s.

There are also rules for accessing the OBKFGCR and OBKKEYR registers.

Table 75. Access conditions to secure control register

-S/NSP/NPTZ stateSECOBKCFGR and
SECOBKKEYR access
X---Bus error
R/WSPActiveOK
R/WSNPActiveRAZ, WI
R/WNSPActiveRAZ, WI, ILAP
R/WNSNPActiveRAZ, WI, ILAP
R/W--DeactivatedRAZ, WI

Table 76. Access conditions to non-secure control register

S/NSP/NPTZ stateNSOBKCFGR and
NSOBKKEYR access
X---Bus error
R/W--ActiveRAZ, WI
R/W-PDeactivatedOK
R/W-NPDeactivatedRAZ, WI

7.6.13 One-time-programmable and read-only memory protections

Sections of OTP/RO in the flash memory are described in details in Section 7.3.9 . There is no protection provided by the flash memory interface other than the dedicated write protection.

No write is possible to the RO area, once it was established in manufacturing. The OTP write protection describes a method of locking out the OTP area.

The access conditions are summarized in Table 77 .

Table 77. OTP/RO access constraints

-8 Kbytes sector dedicated to RO/OTP
0x08FF_E000 - E7FF0x08FF_E800 - EFFF
Reserved
0x08FF_F000 - F7FF
OTP
0x08FF_F800 - FFFF
RO
XSBUS ERRORBUS ERROR
RSRAZ, ILAC
WSWI, WRPERR, ILAFM
XNSBUS ERRORBUS ERROR
RNSIf correct size (1) RAZ,
else BUS ERROR
If correct size OK, else BUS ERROR
WNSIf correct size WI, else
BUS ERROR
BUS ERROR if incorrect size.
WRPERR if block is protected
by LOCKBL, else OK.
If correct size WI, else
BUS ERROR
EraseWI

1. Word size is 16 bits. 32-bit access is possible. Other access attempt leads to bus error.

7.7 System memory

7.7.1 Introduction

System memory stores RSS (root secure services) firmware programmed by ST during production. The RSS provides runtime services to user firmware.

When TrustZone is enabled (user sets TZEN bitfield to 0xB4) then RSS provides secure services to secure user firmware only; when TrustZone is disabled (user sets TZEN bitfield to 0xC3), RSS provides services to user firmware.

7.7.2 RSS user functions

The RSS provides runtime services thanks to RSS library, whose functions are exposed to user within the CMSIS device header file provided by the STM32CubeH5 firmware package (see UM3065 “ Getting started with STM32CubeH5 for STM32H5 Series ” for more details).

RSS provides services through two different libraries, RSSLIB and NSSLIB.

Table 78. RSSLIB/NSSLIB accesses

TZEN configurationUser FW Non-SecureUser FW SecureBootloader/JTAG/SWD (1)
Enabled (0xB4)N/ARSSLIBRSSLIB
Disabled (0xC3)NSSLIBN/A

1. When the devices boot in bootloader, that is, in product state OPEN (with BOOT pin set to 1 and UBE set to 0xB4), or PROVISIONING.

Table 79. RSSLIB/NSSLIB entry point access
C defined macroLocation in flash memory
RSSLIB_PFUNC0xBF9FB68
NSSLIB_PFUNC0xBF9FB6C

RSSLIB

The secure user firmware calls RSSLIB functions using RSSLIB_PFUNC C defined macro, which points to a location within non-secure system memory. Before calling RSSLIB functions, the secure user firmware must define a non-secure region above this location within SAU of the Cortex®-M33, starting from RSSLIB_SYS_FLASH_NS_PFUNC_START (0xBF9FB78), up to RSSLIB_SYS_FLASH_NS_PFUNC_END (0xBF9FB84). These last addresses are provided within the CMSIS device header file.

The user can set this non-secure region either by using the CMSIS system partition header file, or by implementing its own code for SAU setup. The CMSIS system partition header file is part of the STM32CubeH5 firmware package.

Table 80. RSS lib interface functions
LibraryFunctionAttributes
RSSLIB_PFUNCJumpHDPLvl2Secure callable function
JumpHDPLvl3
JumpHDPLvl3NS
DataProvisioningNon-secure callable function

DataProvisioning

Secure attribute: Non-secure callable function.

Prototype:

uint32_t_ DataProvisioning (RSSLIB_DataProvisioningConf_t *pConfig)

User code function call example:

RSSLIB_PFUNC->NSC.DataProvisioning(&pConfig)

Arguments:

pConfig: input parameter. RSSLIB_DataProvisioningConf_t

C structure definition is described below:

typedef struct
{
    uint32_t_ *pSource;
    uint32_t_ *pDestination;
    uint32_t_ Size;
    uint32_t_ DoEncryption;
    uint32_t_ Crc;
} RSSLIB_DataProvisioningConf_t;

Structure elements

pSourceProvides the address of data to be provisioned. Must be within SRAM3 address range (non-secure aliases).
pDestinationProvides the address where to store data to be provisioned. Must be within OBKeys address range. To be aligned on 16 bytes.
SizeProvides the size of data to be provisioned (the number of bytes, must be a multiple of 16).
DoEncryptionNotifies RSSLIB_DataProvisioning function if it must encrypt or not data within OBKeys.
DoEncrypt can be either 0xF5F5A0AAU or 0xCACA0AA0U (the only one allowed on STM32H563xx devices)
  • – 0xF5F5A0AAU: notifies RSSLIB_DataProvisioning to encrypt data with relevant DHUK before programming it within OBKeys. DHUK is selected according to pDestination value.
  • – 0xCACA0AA0U: notifies RSSLIB_DataProvisioning to program in clear data within OBKeys.
CrcCRC over full source data buffer, pConfig->pDestination value, pConfig->Size value and finally pConfig->DoEncryption value.
CRC computation uses CRC-32 (Ethernet):
  • – CRC polynomial: 0x04C11DB7U
  • – Initial value: 0xFFFFFFFFU

Returned values

0xEA EA EA EA EASuccess
0xF5F5E0E0UError:
  • pConfig or pSource are not in SRAM3
  • pDestination is not aligned on 16 bytes
  • pDestination + Size does not fit within an OBKey section
0xF5F50E0EUError: Size is not a multiple of 16
0xF5F58080UError: computed CRC is not the expected one provided within pConfig->CRC
0xF5F58008UError: cannot program data within OBKeys destination section
0xF5F5E00EUError: wrong DoEncryption parameter value
0xF5F50880UError: encryption requested, butw platform does not support it
0xF5F50EE0UError: encryption error
0xF5F50808UError: OBKeys programming error

RSSLIB_DataProvisioning receives in input a data buffer and programs it within OBKeys. A CRC prevents any data and parameters tampering issue.

The destination address ( pDestination ) added to the size ( Size ) of the data to be provisioned must not cross the OBKeys section boundaries, listed below.

OBKeys Level1Start address: 0x0FFD0100UL
End address: 0x0FFD08FFUL
OBKeys Level2Start address: 0x0FFD0900UL
End address: 0x0FFD0BFFUL
OBKeys Level3 secureStart address: 0x0FFD0C00UL
End address: 0x0FFD17FFUL
OBKeys Level3 non-secureStart address: 0x0FFD1800UL
End address: 0x0FFD1FEFUL

When requested through pConfig->DoEncryption parameter, RSSLIB_DataProvisioning encrypts data before programming them within OBKeys.

RSSLIB_DataProvisioning uses AES CBC 128 bits with:

Note: Data encryption within OBKeys is supported only by STM32H533/573xx devices.

JumpHDPLvl2

Secure attribute: Secure callable function.

Prototype:

uint32_t JumpHDPLvl2(uint32_t VectorTableAddr, uint32_t MPUIndex)

User code function call example:

RSSLIB_PFUNC->S.JumpHDPLvl2((uint32_t)NextVectorTableAddr, 1U );

Arguments:

User calls JumpHDPLvl2 to close user Flash HDPL1 area by incrementing HDPL to 2, then jump to the reset handler embedded within the vector table, whose address is passed as input parameter.

After closing HDPL1, JumpHDPLvl2 enables the MPU region provided as input parameter. Once the MPU is enabled, the function sets the SP to the address provided by the passed vector table, and jumps to the reset handler function supported by it. JumpHDPLvl2 does not set the new vector table.

On successful execution, the function does not return and does not push LR onto the stack.

In case of failure (bad input parameter value), RSSLIB_Sec_JumpHDPLvl2 returns 0xF5F5F5F5.

JumpHDPLvl3

Secure attribute: Secure callable function.

Prototype:

uint32_t JumpHDPLvl3(uint32_t VectorTableAddr, uint32_t MPUIndex)

User code function call example:

RSSLIB_PFUNC->S.JumpHDPLvl3((uint32_t)NextVectorTableAddr, 1U );

Arguments:

User calls JumpHDPLvl3 to close user Flash HDPL1 and HDPL2 areas by incrementing HDPL up to 3, then jump to the reset handler embedded within the vector table, whose address is passed as input parameter.

After closing HDPL1/2, JumpHDPLvl3 enables the MPU region provided as input parameter. Once the MPU is enabled, the function sets the SP to the address provided by the passed vector table, and jumps to the reset handler function supported by the vector table. JumpHDPLvl3 does not set the new vector table.

On successful execution, the function does not return and does not push LR onto the stack.

In case of failure (bad input parameter value), JumpHDPLvl3 returns 0xF5F5F5F5.

JumpHDPLvl3NS

Secure attribute: Secure callable function.

Prototype:

uint32_t JumpHDPLvl3NS(uint32_t VectorTableAddr)

User code function call example:

NSSLIB_PFUNC->S.JumpHDPLvl3NS((uint32_t)NextVectorTableAddr, 1U );
    

Arguments:

User calls JumpHDPLvl3NS to close user flash HDPL1 and HDPL2 areas by incrementing HDPL up to 3, to move from secure to non-secure domain, then jump to the non-secure reset handler embedded within the vector table, whose address is passed as input parameter.

After closing HDPL1/2, JumpHDPLvl3 jumps to the non-secure reset handler function supported by the vector table. JumpHDPLvl3NS does not set the new vector table.

On successful execution, the function does not return and does not push LR onto the stack.

In case of failure (bad input parameter value), JumpHDPLvl3NS returns 0xF5F5F5F5.

NSSLIB

The user firmware calls only the NSSLIB function when TrustZone is disabled (TZEN bitfield is set to 0xC3).

The user firmware calls NSSLIB functions using NSSLIB_PFUNC C defined macro, which points to a location within system memory.

Table 81. NSS lib interface functions

LibraryFunctionAttributes
NSSLIB_PFUNCJumpHDPLvl2Non-secure function
JumpHDPLvl3

JumpHDPLvl2

Prototype:

uint32_t JumpHDPLvl2(uint32_t VectorTableAddr, uint32_t MPUIndex)
    

User code function call example:

NSSLIB_PFUNC->JumpHDPLvl2((uint32_t)NextVectorTableAddr, 1U );
    

Arguments:

the MPU region before jumping to the reset handler of the vector table. The vector table reset handler function belongs to the MPU region.

User calls JumpHDPLvl2 to close user Flash HDPL1 area by incrementing HDPL to 2, and to jump to the reset handler embedded within the vector table which address is passed as input parameter

After closing HDPL1, JumpHDPLvl2 enables the MPU region provided as input parameter. Once the MPU is enabled, the function sets the SP to the address provided by the passed vector table and jumps to the reset handler function supported by the vector table too. JumpHDPLvl2 does not set the new vector table.

On successful execution, the function does not return and does not push LR onto the stack.

In case of failure (bad input parameter value), RSSLIB_Sec_JumpHDPLvl2 returns 0xF5F5F5F5.

JumpHDPLvl3

Prototype:

uint32_t JumpHDPLvl3(uint32_t VectorTableAddr, uint32_t MPUIndex)

User code function call example:

NSSLIB_PFUNC->JumpHDPLvl3((uint32_t)NextVectorTableAddr, 1U );

Arguments:

User calls JumpHDPLvl3 to close user Flash HDPL1 and HDPL2 areas by incrementing HDPL up to 3, and then jump to the reset handler embedded within the vector table, whose address is passed as input parameter

After closing HDPL1/2, JumpHDPLvl3 enables the MPU region provided as input parameter. Once the MPU is enabled, the function sets the SP to the address provided by the passed vector table, and jumps to the reset handler function supported by it. JumpHDPLvl3 does not set the new vector table.

On successful execution, the function does not return and does not push LR onto the stack.

In case of failure (bad input parameter value), JumpHDPLvl3 returns 0xF5F5F5F5.

7.8 FLASH low-power modes

Table 82 summarizes the memory behavior in STM32 low-power modes. Embedded flash memory belongs to the core domain.

Table 82. Effect of low-power modes on the embedded flash memory

Power modeCore domain voltage rangeAllowed if FLASH busyFLASH power mode
RunVOS0/1/2/3YesRun
Stop1 (clock stopped)SVOS3/4/5NoClock gated or stopped in case of SVOS5
StandbyOffNoOff

When the system state changes or within a given system state, the memory can operate with a different voltage supply range (VOS), according to the application. The procedure to switch the memory into power modes (run, clock gated, stopped, off) is described hereafter.

Note: For more information on the microcontroller power states, refer to Section 10: Power control (PWR) .

Managing the FLASH domain switching to Stop or Standby

As explained in Table 82 , if the memory informs the reset and clock controller (RCC) that it is busy (BSY, DBNE, WBNE is set), the microcontroller cannot switch the core domain to Stop or Standby mode.

There are two ways to release the memory:

The microcontroller can then switch the domain to Stop or Standby mode.

7.9 FLASH error management

7.9.1 Introduction

The memory automatically reports when an error occurs during a read, program or erase operation. A wide range of errors are reported:

The application software can individually enable the interrupt for each error, as detailed in Section 7.10 .

The flash memory interface uses different interrupt lines to trigger the event. There are two direct lines to NVIC, one for secure interrupts, other for non secure. Third line leads to TZIC, for the ILAFM interrupt.

Note: For all errors, the application software must clear the error flag before attempting a new modify operation.

Since there is just one write buffer and only one operation is allowed at a time, the write control bits and status bits are shared by both banks:

7.9.2 Non-secure write protection error (WRPERR)

When an illegal non-secure erase/program operation is attempted to the nonvolatile memory, the flash interface sets the write protection error flag WRPERR in FLASH_NSSR register.

An erase operation is rejected and flagged as illegal if it targets one of the following memory areas:

A program operation is ignored and flagged as illegal if it targets one of the following memory areas:

When WRPERR flag is raised, the operation is rejected and nothing is changed in the corresponding bank. If this error is detected, the write buffer is invalidated.

Note: WRPERR flag must be cleared before any erase/program operation.

WRPERR flag is cleared by setting CLR_WRPERR bit to 1 in FLASH_NSCCR register.

If WRPERRIE bit in FLASH_NSCR register is set to 1, an interrupt is generated when WRPERR flag is raised (see Section 7.10 for details).

7.9.3 Secure write protection error (WRPERR)

When an illegal secure erase/program operation is attempted to the nonvolatile memory, the flash interface sets the write protection error flag WRPERR in FLASH_SECSR register.

An erase operation is rejected and flagged as illegal if it targets one of the following memory areas:

A program operation is ignored and flagged as illegal if it targets one of the following memory areas:

When WRPERR flag is raised, the operation is rejected and nothing is changed in the corresponding bank.

If this error is detected the write buffer is invalidated.

Note: WRPERR flag must be cleared before any erase/program operation.

WRPERR flag is cleared by setting CLR_WRPERR bit to 1 in FLASH_SECCR register.

If WRPERRIE bit in FLASH_SECCR register is set to 1, an interrupt is generated when WRPERR flag is raised (see Section 7.10 for details).

7.9.4 Non secure programming sequence error (PGSERR)

When the non-secure programming sequence is incorrect, the flash interface sets the programming sequence error flag PGSERR in FLASH_NSSR register.

More specifically, PGSERR flag is set when one of below conditions is met:

When PGSERR flag is raised as consequence of failed write attempt (flash programming), the current program operation is aborted and nothing is changed in the corresponding bank. The write data buffer is also invalidated.

Note: When PGSERR flag is raised, there is a risk that the last write operation performed by the application has been lost because of the above protection mechanism. It is recommended to generate interrupts on PGSERR and verify in the interrupt handler if the last write operation has been successful, by reading back the value in the flash memory.

The PGSERR flag also blocks any new program operation. This means that PGSERR must be cleared before starting a new program operation.

PGSERR flag is cleared by setting CLR_PGSERR bit to 1 in FLASH_NSCCR register.

If PGSERRIE bit in FLASH_NSCR register is set to 1, an interrupt is generated when PGSERR flag is raised. See Section 7.10 for details.

7.9.5 Secure programming sequence error (PGSERR)

When the secure programming sequence is incorrect, the flash interface sets the programming sequence error flag PGSERR in FLASH_SECSR register.

More specifically, PGSERR flag is set when one of below conditions is met:

When PGSERR flag is raised as consequence of failed write attempt (flash programming), the current program operation is aborted and nothing is changed in the corresponding bank. The write data buffer is also invalidated.

Note: When PGSERR flag is raised, there is a risk that the last write operation performed by the application has been lost because of the above protection mechanism. It is recommended to generate interrupts on PGSERR and verify in the interrupt handler if the last write operation has been successful by reading back the value in the flash memory.

The PGSERR flag also blocks any new program operation. This means that PGSERR must be cleared before starting a new program operation.

PGSERR flag is cleared by setting CLR_SECPGSERR bit to 1 in FLASH_SECCCR register.

If PGSERRIE bit in FLASH_SECCR register is set to 1, an interrupt is generated when PGSERR flag is raised. See Section 7.10 for details.

7.9.6 Non-secure strobe error (STRBERR)

When the non-secure application software writes several times to the same byte in the write buffer, the flash interface sets the strobe error flag STRBERR (FLASH_NSSR) whatever the target bank of the write access.

When STRBERR flag is raised, the current program operation is aborted and the write buffer is invalidated.

STRBERR flag is cleared by setting CLR_STRBERR bit to 1 in FLASH_NSCCR register.

If STRBERRIE bit in FLASH_NSCR register is set to 1, an interrupt is generated when STRBERR flag is raised. See Section 7.10 for details.

7.9.7 Secure strobe error (STRBERR)

When the secure application software writes several times to the same byte in the write buffer, the memory sets the strobe error flag STRBERR (FLASH_SECSR) whatever the target bank of the write access.

When STRBERR flag is raised, the current program operation is aborted and the write buffer is invalidated.

STRBERR flag is cleared by setting CLR_STRBERR bit to 1 in FLASH_SECCR register.

If STRBERRIE bit in FLASH_SECCR register is set to 1, an interrupt is generated when STRBERR flag is raised. See Section 7.10 for details.

7.9.8 Non-secure inconsistency error (INCERR)

When a programming inconsistency in non-secure access is detected, the flash interface sets the inconsistency error flag INCERR in register FLASH_NSSR.

More specifically, INCERR flag is set when one of the following conditions is met:

Note: INCERR flag must be cleared before starting a new write operation, otherwise a sequence error (PGSERR) is raised.

It is recommended to follow the following sequence to avoid losing data when an inconsistency error occurs:

  1. 1. Execute a handler routine when INCERR flag is raised.
  2. 2. Stop all write requests to the memory.
  3. 3. Clear INCERR bit.
  4. 4. Restart the write operations from where they have been interrupted.

INCERR flag is cleared by setting CLR_INCERR bit to 1 in FLASH_NSCCR register.

If INCERRIE bit in FLASH_NSCR register is set to 1, an interrupt is generated when INCERR flag is raised (see Section 7.10 for details).

7.9.9 Secure inconsistency error (INCERR)

When a programming inconsistency is detected, the flash interface sets the inconsistency error flag INCERR in register FLASH_SECSR.

More specifically, INCERR flag is set when one of the following conditions is met:

Note: INCERR flag must be cleared before starting a new write operation, otherwise a sequence error (PGSERR) is raised.

It is recommended to follow the sequence below to avoid losing data when an inconsistency error occurs:

  1. 1. Execute a handler routine when INCERR flag is raised.
  2. 2. Stop all write requests to the flash memory.
  3. 3. Clear INCERR bit.
  4. 4. Restart the write operations from where they have been interrupted.

INCERR flag is cleared by setting CLR_INCERR bit to 1 in FLASH_SECCR register.

If INCERRIE bit in FLASH_SECCR register is set to 1, an interrupt is generated when INCERR flag is raised (see Section 7.10 for details).

7.9.10 Error correction code error (ECCC, ECCD)

When a single-error correction is detected during a read, the flash interface sets the single-error correction flag ECCC in FLASH_ECCCORR register.

When two ECC errors are detected during a read, the flash interface sets the double error detection flag ECCD in FLASH_ECCDETR register.

When the ECCC flag is raised, the corrected read data are returned. The application can ignore the error, and request new read operations. When the ECCD the flag is raised, an NMI is generated, it can be masked in SBS registers ( SBS flit ECC NMI mask register (SBS_ECCNMIR) ) for data access (OTP, data area, RO data). Software must invalidate the instruction cache (CACHEINV = 1) in the NMI interrupt service routine when the ECCD flag is set.

When ECCC or ECCD flag is raised, the address of the flash word that generated the error is saved in the FLASH_ECCCORR (FLASH_ECCDETR) register. If the address corresponds to a read-only area or to an OTP area or flash high-cycle data, the OTP_ECC bit is also set to 1 in the FLASH_ECCCORRR (FLASH_ECCDETR) register. This register is automatically cleared when the associated flag that generated the error is reset.

A BK_ECC flag indicates in which flash bank the error occurred.

A SYSF_ECC flag indicates an error detected in the system flash area.

Table 83. Locating ECC failure

OTP_ECCSYSF_ECCBK_ECCEDATA_ECCOBK_ECCFlash areaADDR_ECC minADDR_ECC max
000/100User flash0x00000xFFFF
010/100System flash0x00000x0FFF
10000OTP0x06000x07FF
00101OBKeys0x00000x03FF
000/110Data area sector 70xF0000xF1FF
000/110Data area sector 60xF2000xF3FF
000/110Data area sector 50xF4000xF5FF
000/110Data area sector 40xF6000xF7FF
000/110Data area sector 30xF8000xF9FF
000/110Data area sector 20xFA000xFBFF
000/110Data area sector 10xFC000xFDFF
000/110Data area sector 00xFE000xFFFF

Note: In case of successive single correction or double detection errors, only the address corresponding to the first error is stored in FLASH_ECCCORR (FLASH_ECCDETR) register.

It is mandatory to clear ECCC or ECCD flags before starting a new read operation.

As the ECC interface is shared by the two banks, if the same error is registered simultaneously, a physical Bank1 error is registered. Both errors are registered if one bank reports ECCD and the other bank ECCC.

ECCC (respectively ECCD) flag is cleared by setting to 1 ECCC bit (respectively ECCD bit) in FLASH_ECCCORR (FLASH_ECCDETR) register.

If ECCC bit in FLASH_ECCCORR register is set to 1, an interrupt is generated when ECCC flag is raised. Only NMI is generated for the ECCD. See Section 7.10 for details.

7.9.11 Illegal access (ILAFM/ILAP)

Illegal access is a signal to the TZIC, triggering a secure interrupt in there. It is complementary to the other interrupts and only generated when the TZ is enabled (TZ_STATE = 0xB4).

It can be masked only on GTZC level.

ILAFM is generated when rules on secure flash memory access are violated:

ILAP is generated on:

If ILAFM is detected during write, the write buffer is invalidated.

Note: ILAFM and ILAP has no flag within the flash memory controller to clear to resume operation. It is dealt within the TZIC.

7.9.12 Option byte change error (OPTCHANGEERR)

When the flash interface finds an error during an option change operation, it aborts the operation and sets the option byte change error flag OPTCHANGEERR in FLASH_NSSR register.

The error is raised after OPTSTRT bit set if:

Note: Exceptions and details provided in the OB description (see Section 7.4.7 and Table 52 ).

OPTCHANGEERR flag is cleared by setting CLR_OPTCHANGEERR bit to 1 in FLASH_NSCCR register.

If OPTCHANGEERRIE bit in FLASH_NSCR register is set to 1, an interrupt is generated when OPTCHANGEERR flag is raised (see Section 7.10 for details).

It is mandatory to clean the OPTCHANGEERR flag before starting a new operation (option change, erase or write).

7.9.13 Miscellaneous HardFault errors

The following events generate a bus error on the corresponding bus interface:

7.9.14 OBK error cases (OBKERR, OBKWERR)

Four error types can be detected while filling the OBK write buffer: STRBERR, INCERR, WRPERR or OBKERR. The OBKERR is specific to the OBK access and cannot be raised by access to any other flash memory asset.

Note: For STRBERR, INCERR and WRPERR, non-secure or secure flags are used depending on the AHB access type (sec or non-secure). If a non-secure access is received, the non-secure error flags are used. If a secure access is received, the secure error flags are used. For OBKERR and OBKWERR, non-secure or secure flags are used depending on the value of the secure state. If the SOC is in secure state (TZ_STATE active), the secure error flags (OBKERR and OBKWERR) are used. Otherwise the non-secure error flags (OBKERR and OBKWERR) are used.

OBKERR is raised when:

If OBKERR is raised during write access, the write buffer is flushed. If the OBKERR is raised on read access, the write buffer is intact. In both cases the flag must be cleared to enable write/erase access to flash memory.

OBKWERR is detected after filling the write buffer and raised if:

If OBKWERR is raised, the write buffer is flushed. The flag must be cleared to enable write/erase access to flash memory.

7.10 FLASH interrupts

The flash interface can generate a maskable interrupt to signal the following events on a given bank:

A NMI is raised on double ECC error detection during read operation.

Two interrupt lines gather all the error sources, one for errors in non-secure access and second for errors that happen in secure access.

The user can individually enable or disable flash interface interrupt sources by changing the mask bits in the FLASH_NS/SECCR, FLASH_ECCCORR and FLASH_ECCDETR register. Setting the appropriate mask bit to 1 enables the interrupt.

Note: Prior to writing, FLASH_NS/SECCR register must be unlocked as explained in Section 7.6.7 .

Table 84 gives a summary of the available flash interface interrupt features. As mentioned in the table below, some flags need to be cleared before a new operation is triggered.

Table 84. Flash interrupt request

Interrupt event
Event flag
Error flag label in
register
Enable control bitClear flag to
resume
operation
End of operation eventEOPEOPIEN/A
Write protection errorWRPERRWRPERRIEYes
Programming sequence errorPGSERRPGSERRIEYes
Strobe errorSTRBERRSTRBERRIEYes
OBK write errorOBKWERROBKWERIEYes
OBK general errorOBKERROBKERRIEYes
Inconsistency errorINCERRINCERRIEYes
Illegal access errorILAFMTZENNo
Option byte errorOPTCHANGEERR-Yes
Table 84. Flash interrupt request (continued)
Interrupt event
Event flag
Error flag label in
register
Enable control bitClear flag to
resume
operation
ECC single error correction eventECCCECCCIENo
ECC double error detection event (1)ECCDDisabledNo

1. NMI.

The status of the individual maskable interrupt sources described in Table 84 (except for option byte error and ECC) can be read from the FLASH_NS/SECSR register. They can be cleared by setting to 1 the adequate bit in FLASH_NS/SECCCR register.

Note: No unlocking mechanism is required to clear an interrupt.

End of operation event

Setting the end of operation interrupt enable bit (EOPIE) in the FLASH_NS/SECCR register enables the generation of an interrupt at the end of an erase operation, a program operation, or an option byte change.

When managing the OBKey storage area, the EOP is associated also with the OBK swap operation and the alternate area erase operation. EOP bit in the FLASH_NS/SECSR register is also set when one of these events occurs.

Setting CLR_EOP bit to 1 in FLASH_NS/SECCCR register clears EOP flag.

7.11 FLASH registers

Each register has an offset address and a reset value. In case of registers representing option bytes, the reset value is determined by the OBL process. In case of success the reset value is loaded from OB, in case of failure, a highly restrictive default value is set.

7.11.1 FLASH access control register (FLASH_ACR)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

For more details, refer to Section 7.3.4 and Section 7.3.5 .

Address offset: 0x000

Reset value: 0x0000 0013

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.PRFTENRes.Res.WRHIGHFREQ
[1:0]
LATENCY[3:0]
rwrwrwrwrwrwrw

Bits 31:9 Reserved, must be kept at reset value.

Bit 8 PRFTEN : Prefetch enable. When bit value is modified, user must read back ACR register to be sure PRFTEN has been taken into account.

Bits used to control the prefetch.

0: prefetch disabled.

1: prefetch enabled when latency is at least one wait state.

Bits 7:6 Reserved, must be kept at reset value.

Bits 5:4 WRHIGHFREQ[1:0] : Flash signal delay

These bits are used to control the delay between nonvolatile memory signals during programming operations. Application software has to program them to the correct value depending on the memory interface frequency. Please refer to Table 45 for details.

Note: No check is performed to verify that the configuration is correct.

Two WRHIGHFREQ values can be selected for some frequencies.

Bits 3:0 LATENCY[3:0] : Read latency

These bits are used to control the number of wait states used during read operations on both nonvolatile memory banks. The application software has to program them to the correct value depending on the memory interface frequency and voltage conditions.

0000: no wait states used to read a word from nonvolatile memory

0001: one wait state used to read a word from nonvolatile memory

0010: two wait states used to read a word from nonvolatile memory

...

0111: seven wait states used to read a word from nonvolatile memory

1111: 15 wait states used to read a word from nonvolatile memory

Note: No check is performed by hardware to verify that the configuration is correct.

7.11.2 FLASH non-secure key register (FLASH_NSKEYR)

This register is non-secure. It can be written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

FLASH_NSKEYR is a write-only register. The following values must be programmed consecutively to unlock FLASH_NSCR register and allow programming/erasing it.

A wrong sequence locks the FLASH_NSCR register until next system reset.

Address offset: 0x0004

Reset value: 0x0000 0000

31302928272625242322212019181716
NSKEY[31:16]
wwwwwwwwwwwwwwww
1514131211109876543210
NSKEY[15:0]
wwwwwwwwwwwwwwww

Bits 31:0 NSKEY[31:0] : Non-volatile memory non-secure configuration access unlock key

7.11.3 FLASH secure key register (FLASH_SECKEYR)

This register is secure. It can be written only by secure access. A non-secure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFG register.

FLASH_SECKEYR is a write-only register. The following values must be programmed consecutively to unlock FLASH_SECCR register and allow programming/erasing it. A wrong sequence locks the FLASH_SECCR register until next system reset.

First key = 0x4567 0123

Second key = 0xCDEF 89AB

Address offset: 0x0008

Reset value: 0x0000 0000

31302928272625242322212019181716
SECKEY[31:16]
wwwwwwwwwwwwwwww
1514131211109876543210
SECKEY[15:0]
wwwwwwwwwwwwwwww

Bits 31:0 SECKEY[31:0] : Non-volatile memory secure configuration access unlock key

7.11.4 FLASH option key register (FLASH_OPTKEYR)

This write-only register is non-secure. It can be written by both secure and non-secure accesses, and can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

The following values must be programmed consecutively to unlock FLASH_OPTCR register

A wrong sequence locks FLASH_OPTCR register until next system reset.

Address offset: 0x00C

Reset value: 0x0000 0000

31302928272625242322212019181716
OPTKEY[31:16]
wwwwwwwwwwwwwwww
1514131211109876543210
OPTKEY[15:0]
wwwwwwwwwwwwwwww

Bits 31:0 OPTKEY[31:0] : FLASH option bytes control access unlock key

7.11.5 FLASH non-secure OBK key register (FLASH_NSOBKKEYR)

This is a write-only register. The following values must be programmed consecutively to unlock it register (a wrong sequence locks the register until next system reset).

This register is non-secure. This register can be written only by privileged access.

Address offset: 0x0010

Reset value: 0x0000 0000

31302928272625242322212019181716
NSOBKKEY[31:16]
wwwwwwwwwwwwwwww
1514131211109876543210
NSOBKKEY[15:0]
wwwwwwwwwwwwwwww

Bits 31:0 NSOBKKEY[31:0] : FLASH non-secure option bytes keys control access unlock key

7.11.6 FLASH secure OBK key register (FLASH_SECOBKKEYR)

This is a write-only register. The following values must be programmed consecutively to unlock it (a wrong sequence locks the register until the next system reset)

This register is secure, it can be written only by privileged access.

Address offset: 0x0014

Reset value: 0x0000 0000

31302928272625242322212019181716
SECOBKKEY[31:16]
wwwwwwwwwwwwwwww
1514131211109876543210
SECOBKKEY[15:0]
wwwwwwwwwwwwwwww

Bits 31:0 SECOBKKEY[31:0] : FLASH secure option bytes keys control access unlock key

7.11.7 FLASH operation status register (FLASH_OPSR)

This register is non-secure. This register can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

Address offset: 0x0018

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
CODE_OP[2:0]Res.Res.Res.Res.OTP_OPSYSF_OPBK_OPDATA_OPRes.ADDR_OP[19:16]
rrrrrrrrrrr
1514131211109876543210
ADDR_OP[15:0]
rrrrrrrrrrrrrrrr

Bits 31:29 CODE_OP[2:0] : Flash memory operation code

Bits 28:25 Reserved, must be kept at reset value.

Bit 24 OTP_OP : OTP operation interrupted

Indicates that reset interrupted an ongoing operation in OTP area (or OBKeys area).

Bit 23 SYSF_OP : Operation in system flash memory interrupted

Indicates that reset interrupted an ongoing operation in system flash.

Bit 22 BK_OP : Interrupted operation bank

It indicates which bank was concerned by operation.

Bit 21 DATA_OP : Flash high-cycle data area operation interrupted
It indicates if flash high-cycle data area is concerned by operation.

Bit 20 Reserved, must be kept at reset value.

Bits 19:0 ADDR_OP[19:0] : Interrupted operation address

7.11.8 FLASH option control register (FLASH_OPTCR)

This register is non-secure. It can be read and written by both secure and non-secure access, and protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

Access: No wait states when no memory operations are ongoing. The FLASH_OPTCR register is not accessible in write mode when the BSY bit is set. Any attempt to write to it while the BSY bit set causes the AHB bus to stall until the BSY bit is cleared.

Address offset: 0x01C

Reset value: 0xX000 0001

31302928272625242322212019181716
SWAP_BANKRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
r
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OPT STRTOPT LOCK
rwrs

Bit 31 SWAP_BANK : Bank swapping option configuration bit

SWAP_BANK controls whether Bank1 and Bank2 are swapped or not. This bit is loaded with the SWAP_BANK bit of FLASH_OPTSR_CUR register only after reset or POR.

0: Bank1 and Bank2 not swapped

1: Bank1 and Bank2 swapped

Bits 30:2 Reserved, must be kept at reset value.

Bit 1 OPTSTRT : Option byte start change option configuration bit

OPTSTRT triggers an option byte change operation. The user can set OPTSTRT only when the OPTLOCK bit is cleared to 0. It is set only by Software and cleared when the option byte change is completed or an error occurs (PGSERR or OPTCHANGEERR). It is reset at the same time as BSY bit.

The user application cannot modify any FLASH_XXX_PRG flash interface register until the option change operation has been completed.

Before setting this bit, the user has to write the required values in the FLASH_XXX_PRG registers. The FLASH_XXX_PRG registers are locked until the option byte change operation has been executed in nonvolatile memory.

Bit 0 OPTLOCK : FLASH_OPTCR lock option configuration bit

The OPTLOCK bit locks the FLASH_OPTCR register as well as all _PRG registers. The correct write sequence to FLASH_OPTKEYR register unlocks this bit. If a wrong sequence is executed, or the unlock sequence to FLASH_OPTKEYR is performed twice, this bit remains locked until next system reset.

It is possible to set OPTLOCK by programming it to 1. When set to 1, a new unlock sequence is mandatory to unlock it. When OPTLOCK changes from 0 to 1, the other bits of FLASH_OPTCR register do not change.

0: FLASH_OPTCR register unlocked

1: FLASH_OPTCR register locked.

7.11.9 FLASH non-secure status register (FLASH_NSSR)

This register is non-secure, can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

Address offset: 0x020

Reset value: 0x0000 000X

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.OPT
CHANGE
ERR
OBKW
ERR
OBK
ERR
INC
ERR
STRB
ERR
PGS
ERR
WRP
ERR
EOP
rrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBNERes.WBNEBSY
rrr

Bits 31:24 Reserved, must be kept at reset value.

Bit 23 OPTCHANGEERR : Option byte change error flag

OPTCHANGEERR flag indicates that an error occurred during an option byte change operation. When OPTCHANGEERR is set to 1, the option byte change operation did not successfully complete. An interrupt is generated when this flag is raised if the OPTCHANGEERRIE bit of FLASH_NSCR register is set to 1.

Writing 1 to CLR_OPTCHANGEERR of register FLASH_NSCCR clears OPTCHANGEERR.

0: no option byte change errors occurred

1: one or more errors occurred during an option byte change operation.

Note: The OPTSTRT bit in FLASH_OPTCR cannot be set while OPTCHANGEERR is set.

Bit 22 OBKWERR : OBK write error flag

OBKWERR flag is raised when the address is not virgin on a write access to the OBK storage. Alternatively also when the OBK selector in the alternate sector is not virgin during a swap operation.

0: no OBK write error occurred

1: an OBK write error occurred

  1. Bit 21 OBKERR : OBK general error flag
    OBKERR flag is raised when the OBK-HDPL signal from the SBS does not match the HDPL value associated with the key slot during access to the key location. Alternatively also when the ALT_SECT is unexpectedly changed while the write buffer is being filled.
    0: no OBK general error occurred
    1: an OBK general error occurred
  2. Bit 20 INCERR : inconsistency error flag
    NSINCERR flag is raised when a inconsistency error occurs. An interrupt is generated if INCERRIE is set to 1. Writing 1 to CLR_INCERR bit in the FLASH_NSCCR register clears NSINCERR.
    0: no inconsistency error occurs
    1: a inconsistency error occurs
  3. Bit 19 STRBERR : strobe error flag
    STRBERR flag is raised when a strobe error occurs (when the master attempts to write several times the same byte in the write buffer). An interrupt is generated if the STRBERRIE bit is set to 1. Writing 1 to CLR_STRBERR bit in FLASH_NSCCR register clears STRBERR.
    0: no strobe error occurred
    1: a strobe error occurred
  4. Bit 18 PGSERR : programming sequence error flag
    PGSERR flag is raised when a sequence error occurs. An interrupt is generated if the PGSERRIE bit is set to 1. Writing 1 to CLR_PGSERR bit in FLASH_NSCCR register clears PGSERR.
    0: no sequence error occurred
    1: a sequence error occurred
  5. Bit 17 WRPERR : write protection error flag
    WRPERR flag is raised when a protection error occurs during a program operation. An interrupt is also generated if the WRPERRIE is set to 1. Writing 1 to CLR_WRPERR bit in FLASH_NSCCR register clears WRPERR.
    0: no write protection error occurred
    1: a write protection error occurred
  6. Bit 16 EOP : end of operation flag
    EOP flag is set when a operation (program/erase) completes. An interrupt is generated if the EOPIE is set to 1. It is not necessary to reset EOP before starting a new operation. EOP bit is cleared by writing 1 to CLR_EOP bit in FLASH_NSCCR register.
    0: no operation completed
    1: a operation completed
  7. Bits 15:4 Reserved, must be kept at reset value.
  8. Bit 3 DBNE : data buffer not empty flag
    DBNE flag is set when the flash interface is processing 6-bits ECC data in dedicated buffer. This bit cannot be set to 0 by software. The hardware resets it once the buffer is free.
    0: data buffer not used
    1: data buffer used, wait
  9. Bit 2 Reserved, must be kept at reset value.

Bit 1 WBNE : write buffer not empty flag

WBNE flag is set when the flash interface is waiting for new data to complete the write buffer. In this state, the write buffer is not empty. WBNE is reset by hardware each time the write buffer is complete or the write buffer is emptied following one of the events below:

This bit cannot be reset by software writing 0 directly. To reset it, clear the write buffer by performing any of the above listed actions, or send the missing data.

0: write buffer empty or full

1: write buffer waiting data to complete

Bit 0 BSY : busy flag

BSY flag indicates that a flash memory is busy by an operation (write, erase, option byte change, OBK operation). It is set at the beginning of a flash memory operation and cleared when the operation finishes, or an error occurs.

0: no programming, erase or option byte change operation being executed

1: programming, erase or option byte change operation being executed

7.11.10 FLASH secure status register (FLASH_SECSR)

This register is secure. It can be read only by secure access. A non-secure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGR register.

Address offset: 0x024

Reset value: 0x0000 000X

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.OBKW
ERR
OBK
ERR
INC
ERR
STRB
ERR
PGS
ERR
WRP
ERR
EOP
rrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBNERes.WBNEBSY
rrr

Bits 31:23 Reserved, must be kept at reset value.

Bit 22 OBKWERR : OBK write error flag

OBKWERR flag is raised when the address is not virgin on a write access to the OBK storage. Alternatively also when the OBK selector in the alternate sector is not virgin during a swap operation.

0: no OBK write error occurred

1: an OBK write error occurred

Bit 21 OBKERR : OBK general error flag

OBKERR flag is raised when the OBK-HDPL signal from the SBS does not match the HDPL value associated with the key slot during access to the key location. Alternatively also when the ALT_SECT is unexpectedly changed while the write buffer is being filled.

0: no OBK general error occurred

1: an OBK general error occurred

Bit 20 INCERR: inconsistency error flag

INCERR flag is raised when a inconsistency error occurs. An interrupt is generated if INCERRIE is set to 1. Writing 1 to CLR_INCERR bit in the FLASH_SECCCR register clears INCERR.

0: no inconsistency error occurred

1: a inconsistency error occurred

Bit 19 STRBERR: strobe error flag

STRBERR flag is raised when a strobe error occurs (when the master attempts to write several times the same byte in the write buffer). An interrupt is generated if the STRBERRIE bit is set to 1. Writing 1 to CLR_STRBERR bit in FLASH_SECCCR register clears STRBERR.

0: no strobe error occurred

1: a strobe error occurred

Bit 18 PGSERR: programming sequence error flag

PGSERR flag is raised when a sequence error occurs. An interrupt is generated if the PGSERRIE bit is set to 1. Writing 1 to CLR_PGSERR bit in FLASH_SECCCR register clears PGSERR.

0: no sequence error occurred

1: a sequence error occurred

Bit 17 WRPERR: write protection error flag

WRPERR flag is raised when a protection error occurs during a program operation. An interrupt is also generated if the WRPERRIE is set to 1. Writing 1 to CLR_WRPERR bit in FLASH_SECCCR register clears WRPERR.

0: no write protection error occurred

1: a write protection error occurred

Bit 16 EOP: end of operation flag

EOP flag is set when a operation (program/erase) completes. An interrupt is generated if the EOPIE is set to. It is not necessary to reset EOP before starting a new operation. EOP bit is cleared by writing 1 to CLR_EOP bit in FLASH_SECCCR register.

0: no operation completed

1: a operation completed

Bits 15:4 Reserved, must be kept at reset value.

Bit 3 DBNE: data buffer not empty flag

DBNE flag is set when the memory interface is processing 6-bits ECC data in dedicated buffer. This bit cannot be set to 0 by software. The hardware resets it once the buffer is free.

0: data buffer not used

1: data buffer used, wait

Bit 2 Reserved, must be kept at reset value.

Bit 1 WBNE: write buffer not empty flag

WBNE flag is set when the flash interface is waiting for new data to complete the write buffer. In this state, the write buffer is not empty. WBNE is reset by hardware each time the write buffer is complete or the write buffer is emptied following one of the events below:

This bit cannot be reset by writing 0 directly by software. To reset it, clear the write buffer by performing any of the above listed actions, or send the missing data.

0: write buffer empty or full

1: write buffer waiting data to complete

Bit 0 BSY : busy flag

BSY flag indicates that a FLASH memory is busy (write, erase, option byte change, OBK operations). It is set at the beginning of a flash memory operation and cleared when the operation finishes or an error occurs.

0: no programming, erase or option byte change operation being executed

1: programming, erase or option byte change operation being executed

7.11.11 FLASH non-secure control register (FLASH_NSCR)

This register is non-secure. It can be read and written by both secure and non-secure accesses, and can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

Access: No wait states when no memory operations are ongoing. The FLASH_NSCR register is not accessible in write mode when the BSY bit is set. Any attempt to write to it with the BSY bit set causes the AHB bus to stall until the BSY bit is cleared.

Address offset: 0x028

Reset value: 0x0000 0001

31302928272625242322212019181716
BKSELRes.Res.Res.Res.Res.Res.Res.OPT
CHANGE
ERRIE
OBKW
ERRIE
OBK
ERRIE
INC
ERRIE
STRB
ERRIE
PGS
ERRIE
WRP
ERRIE
EOPIE
rwrwrwrwrwrwrwrwrw
1514131211109876543210
MERRes.Res.SNB[6:0]STRTFWBERSERPGLOCK
rwrwrwrwrwrwrwrwrsrwrwrwrwrs

Bit 31 BKSEL : Bank selector bit

Can be programmed only when LOCK is cleared to 0. The bit selects physical bank, SWAP_BANK setting is ignored.

0: Bank1 is selected for Bank erase / sector erase / interrupt enable

1: Bank2 is selected for BER / SER

Bits 30:24 Reserved, must be kept at reset value.

Bit 23 OPTCHANGEERRIE : Option byte change error interrupt enable bit

This bit controls if an interrupt must be generated when an error occurs during an option byte change. It can be programmed only when LOCK bit is cleared to 0.

0: no interrupt is generated when an error occurs during an option byte change

1: an interrupt is generated when an error occurs during an option byte change.

Bit 22 OBKWERRIE : OBK write error interrupt enable bit

OBKWERRIE enables generation of interrupt in case of OBK specific write error. This bit can be programmed only when LOCK bit is cleared to 0.

0: no interrupt is generated on OBK write error

1: an interrupt is generated on OBK write error

Bit 21 OBKERRIE : OBK general error interrupt enable bit

OBKERRIE enables generating an interrupt in case of OBK specific access error. This bit can be programmed only when LOCK bit is cleared to 0.

0: no interrupt is generated on OBK general access error

1: an interrupt is generated on OBK general access error

Bit 20 INCERRIE : inconsistency error interrupt enable bit

When INCERRIE bit is set to 1, an interrupt is generated when an inconsistency error occurs during a write operation. INCERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated when a inconsistency error occurs

1: interrupt generated when a inconsistency error occurs.

Bit 19 STRBERRIE : strobe error interrupt enable bit

When STRBERRIE bit is set to 1, an interrupt is generated when a strobe error occurs (the master programs several times the same byte in the write buffer) during a write operation. STRBERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated when a strobe error occurs

1: interrupt generated when strobe error occurs.

Bit 18 PGSERRIE : programming sequence error interrupt enable bit

When this bit is set to 1, an interrupt is generated when a sequence error occurs during a program operation. PGSERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated when a sequence error occurs

1: interrupt generated when sequence error occurs

Bit 17 WRPERRIE : write protection error interrupt enable bit

When this bit is set to 1, an interrupt is generated when a protection error occurs during a program operation. WRPERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated when a protection error occurs

1: interrupt generated when a protection error occurs

Bit 16 EOPIE : end of operation interrupt control bit

Setting EOPIE bit to 1 enables the generation of an interrupt at the end of a program or erase operation. EOPIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated at the end of operation.

1: interrupt enabled when at the end of operation

Bit 15 MER : mass erase request

Setting MER bit to 1 requests a mass erase operation (user flash memory only). MER can be programmed only when LOCK is cleared to 0.

If BER or SER are both set, a PGSERR is raised.

0: mass erase not requested

1: mass erase requested

Note: An error is triggered when a mass erase is required and some sectors are protected.

Bits 14:13 Reserved, must be kept at reset value.

Bits 12:6 SNB[6:0] : sector erase selection number

These bits are used to select the target sector for an erase operation, otherwise they are not used. They can be programmed only when LOCK is cleared to 0.

0x00: Sector 0 selected

0x01: Sector 1 selected

..

0x7F: Sector 127 selected

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bit 5 STRT : erase start control bit

STRT bit is used to start a sector erase or a bank erase operation. STRT can be programmed only when LOCK is cleared to 0.

STRT is reset at the end of the operation or when an error occurs. It cannot be reset by software.

Bit 4 FW: write forcing control bit

FW forces a write operation even if the write buffer is not full. In this case all bits not written are set to 1 by hardware. FW can be programmed only when LOCK is cleared to 0.

The memory resets FW when the corresponding operation has been acknowledged.

Note: Using a force-write operation prevents the application from updating later the missing bits with something else than 1, because it is likely that it leads to permanent ECC error.

Write forcing is effective only if the write buffer is not empty and was filled by non-secure access (in particular, FW does not start several write operations when the force-write operations are performed consecutively).

Since there is just one write buffer, FW can force a write in Bank1 or Bank2.

Bit 3 BER: erase request

Setting BER bit to 1 requests a bank erase operation (user flash memory only). BER can be programmed only when LOCK is cleared to 0.

If MER and SER are also set, a PGSERR is raised.

0: bank erase not requested

1: bank erase requested

Note: Write protection error is triggered when a bank erase is required and some sectors are protected.

Bit 2 SER: sector erase request

Setting SER bit to 1 requests a sector erase. SER can be programmed only when LOCK is cleared to 0.

If MER and SER are also set, a PGSERR is raised.

0: sector erase not requested

1: sector erase requested

Bit 1 PG: programming control bit

PG can be programmed only when LOCK is cleared to 0.

PG allows programming in Bank1 and Bank2.

0: programming disabled

1: programming enabled

Bit 0 LOCK: configuration lock bit

This bit locks the FLASH_NSCR register. The correct write sequence to FLASH_NSKEYR register unlocks this bit. If a wrong sequence is executed, or if the unlock sequence to FLASH_NSKEYR is performed twice, this bit remains locked until the next system reset.

LOCK can be set by programming it to 1. When set to 1, a new unlock sequence is mandatory to unlock it. When LOCK changes from 0 to 1, the other bits of FLASH_NSCR register do not change.

0: FLASH_NSCR register unlocked

1: FLASH_NSCR register locked

7.11.12 FLASH secure control register (FLASH_SECCR)

This register is secure, can be read and written only by secure access. A non-secure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFG register.

Access: No wait states when no memory operations are ongoing. The FLASH_SECCR register is not accessible in write mode when the BSY bit is set. Any attempt to write to it with the BSY bit set causes the AHB bus to stall until the BSY bit is cleared.

Address offset: 0x02C

Reset value: 0x0000 0001

31302928272625242322212019181716
BKSELRes.INVRes.Res.Res.Res.Res.Res.OBKW
ERRIE
OBK
ERRIE
INC
ERRIE
STRB
ERRIE
PGS
ERRIE
WRP
ERRIE
EOPIE
rwrwrwrwrwrwrwrwrw
1514131211109876543210
MERRes.Res.SNB[6:0]STRTFWBERSERPGLOCK
rwrwrwrwrwrwrwrwrsrwrwrwrwrs

Bit 31 BKSEL : Bank selector bit

BKSEL can only be programmed when LOCK is cleared to 0. The bit selects physical bank, SWAP_BANK setting is ignored.

0: Bank1 is selected for Bank erase / sector erase / interrupt enable

1: Bank2 is selected for BER / SER

Bit 30 Reserved, must be kept at reset value.

Bit 29 INV : Flash memory security state invert.

This bit inverts the flash memory security state.

Bits 28:23 Reserved, must be kept at reset value.

Bit 22 OBKWERRIE : OBK write error interrupt enable bit

OBKWERRIE enables generation of interrupt in case of OBK specific write error.

OBKWERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt is generated on OBK write error

1: an interrupt is generated on OBK write error

Bit 21 OBKERRIE : OBK general error interrupt enable bit

OBKERRIE enables generating an interrupt in case of OBK specific access error.

OBKERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt is generated on OBK general access error

1: an interrupt is generated on OBK general access error

Bit 20 INCERRIE : inconsistency error interrupt enable bit

When INCERRIE bit is set to 1, an interrupt is generated when an inconsistency error occurs during a write operation. INCERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated when a inconsistency error occurs

1: interrupt generated when a inconsistency error occurs.

Bit 19 STRBERRIE : strobe error interrupt enable bit

When STRBERRIE bit is set to 1, an interrupt is generated when a strobe error occurs (the master programs several times the same byte in the write buffer) during a write operation. STRBERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated when a strobe error occurs

1: interrupt generated when strobe error occurs.

Bit 18 PGSERRIE : programming sequence error interrupt enable bit

When PGSERRIE is set to 1, an interrupt is generated when a sequence error occurs during a program operation. PGSERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated when a sequence error occurs

1: interrupt generated when sequence error occurs

Bit 17 WRPERRIE : write protection error interrupt enable bit

When WRPERRIE bit is set to 1, an interrupt is generated when a protection error occurs during a program operation. WRPERRIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated when a protection error occurs

1: interrupt generated when a protection error occurs

Bit 16 EOPIE : end of operation interrupt control bit

Setting EOPIE bit to 1 enables the generation of an interrupt at the end of a program/erase operation. EOPIE can be programmed only when LOCK is cleared to 0.

0: no interrupt generated at the end of operation.

1: interrupt enabled when at the end of operation

Bit 15 MER : mass erase request

Setting MER bit to 1 requests a mass erase operation (user flash memory only). MER can be programmed only when LOCK is cleared to 0.

If BER or SER are also set, a PGSERR is raised.

0: mass erase not requested

1: mass erase requested

Note: An error is triggered when a mass erase is required and some sectors are protected.

Bits 14:13 Reserved, must be kept at reset value.

Bits 12:6 SNB[6:0] : sector erase selection number

These bits are used to select the target sector for an erase operation, otherwise they are unused. SNB can be programmed only when LOCK is cleared to 0.

0x00: Sector 0 selected

0x01: Sector 1 selected

..

0x7F: Sector 127 selected

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bit 5 STRT : erase start control bit

STRT bit is used to start a sector erase or a bank erase operation. STRT can be programmed only when LOCK is cleared to 0.

STRT is reset at the end of the operation or when an error occurs. It cannot be reset by software.

Bit 4 FW : write forcing control bit

FW forces a write operation even if the write buffer is not full. In this case all bits not written are set to 1 by hardware. FW can be programmed only when LOCK is cleared to 0.

The memory resets FW when the corresponding operation has been acknowledged.

Note: Using a force-write operation prevents the application from updating later the missing bits with something else than 1, because it is likely that it leads to permanent ECC error.

Write forcing is effective only if the write buffer is not empty and was filled by secure access (in particular, FW does not start several write operations when the force-write operations are performed consecutively).

Since there is just one write buffer, FW can force a write in Bank1 or Bank2.

Bit 3 BER : erase request

Setting BER bit to 1 requests a bank erase operation (user flash memory only). BER can be programmed only when LOCK is cleared to 0.

If MER and SER are also set, a PGSERR is raised.

0: bank erase not requested

1: bank erase requested

Note: A write protection error is triggered when a bank erase is required and some sectors are protected.

Bit 2 SER : sector erase request

Setting SER bit to 1 requests a sector erase. SER can be programmed only when LOCK is cleared to 0.

If BER and MER are also set, a PGSERR is raised.

0: sector erase not requested

1: sector erase requested

Bit 1 PG : programming control bit

PG can be programmed only when LOCK is cleared to 0.

PG allows programming in Bank1 and Bank2.

0: programming disabled

1: programming enabled

Bit 0 LOCK : configuration lock bit

This bit locks the FLASH_SECCR register. The correct write sequence to FLASH_SECKEYR register unlocks this bit. If a wrong sequence is executed, or if the unlock sequence to FLASH_NSKEYR is performed twice, this bit remains locked until the next system reset.

LOCK can be set by programming it to 1. When set to 1, a new unlock sequence is mandatory to unlock it. When LOCK changes from 0 to 1, the other bits of FLASH_SECCR register do not change.

0: FLASH_SECCR register unlocked

1: FLASH_SECCR register locked

7.11.13 FLASH non-secure clear control register (FLASH_NSCCR)

This register is non-secure. It can be written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

Address offset: 0x030

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.CLR_O
PTCHA
NGE
ERR
CLR_O
BKW
ERR
CLR_O
BK
ERR
CLR_
INC
ERR
CLR_
STRB
ERR
CLR_
PGS
ERR
CLR_
WRP
ERR
CLR_
EOP 1
wwwwwwww
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

Bits 31:24 Reserved, must be kept at reset value.

Bit 23 CLR_OPTCHANGEERR : Clear the flag corresponding flag in FLASH_NSSR by writing this bit.

Bit 22 CLR_OBKWERR : OBKWERR flag clear bit.

Setting this bit to 1 resets to 0 OBKWERR flag in FLASH_NSSR register.

Bit 21 CLR_OBKERR : OBKERR flag clear bit.

Setting this bit to 1 resets to 0 OBKERR flag in FLASH_NSSR register.

Bit 20 CLR_INCERR : INCERR flag clear bit

Setting this bit to 1 resets to 0 INCERR flag in FLASH_NSSR register.

Bit 19 CLR_STRBERR : STRBERR flag clear bit

Setting this bit to 1 resets to 0 STRBERR flag in FLASH_NSSR register.

Bit 18 CLR_PGSERR : PGSERR flag clear bit

Setting this bit to 1 resets to 0 PGSERR flag in FLASH_NSSR register.

Bit 17 CLR_WRPERR : WRPERR flag clear bit

Setting this bit to 1 resets to 0 WRPERR flag in FLASH_NSSR register.

Bit 16 CLR_EOP : EOP flag clear bit

Setting this bit to 1 resets to 0 EOP flag in FLASH_NSSR register.

Bits 15:0 Reserved, must be kept at reset value.

7.11.14 FLASH secure clear control register (FLASH_SECCCR)

This register is secure. It can be written only by secure access. A non-secure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGR register.

Address offset: 0x034

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.CLR_OBKWERRCLR_OBKERRCLR_INCERRCLR_STRBERRCLR_PGSERRCLR_WRPERRCLR_EOP
wwwwwww
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.

Bits 31:23 Reserved, must be kept at reset value.

Bit 22 CLR_OBKWERR : OBKWERR flag clear bit

Setting this bit to 1 resets to 0 OBKWERR flag in FLASH_SECSR register.

Bit 21 CLR_OBKERR : OBKERR flag clear bit

Setting this bit to 1 resets to 0 OBKERR flag in FLASH_SECSR register.

Bit 20 CLR_INCERR : INCERR flag clear bit

Setting this bit to 1 resets to 0 INCERR flag in FLASH_SECSR register.

Bit 19 CLR_STRBERR : STRBERR flag clear bit

Setting this bit to 1 resets to 0 STRBERR flag in FLASH_SECSR register.

Bit 18 CLR_PGSERR : PGSERR flag clear bit

Setting this bit to 1 resets to 0 PGSERR flag in FLASH_SECSR register.

Bit 17 CLR_WRPERR : WRPERR flag clear bit

Setting this bit to 1 resets to 0 WRPERR flag in FLASH_SECSR register.

Bit 16 CLR_EOP : EOP flag clear bit

Setting this bit to 1 resets to 0 EOP flag in FLASH_SECSR register.

Bits 15:0 Reserved, must be kept at reset value.

7.11.15 FLASH privilege configuration register (FLASH_PRIVCFGR)

Address offset: 0x03C

Reset value: 0x0000 0000

This register can be read by both privileged and unprivileged access. NSPRIV is a non-secure bit. SPRIV is a secure bit. It can be written only by privileged mode.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.NSPRIVSPRIV
rwrw

Bits 31:2 Reserved, must be kept at reset value.

Bit 1 NSPRIV : privilege attribute for non secure registers

0: access to non secure registers is always granted

1: access to non secure registers is denied in case of unprivileged access.

Bit 0 SPRIV : privilege attribute for secure registers

0: access to secure registers is always granted

1: access to secure registers is denied in case of unprivileged access.

7.11.16 FLASH non-secure OBK configuration register (FLASH_NSOBKCFGR)

Register is only available when TZ_STATE = 0xC3. This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can only be accessed by privilege code. This register is not accessible in write mode when the BSY bit is set. Any attempt to write to it with the BSY bit set causes the AHB bus to stall until the BSY bit is cleared.

Address offset: 0x040

Reset value: 0x01FF 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.SWAP_OFFSET[8:0]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ALT_SECT_ERASEALT_SECTSWAP_SECT_REQLOCK
rwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:16 SWAP_OFFSET[8:0] : Key index (offset /16 bits) pointing for next swap.

0x00: means that no OBK is copied from current to alternate OBK sector during SWAP operation.

0x01 means that only the first OBK data (128 bits) are copied from current to alternate OBK sector

0x02 means that the two first OBK data are copied

...

0x1FF: means that all OBK data (511) are copied

Bits 15:4 Reserved, must be kept at reset value.

Bit 3 ALT_SECT_ERASE : alternate sector erase bit

0: do not touch OBK sector

1: erase the alternate OBK sector

When ALT_SECT bit is set, use this bit to generate an erase command for the OBK alternate sector. It is set only by Software and cleared when the OBK swap operation is completed or an error occurs (PGSERR). It is reset at the same time as BUSY bit.

Bit 2 ALT_SECT : alternate sector bit

0: current OBK sector is mapped to OBK address range for access

1: alternate OBK sector is mapped to OBK address range for access

This bit must not change while filling the write buffer, otherwise an error (OBKERR) is generated

Bit 1 SWAP_SECT_REQ : OBK swap sector request bit

0: no swap requested

1: launch the sector swap

When set, all the OBKs not updated in the alternate sector are copied from current sector to alternate one.

The SWAP_OFFSET must have a minimum value to launched the swap. The minimum value is 16 for OBK-HDPL = 1, 144 for OBK-HDPL = 2, and 192 for OBK-HDPL = 3.

Bit 0 LOCK : OBKCFGR lock option configuration bit

This bit locks the register, the correct write sequence unlocks it. If a wrong sequence is executed, or if the unlock sequence is performed twice, this bit remains locked until the next system reset. LOCK can be set by programming it to 1. When set to 1, a new unlock sequence is mandatory to unlock it. When LOCK changes from 0 to 1, the other bits of FLASH_NSCR register do not change.

0: FLASH_NSOBKCFGR register unlocked

1: FLASH_NSOBKCFGR register locked

7.11.17 FLASH secure OBK configuration register (FLASH_SECOBKCFGR)

This register can be accessed only in secure privileged mode. The FLASH_SECOBKCFGR register is not accessible in write mode when the BSY bit is set. Any attempt to write to it with the BSY bit set causes the AHB bus to stall until the BSY bit is cleared.

Address offset: 0x044

Reset value: 0x01FF 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.SWAP_OFFSET[8:0]
rwrwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ALT_SECT_ERASEALT_SECTSWAP_SECT_REQLOCK
rwrwrwrw

Bits 31:25 Reserved, must be kept at reset value.

Bits 24:16 SWAP_OFFSET[8:0] : key index (offset /16 bits) pointing for next swap.

0x0: no OBK is copied from current to alternate OBK sector during SWAP operation.

0x1: only the first OBK data (128 bits) are copied from current to alternate OBK sector

0x2: the two first OBK data are copied

...

0x1FF: the 511 first OBK data are copied

Bits 15:4 Reserved, must be kept at reset value.

Bit 3 ALT_SECT_ERASE : alternate sector erase bit

0: do not touch OBK sector

1: erase the alternate OBK sector

When ALT_SECT bit is set, use this bit to generate an erase command for the OBK alternate sector. It is set only by Software and cleared when the OBK swap operation is completed or an error occurs (PGSERR). It is reset at the same time as the BUSY bit.

Bit 2 ALT_SECT : alternate sector bit

0: current OBK sector is mapped to OBK address range for access

1: alternate OBK sector is mapped to OBK address range for access

This bit must not change while filling the write buffer, otherwise an error is generated

Bit 1 SWAP_SECT_REQ : OBK swap sector request bit

0: no swap requested

1: launch the sector swap

When set, all the OBKs not updated in the alternate sector are copied from current sector to alternate one.

SWAP_OFFSET must have a minimum value to launch the swap. The minimum value is 16 for OBK-HDPL = 1, 144 for OBK-HDPL = 2, and 192 for OBK-HDPL = 3.

Bit 0 LOCK : OBKCFGR lock option configuration bit

This bit locks the FLASH_OBKCFGR register. The correct write sequence to FLASH_SECOBKKEYR register unlocks this bit. If a wrong sequence is executed, or if the unlock sequence to FLASH_SECOBKKEYR is performed twice, this bit remains locked until the next system reset. LOCK can be set by programming it to 1. When set to 1, a new unlock sequence is mandatory to unlock it. When LOCK changes from 0 to 1, the other bits of FLASH_NSCR register do not change.

0: FLASH_OBKCFGR register unlocked

1: FLASH_OBKCFGR register locked

7.11.18 FLASH HDP extension register (FLASH_HDPEXTR)

All bits in this register are non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

The register can be modified only in HDPL \( \leq 2 \) .

The values in this register cannot be decremented. Attempts to write a value lower than the current one are ignored.

Address offset: 0x048

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_EXT[6:0]
rwrwrwrwrwrwrw

1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP1_EXT[6:0]
rwrwrwrwrwrwrw

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 HDP2_EXT[6:0] : HDP area extension in 8 Kbytes sectors in Bank2. Extension is added after the HDP2_END sector (included).

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 HDP1_EXT[6:0] : HDP area extension in 8 Kbytes sectors in Bank1. Extension is added after the HDP1_END sector (included).

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.11.19 FLASH option status register (FLASH_OPTSR_CUR)

This register is non-secure, can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

Default value: 0x0030 5CD8 (value in case of double ECC issue during OBL).

This read-only register reflects the current values of the corresponding option bits.

Address offset: 0x050

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
SWAP_BANKRes.BOOT_UBE[7:0]IWDG_STDBYIWDG_STOPRes.Res.IO_VDDIO2_HSLVIO_VDD_HSLV
rrrrrrrrrrrrr

1514131211109876543210
PRODUCT_STATE[7:0]NRST_STDBYNRST_STOPRes.WWDG_SWIWDG_SWBORH_ENBOR_LEV[1:0]
rrrrrrrrrrrrrrr
  1. Bit 31 SWAP_BANK : Bank swapping option status bit
    SWAP_BANK reflects whether Bank1 and Bank2 are swapped or not.
    SWAP_BANK is loaded to SWAP_BANK of FLASH_OPTCR after a reset.
    0: Bank1 and Bank2 not swapped
    1: Bank1 and Bank2 swapped
  2. Bit 30 Reserved, must be kept at reset value.
  3. Bits 29:22 BOOT_UBE[7:0] : Available only on cryptography enabled devices.
    Unique boot entry control, selects either ST or OEM iRoT for secure boot.
    0xC3: ST-iRoT (system flash) selected
    0xB4: OEM-iRoT (user flash) selected. In Open PRODUCT_STATE this value selects bootloader. Default value.
  4. Bit 21 IWDG_STDBY : IWDG Standby mode freeze option status bit
    When set the independent watchdog IWDG is frozen in system Standby mode.
    0: Independent watchdog frozen in Standby mode
    1: Independent watchdog keep running in Standby mode.
  5. Bit 20 IWDG_STOP : IWDG Stop mode freeze option status bit
    When set the independent watchdog IWDG is in system Stop mode.
    0: Independent watchdog frozen in system Stop mode
    1: Independent watchdog keep running in system Stop mode.
  6. Bits 19:18 Reserved, must be kept at reset value.
  7. Bit 17 IO_VDDIO2_HSLV : High-speed IO at low V DDIO2 voltage configuration bit.
    This bit can be set only with V DDIO2 below 2.7 V.
    0: High-speed IO at low V DDIO2 voltage feature disabled (V DDIO2 can exceed 2.7 V)
    1: High-speed IO at low V DDIO2 voltage feature enabled (V DDIO2 remains below 2.7 V)
  8. Bit 16 IO_VDD_HSLV : High-speed IO at low V DD voltage configuration bit.
    This bit can be set only with V DD below 2.7 V.
    0: High-speed IO at low V DD voltage feature disabled (V DD can exceed 2.7 V)
    1: High-speed IO at low V DD voltage feature enabled (V DD remains below 2.7 V)
  9. Bits 15:8 PRODUCT_STATE[7:0] : Life state code (based on Hamming 8,4). See Section 7.6.11 .
  10. Bit 7 NRST_STDBY : Core domain Standby entry reset option status bit
    0: a reset is generated when entering Standby mode on core domain
    1: no reset generated when entering Standby mode on core domain.
  11. Bit 6 NRST_STOP : Core domain Stop entry reset option status bit
    0: a reset is generated when entering Stop mode on core domain
    1: no reset generated when entering Stop mode on core domain.
  12. Bit 5 Reserved, must be kept at reset value.
  13. Bit 4 WWDG_SW : WWDG control mode option status bit
    0: WWDG watchdog is controlled by hardware
    1: WWDG watchdog is controlled by software
  14. Bit 3 IWDG_SW : IWDG control mode option status bit
    0: IWDG watchdog is controlled by hardware
    1: IWDG watchdog is controlled by software
  15. Bit 2 BORH_EN : Brownout high enable
    0: disable
    1: enable

Bits 1:0 BOR_LEV[1:0] : Brownout level option status bit

These bits reflects the power level that generates a system reset.

00 or 11: BOR Level 1, the threshold level is low (~ 2.1 V)

01: BOR Level 2, the threshold level is medium (~ 2.4 V)

10: BOR Level 3, the threshold level is high (~ 2.7 V)

7.11.20 FLASH option status register (FLASH_OPTSR_PRG)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

This register is used to program values in corresponding option bits. Values after reset reflects the current values of the corresponding option bits.

Address offset: 0x054

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
SWAP_BANKRes.BOOT_UBE[7:0]IWDG_STDBYIWDG_STOPRes.Res.IO_VD_DIO2_HSLVIO_VD_D_HSLV
rwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
PRODUCT_STATE[7:0]NRST_STDBYNRST_STOPRes.WWDG_SWIWDG_SWBORH_ENBOR_LEV[1:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bit 31 SWAP_BANK : Bank swapping option configuration bit

SWAP_BANK option bit is used to configure whether the Bank1 and Bank2 are swapped or not. This bit is loaded with the SWAP_BANK bit of FLASH_OPTSR_CUR register after a reset.

0: Bank1 and Bank2 not swapped

1: Bank1 and Bank2 swapped

Bit 30 Reserved, must be kept at reset value.

Bits 29:22 BOOT_UBE[7:0] : Available only on cryptography enabled devices.

Unique boot entry control, selects either ST or OEM iRoT for secure boot.

0xC3: ST-iRoT (system flash) selected

0xB4: OEM-iRoT (user flash) selected.

In Open PRODUCT_STATE this value selects bootloader. Default value.

Bit 21 IWDG_STDBY : IWDG Standby mode freeze option status bit

When set the independent watchdog IWDG is frozen in system Standby mode.

0: Independent watchdog frozen in Standby mode

1: Independent watchdog keep running in Standby mode.

Bit 20 IWDG_STOP : IWDG Stop mode freeze option status bit

When set the independent watchdog IWDG is in system Stop mode.

0: Independent watchdog frozen in system Stop mode

1: Independent watchdog keep running in system Stop mode.

Bits 19:18 Reserved, must be kept at reset value.

  1. Bit 17 IO_VDDIO2_HSLV : High-speed IO at low V DDIO2 voltage configuration bit.
    This bit can be set only with V DDIO2 below 2.7 V.
    0: High-speed IO at low V DDIO2 voltage feature disabled (V DDIO2 can exceed 2.7 V)
    1: High-speed IO at low V DDIO2 voltage feature enabled (V DDIO2 remains below 2.7 V)
  2. Bit 16 IO_VDD_HSLV : High-speed IO at low V DD voltage configuration bit.
    This bit can be set only with V DD below 2.7 V.
    0: High-speed IO at low V DD voltage feature disabled (V DD can exceed 2.7 V)
    1: High-speed IO at low V DD voltage feature enabled (V DD remains below 2.7 V)
  3. Bits 15:8 PRODUCT_STATE[7:0] : Life state code (based on Hamming 8,4). See Section 7.6.11 .
  4. Bit 7 NRST_STDBY : Core domain Standby entry reset option configuration bit
    0: a reset is generated when entering Standby mode on core domain
    1: no reset generated when entering Standby mode on core domain.
  5. Bit 6 NRST_STOP : Core domain Stop entry reset option configuration bit
    0: a reset is generated when entering Stop mode on core domain
    1: no reset generated when entering Stop mode on core domain.
  6. Bit 5 Reserved, must be kept at reset value.
  7. Bit 4 WWDG_SW : WWDG control mode option configuration bit
    0: WWDG watchdog is controlled by hardware
    1: WWDG watchdog is controlled by software
  8. Bit 3 IWDG_SW : IWDG control mode option configuration bit
    0: IWDG watchdog is controlled by hardware
    1: IWDG watchdog is controlled by software
  9. Bit 2 BORH_EN : Brownout high enable configuration bit
    0: disabled
    1: enabled
  10. Bits 1:0 BOR_LEV[1:0] : Brownout level option configuration bit
    These bits reflects the power level that generates a system reset.
    00 or 11: BOR Level 1, the threshold level is low (~ 2.1 V)
    01: BOR Level 2, the threshold level is medium (~ 2.4 V)
    10: BOR Level 3, the threshold level is high (~ 2.7 V)

7.11.21 FLASH non-secure EPOCH register (FLASH_NSEPOCHR_CUR)

This register is non-secure, can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

This read-only register reflects the current values of the corresponding option bits.

Address offset: 0x060

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.NS_EPOCH[23:16]
rrrrrrrr
1514131211109876543210
NS_EPOCH[15:0]
rrrrrrrrrrrrrrrr

Bits 31:24 Reserved, must be kept at reset value.

Bits 23:0 NS_EPOCH[23:0] : Non-volatile non-secure EPOCH counter

7.11.22 FLASH secure EPOCH register (FLASH_SECEPOCHR_CUR)

This register is non-secure, can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

This read-only register reflects the current values of the corresponding option bits.

Address offset: 0x068

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.SEC_EPOCH[23:16]
rrrrrrrr
1514131211109876543210
SEC_EPOCH[15:0]
rrrrrrrrrrrrrrrr

Bits 31:24 Reserved, must be kept at reset value.

Bits 23:0 SEC_EPOCH[23:0] : Non-volatile secure EPOCH counter

7.11.23 FLASH option status register 2 (FLASH_OPTSR2_CUR)

This register is non-secure, can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

Default value: 0xB400 0170

This read-only register reflects the current values of the corresponding option bits.

Address offset: 0x070

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
TZEN[7:0]Res.Res.Res.Res.Res.Res.Res.Res.
rrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.USBPD
_DIS
Res.SRAM2
_ECC
SRAM3
_ECC
BKPRAM
_ECC
SRAM2
_RST
SRAM13
_RST
Res.Res.
rrrrrr

Bits 31:24 TZEN[7:0] : TrustZone enable configuration bits

This bit enables the device is in TrustZone mode during an option byte change.

0xC3: TrustZone disabled

0xB4: TrustZone enabled.

Bits 23:15 Reserved, must be kept at reset value.

Bits 14:9 Reserved, must be kept at reset value.

Bit 8 USBPD_DIS : USB power delivery configuration option bit

0: Enabled

1: Disabled

Bit 7 Reserved, must be kept at reset value.

Bit 6 SRAM2_ECC : SRAM2 ECC detection and correction disable

0: SRAM2 ECC check enabled

1: SRAM2 ECC check disabled

Bit 5 SRAM3_ECC : SRAM3 ECC detection and correction disable

0: SRAM3 ECC check enabled

1: SRAM3 ECC check disabled

Bit 4 BKPRAM_ECC : Backup RAM ECC detection and correction disable

0: BKPRAM ECC check enabled

1: BKPRAM ECC check disabled

Bit 3 SRAM2_RST : SRAM2 erase when system reset

0: SRAM2 erased when a system reset occurs

1: SRAM2 not erased when a system reset occurs.

Bit 2 SRAM13_RST : SRAM1 and SRAM3 erase upon system reset

0: SRAM1 and SRAM3 erased when a system reset occurs

1: SRAM1 and SRAM3 not erased when a system reset occurs

Bits 1:0 Reserved, must be kept at reset value.

7.11.24 FLASH option status register 2 (FLASH_OPTSR2_PRG)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

This register is used to program values in corresponding option bits. Values after reset reflects the current values of the corresponding option bits.

Address offset: 0x074

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
TZEN[7:0]Res.Res.Res.Res.Res.Res.Res.Res.
rwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.USBPD
_DIS
Res.SRAM2
_ECC
SRAM3
_ECC
BKPRAM
_ECC
SRAM2
_RST
SRAM1
_3_RST
Res.Res.
rwrwrwrwrwrw

Bits 31:24 TZEN[7:0] : TrustZone enable configuration bits

This bit enables the device is in TrustZone mode during an option byte change.

0xC3: TrustZone disabled

0xB4: TrustZone enabled

Bits 23:15 Reserved, must be kept at reset value.

Bits 14:9 Reserved, must be kept at reset value.

Bit 8 USBPD_DIS : USB power delivery configuration option bit

0: Enabled

1: Disabled

Bit 7 Reserved, must be kept at reset value.

Bit 6 SRAM2_ECC : SRAM2 ECC detection and correction disable

0: SRAM2 ECC check enabled

1: SRAM2 ECC check disabled

Bit 5 SRAM3_ECC : SRAM3 ECC detection and correction disable

0: SRAM3 ECC check enabled

1: SRAM3 ECC check disabled

Bit 4 BKPRAM_ECC : Backup RAM ECC detection and correction disable

0: BKPRAM ECC check enabled

1: BKPRAM ECC check disabled

Bit 3 SRAM2_RST : SRAM2 erase when system reset

0: SRAM2 erased when a system reset occurs

1: SRAM2 not erased when a system reset occurs.

Note: SRAM erase is triggered by option byte change operation, when enabling this feature.

Bit 2 SRAM1_3_RST : SRAM1 and SRAM3 erase upon system reset

0: SRAM1 and SRAM3 erased when a system reset occurs

1: SRAM1 and SRAM3 not erased when a system reset occurs

Note: SRAM erase is triggered by option byte change operation, when enabling this feature.

Bits 1:0 Reserved, must be kept at reset value.

7.11.25 FLASH non-secure boot register (FLASH_NSBOOTR_CUR)

This register is non-secure, can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

This register reflects the current values of the corresponding option bits.

Address offset: 0x080

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
NSBOOTADD[23:8]
rrrrrrrrrrrrrrrr
1514131211109876543210
NSBOOTADD[7:0]NSBOOT_LOCK[7:0]
rrrrrrrrrrrrrrrr

Bits 31:8 NSBOOTADD[23:0] : Non secure unique boot entry address

These bits reflect the Non secure UBE address

Bits 7:0 NSBOOT_LOCK[7:0] : Field locking the values of SWAP_BANK, and NSBOOTADD settings.
0xC3: SWAP_BANK and NSBOOTADD can still be modified following their individual rules.
0xB4: NSBOOTADD is frozen. SWAP_BANK can be modified only with TZEN set to 0xB4 (enabled).

7.11.26 FLASH non-secure boot register (FLASH_NSBOOTR_PRG)

This register is non-secure. It can be read and written by both secure and non-secure accesses, and protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGGR register.

This register is used to program values in corresponding option bits.

Address offset: 0x084

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
NSBOOTADD[23:8]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
NSBOOTADD[7:0]NSBOOT_LOCK[7:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:8 NSBOOTADD[23:0] : Non secure unique boot entry address

These bits allow configuring the Non secure BOOT address

Bits 7:0 NSBOOT_LOCK[7:0] : Field locking the values of SWAP_BANK, and NSBOOTADD settings.
0xC3: SWAP_BANK and NSBOOTADD can still be modified following their individual rules.
0xB4: NSBOOTADD is frozen. SWAP_BANK can be modified only with TZEN set to 0xB4 (enabled).

7.11.27 FLASH secure boot register (FLASH_SECBOOTR_CUR)

This register is secure. It can be read only by secure access. A non-secure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGGR register.

This register reflects the current values of the corresponding option bits.

Address offset: 0x088

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
SECBOOTADD[23:8]
rrrrrrrrrrrrrrrr
1514131211109876543210
SECBOOTADD[7:0]SECBOOT_LOCK[7:0]
rrrrrrrrrrrrrrrr

Bits 31:8 SECBOOTADD[23:0] : Unique boot entry secure address

These bits reflect the Secure UBE address

Bits 7:0 SECBOOT_LOCK[7:0] : Field locking the values of UBE, SWAP_BANK, and SECBOOTADD settings.

0xC3: BOOT_UBE, SWAP_BANK and SECBOOTADD can still be modified following their individual rules.

0xB4: BOOT_UBE and SECBOOTADD are frozen. SWAP_BANK can be modified only with TZEN set to 0xC3 (disabled).

7.11.28 FLASH secure boot register (FLASH_BOOTR_PRG)

This register is secure, can be read and written only by secure access. A non-secure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGGR register.

This register is used to program values in corresponding option bits.

Address offset: 0x08C

Reset value: 0xXXXX XXXX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
SECBOOTADD[23:8]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SECBOOTADD[7:0]SECBOOT_LOCK[7:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:8 SECBOOTADD[23:0] : Secure unique boot entry address.

These bits allow configuring the secure UBE address.

Bits 7:0 SECBOOT_LOCK[7:0] : Field locking the values of UBE, SWAP_BANK, and SECBOOTADD setting.

0xC3: BOOT_UBE, SWAP_BANK and SECBOOTADD can still be modified following their individual rules.

0xB4: BOOT_UBE and SECBOOTADD are frozen. SWAP_BANK can be modified only with TZEN set to 0xC3 (disabled).

7.11.29 FLASH non-secure OTP block lock (FLASH_OTPBLR_CUR)

This register is non-secure, can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

This register reflects the current values of the corresponding option bits.

Address offset: 0x090

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
LOCKBL[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
LOCKBL[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 LOCKBL[31:0] : OTP block lock

Block n corresponds to OTP 16-bit word \( 32 \times n \) to \( 32 \times n + 31 \) .

LOCKBL[n] = 1 indicates that all OTP 16-bit words in OTP Block n are locked and attempt to program them results in WRPERR.

LOCKBL[n] = 0 indicates that all OTP 16-bit words in OTP Block n are not locked.

When one block is locked, it is not possible to remove the write protection.

Also if not locked, it is not possible to erase OTP words.

7.11.30 FLASH non-secure OTP block lock (FLASH_OTPBLR_PRG)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

This register is used to program values in corresponding option bits.

Address offset: 0x094

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
LOCKBL[31:16]
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs
1514131211109876543210
LOCKBL[15:0]
rsrsrsrsrsrsrsrsrsrsrsrsrsrsrsrs

Bits 31:0 LOCKBL[31:0] : OTP block lock

Block \( n \) corresponds to OTP 16-bit word \( 32 \times n \) to \( 32 \times n + 31 \) .

LOCKBL[n] = 1 indicates that all OTP 16-bit words in OTP Block \( n \) are locked and attempt to program them results in WRPERR.

LOCKBL[n] = 0 indicates that all OTP 16-bit words in OTP Block \( n \) are not locked.

When one block is locked, it is not possible to remove the write protection.

LOCKBL bits can be set if the corresponding bit in FLASH_OTPBLR_CUR is cleared.

7.11.31 FLASH secure block based register for Bank1 (FLASH_SECB1Rx)

These registers (only one for STM32H523/33xx devices, as \( x = 1 \) ) are secure. They can be read and written only by secure access. A non-secure read/write access is RAZ/WI.

Address offset: \( 0x0A0 + 0x004 \times (x-1) \) , ( \( x = 1 \) to 4)

Reset value: 0x0000 0000

31302928272625242322212019181716
SECB1[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SECB1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 SECB1[31:0] : Secure/non-secure 8 Kbytes flash Bank1 sector attributes ( \( y = 0 \) to 31)

0: sector ( \( 32 \times (x-1) + y \) ) in Bank1 is non secure.

1: sector ( \( 32 \times (x-1) + y \) ) in Bank1 is secure.

7.11.32 FLASH privilege block based register for Bank1 (FLASH_PRIVB1Rx)

These registers (only one for STM32H523/33xx devices, as \( x = 1 \) ) are privileged. They can be read and written only by a privileged access. This register can be protected against non-secure write access.

Address offset: \( 0x0C0 + 0x004 \times (x-1) \) , ( \( x = 1 \) to 4)

Reset value: 0x0000 0000

31302928272625242322212019181716
PRIVB1[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
PRIVB1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 PRIVB1[31:0] : Privileged/unprivileged 8-Kbyte flash Bank1 sector attribute ( \( y = 0 \) to 31)

0: sectors ( \( 32 \times (x-1) + y \) ) in Bank1 is unprivileged.

1: sector ( \( 32 \times (x-1) + y \) ) in Bank1 is privileged.

7.11.33 FLASH security watermark for Bank1 (FLASH_SECWM1R_CUR)

This read-only register is non-secure, it can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register. It reflects the current values of the corresponding option bits.

Address offset: 0x0E0

Reset value: 0x00XX 00XX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_END[6:0]
rrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_STRT[6:0]
rrrrrrr

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 SECWM1_END[6:0] : Bank1 security WM area 1 end sector

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 SECWM1_STRT[6:0] : Bank1 security WM area 1 start sector

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.11.34 FLASH security watermark for Bank1 (FLASH_SECWM1R_PRG)

This register is secure, can be read and written only by secure access. A non-secure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFG register. This register is used to program values in corresponding option bits.

Address offset: 0x0E4

Reset value: 0x00XX 00XX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_END[6:0]
rwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_STRT[6:0]
rwrwrwrwrwrwrw

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 SECWM1_END[6:0] : Bank1 security WM area 1 end sector

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 SECWM1_STRT[6:0] : Bank1 security WM area 1 start sector

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.11.35 FLASH write sector group protection for Bank1 (FLASH_WRP1R_CUR)

This register is non-secure. It can be read by both secure and non-secure accesses, and can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

This read-only register reflects the current values of the corresponding option bits.

Address offset: 0x0E8

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
WRPSG1[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
WRPSG1[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 WRPSG1[31:0] : Bank1 sector group protection option status byte

Each FLASH_WRP1R_CUR bit reflects the write protection status of the corresponding group of four consecutive sectors in Bank1 (0: the group is write-protected; 1: the group is not write-protected)

Note: In STM32H523/33xx devices only bits [7:0] are used. Consider bits [31:8] as reserved, and keep them at reset value.

7.11.36 FLASH write sector group protection for Bank1 (FLASH_WRP1R_PRG)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

This register is used to program values in corresponding option bits.

Address offset: 0x0EC

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
WRPSG1[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
WRPSG1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 WRPSG1[31:0] : Bank1 sector group protection option status byte

Setting WRPSG1 bits to 0 write protects the corresponding group of four consecutive sectors in Bank1 (0: the group is write-protected; 1: the group is not write-protected)

Bit 0: Group embedding sectors 0 to 3

Bit 1: Group embedding sectors 4 to 7

Bit N: Group embedding sectors \( 4 \times N \) to \( 4 \times N + 3 \)

Bit 31: Group embedding sectors 124 to 127

Note: In STM32H523/33xx devices only bits [7:0] are used. Consider bits [31:8] as reserved, and keep them at reset value.

7.11.37 FLASH data sector configuration Bank1 (FLASH_EDATA1R_CUR)

This register is non-secure, can be read by both secure and non-secure accesses. The register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFG register.

This read-only register reflects the current values of the corresponding options bits.

Address offset: 0x0F0

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
EDATA1_ENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA1_STRT[2:0]
rrrr

Bits 31:16 Reserved, must be kept at reset value.

Bit 15 EDATA1_EN : Bank1 flash high-cycle data enable

0: No flash high-cycle data area

1: Flash high-cycle data is used

Bits 14:3 Reserved, must be kept at reset value.

Bits 2:0 EDATA1_STRT[2:0] :

EDATA1_STRT contains the start sectors of the flash high-cycle data area in Bank1 There is no hardware effect to those bits. They shall be managed by ST tools in Flasher.

000: The last sector of Bank1 is reserved for flash high-cycle data

001: The two last sectors of Bank1 are reserved for flash high-cycle data

010: The three last sectors of Bank1 are reserved for flash high-cycle data

...

111: The eight last sectors of Bank1 are reserved for flash high-cycle data

7.11.38 FLASH data sector configuration Bank1 (FLASH_EDATA1R_PRG)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

This register is used to program values in corresponding options bits.

Address offset: 0xF4

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
EDATA1_ENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA1_STRT[2:0]
rwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bit 15 EDATA1_EN : Bank1 flash high-cycle data enable

0: No flash high-cycle data area

1: Flash high-cycle data is used

Bits 14:3 Reserved, must be kept at reset value.

Bits 2:0 EDATA1_STRT[2:0] :

EDATA1_STRT contains the start sectors of the flash high-cycle data area in Bank1 There is no hardware effect to those bits. They must be managed by ST tools in Flasher.

000: The last sector of Bank1 is reserved for flash high-cycle data

001: The two last sectors of Bank1 are reserved for flash high-cycle data

010: The three last sectors of Bank1 are reserved for flash high-cycle data

...

111: The eight last sectors of Bank1 are reserved for flash high-cycle data

7.11.39 FLASH HDP Bank1 configuration (FLASH_HDP1R_CUR)

This register is non-secure. It can be read by both secure and non-secure accesses, and protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register. This register is initially loaded with the values of the corresponding option bits.

Address offset: 0x0F8

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP1_END[6:0]
rrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP1_STRT[6:0]
rrrrrrr

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 HDP1_END[6:0] : HDPL barrier end set in number of 8-Kbyte sectors

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 HDP1_STRT[6:0] : HDPL barrier start set in number of 8-Kbyte sectors

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.11.40 FLASH HDP Bank1 configuration (FLASH_HDP1R_PRG)

This register is non-secure. It can be read and written by both secure and non-secure access, and can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

The register is accessible only in HDPL1. In HDPL2 or HDPL3 it is WI, RAZ.

This register is used to program values in corresponding option bits.

Address offset: 0x0FC

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP1_END[6:0]
rwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP1_STRT[6:0]
rwrwrwrwrwrwrw

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 HDP1_END[6:0] : HDPL barrier end set in number of 8-Kbyte sectors

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 HDP1_STRT[6:0] : HDPL barrier start set in number of 8-Kbyte sectors

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.11.41 FLASH ECC correction register (FLASH_ECCCORR)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

Address offset: 0x100

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.ECCCRes.Res.Res.Res.ECCCI
E
OTP_E
CC
SYSF
_ECC
BK
_ECC
EDATA
_ECC
OBK
_ECC
Res.Res.Res.Res.
rwrwrrrrr
1514131211109876543210
ADDR_ECC[15:0]
rrrrrrrrrrrrrrrr

Bit 31 Reserved, must be kept at reset value.

Bit 30 ECCC : ECC correction set by hardware when single ECC error has been detected and corrected.

Cleared by writing 1.

Bits 29:26 Reserved, must be kept at reset value.

Bit 25 ECCCI : ECC single correction error interrupt enable bit

When ECCCI bit is set to 1, an interrupt is generated when an ECC single correction error occurs during a read operation.

0: no interrupt generated when an ECC single correction error occurs

1: non-secure interrupt generated when an ECC single correction error occurs

Bit 24 OTP_ECC : OTP ECC error bit

This bit is set to 1 when one single ECC correction occurred during the last successful read operation from the read-only/ OTP area. The address of the ECC error is available in ADDR_ECC bitfield.

Bit 23 SYSF_ECC : ECC fail for corrected ECC error in system flash memory

It indicates if system flash memory is concerned by ECC error.

Bit 22 BK_ECC : ECC fail bank for corrected ECC error

It indicates which bank is concerned by ECC error

Bit 21 EDATA_ECC : ECC fail for corrected ECC error in flash high-cycle data area

It indicates if flash high-cycle data area is concerned by ECC error.

Bit 20 OBK_ECC : Single ECC error corrected in flash OB Keys storage area. It indicates the OBK storage concerned by ECC error.

Bits 19:16 Reserved, must be kept at reset value.

Bits 15:0 ADDR_ECC[15:0] : ECC error address

When an ECC error occurs (for single correction) during a read operation, ADDR_ECC contains the address that generated the error. It is reset when the flag error is reset.

The flash interface programs the address in this register only when no ECC error flags are set. This means that only the first address that generated an ECC error is saved.

The address in ADDR_ECC is relative to the flash memory area where the error occurred (user flash memory, system flash memory, data area, read-only/OTP area).

7.11.42 FLASH ECC detection register (FLASH_ECCDETR)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

Address offset: 0x104

Reset value: 0x0000 0000

31302928272625242322212019181716
ECCDRes.Res.Res.Res.Res.Res.OTP_ECCSYSF_ECCBK_ECCEDATA_ECCOBK_ECCRes.Res.Res.Res.
rwrrrrr
1514131211109876543210
ADDR_ECC[15:0]
rrrrrrrrrrrrrrrr

Bit 31 ECCD : ECC detection

Set by hardware when two ECC error has been detected.

When this bit is set, a NMI is generated.

Cleared by writing 1. Needs to be cleared in order to detect subsequent double ECC errors.

Bits 30:25 Reserved, must be kept at reset value.

Bit 24 OTP_ECC : OTP ECC error bit

This bit is set to 1 when double ECC detection occurred during the last read operation from the read-only/ OTP area. The address of the ECC error is available in ADDR_ECC bitfield.

Bit 23 SYSF_ECC : ECC fail for double ECC error in system flash memory

It indicates if system flash memory is concerned by ECC error.

Bit 22 BK_ECC : ECC fail bank for double ECC error

It indicates which bank is concerned by ECC error

Bit 21 EDATA_ECC : ECC fail double ECC error in flash high-cycle data area

It indicates if flash high-cycle data area is concerned by ECC error.

Bit 20 OBK_ECC : ECC fail double ECC error in flash OB Keys storage area. It indicates the OBK storage concerned by ECC error.

Bits 19:16 Reserved, must be kept at reset value.

Bits 15:0 ADDR_ECC[15:0] : ECC error address

When an ECC error occurs (double detection) during a read operation, the ADDR_ECC contains the address that generated the error. It is reset when the flag error is reset.

The flash interface programs the address in this register only when no ECC error flags are set. This means that only the first address that generated an double ECC error is saved.

The address in ADDR_ECC is relative to the flash memory area where the error occurred (user flash memory, system flash memory, data area, read-only/OTP area).

7.11.43 FLASH ECC data (FLASH_ECCDR)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

Address offset: 0x108

Reset value: 0x0000 0000

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
DATA_ECC[15:0]
rrrrrrrrrrrrrrrr

Bits 31:16 Reserved, must be kept at reset value.

Bits 15:0 DATA_ECC[15:0] : ECC error data

When an double detection ECC error occurs on special areas with 6-bit ECC on 16-bit data (data, read-only/OTP), the failing data is read to this register.

By checking if it is possible to determine whether the failure was on a real data, or due to access to uninitialized memory.

7.11.44 FLASH secure block-based register for Bank2 (FLASH_SECB2Rx)

These registers (only one for STM32H523/33xx devices, as \( x = 1 \) ) are secure, they can be read and written only by secure access. A non-secure read/write access is RAZ/WI. The registers can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGR register.

Address offset: \( 0x1A0 + 0x004 * (x-1) \) , ( \( x = 1 \) to 4)

Reset value: 0x0000 0000

31302928272625242322212019181716
SECBB2[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SECBB2[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 SECBB2[31:0] : Secure/non-secure flash Bank2 sector attribute ( \( y = 0 \) to 31)

0: sectors \( (32 * (x-1) + y) \) in Bank2 is non secure

1: sector \( (32 * (x-1) + y) \) in Bank2 is secure

7.11.45 FLASH privilege block-based register for Bank2 (FLASH_PRIVBB2Rx)

These registers (only one for STM32H523/33xx devices, as \( x = 1 \) ) are privileged, they can be read and written only by a privileged access, and can be protected against non-secure write access by watermark.

Address offset: \( 0x1C0 + 0x004 * (x-1) \) , ( \( x = 1 \) to 4)

Reset value: 0x0000 0000

31302928272625242322212019181716
PRIVBB2[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
PRIVBB2[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 PRIVBB2[31:0] : Privileged / non-privileged 8-Kbyte flash Bank2 sector attribute (y = 0 to 31)
0: sectors \( (32 * (x-1) + y) \) in Bank2 is unprivileged
1: sector \( (32 * (x-1) + y) \) in Bank2 is privileged

7.11.46 FLASH security watermark for Bank2 (FLASH_SECWM2R_CUR)

This register is non-secure, it can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

This read-only register reflects the current values of the corresponding option bits.

Address offset: 0x1E0

Reset value: 0x00XX 00XX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
Res.SECWM2_END[6:0]
rrrrrrr
1514131211109876543210
Res.SECWM2_STRT[6:0]
rrrrrrr

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 SECWM2_END[6:0] : Bank2 security WM end sector

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 SECWM2_STRT[6:0] : Bank2 security WM area start sector

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.11.47 FLASH security watermark for Bank2 (FLASH_SECWM2R_PRG)

This register is secure, can be read and written only by secure access. A non-secure read/write access is RAZ/WI. The register can be protected against unprivileged accesses when SPRIV = 1 in the FLASH_PRIVCFGR register.

This register is used to program values in corresponding option bits.

Address offset: 0x1E4

Reset value: 0x00XX 00XX

Bits 0 to 31 are loaded with values from the flash memory at OBL.

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_END[6:0]
rwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT[6:0]
rwrwrwrwrwrwrw

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 SECWM2_END[6:0] : Bank2 security WM area end sector

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 SECWM2_STRT[6:0] : Bank2 security WM area start sector

Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.11.48 FLASH write sector group protection for Bank2 (FLASH_WRP2R_CUR)

This register is non-secure, can be read by both secure and non-secure access, and protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

This read-only register reflects the current values of the corresponding option bits.

Address offset: 0x1E8

Reset value: 0xFFFF XXXX

31302928272625242322212019181716
WRPSG2[31:16]
rrrrrrrrrrrrrrrr
1514131211109876543210
WRPSG2[15:0]
rrrrrrrrrrrrrrrr

Bits 31:0 WRPSG2[31:0] : Bank2 sector group protection option status byte

Each bit reflects the write protection status of the corresponding group of four consecutive sectors in Bank2 (0: group is write-protected; 1: group is not write-protected)

Bit 0: Group embedding sectors 0 to 3

Bit 1: Group embedding sectors 4 to 7

Bit N: Group embedding sectors 4 x N to 4 x N + 3

Bit 31: Group embedding sectors 124 to 127

Note: In STM32H523/33xx devices only bits [7:0] are used. Consider bits [31:8] as reserved, and keep them at reset value.

7.11.49 FLASH write sector group protection for Bank2 (FLASH_WRP2R_PRG)

This register is non-secure. It can be read and written by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

This register is used to program values in corresponding option bits.

Address offset: 0x1EC

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
WRPSG2[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
WRPSG2[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 WRPSG2[31:0] : Bank2 sector group protection option status byte

Setting WRPSGn2 bits to 0 write protects the corresponding group of four consecutive sectors in Bank2 (0: group is write-protected; 1: group is not write-protected)

Bit 0: Group embedding sectors 0 to 3

Bit 1: Group embedding sectors 4 to 7

Bit N: Group embedding sectors \( 4 \times N \) to \( 4 \times N + 3 \)

Bit 31: Group embedding sectors 124 to 127

Note: In STM32H523/33xx devices only bits [7:0] are used. Consider bits [31:8] as reserved, and keep them at reset value.

7.11.50 FLASH data sectors configuration Bank2 (FLASH_EDATA2R_CUR)

This register is non-secure, can be read by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

This read-only register reflects the current values of the corresponding options bits.

Address offset: 0x1F0

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
EDATA2
_EN
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA2_STRT[2:0]
rrrr

Bits 31:16 Reserved, must be kept at reset value.

Bit 15 EDATA2_EN : Bank2 flash high-cycle data enable

0: No flash high-cycle data area

1: Flash high-cycle data is used

Bits 14:3 Reserved, must be kept at reset value.

Bits 2:0 EDATA2_STRT[2:0] :

EDATA2_STRT contains the start sectors of the flash high-cycle data area in Bank2 There is no hardware effect to those bits. They shall be managed by ST tools in Flasher.

000: The last sector of Bank2 is reserved for flash high-cycle data

001: The two last sectors of Bank2 are reserved for flash high-cycle data

010: The three last sectors of Bank2 are reserved for flash high-cycle data

...

111: The eight last sectors of Bank2 are reserved for flash high-cycle data

7.11.51 FLASH data sector configuration Bank2 (FLASH_EDATA2R_PRG)

This register is non-secure. It can be read and written by both secure and non-secure accesses, and protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register. It is used to program values in corresponding options bits.

Address offset: 0x1F4

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
1514131211109876543210
EDATA2_ENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA2_STRT[2:0]
rwrwrwrw

Bits 31:16 Reserved, must be kept at reset value.

Bit 15 EDATA2_EN : Bank2 flash high-cycle data enable

0: No flash high-cycle data area

1: Flash high-cycle data is used

Bits 14:3 Reserved, must be kept at reset value.

Bits 2:0 EDATA2_STRT[2:0] :

EDATA2_STRT contains the start sectors of the flash high-cycle data area in Bank2 There is no hardware effect to those bits. They shall be managed by ST tools in Flasher.

000: The last sector of Bank2 is reserved for flash high-cycle data.

001: The two last sectors of Bank2 are reserved for flash high-cycle data.

010: The three last sectors of Bank2 are reserved for flash high-cycle data.

...

111: The eight last sectors of Bank2 are reserved for flash high-cycle data.

7.11.52 FLASH HDP Bank2 configuration (FLASH_HDP2R_CUR)

This register is initially loaded with the values of the corresponding option bits. This register is non-secure. It can be read by both secure and non-secure accesses, and can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

Address offset: 0x1F8

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_END[6:0]
rrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT[6:0]
rrrrrrr

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 HDP2_END[6:0] : HDPL barrier end set in number of 8-Kbyte sectors Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 HDP2_STRT[6:0] : HDPL barrier start set in number of 8-Kbyte sectors Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.11.53 FLASH HDP Bank2 configuration (FLASH_HDP2R_PRG)

This register is non-secure. It can be read and written only by both secure and non-secure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register.

Register is accessible only in HDPL1. In HDPL2 or HDPL3 it is WI, RAZ.

This register is used to program values in corresponding option bits.

Address offset: 0x1FC

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_END[6:0]
rwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT[6:0]
rwrwrwrwrwrwrw

Bits 31:23 Reserved, must be kept at reset value.

Bits 22:16 HDP2_END[6:0] : HDPL barrier end set in number of 8-Kbyte sectors Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

Bits 15:7 Reserved, must be kept at reset value.

Bits 6:0 HDP2_STRT[6:0] : HDPL barrier start set in number of 8-Kbyte sectors Note: For STM32H523/33xx devices the maximum value is 0x1F, consider bits [6:5] as reserved, and keep them at reset value.

7.12 FLASH register map and reset values

Table 85. Register map and reset value table

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x000FLASH_ACRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.PRFTENRes.Res.WRHIGHFREQ
[1:0]
LATENCY
[3:0]
Reset value0010011
0x004FLASH_NSKEYRNSKEY[31:0]
Reset value00000000000000000000000000000100
0x008FLASH_SECKEYRSECKEY[31:0]
Reset value00000000000000000000000000000000
0x00CFLASH_OPTKEYROPTKEY[31:0]
Reset value00000000000000000000000000000000
0x010FLASH_NSOBKKEYRNSOBKKEY[31:0]
Reset value00000000000000000000000000000000
0x014FLASH_SECOBKKEYRSECOBKKEY[31:0]
Reset value00000000000000000000000000000000
0x018FLASH_OPSRCODE_OP
[2:0]
Res.Res.Res.Res.OTP_OPSYSF_OPBK_OPDATA_OPRes.ADDR_OP[19:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x01CFLASH_OPTCRSWAP_BANKRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.OPTSTRTOPTLOCK
Reset value001
0x020FLASH_NSSRRes.Res.Res.Res.Res.Res.Res.OPTCHANGERROBKWERROBKERRINCERRSTRBERRPGSERRWRPERREOPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SDBNERes.WBNEBSY
Reset value00000000000
0x024FLASH_SECSRRes.Res.Res.Res.Res.Res.Res.OPTCHANGERROBKWERROBKERRINCERRSTRBERRPGSERRWRPERREOPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBNERes.WBNEBSY
Reset value00000000XXX
0x028FLASH_NSCRBKSELRes.Res.Res.Res.Res.Res.OPTCHANGERRIEOBKWIEOBKIEINCERRIESTRBERRIEPGSERRIEWRPERRIEEOPIEMERRes.Res.SNB[6:0]STRTFWBERSERPGLOCK
Reset value000000000000000000000001

Table 85. Register map and reset value table (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x02CFLASH_SECCRBKSELRes.Res.Res.Res.Res.Res.Res.Res.OBKWIEOBKERRIEINCERRIESTRBERRIEPGSERRIEWRPERRIEEOPIEMERRes.Res.SNB[6:0]STRTFWBERSERPGLOCK
Reset value00000000000000000000001
0x030FLASH_NSCCRRes.Res.Res.Res.Res.Res.Res.Res.CLR_OPTCHANGERRCLR_OBKERRCLR_OBKERRCLR_INCERRCLR_STRBERRCLR_PGSERRCLR_WRPERRCLR_EOPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value00000000
0x034FLASH_SECCCRRes.Res.Res.Res.Res.Res.Res.Res.CLR_OBKWERRCLR_OBKERRCLR_OBKERRCLR_INCERRCLR_STRBERRCLR_PGSERRCLR_WRPERRCLR_EOPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value00000000
0x03CFLASH_PRIVCFGRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.NSPRIVSPRIV
Reset value00
0x040FLASH_NSOBKCFGRRes.Res.Res.Res.Res.Res.Res.Res.SWAP_OFFSET[8:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ALT_SECT_ERASEALT_SECTSWAP_SECT_REQLOCK
Reset value111111110000
0x044FLASH_SECOBKCFGRRes.Res.Res.Res.Res.Res.Res.Res.SWAP_OFFSET[8:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.ALT_SECT_ERASEALT_SECTSWAP_SECT_REQLOCK
Reset value111111110000
0x048FLASH_HDPEXTRRes.Res.Res.Res.Res.Res.Res.Res.HDP2_EXT[6:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP1_EXT[6:0]
Reset value00000000000000
0x04CReservedReserved
0x050FLASH_OPTSR_CURSWAP_BANKRes.BOOT_UBE[7:0]IWDG_STDBYIWDG_STOPRes.IO_VDDIO2_HSLVIO_VDD_HSLVPRODUCT_STATE[7:0]NRST_STDBYNRST_STOPRes.WWDG_SWIWDG_SWBORH_LENBOR_LEV[1:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Table 85. Register map and reset value table (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x054FLASH_OPTSR_PRGSWAP_BANKRes.BOOT_UBE[7:0]IWDG_STDBYIWDG_STOPRes.Res.IO_VDDIO2_HSLVIO_VDD_HSLVPRODUCT_STATE[7:0]NRST_STDBYNRST_STOPRes.WWDG_SWIWDG_SWBORH_ENBOR_LEV[1:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x058ReservedReserved
0x05CReservedReserved
0x060FLASH_NSEPOCHR_CURRes.Res.Res.Res.Res.Res.Res.Res.NS_EPOCH[23:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXX
0x064FLASH_NSEPOCHR_PRGRes.Res.Res.Res.Res.Res.Res.Res.NS_EPOCH[23:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXX
0x068FLASH_SECEPOCHR_CURRes.Res.Res.Res.Res.Res.Res.Res.SEC_EPOCH[23:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXX
0x06CFLASH_SECEPOCHR_PRGRes.Res.Res.Res.Res.Res.Res.Res.SEC_EPOCH[23:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXX
0x070FLASH_OPTSR2_CURTZEN[7:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.USBPD_DISSRAM2_ECCSRAM3_ECCBKPRAM_ECCSRAM2_RSTSRAM13_RSTRes.Res.
Reset valueXXXXXXXXXXXXXX
0x074FLASH_OPTSR2_PRGTZEN[7:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.USBPD_DISSRAM2_ECCSRAM3_ECCBKPRAM_ECCSRAM2_RSTSRAM13_RSTRes.Res.
Reset valueXXXXXXXXXXXXXX
0x080FLASH_NSBOOTR_CURNSBOOTADD[23:0]NSBOOT_LOCK[7:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x084FLASH_NSBOOTR_PRGNSBOOTADD[23:0]NSBOOT_LOCK[7:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x088FLASH_SECBOOTR_CURSECBOOTADD[23:0]SECBOOT_LOCK[7:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x08CFLASH_SECBOOTR_PRGSECBOOTADD[23:0]SECBOOT_LOCK[7:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x090FLASH_OTPBLR_CURLOCKBL[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Table 85. Register map and reset value table (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x094FLASH_OTPBLR_PRGLOCKBL[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x0A0
+ 0x004
* x (x =
1 to 4)
FLASH_SECB1R_xSECB1[31:0]
Reset value00000000000000000000000000000000
0x0C0
+ 0x004
* x (x =
1 to 4)
FLASH_PRIVBB1R_xPRIVBB1[31:0]
Reset value00000000000000000000000000000000
0x0D0 -
0x0DC
ReservedReserved
0x0E0FLASH_SECWM1R_
_CUR
Res.SECWM1_END[6:0]Res.SECWM1_STRT[6:0]
Reset valueX X X X X X XX X X X X X X
0x0E4FLASH_SECWM1R_
_PRG
Res.SECWM1_END1[6:0]Res.SECWM1_STRT[6:0]
Reset valueX X X X X X XX X X X X X X
0x0E8FLASH_WRP1R_
_CUR
WRPSG1[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x0ECFLASH_WRP1R_
_PRG
WRPSG1[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x0F0FLASH_EDATA1R_
_CUR
Res.EDATA1_ENRes.EDATA1_STRT
[2:0]
Reset valueXX X X
0x0F4FLASH_EDATA1R_
_PRG
Res.EDATA1_ENRes.EDATA1_STRT
[2:0]
Reset valueXX X X
0x0F8FLASH_HDP1R_
_CUR
Res.HDP1_END[6:0]Res.HDP1_STRT[6:0]
Reset value0 0 0 0 0 0 00 0 0 0 0 0 1
0x0FCFLASH_HDP1R_
_PRG
Res.HDP1_END[6:0]Res.HDP1_STRT[6:0]
Reset valueX X X X X X 0X X X X X X X
0x100FLASH_ECCCORRRes.ECCCRes.ECCIEOTP_ECCSYSF_ECCBK_ECCEDATA_ECCOBK_ECCRes.ADDR_ECC[15:0]
0x0000 000000000000 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

Table 85. Register map and reset value table (continued)

OffsetRegister name313029282726252423222120191817161514131211109876543210
0x104FLASH_ECCDETRECCDRes.Res.Res.Res.Res.Res.OTP_ECC_FAILSYSF_ECCBK_ECCEDATA_ECCOBK_ECCRes.Res.Res.Res.ADDR_ECC[15:0]
Reset value0000000000000000000000
0x108FLASH_ECCDRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DATA_ECC[15:0]
Reset value000000000000000
0x1A0 +
0x004 *
x (x = 1
to 4)
FLASH_SECB2R_xSECB2[31:0]
Reset value00000000000000000000000000000000
0x1A0 +
0x004 *
x (x = 1
to 4)
FLASH_PRIVB2R_xPRIVB2[31:0]
Reset value00000000000000000000000000000000
0x1D0 -
0x1DC
ReservedReserved
0x1E0FLASH_SECW2R_CURRes.Res.Res.Res.Res.Res.Res.Res.SECWM2_END[6:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT[6:0]
Reset valueXXXXXXXXXXXX
0x1E4FLASH_SECW2R_PRGRes.Res.Res.Res.Res.Res.Res.Res.SECWM2_END1[6:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT[6:0]
Reset valueXXXXXXXXXXXX
0x1E8FLASH_WRP2R_CURWRPSG2[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x1ECFLASH_WRP2R_PRGWRPSG2[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x1F0FLASH_EDATA2R_CURRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA2_ENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA2_STRT[2:0]
Reset valueXXX
0x1F4FLASH_EDATA2R_PRGRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA2_ENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA2_STRT[2:0]
Reset valueXXX
0x1F8FLASH_HDP2R_CURRes.Res.Res.Res.Res.Res.Res.Res.HDP2_END[6:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT[6:0]
Reset valueXXXXXXXXXXXX
0x1FCFLASH_HDP2R_PRGRes.Res.Res.Res.Res.Res.Res.Res.HDP2_END[6:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT[6:0]
Reset valueXXXXXXXXXXXX
Refer to Section 2.3: Memory organization for the register boundary addresses.