7. Embedded flash memory (FLASH)

7.1 FLASH introduction

The embedded flash memory (FLASH) manages the accesses of any master to the 4 Mbytes of embedded nonvolatile memory. It implements the 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 20 shows the embedded flash memory block diagram.

Figure 20. FLASH block diagram (simplified)

Simplified block diagram of the FLASH memory system. The diagram shows external components (DEBUG, RCC, TAMP, SBS, SAES, Backup registers) interacting with an internal FLASH block. The internal block contains AHB interfaces, IRQ logic, Flash interface logic, Register banks, and two NVM Banks (Bank1 and Bank2). Data paths include 32-bit and 128-bit AHB buses, and various control and status signals like ECC, redundancy, and 128-bit data transfers.

The diagram illustrates the internal architecture of the FLASH memory system. External components include DEBUG, RCC, TAMP, SBS, SAES, and Backup registers. The internal FLASH block contains the following components and interfaces:

MSv68825V3

Simplified block diagram of the FLASH memory system. The diagram shows external components (DEBUG, RCC, TAMP, SBS, SAES, Backup registers) interacting with an internal FLASH block. The internal block contains AHB interfaces, IRQ logic, Flash interface logic, Register banks, and two NVM Banks (Bank1 and Bank2). Data paths include 32-bit and 128-bit AHB buses, and various control and status signals like ECC, redundancy, and 128-bit data transfers.

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 21 shows the organization supported by the embedded flash memory.

Figure 21. Embedded flash memory organization (4-Mbyte devices)

Figure 21: Embedded flash memory organization (4-Mbyte devices). The diagram illustrates the internal structure of the flash memory, divided into Bank1 and Bank2. Bank1 contains User main memory (up to 256 sectors of 8-Kbyte each, 9-bit ECC per 128-bit flash word), System memory (16 sectors of 8-Kbyte each, 9-bit ECC per 128-bit flash word), High cycle data (16 sectors of 6-Kbyte each, 6-bit ECC per 16-bit), Special region (Bank 1 only, 6-bit ECC per 16-bit, OTP writable only once, Read-only writable only by STMicroelectronics), Read-only area, OTP area, and Option Bytes. Bank2 contains System memory (16 sectors of 8-Kbyte each, 9-bit ECC per 128-bit flash word), High cycle Data (16 sectors of 6-Kbyte each, 6-bit ECC per 16-bit), and Option byte key storage (2 sectors of 8-Kbyte each, 9-bit ECC). The Flash interface logic is connected to the Main AHB system bus and the AHB config port. Secure-only and Write-protected regions are indicated. The diagram also shows the connection to the OBK (Option Byte Key) and the OTP (One-Time Programmable) area.
Figure 21: Embedded flash memory organization (4-Mbyte devices). The diagram illustrates the internal structure of the flash memory, divided into Bank1 and Bank2. Bank1 contains User main memory (up to 256 sectors of 8-Kbyte each, 9-bit ECC per 128-bit flash word), System memory (16 sectors of 8-Kbyte each, 9-bit ECC per 128-bit flash word), High cycle data (16 sectors of 6-Kbyte each, 6-bit ECC per 16-bit), Special region (Bank 1 only, 6-bit ECC per 16-bit, OTP writable only once, Read-only writable only by STMicroelectronics), Read-only area, OTP area, and Option Bytes. Bank2 contains System memory (16 sectors of 8-Kbyte each, 9-bit ECC per 128-bit flash word), High cycle Data (16 sectors of 6-Kbyte each, 6-bit ECC per 16-bit), and Option byte key storage (2 sectors of 8-Kbyte each, 9-bit ECC). The Flash interface logic is connected to the Main AHB system bus and the AHB config port. Secure-only and Write-protected regions are indicated. The diagram also shows the connection to the OBK (Option Byte Key) and the OTP (One-Time Programmable) area.

The embedded flash nonvolatile memory is composed of:

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

Partition usage

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

Figure 22. Embedded flash memory usage

Diagram of embedded flash memory usage across different modes and banks.

The diagram illustrates the partitioning of embedded flash memory across three modes: STM32 Standard mode, SWAP_BANK=0, and SWAP_BANK=1 (STM32 Secure access mode). The memory is divided into User memory and System memory.

STM32 Standard mode:

SWAP_BANK=0 and SWAP_BANK=1:

STM32 Secure access mode:

Notable startup addresses: Indicated by pink arrows. One arrow points to the top of the User memory in Standard mode. Another arrow points to the top of the Application secure software in Secure access mode, with a 'Jump' arrow indicating a transition.

Legend:

MSv68817V2

Diagram of embedded flash memory usage across different modes and banks.

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 39 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 39. 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 V
VOS2 range
1.05 to 1.15 V
VOS1 range
1.15 to 1.26 V
VOS0 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 39).

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 39.
  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 39.
  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 bank2, 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.

possible to launch an erase, an option modification, an OBK swap or OBK alternate sector erase operation on flash memory.

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_NS/OBKKEYR unlocks FLASH_NS/OBKCFGR. 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 39 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.

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 nonsecure 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.
  6. 6. Set the STRT bit in the FLASH_SECCR register.
  7. 7. Wait for the BSY bit to be cleared in the FLASH_SECSR 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_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 nonsecure 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 nonsecure access, all sectors must be configured as nonsecure. 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 nonsecure 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 40. 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 40. 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

Table 40. Flash memory OTP organization (continued)

OTP blockAHB addressAHB wordLock bit
[31:16][15:0]
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 40). 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 40. 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 41.

Table 41. 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 192 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 0x0902_7FFF (see Figure 23). It is mapped in the 16 last sectors of bank1 and bank2. This area is protected by a robust 6-bit ECC, which allows a read and write granularity of 16 bits 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 96Kbytes of data are needed in bank1, set EDATA1_EN to 1, and EDATA1_STRT to 15. If no data are needed in bank2, set EDATA2_EN to 0. In this case the data are accessible from address 0x0900_0000 to 0x0901_7FFF for bank1.

For greater efficiency, it is always 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 on the bank1 address range, and vice versa.

A bus error is generated on:

Erasing the data area sector is possible by normal erase request for the corresponding user flash sector (255-240 for largest device).

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

Figure 23. Flash high-cycle data memory map on 4-Mbyte device

Memory map diagram for a 4-Mbyte device showing Data and Code memory maps for Bank1 and Bank2. Bank1 Code map (9-bit ecc) ranges from 0x0800_0000 / 0x0C00_0000 containing Sector 0, Sector 1 down to Sector 255 / 0. Bank2 Code map (9-bit ecc) ranges from 0x0820_0000 / 0x0C20_0000 containing Sector 0, Sector 1 down to Sector 255 / 0. High-cycle data areas are marked starting at EDATA1_STRT and EDATA2_STRT (Sector 240 / 15). Sector sizes are 8-Kbyte for code memory and 6-Kbyte for data memory. MSv74524V1 is shown at the bottom right.
Memory map diagram for a 4-Mbyte device showing Data and Code memory maps for Bank1 and Bank2. Bank1 Code map (9-bit ecc) ranges from 0x0800_0000 / 0x0C00_0000 containing Sector 0, Sector 1 down to Sector 255 / 0. Bank2 Code map (9-bit ecc) ranges from 0x0820_0000 / 0x0C20_0000 containing Sector 0, Sector 1 down to Sector 255 / 0. High-cycle data areas are marked starting at EDATA1_STRT and EDATA2_STRT (Sector 240 / 15). Sector sizes are 8-Kbyte for code memory and 6-Kbyte for data memory. MSv74524V1 is shown at the bottom right.

Figure 24. Flash high-cycle area memory map on a 3-Mbyte device

Memory map diagram for a 3-Mbyte device showing Data and Code memory maps for Bank1 and Bank2. Bank1 Code map (9-bit ecc) ranges from 0x0800_0000 / 0x0C00_0000 containing Sector 0, Sector 1 down to Sector 191. Bank2 Code map ranges from 0x0818_0000 / 0x0C18_0000 containing Sector 0, Sector 1 down to Sector 191. High-cycle data areas are marked starting at EDATA1_STRT and EDATA2_STRT (Sector 240 / 15 down to Sector 255 / 0). Sector sizes are 8-Kbyte for code memory and 6-Kbyte for data memory. MSv74523V1 is shown at the bottom right.
Memory map diagram for a 3-Mbyte device showing Data and Code memory maps for Bank1 and Bank2. Bank1 Code map (9-bit ecc) ranges from 0x0800_0000 / 0x0C00_0000 containing Sector 0, Sector 1 down to Sector 191. Bank2 Code map ranges from 0x0818_0000 / 0x0C18_0000 containing Sector 0, Sector 1 down to Sector 191. High-cycle data areas are marked starting at EDATA1_STRT and EDATA2_STRT (Sector 240 / 15 down to Sector 255 / 0). Sector sizes are 8-Kbyte for code memory and 6-Kbyte for data memory. MSv74523V1 is shown at the bottom right.

Note: When the flash high-cycle data area on bank1 is enabled, the code memory map is not continuous from bank1 to bank2 on 4M 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 42 shows the accessible memory, depending upon the SWAP_BANK bit value.

Table 42. Memory map and swapping data

AreaCorresponding bankStart addressEnd addressSize (bytes)Region name
SWAP_BANK = 0SWAP_BANK = 1
User main memoryBank1Bank20x0800 00000x0800 1FFF8 KSector 0
0x0800 20000x0800 3FFF8 KSector 1
............
0x081F E0000x081F FFFF8 KSector 255
Bank2Bank10x0820 00000x0820 1FFF8 KSector 0
0x0820 20000x0820 3FFF8 KSector 1
............
0x083F E0000x083F FFFF8 KSector 255
System memoryBank10x0BF8 00000x0BF8 1FFF8 KSystem 1 Sector 0
0x0BF8 20000x0BF8 3FFF8 KSystem 1 Sector 1
............
0x0BF9 E0000x0BF9 FFFF8 KSystem 1 Sector 15
Bank20x0BFA 00000x0BFA 1FFF8 KSystem 2 Sector 0
0x0BFA 00000x0BFA 3FFF8 KSystem 2 Sector 1
............
0x0BFB E0000x0BFB FFFF8 KSystem 2 Sector 15

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 25 gives an overview of the bank swapping sequence.

Figure 25. Flash bank swapping sequence

Flowchart of Flash bank swapping sequence. The process 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 dashed line labeled 'System reset' separates the programming phase from the execution phase. 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'. On the right, three registers are shown: FLASH_OPTSR_PRG (yellow), FLASH_OPTSR_CUR (pink), and FLASH_OPTCR (blue). Arrows show 'Option byte programming' from PRG to memory, 'Option byte reload' from memory to CUR, and 'System reset option byte reload' from CUR to OPTCR. Below, 'User flash memory SWAP logic' is connected to 'Non-volatile memory Bank1' and 'Non-volatile memory Bank2' via 'AHB bus'. A label 'New swap policy effective' points to the logic block.
graph TD
    Begin([Begin]) --> UpdateFirmware[Update new firmware in user Flash bank 1/2]
    UpdateFirmware --> SetOptionBit[Set/unset SWAP_BANK_OPT option bit in FLASH_OPTSR_PRG]
    SetOptionBit --> WriteOPTSTRT[Write OPTSTRT bit in FLASH_OPTCR to start option byte change sequence]
    WriteOPTSTRT --> SystemReset[System reset]
    SystemReset --> CopySWAPBANK[SWAP_BANK of FLASH_OPTSR_CUR is copied to SWAP_BANK_OPT bit in FLASH_OPTCR]
    CopySWAPBANK --> End([End])
    End --> Execution[Execution of new firmware]

    subgraph Registers
        direction TB
        PRG[SWAP BANK OPT FLASH_OPTSR_PRG]
        CUR[SWAP BANK OPT FLASH_OPTSR_CUR]
        OPTCR[SWAP BANK FLASH_OPTCR]
    end

    PRG -- "Option byte programming" --> NonVol[Non-volatile memory]
    NonVol -- "Option byte reload" --> CUR
    CUR -- "System reset option byte reload" --> OPTCR

    subgraph MemoryLogic
        direction TB
        UserFlash[User flash memory SWAP logic]
        Bank1[Non-volatile memory Bank1]
        Bank2[Non-volatile memory Bank2]
        AHB[AHB bus]
        UserFlash <--> AHB
        AHB <--> Bank1
        AHB <--> Bank2
    end

    OPTCR -- "New swap policy effective" --> UserFlash
  

MSv68819V2

Flowchart of Flash bank swapping sequence. The process 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 dashed line labeled 'System reset' separates the programming phase from the execution phase. 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'. On the right, three registers are shown: FLASH_OPTSR_PRG (yellow), FLASH_OPTSR_CUR (pink), and FLASH_OPTCR (blue). Arrows show 'Option byte programming' from PRG to memory, 'Option byte reload' from memory to CUR, and 'System reset option byte reload' from CUR to OPTCR. Below, 'User flash memory SWAP logic' is connected to 'Non-volatile memory Bank1' and 'Non-volatile memory Bank2' via 'AHB bus'. A label 'New swap policy effective' points to the logic block.

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 (programing, 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 43 indicates how to use FLASH_OPSR, and which operation is required.

Table 43. 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

Table 43. Recommended reactions to FLASH_OPSR contents (continued)

CODE_OPOperation interruptedOTP_OPSYSF_OPBK_OPDATA_OPFlash areaADDR_OP minADDR_OP maxRecommended action
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. 1. Dash represents “does not matter”.
  2. 2. Depends on current OBK sector.
  3. 3. Depends on EDATA setting in the OB.
  4. 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 documents:

7.4.2 Option bytes loading

There are multiple ways of loading the option bytes:

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 byte 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 byte 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 byte overview

Table 44 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 44. Option byte organization

Register313029282726252423222120191817161514131211109876543210
FLASH_OPTSRSWAP_BANKRes.BOOT_UBEIWDG_STDBYIWDG_STOPRes.Res.IO_VDDIO2_HSLVIO_VDD_HSLVPRODUCT_STATENRST_STDBYNRST_STOPRes.WWDG_SWIWDG_SWBORH_ENBOR_LEV
0101101001100111011011111000
FLASH_OPTSR2TZENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.USBPD_DISRes.SRAM2_ECCSRAM3_ECCBKPRAM_ECCSRAM2_RSTSRAM1345_RSTRes.Res.
110000110111111
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.SECWM1_STRT
111111100000000
FLASH_SECWM2RRes.Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_ENDRes.Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT
111111100000000
FLASH_WRPSGN11RWRPSG[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_WRPSGN12RWRPSG[255:252]WRPSG[251:248]...WRPSG[199:196]WRPSG[195:192]WRPSG[191:188]WRPSG[187:184]...WRPSG[135:132]WRPSG[131:128]
11111111111111111111111111111111
ST logo
ST logo
Table 44. Option byte organization (continued)
Register313029282726252423222120191817161514131211109876543210
FLASH_
WRPSGN21R
WRPSG[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_
WRPSGN22R
WRPSG[255:252]WRPSG[251:248]...WRPSG[199:196]WRPSG[195:192]WRPSG[191:188]WRPSG[187:184]...WRPSG[135:132]WRPSG[131:128]
11111111111111111111111111111111
FLASH_
OTPBLR
LOCKBL
00000000000000000000000000000000
FLASH_
EDATA1R
Res.Res.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.SECTOR
_START_1
00000
FLASH_
EDATA2R
Res.Res.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.SECTOR
_START_2
00000
FLASH_
NSEPOCHR
Res.Res.Res.Res.Res.Res.Res.Res.NS_EPOCH
000000000000000000000001
FLASH_
SECEPOCHR
Res.Res.Res.Res.Res.Res.Res.Res.SEC_EPOCH
000000000000000000000001
FLASH_
HDP1R
Res.Res.Res.Res.Res.Res.Res.Res.HDP1_ENDRes.Res.Res.Res.Res.Res.Res.Res.HDP1_STRT
0000000000000001
FLASH_
HDP2R
Res.Res.Res.Res.Res.Res.Res.Res.HDP2_ENDRes.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT
0000000000000001

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:

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 45. Specific OB modifying rules

Option byteHDPLTZ secureValueProduct state
PRODUCT_STATE1(1)Some values only when TZ is enabledSet of possible transitionsSet of possible transitions (Table 39)
HDP1(2)-(3)-Refer to Table 46
TZEN---Regression, Open or Provisioning
EPOCH--PRG > CURRegression
EPOCH_NS--PRG > CURNS-Regression, Regression
SECWM-Secure mode only(2)-Refer to Table 46
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 46.

Table 46. 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:

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 byte key 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 47 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 47. Option byte key area

OBK-HDPLAddress offset startAddress offset endComment
-0x00000x00FFReserved
10x01000x08FFOEM iRoT keys
20x09000x0FFFuRoT, OS or secure application
30x10000x17FFHDPL 3 secure keys
30x18000x1FEFHDPL 3 nonsecure 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 26. OBK protection checks

Flowchart of OBK protection checks. The process starts at 'Idle' and proceeds to 'Write access of any type: 128, 64, 32, 16, 8 bit length'. It then checks buffer address, protection (TZ/Priv), and OBK-HDPL value. If a protection error occurs, it leads to 'Protection error (WI, ILAFM, WRPERR)'. If a strobe error occurs, it leads to 'Strobe error STRBERR'. If an inconsistency error occurs, it leads to 'Inconsistency error INCERR'. If the buffer is full or SECFW=1, it leads to 'OBK error OBKERR'. If the sector request is for the same sector (ALT_SECT=0), it calls 'OBK Write (same sector)'. If it's for an alternate sector, it calls 'OBK Write (alternate sector)'. If the sector request is for a swap sector, it calls 'OBK Swap sector'. The 'OBK Swap sector' call also involves setting SWAP_SECT_REQ and SWAP_OFFSET in the OBKCR register.
graph TD; Idle([Idle]) --> WriteAccess([Write access of any type: 128, 64, 32, 16, 8 bit length]); WriteAccess --> CheckBufferAddress{Check buffer address (inside same 128-bit address range)}; CheckBufferAddress --> CheckBufferAddressTwice{Check buffer address : same addr is not written twice}; CheckBufferAddressTwice --> CheckProtection{Check protection (TZ/Priv)}; CheckProtection --> CheckOBKHDPL{Check OBK-HDPL value*}; CheckOBKHDPL --> StoreDate[Store date in 128-bit Write buffer]; StoreDate --> BufferFull{128-bit buffer full or SECFW=1}; BufferFull --> SameSectorRequest{Same sector request ALT_SECT=0?}; SameSectorRequest --> CallOBKWriteSame[Call OBK Write (same sector)]; SameSectorRequest --> CallOBKWriteAlternate[Call OBK Write (alternate sector)]; SameSectorRequest --> CallOBKSwapSector[Call OBK Swap sector]; CallOBKSwapSector --> SetSwapRegisters([OBKCR register Set SWAP_SECT_REQ and SWAP_OFFSET]); SetSwapRegisters --> Idle; CheckProtection -- Protection error --> ProtectionError([Protection error (WI, ILAFM, WRPERR)]); CheckProtection -- Strobe error --> StrobeError([Strobe error STRBERR]); CheckProtection -- Inconsistency error --> InconsistencyError([Inconsistency error INCERR]); CheckBufferAddress -- OBK error --> OBKError([OBK error OBKERR]);

MSv68820V4

Flowchart of OBK protection checks. The process starts at 'Idle' and proceeds to 'Write access of any type: 128, 64, 32, 16, 8 bit length'. It then checks buffer address, protection (TZ/Priv), and OBK-HDPL value. If a protection error occurs, it leads to 'Protection error (WI, ILAFM, WRPERR)'. If a strobe error occurs, it leads to 'Strobe error STRBERR'. If an inconsistency error occurs, it leads to 'Inconsistency error INCERR'. If the buffer is full or SECFW=1, it leads to 'OBK error OBKERR'. If the sector request is for the same sector (ALT_SECT=0), it calls 'OBK Write (same sector)'. If it's for an alternate sector, it calls 'OBK Write (alternate sector)'. If the sector request is for a swap sector, it calls 'OBK Swap sector'. The 'OBK Swap sector' call also involves setting SWAP_SECT_REQ and SWAP_OFFSET in the OBKCR register.

7.5.4 OBK programming finite state machine

When the OBK write buffer is filled, the OBK programing is launched automatically either in the current OBK sector or in the alternate OBK sector depending on the ALT_SECT bit.

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

Figure 27. Key writing flow

Flowchart of Key writing flow for Same sector and Alternate sector.
graph TD; subgraph SameSector ["Same sector (current sector = S1)"]; Start1([OBK write request
Same sector
(current sector = S1)]) --> Read1[Read data @ key index S1]; Read1 --> IsData1{Is data =
0xFF..FF}; IsData1 -- Yes --> Write1[Write data]; IsData1 -- No --> Error1[Signal OBK Write error
OBKWRERR]; Write1 --> End1([End]); Error1 --> End1; end; subgraph AlternateSector ["Alternate sector (current sector = S1)"]; Start2([OBK write request
Alternate sector
(current sector = S1)]) --> Read2[Read data @ key index S2]; Read2 --> IsData2{Is data =
0xFF..FF}; IsData2 -- Yes --> Write2[Write data]; IsData2 -- No --> Error2[Signal OBK Write error
OBKWRERR]; Write2 --> End2([End]); Error2 --> End2; end;

The flowchart illustrates the key writing process for two scenarios: Same sector and Alternate sector. Both scenarios start with an OBK write request. The process involves reading data at a specific key index, checking if the data is 0xFF..FF, and then either writing the data or signaling an error (OBKWRERR) if the data is not 0xFF..FF. The process ends with an 'End' state.

MSv68821V4

Flowchart of Key writing flow for Same sector and Alternate sector.

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/nonsecure error flags due to previous operation.
  3. 3. Unlock NS/SECOBKCFGR register if not unlocked already thanks to FLASH_NS/SECOBKKEYR.
  4. 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.
  5. 5. Set bit SWAP_SECT_REQ in NS/SECOBKCFGR.
  6. 6. Wait for BSY bit to be cleared. In case of error OBKERR flag is set.
  7. 7. SWAP_SECT_REQ is cleared automatically at the end of the operation or in case of error.

Figure 28. Swap workflow

Flowchart of the OBK Swap workflow. It starts with an 'OBK swap sector request (current sector = S1)' oval, followed by a decision 'SWAP_OFFSET > 1' (labeled ①). If 'Yes', it sets 'Addr index = 0' and enters a loop: 'Read data @ S2 (addr index)', 'Is data = 0xFF..FF?'. If 'Yes', it copies data from S1 to S2. If 'No', it increments the address index and checks if 'Addr index = SWAP_OFFSET?' (labeled ①). If 'Yes', it sets the current sector to S2 and erases sector 1. If 'No', it loops back to reading data. If the initial 'SWAP_OFFSET > 1' is 'No', it also loops back to reading data. The process ends with an 'End' oval.
graph TD
    Start([OBK swap sector request
(current sector = S1)]) --> Decision1{SWAP_OFFSET > 1 ①} Decision1 -- Yes --> Init[Addr index = 0] Init --> ReadData[Read data @ S2
(addr index)] ReadData --> IsData{Is data =
0xFF..FF} IsData -- Yes --> CopyData[Copy data
S1(addr index) ->
S2(addr index)] IsData -- No --> IncIndex[Increment addr
index] CopyData --> IncIndex IncIndex --> Decision2{Addr index =
SWAP_OFFSET? ①} Decision2 -- Yes --> SetSector[Set current sector = S2
Erase sector 1] Decision2 -- No --> ReadData Decision1 -- No --> ReadData SetSector --> End([End])

① SWAP_OFFSET is set in OBKCR register. It indicates the numbers of data to swap.

MSv68822V3

Flowchart of the OBK Swap workflow. It starts with an 'OBK swap sector request (current sector = S1)' oval, followed by a decision 'SWAP_OFFSET > 1' (labeled ①). If 'Yes', it sets 'Addr index = 0' and enters a loop: 'Read data @ S2 (addr index)', 'Is data = 0xFF..FF?'. If 'Yes', it copies data from S1 to S2. If 'No', it increments the address index and checks if 'Addr index = SWAP_OFFSET?' (labeled ①). If 'Yes', it sets the current sector to S2 and erases sector 1. If 'No', it loops back to reading data. If the initial 'SWAP_OFFSET > 1' is 'No', it also loops back to reading data. The process ends with an 'End' oval.

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/nonsecure 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 48).

Table 48. Default secure watermark

Secure watermark in case of configuration errorSecurity attribute
SECWMx_STRT = 0
SECWMx_END = 0xFF
All flash memory is secure

Illegal access generation

A nonsecure 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 nonsecure 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 49. Flash memory TZ protection summary

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

Table 49. Flash memory TZ protection summary (continued)

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

Table 50. TZ protection and bank or mass erase summary

TZ protection
(TZ_STATE = 0xB4)
Main flash
Nonsecure flashSecure flashMix of secure and nonsecure
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 nonsecure 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 51. Secure watermark-based area

Secure watermark option bytes values (x = 1,2)Secure watermark protection area
SECWMx_STRT > SECWMx_ENDNo secure 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 no-secure does not erase its content. The user secure software must perform the needed operation to erase the secure area before switching an area to nonsecure 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 ≥ 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 29. HDP(a) in user flash memory Diagram of HDP protection in user flash memory. A large green rectangle represents the 'Flash bank' from Sector 0 to Sector 255. Above it, a timeline shows protection parameters: PSTRT = 0x0A, PEND = 0x27, and HDP_EXT = 0x1D. A double-headed arrow labeled 'HDP1 - HDPL1 closes' spans from Sector 0 to Sector 1. Another double-headed arrow labeled 'HDP_EXT = 0x1D' spans from Sector 1 to Sector 255.
Diagram of HDP protection in user flash memory. A large green rectangle represents the 'Flash bank' from Sector 0 to Sector 255. Above it, a timeline shows protection parameters: PSTRT = 0x0A, PEND = 0x27, and HDP_EXT = 0x1D. A double-headed arrow labeled 'HDP1 - HDPL1 closes' spans from Sector 0 to Sector 1. Another double-headed arrow labeled 'HDP_EXT = 0x1D' spans from Sector 1 to Sector 255.

Note: For more details on the bank swapping mechanism, refer to Section 7.6.6.

Table 52. 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 53. 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 nonsecure using the block-based configuration registers. FLASH_SECBB1x/FLASH_SECBB2x 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 SECBByx[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 nonsecure 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 54.

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

Table 54. Secure configuration block-based registers access conditions

AccessCorresponding sector privilege statusSector setting in SECBBxy
FetchSecure/
nonsecure
Privilege/
unprivilege
-BUS ERROR
Read-OK
WriteSecurePrivilege-OK
Unprivilege0OK
1WI
NonsecurePrivilege/
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 PRIVBByx[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 55. Privilege protection summary

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

Table 56. 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 PRIVBByx[i] access control, refer to Table 57 and Table 58.

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

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

1. Either watermark or block-based.

Table 58. Privilege configuration register access conditions (TZ disabled)
AccessSector setting access in PRIVBBRxy
FetchPrivileged/
unprivileged
BUS 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 59. Flash register accesses(1)
AccessNonsecure registerSecure register
NSPRIV = 1NSPRIV = 0SPRIV = 1SPRIV = 0
XSecure/
nonsecure
Privileged/
unprivileged
Bus error
R/WSecurePrivilegedOK
R/WUnprivilegedRAZ, WIOKRAZ, WIOK
Table 59. Flash register accesses(1) (continued)
AccessNonsecure registerSecure register
NSPRIV = 1NSPRIV = 0SPRIV = 1SPRIV = 0
R/WNonsecurePrivilegedOKRAZ, 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 nonsecure 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 30 shows how security attributes and protections behave in case of bank swap.

Figure 30. Protection attributes in case of bank swap illustration

Diagram illustrating protection attributes in case of bank swap. It shows two memory banks, Bank 1 and Bank 2, with their respective protection areas (HDP area, Secure watermark area, Write protection blocks, Data area) and addresses (0x0800_0000 to 0x081F_FFFF for Bank 1, 0x0820_0000 to 0x083F_FFFF for Bank 2). A 'SWAP_BANK' operation is shown swapping the banks.

The diagram illustrates the protection attributes of two flash memory banks, Bank 1 and Bank 2, before and after a bank swap operation. The memory is divided into two main address ranges: 0x0800_0000 to 0x081F_FFFF and 0x0820_0000 to 0x083F_FFFF.

Initial State (Top):

Swap Operation: A central "SWAP_BANK" operation with crossed arrows indicates the swap of the banks.

Final State (Bottom):

MSv68824V2

Diagram illustrating protection attributes in case of bank swap. It shows two memory banks, Bank 1 and Bank 2, with their respective protection areas (HDP area, Secure watermark area, Write protection blocks, Data area) and addresses (0x0800_0000 to 0x081F_FFFF for Bank 1, 0x0820_0000 to 0x083F_FFFF for Bank 2). A 'SWAP_BANK' operation is shown swapping the banks.

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 60. Registers not present in this table are not protected by a key.

Table 60. 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_NSObKCFGRFLASH_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 flash 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 1 protection for bank1 (FLASH_WRP11R_CUR) and FLASH write sector group 1 protection for bank2 (FLASH_WRP21R_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 embedded flash 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 61.

Volatile settings using FLASH_SECBBxx 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 23 and Figure 25.

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

Table 61. 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 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
NonsecureFetchBUS ERRORBUS ERROR
ReadRAZ, ILACOKBUS
ERROR
WriteWI, WRPERR, ILAFMIf not WRP:
OK else WI,
WRPERR
EraseSame protection as in corresponding classic user flash sector
Table 62. 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 63. 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 64. Product states, debug states and debug policy

PRODUCT_STATECode in OBDescription
Open0xEDUser flash open (TZ secure and nonsecure open).
External access (debug) N and NS enabled (~RDP0).
Provisioning0x17Provisioning - Immutable root of trust is being installed.
Open if TZEN = 0xC3.
iROT-Provisioned0x2EThe immutable root of trust is installed (~RDP 0.5).
TZ-Closed0xC6State for debugging the NS application.
Debug is restrained to nonsecure 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. Nonsecure debug only

All read and write operations (if no write protection is set) from/to the nonsecure flash memory are possible. The debug access to secure area is prohibited. Debug access to nonsecure 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 to more closed state is the normal product life cycle, that does not require security measures. Transition in direction to 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 TZ-Closed debug state

This transition opens the device to authorize the debug of the nonsecure 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 ZT-Closed.

The transition has the following consequence:

Table 65. 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)

Table 65. PRODUCT_STATE transitions (continued)

FromTo(1)
OpenProvisioningiROT-ProvisionedTZ-Closed(2)ClosedLockedRegressionNS-Regression(2)
LockedXXXXX-XX
RegressionOK
(HDPL0)
XXXXX-X
NS-RegressionXXXOK
(HDPL0)
XXX-
  1. 1. X = transitions not permitted (OPTCHANGEERR raised), - = no change, OK = valid transitions.
  2. 2. To transition into this state, both current and programmed value of TZEN must be enabled (TZEN = 0xB4), otherwise the change is ignored with OPTCHANGEERR.

In Table 65, X indicates transitions that are not permitted, 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 66.

Table 66. TZ OBK protection summary

TZ protection
(when
TZ_STATE =
0xB4)
OBK access
No tamperTamper
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 67. OBK protection summary with TZ disabled

TZ protection
(when
TZ_STATE = 0x
C3)
OBK access
No tamperTamper
HDPL1/2/3OBK selector
XNSBUS ERRORBUS ERRORRAZ, WI
RNSOK if privileged, otherwise RAZRAZ
WNSOK if privilege, otherwise WI, WRPERRWI if privileged, otherwise WI, WRPERR
EraseNANANA

Note: Cacheable access is managed at system level and not in the 2flash 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 68. Access conditions to secure control register

-S/NSP/NPTZ stateSECOBKCFGR and
SECOBKKEYR access
X---Bus error
R/WSPActiveOK

Table 68. Access conditions to secure control register (continued)

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

Table 69. Access conditions to nonsecure 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 70.

Table 70. 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 ERRORIf correct size OK, else BUS ERROR
WNSIf correct size WI, else BUS ERRORBUS 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, dedicated to secure user firmware when system is configured, respectively, with TrustZone enabled (TZEN bitfield set to 0xB4) and TrustZone disabled (TZEN bitfield set to 0xC3).

Table 71. Macros for RSS services

TrustZoneC defined macroLocation in flash memory
EnabledRSSLIB_PFUNC0x0BFB6068
DisabledNSSLIB_PFUNC0x0BFB606C

RSSLIB

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

The user can set this nonsecure 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 72. RSS lib interface functions

LibraryFunctionAttributes
RSSLIB_PFUNCJumpHDPLvl2Secure callable function
JumpHDPLvl3
JumpHDPLvl3NS
RSSLIB_DataProvisioningNonsecure callable function

RSSLIB_DataProvisioning

Secure attribute: Nonsecure callable function.

Prototype:

uint32_t RSSLIB_DataProvisioning_(RSSLIB_DataProvisioningConf_t *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

Returned values

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: 0x0FFD0FFFUL
OBKeys Level3 secureStart address: 0x0FFD1000UL
End address: 0x0FFD17FFUL
OBKeys Level3 nonsecureStart 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 STM32H5Fxxx 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:

RSSLIB_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 nonsecure domain, then jump to the nonsecure reset handler embedded within the vector table, whose address is passed as input parameter.

After closing HDPL1/2, JumpHDPLvl3 jumps to the nonsecure 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 73. NSS lib interface functions

LibraryFunctionAttributes
NSSLIB_PFUNCJumpHDPLvl2Nonsecure 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:

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 74 summarizes the memory behavior in STM32 low-power modes. Embedded flash memory belongs to the core domain.

Table 74. 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 74, 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 nonsecure. 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 Nonsecure write protection error (WRPERR)

When an illegal nonsecure 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_SECCCR 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 Nonsecure programming sequence error (PGSERR)

When the nonsecure 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 Nonsecure strobe error (STRBERR)

When the nonsecure 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_SECCCR 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 Nonsecure inconsistency error (INCERR)

When a programming inconsistency in nonsecure 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_SECCCR 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 flag is raised, an NMI is generated, it can be masked in SBS registers (SBS flift 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_ECCCORR (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 75. 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 (0x200 per sector)0xE0000xFFFF

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 45).

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, nonsecure or secure flags are used depending on the AHB access type (sec or nonsecure). If a nonsecure access is received, the nonsecure error flags are used. If a secure access is received, the secure error flags are used.

For OBKERR and OBKWERR, nonsecure 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 nonsecure 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 nonsecure 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 76 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 76. 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 errorOBKWERROBKWERRIEYes
OBK general errorOBKERROBKERRIEYes
Inconsistency errorINCERRINCERRIEYes
Illegal access errorILAFMTZENNo
Option byte errorOPTCHANGEERR-Yes
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 76 (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 nonsecure. It can be read and written by both secure and nonsecure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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.PRF
TEN
Res.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 39 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 nonsecure key register (FLASH_NSKEYR)

This register is nonsecure. It can be written by both secure and nonsecure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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: 0x004

Reset value: 0x0000 0000

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

Bits 31:0 NSKEY[31:0]: Non-volatile memory nonsecure 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 nonsecure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGR 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: 0x008

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 nonsecure. It can be written by both secure and nonsecure accesses, and can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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 nonsecure 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 nonsecure. 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 nonsecure 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 nonsecure. This register can be read by both secure and nonsecure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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).

7.11.8 FLASH option control register (FLASH_OPTCR)

This register is nonsecure. It can be read and written by both secure and nonsecure access, and protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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 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 others bits of FLASH_OPTCR register do not change.

0: FLASH_OPTCR register unlocked

1: FLASH_OPTCR register locked.

7.11.9 FLASH nonsecure status register (FLASH_NSSR)

This register is nonsecure. It can be read by both secure and nonsecure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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

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 nonsecure 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 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 nonsecure control register (FLASH_NSCR)

This register is nonsecure. It can be read and written by both secure and nonsecure accesses, and can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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.SNB[7:0]STRTFWBERSERPGLOCK
rwrwrwrwrwrwrwrwrwrsrwrwrwrwrs

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 and 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 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 nonsecure 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. It can be read and written only by secure access. A nonsecure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGR 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

RM0517Bit 0UART9LPEN
31 30 292827 26 25 24 23 22 21 20 19 18 17 16
BKSEL Res. INVRes.Res. Res. Res. Res. Res. OBKW OBK INC STRB PGS WRP
ERRIE ERRIE ERRIE ERRIE ERRIE ERRIE EOPIE
rw rwrw rw rw rw rw rw rw
15 14 131211 10 9 8 7 6 5 4 3 2 1 0
MER Res.SNB[7:0] STRT FW BER SER PG LOCK
rw rwrwrw rw rw rw rw rw rs rw rw rw rw rs
Bit 31BKSEL: Bank selector bit
Bit 29INV : Flash memory security state invert.
Bit 22OBKWERRIE: OBK write error interrupt enable bit
Bit 21OBKERRIE: OBK general error interrupt enable bit
Bit 20INCERRIE: inconsistency error interrupt enable bit
Bit 19STRBERRIE: strobe error interrupt enable bit
Bit 18PGSERRIE: programming sequence error interrupt enable bit

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 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 nonsecure clear control register (FLASH_NSCCR)

This register is nonsecure. It can be written by both secure and nonsecure 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_OPTCHANGEERRCLR_OBKWERRCLR_OBKERRCLR_INCERRCLR_STRBERRCLR_PGSERRCLR_WRPERRCLR_EOP
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 nonsecure 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: OBKWERR flag clear bit
Setting this bit to 1 resets to 0 OBKWERR 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 nonsecure bit. SPRIV is a secure bit. It can be written only by privileged mode.

column_1column_2column_3column_4column_5column_6column_7column_8column_9column_10column_11column_12column_13column_14column_15RM0517
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.NSPRIV SPRIV
rw rwrw rw
Bit 1NSPRIV: privilege attribute for nonsecure registers
Bit 0SPRIV: privilege attribute for secure registers
31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.SWAP_OFFSET[8:0]
rwrwrwrwrwrwrwrwrw
1514131211109876543 ALT_2 ALT_1 SWAP_0
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SECT_ ERASESECT _REQLOCK
rwrwrwrw

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

Bit 1 NSPRIV: privilege attribute for nonsecure registers

0: access to nonsecure registers is always granted

1: access to nonsecure 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 nonsecure OBK configuration register (FLASH_NSOBKCFGR)

Register is only available when TZ_STATE = 0xC3. This register is nonsecure. It can be read and written by both secure and nonsecure accesses. This register can only be accessed by privilege code.

The FLASH_NSOBKCFGR 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

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.

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

Bit 3 ALT_SECT_ERASE: alternate sector erase bit

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

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

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.

7.11.18 FLASH HDP extension register (FLASH_HDPEXTR)

All bits in this register are nonsecure. It can be read and written by both secure and nonsecure 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 ≤ 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.HDP2_EXT[7:0]
rwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.HDP1_EXT[7:0]
rwrwrwrwrwrwrwrw

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

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

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

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

7.11.19 FLASH option status register (FLASH_OPTSR_CUR)

This register is nonsecure. It can be read by both secure and nonsecure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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

(Register bits 0 to 31 are loaded with values from the flash memory at OBL)

31302928272625242322212019181716
SWAP_BANKRes.BOOT_UBE[7:0]IWDG_STOPBYIWDG_STOPRes.Res.IO_VDDIO2_HSLVIO_VDD_HSLV
rrrrrrrrrrrrr
1514131211109876543210
PRODUCT_STATE[7:0]NRST_STOPBYNRST_STOPRes.WWDG_SWIWDG_SWBORH_ENBOR_LEV[1:0]
rrrrrrrrrrrrrrr

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 (around 2.1 V)

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

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

7.11.20 FLASH option status register (FLASH_OPTSR_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure 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

(Register 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. Defaut 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.

7.11.21 FLASH nonsecure EPOCH register (FLASH_NSEPOCHR_CUR)

This register is nonsecure. It can be read by both secure and nonsecure 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: 0x060

Reset value: 0xXXXX XXXX

(Register 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 nonsecure EPOCH counter

7.11.22 FLASH secure EPOCH register (FLASH_SECEPOCHR_CUR)

This register is nonsecure. It can be read by both secure and nonsecure 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 nonsecure. It can be read by both secure and nonsecure 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

(Register 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.USBD_DISRes.SRAM2_ECCSRAM3_ECCBKPRAM_ECCSRAM2_RSTSRAM1345_RSTRes.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 USBD_DIS: UCPD USB power delivery configuration option bit for UCPDx_CC1 pin only
Enables USB Type-C dead battery pull-down behavior on UCPDx_CC1 pin.
0: Enabled. For USB Type-C® and Power Delivery applications: enables correct dead-battery behavior of UCPDx_CC1 pin.
1: Disabled: Stops the dead battery pull-down behavior on the UCPDx_CC1 pin after power-up

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 SRAM1345_RST: SRAM1, SRAM3, SRAM4, and SRAM5 erase upon system reset
0: SRAM1, SRAM3, SRAM4, and SRAM5 erased when a system reset occurs
1: SRAM1, SRAM3, SRAM4, and SRAM5 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 nonsecure. It can be read and written by both secure and nonsecure 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: 0x074

Reset value: 0XXXXX XXXX

(Register bits 0 to 31 are loaded with values from the flash memory at OBL)

Bit 0LPTIM6SECRM0517
31 30 292827 26 25 24 23 22 21 20 19 18 17 16
31 30 29TZEN[7:0]Res. Res. Res. Res. Res. Res. Res. Res.
rw rw rwrwrw rw rw rw
15 14 131211 10 9 8 7 6 5 4 3 2 1 0
Res. Res. Res.Res.Res. Res. Res. USBPD SRAM3 BKPRAM SRAM2 SRAM1345
Res. Res. Res._DIS Res. SRAM2
Res. Res. Res._ECC _ECC _ECC _RST _RST Res. Res.
Res. Res. Res.rw rw rw rw rw rw
Bits 31:24TZEN[7:0]: TrustZone enable configuration bits
Bit 8USBPD_DIS: UCPD USB power delivery configuration option bit for UCPDx_CC1 pin only.
Bit 6SRAM2_ECC: SRAM2 ECC detection and correction disable
Bit 5SRAM3_ECC: SRAM3 ECC detection and correction disable
Bit 4BKPRAM_ECC: Backup RAM ECC detection and correction disable
Bit 4RM0517 Rev 1 375/ 3945

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 USBDP_DIS: UCPD USB power delivery configuration option bit for UCPDx_CC1 pin only.
Enables USB Type-C dead battery pull-down behavior on UCPDx_CC1 pin.
0: Enabled. For USB Type-C and Power Delivery applications: enables correct dead battery behavior of UCPDx_CC1 pin.
1: Disabled. Stops the dead battery pull-down behavior on the UCPDx_CC1 pin after power-up.

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

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

Bit 2 SRAM1345_RST: SRAM1, SRAM3, SRAM4, and SRAM5 erase upon system reset

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 nonsecure boot register (FLASH_NSBOOTR_CUR)

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

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

Address offset: 0x080

Reset value: 0XXXXX XXXX

(Register 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]: Nonsecure unique boot entry address

These bits reflect the Nonsecure UBE address

Bits 7:0 NSBOOT_LOCK[7:0]: Field locking the values of SWAP_BANK, and NSBOOTADD settings.

7.11.26 FLASH nonsecure boot register (FLASH_NSBOOTR_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure accesses, and 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: 0x084

Reset value: 0XXXXX XXXX

(Register 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]: Nonsecure unique boot entry address
These bits allow configuring the Nonsecure 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 nonsecure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGR register.

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

Address offset: 0x088

Reset value: 0XXXXX XXXX

(Register 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. It can be read and written only by secure access. A nonsecure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGR register.

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

Address offset: 0x08C

Reset value: 0XXXXX XXXX

(Register 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 nonsecure OTP block lock (FLASH_OTPBLR_CUR)

This register is nonsecure. It can be read by both secure and nonsecure accesses. This register can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR 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 × n to 32 × 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 nonsecure OTP block lock (FLASH_OTPBLR_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure 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: 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 × n to 32 × 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 write sector group 2 protection for bank1 (FLASH_WRP12R_CUR)

This register is nonsecure. It can be read by both secure and nonsecure accesses, and 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: 0x098

Reset value: 0XXXXX XXXX

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

Bits 31:0 WRPSG12[31:0]: Bank1 sector group 2 protection option status byte

Each 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)

Bit 0: Group embedding sectors 128 to 131

Bit 1: Group embedding sectors 132 to 135

Bit N: Group embedding sectors 128+4 × N to 128+4 × N+3

Note: Bit 31: Group embedding sectors 252 to 255

7.11.32 FLASH write sector group 2 protection for bank1 (FLASH_WRP12R_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure 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: 0x09C

Reset value: 0XXXXX XXXX

31302928272625242322212019181716
WRPSG12[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
WRPSG12[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 WRPSG12[31:0]: Bank1 sector group 2 protection option status byte

Setting WRPSG12 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 128 to 131

Bit 1: Group embedding sectors 132 to 135

Bit N: Group embedding sectors 128+4 × N to 128+4 × N+3

Note: Bit 31: Group embedding sectors 252 to 255

7.11.33 FLASH secure block based register for bank1 (FLASH_SECBB1Rx)

These registers are secure. They can be read and written only by secure access. A nonsecure read/write access is RAZ/WI.

Address offset: 0x0A0+0x004 × (x-1), (x = 1 to 8)

Reset value: 0x0000 0000

31302928272625242322212019181716
SECBB1[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SECBB1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 SECBB1[31:0]: Secure/nonsecure 8 Kbytes flash bank1 sector attributes (y = 0 to 31)

0: sector (32 × (x-1)+y) in bank1 is nonsecure.

1: sector (32 × (x-1)+y) in bank1 is secure.

7.11.34 FLASH privilege block based register for bank1 (FLASH_PRIVBB1Rx)

These registers are privileged. They can be read and written only by a privileged access. This register can be protected against nonsecure write access.

Address offset: 0x0C0+0x004 × (x-1), (x = 1 to 8)

Reset value: 0x0000 0000

31302928272625242322212019181716
PRIVBB1[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
PRIVBB1[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 PRIVBB1[31:0]: Privileged/unprivileged 8-Kbyte flash bank1 sector attribute (y = 0 to 31)
0: sectors (32 * (x-1) + y) in bank1 is unprivileged.
1: sector (32 * (x-1) + y) in bank1 is privileged.

7.11.35 FLASH security watermark for bank1 (FLASH_SECWM1R_CUR)

This read-only register is nonsecure, it can be protected against unprivileged access when NSPRIV = 1 in the FLASH_PRIVCFGR register. It reflects the current values of the corresponding option bits.

Address offset: 0x0E0

Reset value: 0x00XX 00XX

(Register bits 0 to 31 are loaded with values from the flash memory at OBL)

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_END[7:0]
rrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_STRT[7:0]
rrrrrrrr

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

Bits 23:16 SECWM1_END[7:0]: bank1 security WM area 1 end sector

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

Bits 7:0 SECWM1_STRT[7:0]: bank1 security WM area 1 start sector

7.11.36 FLASH security watermark for bank1 (FLASH_SECWM1R_PRG)

This register is secure. It can be read and written only by secure access. A nonsecure read/write access is RAZ/WI. This register can be protected against unprivileged access when SPRIV = 1 in the FLASH_PRIVCFGR register. This register is used to program values in corresponding option bits.

Address offset: 0x0E4

Reset value: 0x00XX 00XX

(Register bits 0 to 31 are loaded with values from the flash memory at OBL)

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_END[7:0]
rwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_STRT[7:0]
rwrwrwrwrwrwrwrw

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

Bits 23:16 SECWM1_END[7:0]: bank1 security WM area 1 end sector

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

Bits 7:0 SECWM1_STRT[7:0]: bank1 security WM area 1 start sector

7.11.37 FLASH write sector group 1 protection for bank1 (FLASH_WRP11R_CUR)

This register is nonsecure. It can be read by both secure and nonsecure accesses, and 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: 0x0E8

Reset value: 0xXXXX XXXX

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

Bits 31:0 WRPSG11[31:0]: bank1 sector group 1 protection option status byte

Each 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)

Bit 0: Group embedding sectors 0 to 3

Bit 1: Group embedding sectors 4 to 7

Bit N: Group embedding sectors 4 × N to 4 × N+3

Note: Bit 31: Group embedding sectors 124 to 127

7.11.38 FLASH write sector group 1 protection for bank1 (FLASH_WRP11R_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure 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: 0x0EC

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
WRPSG11[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
WRPSG11[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 WRPSG11[31:0]: Bank1 sector group 1 protection option status byte
Setting WRPSG11 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 x N to 4 x N + 3
Note: Bit 31: Group embedding sectors 124 to 127

7.11.39 FLASH data sector configuration bank1 (FLASH_EDATA1R_CUR)

This register is nonsecure, can be read by both secure and nonsecure accesses. The 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: 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.EDATA1_STRT[3:0]
rrrrr

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:4 Reserved, must be kept at reset value.

Bits 3:0 EDATA1_STRT[3: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.
0000: The last sector of bank1 is reserved for flash high-cycle data
0001: The two last sectors of bank1 are reserved for flash high-cycle data
0010: The three last sectors of bank1 are reserved for flash high-cycle data
...
1111: The sixteen last sectors of bank1 are reserved for flash high-cycle data

7.11.40 FLASH data sector configuration bank1 (FLASH_EDATA1R_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure 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.EDATA1_STRT[3:0]
rwrwrwrwrw

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:4 Reserved, must be kept at reset value.

Bits 3:0 EDATA1_STRT[3: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.

0000: The last sector of the bank1 is reserved for flash high-cycle data

0001: The two last sectors of the bank1 are reserved for flash high-cycle data

0010: The three last sectors of the bank1 are reserved for flash high-cycle data

...

Note: 1111: The sixteen last sectors of the bank1 are reserved for flash high-cycle data

7.11.41 FLASH HDP bank1 configuration (FLASH_HDP1R_CUR)

This register is nonsecure. It can be read by both secure and nonsecure 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.HDP1_END[7:0]
rrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.HDP1_STRT[7:0]
rrrrrrrr

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

Bits 23:16 HDP1_END[7:0]: HDPL barrier end set in number of 8-Kbyte sectors

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

Bits 7:0 HDP1_STRT[7:0]: HDPL barrier start set in number of 8-Kbyte sectors

7.11.42 FLASH HDP bank1 configuration (FLASH_HDP1R_PRG)

ST logo
ST logo

This register is nonsecure. It can be read and written by both secure and nonsecure 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.HDP1_END[7:0]
rwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.HDP1_STRT[7:0]
rwrwrwrwrwrwrwrw

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

Bits 23:16 HDP1_END[7:0]: HDPL barrier end set in number of 8-Kbyte sectors

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

Bits 7:0 HDP1_STRT[7:0]: HDPL barrier start set in number of 8-Kbyte sectors

7.11.43 FLASH ECC correction register (FLASH_ECCCORR)

This register is nonsecure. It can be read and written by both secure and nonsecure 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.ADDR_ECC[16]
rwrwrrrrrr
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.

ST logo
ST logo

7.11.44 FLASH ECC detection register (FLASH_ECCDETR)

This register is nonsecure. It can be read and written by both secure and nonsecure 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.ADDR_ECC[16]
rwrrrrrr
1514131211109876543210
ADDR_ECC[15:0]
rrrrrrrrrrrrrrrr

7.11.45 FLASH ECC data (FLASH_ECCDR)

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

Address offset: 0x108

Reset value: 0x0000 0000

column_1column_2Bit 24 Bit 23 Bit 22 Bit 21 Bit 20 Bits 16:0OTP_ECC SYSF_ECC BK_ECC EDATA_ECC OBK_ECCcolumn_5column_6column_7column_8column_9column_10column_11column_12column_13column_14column_15RM0517
31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
151413121110987 DATA_ECC[15:0]6543210
rrrrrrrrrrrrrrrr
Bits 15:0DATA_ECC[15:0]: ECC error data

7.11.46 FLASH write sector group 2 protection for bank2 (FLASH_WRP22R_CUR)

This register is nonsecure, can be read by both secure and nonsecure 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: 0x198

Reset value: 0xXXXX XXXX

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

Bits 31:0 WRPSG22[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 128 to 131

Bit 1: Group embedding sectors 132 to 135

Bit N: Group embedding sectors 128+4 × N to 128+4 × N+3

Bit 31: Group embedding sectors 252 to 255

7.11.47 FLASH write sector group 2 protection for bank2 (FLASH_WRP22R_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure 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: 0x19C

Reset value: 0xXXXX XXXX

31302928272625242322212019181716
WRPSG22[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
WRPSG22[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 WRPSG22[31:0]: Bank2 sector group protection option status byte
Setting WRPSG22 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 128 to 131
Bit 1: Group embedding sectors 132 to 135
Bit N: Group embedding sectors 128 + 4 x N to 128 + 4 x N + 3
Bit 31: Group embedding sectors 252 to 255

7.11.48 FLASH secure block-based register for bank2 (FLASH_SECBB2Rx)

These registers are secure, they can be read and written only by secure access. A nonsecure 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 8)

Reset value: 0x0000 0000

31302928272625242322212019181716
SECBB2[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
SECBB2[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 SECBB2[31:0]: Secure/nonsecure flash bank2 sector attribute (y = 0 to 31)
0: sectors (32 * (x-1) + y) in bank2 is nonsecure
1: sector (32 * (x-1) + y) in bank2 is secure

7.11.49 FLASH privilege block-based register for bank2 (FLASH_PRIVBB2Rx)

These registers are privileged, they can be read and written only by a privileged access, and can be protected against nonsecure write access by watermark.

Address offset: 0x1C0 + 0x004 * (x-1), (x = 1 to 8)

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.50 FLASH security watermark for bank2 (FLASH_SECWM2R_CUR)

This register is nonsecure, 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

(Register bits 0 to 31 are loaded with values from the flash memory at OBL)

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_END[7:0]
rrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT[7:0]
rrrrrrrr

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

Bits 23:16 SECWM2_END[7:0]: Bank2 security WM end sector

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

Bits 7:0 SECWM2_STRT[7:0]: Bank2 security WM area start sector

7.11.51 FLASH security watermark for bank2 (FLASH_SECWM2R_PRG)

This register is secure. It can be read and written only by secure access. A nonsecure 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

(Register bits 0 to 31 are loaded with values from the flash memory at OBL)

31302928272625242322212019181716
Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_END[7:0]
rwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT[7:0]
rwrwrwrwrwrwrwrw

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

Bits 23:16 SECWM2_END[7:0]: Bank2 security WM area end sector

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

Bits 7:0 SECWM2_STRT[7:0]: Bank2 security WM area start sector

7.11.52 FLASH write sector group 1 protection for bank2 (FLASH_WRP21R_CUR)

This register is nonsecure, can be read by both secure and nonsecure 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: 0xXXXX XXXX

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

Bits 31:0 WRPSG21[31:0]: Bank2 sector group 1 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

Note: Bit 31: Group embedding sectors 124 to 127

7.11.53 FLASH write sector group 1 protection for bank2 (FLASH_WRP21R_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure 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
WRPSG21[31:16]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw
1514131211109876543210
WRPSG21[15:0]
rwrwrwrwrwrwrwrwrwrwrwrwrwrwrwrw

Bits 31:0 WRPSG21[31:0]: Bank2 sector group 1 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 × N to 4 × N+3

Note: Bit 31: Group embedding sectors 124 to 127

7.11.54 FLASH data sectors configuration bank2 (FLASH_EDATA2R_CUR)

This register is nonsecure. It can be read by both secure and nonsecure 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
EDATA
2_EN
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA2_STRT[3:0]
rrrrr

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:4 Reserved, must be kept at reset value.

Bits 3:0 EDATA2_STRT[3: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.

0000: The last sector of bank2 is reserved for flash high-cycle data

0001: The two last sectors of bank2 are reserved for flash high-cycle data

0010: The three last sectors of bank2 are reserved for flash high-cycle data

...

Note: 1111: The sixteen last sectors of bank2 are reserved for flash high-cycle data

7.11.55 FLASH data sector configuration bank2 (FLASH_EDATA2R_PRG)

This register is nonsecure. It can be read and written by both secure and nonsecure 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.EDATA2_STRT[3:0]
rwrwrwrwrw

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

Bit 15 EDATA2_EN: bank2 flash high-cycle data enable

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

Bits 3:0 EDATA2_STRT[3: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.
0000: The last sector of bank2 is reserved for flash high-cycle data
0001: The two last sectors of bank2 are reserved for flash high-cycle data
0010: The three last sectors of bank2 are reserved for flash high-cycle data
...

Note: 1111: The sixteen last sectors of bank2 are reserved for flash high-cycle data

7.11.56 FLASH HDP bank2 configuration (FLASH_HDP2R_CUR)

This register is initially loaded with the values of the corresponding option bits.

This register is nonsecure. It can be read by both secure and nonsecure 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.HDP2_END[7:0]
rrrrrrrr
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT[7:0]
rrrrrrrr
ST logo
ST logo

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

Bits 23:16 HDP2_END[7:0]: HDPL barrier end set in number of 8-Kbyte sectors

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

Bits 7:0 HDP2_STRT[7:0]: HDPL barrier start set in number of 8-Kbyte sectors

7.11.57 FLASH HDP bank2 configuration (FLASH_HDP2R_PRG)

This register is nonsecure. It can be read and written only by both secure and nonsecure 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.HDP2_END[7:0]
rwrwrwrwrwrwrwrw
1514131211109876543210
Res.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT[7:0]
rwrwrwrwrwrwrwrw

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

Bits 23:16 HDP2_END[7:0]: HDPL barrier end set in number of 8-Kbyte sectors

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

Bits 7:0 HDP2_STRT[7:0]: HDPL barrier start set in number of 8-Kbyte sectors

7.12 FLASH register map and reset values

Table 77. Register map and reset value table

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
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_
SECKEYR
SECKEY[31:0]
Reset value00000000000000000000000000000000
0x00CFLASH_OPTKEYROPTKEY[31:0]
Reset value00000000000000000000000000000000
0x010FLASH_
NSOBKKEYR
NSOBKKEY[31:0]
Reset value00000000000000000000000000000000
0x014FLASH_
SECOBKKEYR
SECOBKKEY[31:0]
Reset value00000000000000000000000000000000
0x018FLASH_OPSRCODE_OP
[2:0]
Res.Res.Res.Res.Res.OTP_OPSYSF_OPBK_OPDATA_OPRes.ADDR_OP[19:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXX
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.Res.OPTSTRTOPTLOCK
Reset value001
0x020FLASH_NSSRRes.Res.Res.Res.Res.Res.Res.Res.OPTCHANGERROBKWERROBKERRINCERRSTRBERRPGSERRWRPERREOPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.SDBNERes.WBNEBSY
Reset value00000000000
0x024FLASH_SECSRRes.Res.Res.Res.Res.Res.Res.Res.Res.OBKWERROBKERRINCERRSTRBERRPGSERRWRPERREOPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DBNERes.WBNEBSY
Reset value0000000XXX
0x028FLASH_NSCRBKSELRes.Res.Res.Res.Res.Res.Res.OPTCHANGEERRIEOBKWIEOBKIEINCERRIESTRBERRIEPGSERRIEWRPERRIEEOPIEMERRes.SNB[7:0]STRTFWBERSERPGLOCK
Reset value000000000000000000000001
ST logo
ST logo

Table 77. Register map and reset value table (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x02CFLASH_SECCRBKSELRes.Res.Res.Res.Res.Res.Res.Res.OBKWIEOBKERRIEINCERRIESTRBERRIEPGSERRIEWRPERRIEEOPIEMERRes.SNB[7:0]STRTFWBERSERPGLOCK
Reset value00000000000000000000001
0x030FLASH_NSCCRRes.Res.Res.Res.Res.Res.Res.Res.CLR_OPTCHANGEERRCLR_OBKWERRCLR_OBKERRCLR_INCERRCLR_STRBERRCLR_PGSERRCLR_WRPERRCLR_EOPRes.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.Res.CLR_OBKWERRCLR_OBKERRCLR_INCERRCLR_STRBERRCLR_PGSERRCLR_WRPERRCLR_EOPRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.
Reset value0000000
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.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.ALT_SECT_ERASEALT_SECTLOCK
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.ALT_SECT_ERASEALT_SECTLOCK
Reset value111111110000
0x048FLASH_HDPEXTRRes.Res.Res.Res.Res.Res.Res.Res.HDP2_EXT[7:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP1_EXT[7:0]
Reset value000000000000000
0x04CReservedReserved
0x050FLASH_OPTSR_CURSWAP_BANKRes.BOOT_UBE[7:0]IWDG_STDBYIWDG_STOPRes.Res.IO_VDDIO2_HSLVIO_VDD_HSLVPRODUCT_STATE[7:0]NRST_STDBYNRST_STOPRes.WWDG_SWIWDG_SWBORH_LENBOR_LEV[1:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Table 77. Register map and reset value table (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
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.Res.NS_EPOCH[23:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXX
0x064FLASH_NSEPOCHR_PRGRes.Res.Res.Res.Res.Res.Res.Res.Res.NS_EPOCH[23:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXX
0x068FLASH_SECEPOCHR_CURRes.Res.Res.Res.Res.Res.Res.Res.Res.SEC_EPOCH[23:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXX
0x06CFLASH_SECEPOCHR_PRGRes.Res.Res.Res.Res.Res.Res.Res.Res.SEC_EPOCH[23:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXX
0x070FLASH_OPTSR2_CURTZEN[7:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.USBPD_DISRes.SRAM2_ECCSRAM3_ECCBKPRAM_ECCSRAM2_RSTSRAM1345_RSTRes.
Reset valueXXXXXXXXXXXXXX
0x074FLASH_OPTSR2_PRGTZEN[7:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.USBPD_DISRes.SRAM2_ECCSRAM3_ECCBKPRAM_ECCSRAM2_RSTSRAM1345_RSTRes.
Reset valueXXXXXXXXXXXXXX
0x080FLASH_NSBOOTR_CURNSBOOTADD[23:0]NSBOOT_LOCK[7:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x084FLASH_NSBOOTR_PRGNSBOOTADD[23:0]NSBOOT_LOCK[7:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x088FLASH_SECBOOTR_CURSECBOOTADD[23:0]SECBOOT_LOCK[7:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x08CFLASH_SECBOOTR_PRGSECBOOTADD[23:0]SECBOOT_LOCK[7:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x090FLASH_OTPBLR_CURLOCKBL[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x094FLASH_OTPBLR_PRGLOCKBL[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ST logo
ST logo
Table 77. Register map and reset value table (continued)
OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x098FLASH_WRP12R_
CUR
WRPSG12[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x09CFLASH_WRP12R_
PRG
WRPSG12[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x0A0
+ 0x004
* x (x =
1 to 8)
FLASH_
SECBB1R_x
SECBB1[31:0]
Reset value00000000000000000000000000000000
0x0C0
+ 0x004
* x (x =
1 to 8)
FLASH_
PRIVBB1R_x
PRIVBB1[31:0]
Reset value00000000000000000000000000000000
0x0D0 -
0x0DC
ReservedReserved
0x0E0FLASH_SECWM1R
_CUR
Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_END[7:0]Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_STRT[7:0]
Reset valueXXXXXXXXXXXXXXXX
0x0E4FLASH_SECWM1R
_PRG
Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_END1[7:0]Res.Res.Res.Res.Res.Res.Res.Res.SECWM1_STRT[7:0]
Reset valueXXXXXXXXXXXXXXXX
0x0E8FLASH_WRP11R_
CUR
WRPSG11[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x0ECFLASH_WRP11R_
PRG
WRPSG11[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x0F0FLASH_EDATA1R
_CUR
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA1_ENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA1_STRT
[2:0]
Reset valueXXXX
0x0F4FLASH_EDATA1R
_PRG
Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA1_ENRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.EDATA1_STRT
[2:0]
Reset valueXXXX
0x0F8FLASH_HDP1R
_CUR
Res.Res.Res.Res.Res.Res.Res.Res.HDP1_END[7:0]Res.Res.Res.Res.Res.Res.Res.Res.HDP1_STRT[7:0]
Reset valueXXXXXXXXXXXXXXXX
0x0FCFLASH_HDP1R
_PRG
Res.Res.Res.Res.Res.Res.Res.Res.HDP1_END[7:0]Res.Res.Res.Res.Res.Res.Res.Res.HDP1_STRT[7:0]
Reset valueXXXXXXXXXXXXXXXX
0x100FLASH_ECCCORRRes.ECCCRes.Res.Res.Res.ECCCIEOTP_ECCSYSF_ECCBK_ECCEDATA_ECCOBK_ECCRes.Res.Res.Res.ADDR_ECC[15:0]
0x0000 000000000000000000000000000

Table 77. Register map and reset value table (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x104FLASH_ECCDETRECCDRes.Res.Res.Res.Res.Res.Res.OTP_ECC_FAILSYSF_ECCBK_ECCEDATA_ECCOBK_ECCRes.Res.Res.Res.ADDR_ECC[15:0]
Reset value000000000000000000000
0x108FLASH_ECCDRRes.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.Res.DATA_ECC[15:0]
Reset value0000000000000000
0x198FLASH_WRP22R_CURWRPSG22[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x19CFLASH_WRP22R_PRGWRPSG22[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x1A0 + 0x004 * x (x = 1 to 8)FLASH_SECBB2R_xSECBB2[31:0]
Reset value00000000000000000000000000000000
0x1A0 + 0x004 * x (x = 1 to 8)FLASH_PRIVBB2R_xPRIVBB2[31:0]
Reset value00000000000000000000000000000000
0x1D0-0x1DCReservedReserved
0x1E0FLASH_SECWM2R_CURRes.Res.Res.Res.Res.Res.Res.Res.SECWM2_END[7:0]Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT[7:0]
Reset valueXXXXXXXXXXXXXXXX
0x1E4FLASH_SECWM2R_PRGRes.Res.Res.Res.Res.Res.Res.Res.SECWM2_END1[7:0]Res.Res.Res.Res.Res.Res.Res.Res.SECWM2_STRT[7:0]
Reset valueXXXXXXXXXXXXXXXX
0x1E8FLASH_WRP21R_CURWRPSG21[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x1ECFLASH_WRP21R_PRGWRPSG21[31:0]
Reset valueXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0x1F0FLASH_EDATA2R_CURRes.Res.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.EDATA2_STRT[2:0]
Reset valueXXXX
0x1F4FLASH_EDATA2R_PRGRes.Res.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.EDATA2_STRT[2:0]
Reset valueXXXX
0x1F8FLASH_HDP2R_CURRes.Res.Res.Res.Res.Res.Res.Res.HDP2_END[7:0]Res.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT[7:0]
Reset valueXXXXXXXXXXXXXXXX
ST logo
ST logo

Table 77. Register map and reset value table (continued)

OffsetRegister name
reset value
313029282726252423222120191817161514131211109876543210
0x1FCFLASH_HDP2R
_PRG
Res.Res.Res.Res.Res.Res.Res.Res.HDP2_END[7:0]Res.Res.Res.Res.Res.Res.Res.Res.Res.HDP2_STRT[7:0]
Reset valueXXXXXXXXXXXXXXXX

Refer to Section 2.3 for the register boundary addresses.