31. Mass storage interfaces
31.1 Overview
STM32MP21xx devices embed three types of mass storage interfaces:
- • FMC interface: manages access to external parallel NOR, parallel NAND, or parallel static RAM devices.
- • Octo-SPI interface: manages access to external serial NOR or serial NAND devices.
- • SD/e.MMC interface: manages access to external SD or e.MMC or SDIO devices.
31.2 FMC interface
The FMC is compliant with the RIF (resource isolation framework). See Section 32: Flexible memory controller (FMC).
Main features of the FMC interface
- • NOR/PSRAM:
- – ‘Generic interface’ to parallel NOR/PSRAM or external device 8080 display or external FPGA
- – Parallel NOR flash memory not supported as BOOT device
- – Up to 4 regions (4 CS, 64 Mbytes each), independent memory and RIF configuration for each region
- – 8- or 16-bit data modes
- – Separate or multiplexed address and data buses
- – A clock divided from the kernel clock provided for synchronous devices
- • NAND:
- – SLC NAND ONFI 1.0
- – Hamming and BCH ECC controllers
- – Supported as BOOT device
- – 4 CS + 1 RnB signals
- – 8- or 16-bit data modes
- – Hardware sequencer which can be used jointly with DMA channels to free the CPU of sequencing tasks
- – RIF compliant
31.2.1 FMC interface block diagram
Figure 163. FMC interface block diagram

The diagram shows the FMC interface internal and external connections. Major blocks include RCC supplying clock signals (ck_ker_fmc -> kclk, ck_icn_s_fmc -> aclk, ck_icn_p_fmc -> hclk) to FMC; SoC Interconnect interfacing via AHB Slave and AXI Slave; IAC (RIF Illegal Access Controller) receiving illegal access signals (h*_ilac, a*_ilac); HPDMA communicating via dmareq/dmaack pairs for FMC_TXRX and FMC_BCH; interrupt outputs nd_int[1] (fmc_gbl_it) to CPU1 GIC and nd_int[2] (fmc_gbl_it) to CPU2 NVIC; and external pins including FMC_CLK, FMC_NE[4:1], FMC_NBL[1:0], FMC_NL, FMC_A[25:18], FMC_A17/FMC_ALE, FMC_A16/FMC_CLE, FMC_NCE[4:1], FMC_AD[15:0] / FMC_D[15:0], FMC_NWE, FMC_NOE, FMC_NWAIT, FMC_RNB along with internal nd_rnb[0] and nd_rnb[3:1] tied to 0.
31.2.2 FMC interface reset
Figure 164. FMC interface reset

The diagram shows the RCC block with FMCRST generating the rstn_fmc signal which drives the active-low RESETn input of the FMC block (MSv66527V1).
There is only one reset for the FMC interface (rstn_fmc) which is controlled by FMCRST in RCC_FMCCFGR register.
31.2.3 FMC interface interrupt
The FMC generates two interrupts, one for each CID that can be attached to the NAND controller:
- • nd_int[1] generated if the CID attached to the NAND controller corresponds to CPU1
- • nd_int[2] generated if the CID attached to the NAND controller corresponds to CPU2
Table 207. FMC interface interrupts
| FMC signal name | CPU1 interrupt | CPU2 interrupt |
|---|---|---|
| nd_int[1] | fmc_gbl_it | - |
| nd_int[2] | - | fmc_gbl_it |
31.3 Octo-SPI interface
The Octo-SPI interface offers one OCTOSPI physical port. Accesses to the OCTOSPI controller are protected by RISUP components.
31.3.1 Main features of the Octo-SPI interface
- • Support sNOR and sNAND devices from different families: HyperBus™ compliant devices (HyperRAM™ and HyperFlash™ devices from Spansion, Cypress, including MCP devices which integrate both HyperRAM™ and HyperFlash™), Micron devices (Xcella family), Macronix™ devices.
- • Three functional modes: indirect, automatic-status polling, memory-mapped
- • Up to 4 Gbytes of external memory can be addressed in indirect mode (per physical port and per CS), and up to 256 Mbytes in memory-mapped mode (combined for both physical ports and per CS).
- • Single-, dual-, quad-, and octal-SPI communication
- • Dual-quad communication
- • Single data rate (SDR) and double transfer rate (DTR)
- • Maximum target frequency is 133 MHz for SDR and 133 MHz for DTR
- • Data strobe support
- • DMA channel for indirect mode
- • Support for on-the-fly decryption of data read from an external flash memory:
- – Up to four regions can be defined with independent decryption attributes (execute-only and execute-never) and keys.
- – The decryption applies when the OCTOSPI controller is used in read memory-mapped mode.
- • Encryption support
- • Double CS mapping that can be used to address two external flash memory devices with a single OCTOSPI controller.
For a complete list of features, refer to:
31.3.2 Octo-SPI interface block diagram
Figure 165. Octo-SPI interface block diagram

A detailed block diagram of the Octo-SPI interface containing:
- SoC Interconnect: Bidirectional bus connected to AHB Slave interfaces on OCTOSPI1 and OTFDEC1, and to HPDMA.
- SYSCFG: Interconnected with DLYBOS1.
- DLYBOS1: Interconnected with SYSCFG and receives feedback from OCTOSPI1.
- OTFDEC1: Contains S0 (reg), S1 (mem), and an irq line. Connected to SoC Interconnect and OCTOSPI1 memory path.
- OCTOSPI1: Labeled with 'Delayed RX and TX clocks'. Has internal sections for reg, mem, and dma. Outputs include:
- it_ospi interrupt signal
- ospi_clk_o connected to OCTOSPI_CLK and via an inverter to OCTOSPI_NCLK
- afo_ncs and afo_CSSEL going to Dual CS Mapping block, which outputs to OCTOSPI_NCS1 and OCTOSPI_NCS2
- afo_data[7:0], afi_data[7:0], and afoen_data[7:0] connected to OCTOSPI_IO[7:0]
- afo_dqs, afi_dqs, and afoen_dqs connected to OCTOSPI_DQS
- Interrupt targets:
- CPU1 GIC receiving octospi1_it and otfdec1_it
- CPU2 NVIC receiving octospi1_it and otfdec1_it
- HPDMA: Connected to SoC Interconnect and OCTOSPI1 DMA.
MSv73180V2
OCTOSPI1 is the memory controller. It can be accessed by either CPU1 or CPU2. It provides 1 chip select which can be mapped on OCTOSPI_NCS1 or OCTOSPI_NCS2 depending on CSSEL setting.
OTFDEC1 is in charge of on-the-fly decryption of data read from the external memory devices.
DLYBOS1 is a DLL-based programmable delay which allows to tune the phase of the RX sampling clock and the TX launch clock.
31.3.3 Octo-SPI interface resets
Figure 166. OCTOSPI interface resets

The diagram illustrates the reset logic for the OCTOSPI interface. It is divided into two main sections: the RCC (Reset and Clock Control) block on the left and a dashed box on the right containing the DLYBOS1, OCTOSPI1, and OTFDEC1 blocks.
- RCC Block:
- OSPI1DLLRST input leads to
rstn_ospi1dll. - OSPI1RST input leads to
rstn_ospi1. - OTFDEC1RST input leads to
rstn_otfd1. - There are also clock inputs:
ck_icn_s_ospi1andck_icn_p_otfd1.
- OSPI1DLLRST input leads to
- Dashed Box (Peripheral Interface):
- DLYBOS1: Receives
rstn_ospi1dlland outputsrst_n. - OCTOSPI1: Receives
ck_icn_s_ospi1forHCLKandrstn_ospi1through aReset Syncblock forHRESETn. - OTFDEC1: Receives
ck_icn_p_otfd1forHCLKandrstn_otfd1through aReset Syncblock forHRESETn.
- DLYBOS1: Receives
MSv73182V1
There are three independent resets for the OCTOSPI interface:
- •
rstn_ospi1dllwhich is controlled by the OSPI1DLLRST bit in RCC_OSPI1CFGR register. - •
rstn_ospi1which is controlled by the OSPI1RST bit in RCC_OSPI1CFGR register. - •
rstn_otfd1which is controlled by the OTFDEC1RST bit in RCC_OSPI1CFGR register.
When configuring the OCTOSPI interface, the reset sequence to be applied is:
- 1. At device reset, OSPI1DLLRST, OSPI1RST, OTFDEC1RST are all 0. DLYBOS1, OCTOSPI1, OTFDEC1 are under reset because their clocks are disabled.
- 2. Set OSPI1EN. This activates the peripheral clock of OCTOSPI1 and OTFDEC1 and releases their resets.
- 3. Configure the OCTOSPI1 controller and OTFDEC1 engine.
- 4. For configurations where the programmable delays must be used:
- a) Wait for the DLL to be locked. This is indicated by the bit LOCK in SYSCFG_DLYBOS1SR register.
- b) Perform a training sequence to determine which delay values correspond to the middle of the valid window for RX sampling (and possibly Tx launching)
For configurations where the programmable delay is not needed, DLYBOS1 can be maintained under reset by setting OSPI1DLLRST to 1.
31.3.4 Octo-SPI interface memory
256 MBytes are allocated in STM32MP21xx memory map for OCTOSPI1. This area is used when OCTOSPI1 is operating in memory-mapped mode.
31.3.5 OCTOSPI1 description
Refer to Section 33: Octo-SPI interface (OCTOSPI).
31.3.6 OTFDEC1 description
Refer to Section 51: On-the-fly decryption engine (OTFDEC).
31.3.7 DLYBOS1 description
Refer to Section 35: Delay block (DLYB)
The programmable delay is used to tune the phase of:
- • the RX sampling clock (or DQS) in order to sample the data in their valid window
- • the TX launch clock in order to meet setup and hold constraints of TX signals versus the memory clock
The programmable delay block is based on a DLL that compensates for voltage and temperature variations. The DLL features 32 taps and covers the [50 MHz, 208 MHz] frequency range. The clock on which the DLL locks is a free running clock provided by the OCTOSPI. This clock is at the same frequency as the clock sent to the memory. When OCTOSPI1 interface operates below 50 MHz, either the programmable delay is not used (standard case), or it must be used in bypass mode (case of OCTOSPI devices with DQS strobe).
Figure 167. Programmable delay block diagram
![Block diagram of the DLYBOSx programmable delay block. The diagram shows the internal structure of the DLYBOSx block, which includes a Master Delay Line, a Phase Comparator, a Digital Control unit, and RX/TX Delay Lines. The Master Delay Line has 32 taps. The Phase Comparator compares the Master Delay Line output with the input clock (dll_clk) and provides up/down control signals to the Digital Control unit. The Digital Control unit receives commands (dll_start_lock, dll_bypass_cmd[4:0], dll_bypass_cmd_en) and feedback (dll_locked, rx_ph_select_ack, tx_ph_select_ack) from the SYSCFG block. It also receives rx_ph_select[5:0] and tx_ph_select[5:0] for phase selection. The RX Delay Line and TX Delay Line each have 32 taps and are controlled by the Digital Control unit. The RX Delay Line takes rx_ip_clk as input and produces rx_op_clk as output. The TX Delay Line takes tx_ip_clk as input and produces tx_op_clk as output. The SYSCFG block is shown as an external interface to the DLYBOSx block.](/RM0506-STM32MP21/4c198738d4aae7f9064ad0d441681ea4_img.jpg)
The DLL architecture is based on one master delay line, and two slave delay lines (RX and TX). There are two operating modes:
- • Lock mode (dll_bypass_cmd_en = 0)
- – This mode can only be used when the dll_clk frequency is in the range [50 MHz, 208 MHz].
- – The DLL is enabled by setting dll_start_lock to 1.
- – The DLL locks on the frequency of the dll_clk input clock, and compensates for voltage and temperature variations. This process determines the command to be applied to each of the 32 delay units (named tap) of the master delay line for the total master delay to represent one period of dll_clk. This command is copied to each delay unit of the RX and TX delay lines. The command varies with voltage and temperature for the DLL to remain locked. This guarantees that each delay unit of the RX and TX delay lines represents 1/32th of the input clock period.
- – Independent delay values can be selected for the RX and TX delay lines by controlling rx_ph_select[5:0] and tx_ph_select[5:0] parameters independently. The granularity of the delay is 1/32th of the input clock period.
Table 208. RX and TX delays in lock mode
| rx_ph_select[5:0] (respectively tx_ph_select[5:0]) | RX delay (respectively TX delay) |
|---|---|
| 000000 | 0 |
| 000001 | 1/32 x T(dll_clk) |
| ... | ... |
| 011111 | 31/32 x T(dll_clk) |
| 100000 | 32/32 x T(dll_clk) |
- – When selecting a new delay value with rx_ph_select[5:0] (respectively tx_ph_select[5:0]), an acknowledge is returned when the change takes place with rx_ph_select_ack (respectively tx_ph_select_ack).
- • Bypass mode (dll_bypass_cmd_en = 1)
- – In this mode, delays in RX and TX delay lines are used as “pure” delays: without trying to lock on the frequency of the dll_clk input clock. There is therefore no voltage nor temperature compensation in this mode, and RX and TX delay values vary with the voltage and the temperature. The command applied to each delay unit of the RX and TX delay lines is controlled by dll_bypass_cmd[4:0]. Each delay unit includes 24 delay elements. The number of delay elements which are enabled in each delay unit depends on the value of dll_bypass_cmd[4:0].
| dll_bypass_cmd[4:0] | Number of delay elements enabled |
|---|---|
| 00000 | reserved |
| 00001 | 1 delay element is enabled |
| 00010 | 2 delay elements are enabled |
| ... | ... |
| 11000 to 11111 | All 24 delay elements are enabled |
- – Independent delay values can be selected for the RX and TX delay lines by controlling rx_ph_select[5:0] and tx_ph_select[5:0] parameters independently. Rx_ph_select[5:0] and tx_ph_select[5:0] control the number of delay units that are enabled in the RX and TX delay lines: a value of n corresponds to n delay units enabled. The total delay inserted by the RX (respectively TX) delay line depends on rx_ph_select[5:0] (respectively tx_ph_select[5:0]) and dll_bypass_cmd[4:0] values.
- – This mode is required to be able to insert a delay between the rx_ip_clk (respectively tx_ip_clk) input clock and the rx_op_clk (respectively tx_op_clk) output clock when the operating frequency is lower than the minimum frequency supported by the DLL (f < 50 MHz). This is necessary to support OCTOSPI devices in DTR mode at low frequency for which DQS must be delayed to sample data.
31.3.8 Octo-SPI interface interrupts
OCTOSPI1 and OTFDEC1 generate one interrupt.
Table 210. Octo-SPI interface interrupts| Peripheral | Signal name | CPU1 interrupt | CPU2 interrupt |
|---|---|---|---|
| OCTOSPI1 | it_osp | octospi1_it | octospi1_it |
| OTFDEC1 | irq | otfdec1_it | otfdec1_it |
31.3.9 Chip select management
The chip select signal provided by the OCTOSPI controller is mapped on OCTOSPI_NCS1 or OCTOSPI_NCS2 depending on the value of CSSEL bit in OCTOSPI_CR register.
Table 211. OCTOSPI1 CS mapping| OCTOSPI1 CSSEL | OCTOSPI1 CS mapped on |
|---|---|
| 0 | OCTOSPI_NCS1 |
| 1 | OCTOSPI_NCS2 |
Note: It is possible to connect 2 flash devices to the OCTOSPI interface and control them both by the OCTOSPI controller. However, the two devices cannot be used simultaneously. Switching from one device to the other requires to:
- • re-program OCTOSPI1 CSSEL to remap the chip select.
- • re-program the OCTOSPI controller.
The figure below gives an example of this possibility where two 8-bit devices are attached to the OCTOSPI interface.
Figure 168. Flash configuration example:
2× 8-bit flash devices connected to the OCTOSPI interface
![Schematic diagram of two 8-bit flash devices connected to the OCTOSPI interface. The OCTOSPI1 block outputs OCTOSPI_NCLK (buffered), OCTOSPI_CLK, OCTOSPI_IO[7:0], and OCTOSPI_DQS. These connect to Device 1 and Device 2. Device 1 uses OCTOSPI_NCS1 as its chip select. Device 2 uses OCTOSPI_NCS2 as its chip select. The afo_ncs and afo_CSSEL signals control multiplexers that route the chip select signals. A table on the left explains the CSSEL mapping: 0 maps to OCTOSPI_NCS1 ( Device 1 active), and 1 maps to OCTOSPI_NCS2 ( Device 2 active).](/RM0506-STM32MP21/5fba4a13c6c2637e667ce0f7b8ad5092_img.jpg)
OCTOSPI1 CSSEL value
| 0: | chip select is mapped to OCTOSPI_NCS1. OCTOSPI_NCS2 is inactive. Device1 can be selected. |
| 1: | chip select is mapped to OCTOSPI_NCS2. OCTOSPI_NCS1 is inactive. Device2 can be selected. |
OCTOSPI1
afo_ncs
afo_CSSEL
OCTOSPI_NCLK
OCTOSPI_CLK
OCTOSPI_IO[7:0]
OCTOSPI_DQS
OCTOSPI_NCS1
OCTOSPI_NCS2
Device 1
clock
data
data strobe
chip select
Device 2
data strobe
data
clock
chip select
MSv73181V1
The OCTOSPI interface also supports dual-quad mode. In dual quad mode, two 4-bit devices are connected to the same chip select in order to provide a throughput similar to an 8-bit device. This mode is configured by the bit DQM in OCTOSPI_CR register. An example is shown in the figure below.
Figure 169. Flash configuration example: dual quad mode.
Two 4-bit devices are connected to the same Chip Select of the OCTOSPI interface
![Schematic diagram of OCTOSPI1 interface configuration for dual quad mode. The OCTOSPI1 block has pins: OCTOSPI_NCLK, OCTOSPI_CLK, OCTOSPI_IO[3:0], OCTOSPI_IO[7:4], OCTOSPI_DQS, OCTOSPI_NCS1, and OCTOSPI_NCS2. It also has internal control pins afo_ncs and afo_CSSEL. OCTOSPI_NCLK is connected to an inverter. OCTOSPI_CLK, OCTOSPI_IO[3:0], OCTOSPI_IO[7:4], and OCTOSPI_DQS are connected to Quad device 1. OCTOSPI_NCS1 and OCTOSPI_NCS2 are connected to Quad device 2. The afo_ncs and afo_CSSEL pins are connected to a 2-to-1 multiplexer. The multiplexer's output is connected to OCTOSPI_NCS1. The multiplexer's select input is connected to afo_CSSEL. The multiplexer's other input is connected to a constant '1'.](/RM0506-STM32MP21/d98a792406622add74d329bcae2c6940_img.jpg)
OCTOSPI1 DQM = 1
OCTOSPI1 CSSEL = 0: OCTOSPI1 Chip Select is mapped to OCTOSPI_NCS1.
MSv72203V1
31.3.10 Octo-SPI interface programmable parameters
Octo-SPI memory area allocation in memory-mapped mode
Refer to Section 31.3.4: Octo-SPI interface memory.
DLYBOS1 control
The DLYBOS1 programmable delay is controlled by bits in SYSCFG_DLYBOS1CR and SYSCFG_DLYBOS1SR registers. The table below gives the correspondence between SYSCFG bitfields and the control parameters described in Section 31.3.7.
Table 212. DLYBOS1 SYSCFG bits
| DLYBOS1 SYSCFG bits | Control input or status output in the OCTOSPI | Comment |
|---|---|---|
| BYP_EN | dll_bypass_cmd_en | Selection of lock or pure-delay mode |
| EN | dll_start_lock | Enable of DLL when configured in Lock mode |
| RX_TAP_SEL[5:0] | rx_ph_select[5:0] | Selection of delay in RX delay line |
| TX_TAP_SEL[5:0] | tx_ph_select[5:0] | Selection of delay in TX delay line |
| BYP_CMD[4:0] | dll_bypass_cmd[4:0] | Command applied to every delay units in RX and TX delay lines when the DLL is configured in pure-delay mode |
| LOCK | dll_locked | When in lock mode, indicates that the DLL has locked on the input clock frequency |
Table 212. DLYBOS1 SYSCFG bits (continued)
| DLYBOS1 SYSCFG bits | Control input or status output in the OCTOSPI | Comment |
|---|---|---|
| RX_TAP_SEL_ACK | rx_ph_select_ack | Indicates that the RX delay line has switched to the delay selected by RX_TAP_SEL[5:0] |
| TX_TAP_SEL_ACK | tx_ph_select_ack | Indicates that the TX delay line has switched to the delay selected by TX_TAP_SEL[5:0] |
31.3.11 Select the RX sampling strobe and configure the TX clock
The table below lists the various OCTOSPI modes, and gives guidelines to select the RX sampling strobe and configure the TX clock. Some information is also given on how to enable the DLL.
Table 213. OCTOSPI modes and recommended clock configuration
| OCTOSPI Mode | STR or DTR | DQS used in read ? | Max frequency | Setup/Hold constraints on memory device | Data valid Window at output of memory Device | TX clock configuration | RX sampling strobe selection |
|---|---|---|---|---|---|---|---|
| HyperBus( Cypress, Spansion) | DTR | yes | 200 166 133 100 50 | 0.40 / 0.40 ns 0.60 / 0.60 ns 0.80 / 0.80 ns 1 / 1 ns wrt memory clock edges | 1.45 ns 1.70 ns 2.37 ns 3.30 ns | if kernel clock is a multiple of memory clock, set DHQC = 1 (this automatically bypasses the TX delay). If kernel clock is equal to memory clock, set DQHC = 0. The DLL must be used for TX delay. | DQS delayed (DQSE = 1, DLYBYP = 0). The DLL must be used for RX delay. |
| Macronix [For instr. READ, FASTREAD, OCTAREAD-STR] | STR | no | 133 100 66 | 2 / 2 ns 2 / 2 ns 2 / 2 ns wrt memory clock rising edge | 2 ns@10pF 4 ns@15pF 7 ns@30pF | Set DQHC = 0 and configure the TX delay to minimum value. | Feedback clock delayed @133 MHz and 100 MHz (DQSE=0, DLYBYP=0). The DLL must be used for RX delay. Feedback clock @66 MHz (DQSE=0, DLYBYP=1). The DLL is not used for RX delay. |
| Macronix [For instr. OCTAREAD - DTR] | DTR | yes | 133 100 66 | 0.8 / 0.8 ns 1 / 1 ns 1 / 1 ns | 1.5ns@10pF 2.8ns @15pF 4.9ns @30pF | if kernel clock is a multiple of memory clock, set DHQC = 1 (this automatically bypasses the TX delay). If kernel clock is equal to memory clock, set DQHC = 0. The DLL must be used for TX delay. | DQS delayed (DQSE = 1, DLYBYP = 0). The DLL must be used for RX delay. |
| Micron Xcella (MT35XL01 GBBA ds) | STR | no | 133 | 1.8 / 1.8 ns Wrt memory clock rising edge | 2.8ns @12pF | Set DQHC = 0 and configure the TX delay to minimum value. | Feedback clock delayed @133 MHz and 100 MHz (DQSE=0, DLYBYP=0). The DLL must be used for RX delay. Feedback clock @66 MHz (DQSE=0, DLYBYP=1). The DLL is not used for RX delay. |
| Micron Xcella (MT35XL01 GBBA ds) | DTR | yes | 133 | 0.8 / 0.8 ns Wrt memory clock edges | 2 ns | if kernel clock is a multiple of memory clock, set DHQC = 1 (this automatically bypasses the TX delay). If kernel clock is equal to memory clock, set DQHC = 0. The DLL must be used for TX delay. | DQS delayed (DQSE = 1, DLYBYP = 0). The DLL must be used for RX delay. |
DHQC is bit #28 in OCTOSPI_TCR register. DQSE is bit #29 in OCTOSPI_CCR register. DLYBYP is bit #3 in OCTOSPI_DCR1 register.
Enabling the DLL for frequencies greater or equal to 50 MHz (lock mode)
The DLL is enabled by setting EN = 1. The DLL lock state is reached when LOCK = 1. Once the DLL is locked, an RX delay value can be selected by programming RX_TAP_SEL[5:0], and a TX delay value can be selected by programming TX_TAP_SEL[5:0]. Each tap corresponds to 1/32th of the memory device clock period. The selected delays are applied to RX sampling strobe and TX launch clock once RX_TAP_SEL_ACK and TX_TAP_SEL_ACK are set to 1.
Enabling the DLL for frequencies lower than 50 MHz (bypass mode)
The DLL is enabled by setting BYP_EN = 1. The command applied to every DLL delay unit is defined by BYP_CMD[4:0] bits (the value 0 is reserved and must not be used). RX_TAP_SEL[5:0] and TX_TAP_SEL[5:0] define the number of elementary delays inserted on RX sampling clock and TX launch clock. For minimum delay, RX_TAP_SEL[5:0] (respectively TX_TAP_SEL[5:0]) must be set to 0.
EN, RX_TAP_SEL[5:0], TX_TAP_SEL[5:0], BYP_EN, BYP_CMD[4:0] bits are located in SYSCFG_DLYBOSnCR (n=1,2) registers. LOCK, RX_TAP_SEL_ACK, TX_TAP_SEL_ACK bits are located in SYSCFG_DLYBOSnSR (n=1,2) registers.
31.4 SD/eMMC interface
The SD/eMMC interface offers three SD/eMMC physical ports. The accesses to the SDMMC controllers are protected by RISUP components.
31.4.1 SD/eMMC interface main features
- • SDMMC1 interface:
- – supports SD cards, eMMC memories, and SDIO devices. Alternate multiplexing is optimized for SD.
- – 1-bit, 4-bit, 8-bit modes.
- – SD: supports SD 3.01 up to UHS-1 modes (SDR104, DDR50, SDR50, DDR25) and all backward compatible modes.
- – eMMC: supports eMMC 5.1 up to HS200 (HS400 not supported)
- – SDIO: supports SDIO 4.0 and all backward compatible modes.
- – SD or eMMC devices are supported as Boot device.
- – DLL to tune the RX sampling clock.
- – SDMMC1 IO segment is in a dedicated \(V_{DDIO1}\) supply domain. Both 1V8 and 3V3 devices are supported. 1V2 is not supported.
- – 3V3 to 1V8 voltage transition for UHS-1 modes of SD card can be supported in two different ways:
- . An SDMMC1_VSEL function is mapped on a GPIO and controls an external voltage regulator to switch from 3V3 to 1V8. This voltage regulator supplies the SDMMC1 IO segment.
- . External Level Shifters are used. The enable of these Level Shifters is controlled by a GPIO and their direction is controlled by SDMMC1_CDIR, SDMMC1_D0DIR and SDMMC1_D123DIR alternate functions.
- • SDMMC2 interface:
- – supports SD cards, eMMC memories and SDIO devices. Alternate multiplexing is optimized for eMMC.
- – 1-bit, 4-bit, 8-bit modes.
- – SD: supports SD 3.01 up to UHS-1 modes (SDR104, DDR50, SDR50, DDR25) and all backward compatible modes.
- – eMMC: supports eMMC 5.1 up to HS200 (HS400 not supported).
- – SDIO: supports SDIO 4.0 and all backward compatible modes.
- – SD or eMMC devices are supported as Boot device.
- – DLL to tune the RX sampling clock.
- – SDMMC2 IO segment is in a dedicated \(V_{DDEMMC}\) supply domain. Both 1V8 and 3V3 devices are supported. 1V2 is not supported.
- – 3V3 to 1V8 voltage transition for UHS-1 modes of SD card can be supported in two different ways:
- . An SDMMC2_VSEL function is mapped on a GPIO and controls an external voltage regulator to switch from 3V3 to 1V8. This voltage regulator supplies the SDMMC2 IO segment.
- . External Level Shifters are used. The enable of these Level Shifters is controlled by a GPIO and their direction is controlled by SDMMC2_CDIR, SDMMC2_D0DIR and SDMMC2_D123DIR alternate functions.
- • SDMMC3 interface:
- – supports SD cards, eMMC memories (limited to 4-bit) and SDIO devices.
- – 1-bit, 4-bit modes.
- – SD: supports SD 3.01 up to UHS-1 modes (SDR104, DDR50, SDR50, DDR25) and all backward compatible modes.
- – eMMC: supports eMMC 5.1 up to HS200 (HS400 not supported).
- – SDIO: supports up to SDIO 4.0 and all backward compatible modes.
- – DLL to tune the RX sampling clock.
- – SDMMC3 IOs do not have a dedicated supply. They are in VDD IO domain. The external device must also be in VDD IO domain or external Level Shifters must be used.
- – 3V3 to 1V8 voltage transition for UHS-1 modes of SD card can only be supported with external Level Shifters. Like for the other SDMMC interfaces, the enable of these Level Shifters is controlled by a GPIO and their direction is controlled by SDMMC3_CDIR, SDMMC3_D0DIR and SDMMC3_D123DIR alternate functions.
For a complete list of features refer to Section 34: Secure digital input/output MultiMediaCard interface (SDMMC).
31.4.2 SD/eMMC interface block diagram
Figure 170. SD/eMMC interface block diagram
![SD/eMMC interface block diagram showing SoC Interconnect, SYSCFG, SDMMC1, SDMMC2, SDMMC3, DLYBSD1, DLYBSD2, DLYBSD3, and various signal lines like SDVSEL, SDMMC1_CMD, SDMMC1_D[3:0], etc.](/RM0506-STM32MP21/e9210d858f9b7a293841b3194287ecfc_img.jpg)
The diagram illustrates the SD/eMMC interface architecture within a SoC. A vertical SoC Interconnect bus on the left connects to three SDMMC blocks (SDMMC1, SDMMC2, and SDMMC3) via AHB Slave and AHB Master interfaces. Each SDMMC block is associated with a SYSCFG block and a DLYBSD block. The DLYBSD blocks are connected to the SDMMC blocks and to SDVSEL signals. The SDMMC blocks have IRQ outputs connected to CPU1 GIC and CPU2 NVIC. The SDMMC blocks also have various signal inputs/outputs: SDMMC1_CMD, SDMMC1_D[3:0], SDMMC1_D[7:4], SDMMC1_CDIR, SDMMC1_D0DIR, SDMMC1_D123DIR, SDMMC2_CMD, SDMMC2_D[7:0], SDMMC2_CDIR, SDMMC2_D0DIR, SDMMC2_D123DIR, SDMMC3_CMD, SDMMC3_D[3:0], SDMMC3_CDIR, SDMMC3_D0DIR, and SDMMC3_D123DIR. The CPU1 GIC and CPU2 NVIC blocks are connected to the IRQ outputs of the SDMMC blocks via sdmmc1_gbl_it, sdmmc2_gbl_it, and sdmmc3_gbl_it signals.
MSv66525V2
31.4.3 SD/eMMC interface reset
Figure 171. SD/eMMC interface resets

The diagram illustrates the reset architecture for SDMMC1, SDMMC2, and SDMMC3 along with delay blocks DLYBSD1, DLYBSD2, and DLYBSD3. From the RCC block on the left: - SDMMC1RST generates rstn_sdmmc1 which goes to a Reset Sync block clocked by ck_icn_m_sdmmc1, outputting to HRESETn of SDMMC1. ck_icn_m_sdmmc1 connects directly to HCLK of SDMMC1. - SDMMC1DLLRST generates rstn_sdmmc1dll connecting directly to rst_n of DLYBSD1. - SDMMC2RST generates rstn_sdmmc2 which goes to a Reset Sync block clocked by ck_icn_m_sdmmc2, outputting to HRESETn of SDMMC2. ck_icn_m_sdmmc2 connects directly to HCLK of SDMMC2. - SDMMC2DLLRST generates rstn_sdmmc2dll connecting directly to rst_n of DLYBSD2. - SDMMC3RST generates rstn_sdmmc3 which goes to a Reset Sync block clocked by ck_icn_m_sdmmc3, outputting to HRESETn of SDMMC3. ck_icn_m_sdmmc3 connects directly to HCLK of SDMMC3. - SDMMC3DLLRST generates rstn_sdmmc3dll connecting directly to rst_n of DLYBSD3.
31.4.4 SDMMC1/2 description
Refer to Section 34: Secure digital input/output MultiMediaCard interface (SDMMC).
31.4.5 DLYBSD1/2 description
One programmable delay is used for each SDMMC interface. The programmable delay can be used to tune the phase of the RX sampling clock in order to sample the data in their valid window. The programmable delay has no effect on the TX path.
These programmable delays are identical to the ones used in the OCTOSPI interfaces. The clock on which the DLL locks is a free running clock provided by the SDMMC controller which is at the same frequency as the clock sent to the memory. When an SDMMC interface operates below 50 MHz, the programmable delay cannot be used. Refer to Section 31.3.7 for a detailed description.
31.4.6 SD/eMMC interface interrupts
Each SDMMC instance generates one interrupt.
Table 214. SD/eMMC interface interrupts
| Peripheral | pin name | CPU1 interrupt | CPU2 interrupt |
|---|---|---|---|
| SDMMC1 | IRQ | sdmmc1_gbl_it | sdmmc1_gbl_it |
| SDMMC2 | IRQ | sdmmc2_gbl_it | sdmmc2_gbl_it |
| SDMMC3 | IRQ | sdmmc3_gbl_it | sdmmc3_gbl_it |
31.4.7 SD/eMMC interface programmable parameters
Control of external voltage regulator
For SDMMC1 and SDMMC2 interfaces, an external voltage regulator can be used to manage the 3V3 to 1V8 voltage transition for UHS-1 modes of SD card. This external voltage regulator can be controlled by the SDMMC1_VSEL (respectively SDMMC2_VSEL) alternate function. These alternate functions are controlled by the following SYSCFG bits:
- • SDMMC1 interface: SDMMC1_VSEL bit in SYSCFG_SDMMC1CR register.
- • SDMMC2 interface: SDMMC2_VSEL bit in SYSCFG_SDMMC2CR register.
PWR_CR8.VDDIO1VRSEL (respectively PWR_CR7.VDDIO2VRSEL) must be controlled according to external voltage regulator transition.
DLYBSD1 control
DLYBSD1 programmable delay is controlled by bits in SYSCFG_DLYBSD1CR and SYSCFG_DLYBSD1SR registers. The table below gives the correspondence between the SYSCFG bitfields and the control parameters described in Section 31.3.7.
Table 215. DLYBSD1 SYSCFG bits
| DLYBSD1 SYSCFG bits | Control input or status output in the SDMMC | Comment |
|---|---|---|
| BYP_EN | dll_bypass_cmd_en | Selection of lock or pure-delay mode |
| EN | dll_start_lock | Enable of DLL when configured in Lock mode |
| RX_TAP_SEL[5:0] | rx_ph_select[5:0] | Selection of delay in RX delay line |
| DLYBSD1 SYSCFG bits | Control input or status output in the SDMMC | Comment |
|---|---|---|
| BYP_CMD[4:0] | dll_bypass_cmd[4:0] | Command applied to every delay units in RX and TX delay lines when the DLL is configured in pure-delay mode |
| LOCK | dll_locked | When in lock mode, indicates that the DLL has locked on the input clock frequency |
| RX_TAP_SEL_ACK | rx_ph_select_ack | Indicates that the RX delay line has switched to the delay selected by RX_TAP_SEL[5:0] |
DLYBSD2 control
DLYBSD2 programmable delay is controlled by bits in SYSCFG_DLYBSD2CR and SYSCFG_DLYBSD2SR registers. The table below gives the correspondence between the SYSCFG bitfields and the control parameters described in Section 31.3.7.
Table 216. DLYBSD2 SYSCFG bits| DLYBSD2 SYSCFG bits | Control input or status output in the SDMMC | Comment |
|---|---|---|
| BYP_EN | dll_bypass_cmd_en | Selection of lock or pure-delay mode |
| EN | dll_start_lock | Enable of DLL when configured in Lock mode |
| RX_TAP_SEL[5:0] | rx_ph_select[5:0] | Selection of delay in RX delay line |
| BYP_CMD[4:0] | dll_bypass_cmd[4:0] | Command applied to every delay units in RX and TX delay lines when the DLL is configured in pure-delay mode |
| LOCK | dll_locked | When in lock mode, indicates that the DLL has locked on the input clock frequency |
| RX_TAP_SEL_ACK | rx_ph_select_ack | Indicates that the RX delay line has switched to the delay selected by RX_TAP_SEL[5:0] |
DLYBSD3 control
DLYBSD3 programmable delay is controlled by bits in SYSCFG_DLYBSD3CR and SYSCFG_DLYBSD3SR registers. The table below gives the correspondence between the SYSCFG bitfields and the control parameters described in Section 31.3.7.
Table 217. DLYBSD3 SYSCFG bits
| DLYBSD3 SYSCFG bits | Control input or status output in SDMMC | Comment |
|---|---|---|
| BYP_EN | dll_bypass_cmd_en | Selection of lock or pure-delay mode |
| EN | dll_start_lock | Enable of DLL when configured in Lock mode |
| RX_TAP_SEL[5:0] | rx_ph_select[5:0] | Selection of delay in RX delay line |
| BYP_CMD[4:0] | dll_bypass_cmd[4:0] | Command applied to every delay units in RX and TX delay lines when the DLL is configured in pure-delay mode |
| LOCK | dll_locked | When in lock mode, indicates that the DLL has locked on the input clock frequency |
| RX_TAP_SEL_ACK | rx_ph_select_ack | Indicates that the RX delay line has switched to the delay selected by RX_TAP_SEL[5:0] |
31.4.8 Guidelines for selecting the RX sampling clock
The tables below list the various SD/eMMC speed modes and gives guidelines to select the RX sampling clock and configure the clock control bits in the SDMMC cell. It is assumed here that no external level shifters are used. Some information is also given on how to enable the DLL.
Table 218. SD speed modes and recommended clock configuration
| Speed Mode | Max card clock freq. SDMMCn_CLK | IO Voltage | Setup/hold constraints on SD device | Data valid Window at output of SD Device | Kernel clock freq (SCLK) | DDR | NEGEDGE | CLKDIV | Selection of RX sampling clock (SELCLKRX) |
|---|---|---|---|---|---|---|---|---|---|
| DS (default speed)(1) | 25 MHz | 3V3 | 5ns/5ns | 26ns | 25 MHz | 0 | NA | 0 (div by 1) | SDMMC_CLKio |
| HS (high speed)(1) | 50 MHz | 3V3 | 6ns/2ns | 8.5ns | 50 MHz | 0 | NA | 0 (div by 1) | SDMMC_CLKio |
| SDR12(1) | 25 MHz | 1V8 | 3ns/0.8ns | 27.5ns | 25 MHz | 0 | NA | 0 (div by 1) | SDMMC_CLKio |
| SDR25(1) | 50 MHz | 1V8 | 3ns/0.8ns | 7.5ns | 50 MHz | 0 | NA | 0 (div by 1) | SDMMC_CLKio |
| DDR50 (2) | 50 MHz | 1V8 | 3ns/0.8ns | 4.5ns | 50 MHz | 1 | (3) | 1 (div by 2) | SDMMC_CLKio |
| SDR50(2) | 100 MHz | 1V8 | 3ns/0.8ns | 4ns | 100 MHz | 0 | NA | 0 (div by 1) | SDMMC_CLKio |
| SDR104 | 208 MHz | 1V8 | 1.4ns/0.8ns | 2,88ns | 208 MHz | 0 | NA | 0 (div by 1) | SDMMC_FB_CLK |
- 1. For these modes, other clock configurations exist where the kernel clock frequency is a multiple of the card clock. However, considering that all three SDMMC controllers have dedicated kernel clocks, it seems more straightforward to align the kernel clock frequency with the card clock frequency.
- 2. For these modes, it is also possible to enable the programmable delay and select the delayed loopback clock (SDMMC_FB_CLK) as RX sampling clock if it is needed to adjust the sampling edge.
- 3. Value to be programmed depend on timings of the interface. For functional simulation, either value works.
| Speed Mode | Max card clock freq. SDMMCn_CK | IO Voltage(1) | Setup/Hold constraints on SD device | Data valid Window at output of eMMC Device | Kernel clock freq (SCLK) | DDR | NEGEDGE | CLKDIV | Selection of RX sampling clock (SELCLKRX) |
|---|---|---|---|---|---|---|---|---|---|
| Legacy compatible(2) | 26 MHz | 3V3, 1V8, 1V2 | 3ns/3ns | 20ns | 26 MHz | 0 | NA | 0 (div by 1) | SDMMC_CLKio |
| High speed SDR(2) | 52 MHz | 3V3, 1V8, 1V2 | 3ns/3ns | 8ns | 52 MHz | 0 | NA | 0 (div by 1) | SDMMC_CLKio |
| High Speed DDR(3) | 52 MHz | 3V3, 1V8, 1V2 | CMD: 3ns/3ns DATA: 2.5ns/2.5ns | CMD: 8ns DATA: 4.1ns | 104 MHz | 1 | (4) | 1 (div by 2) | SDMMC_CLKio |
| High speed HS200 | 200 MHz | 1V8, 1V2 | 1.4ns/0.8ns | 0.575 UI (2.88ns at 200 MHz) | 200 MHz | 0 | NA | 0 (div by 1) | SDMMC_FB_CLK |
- 1V2 is not supported in STM32MP21xx.
- For these modes, other clock configurations exist where the kernel clock frequency is a multiple of the card clock. However, considering that all three SDMMC controllers have dedicated kernel clocks, it seems more straightforward to align the kernel clock frequency with the card clock frequency.
- For this mode, it is also possible to enable the programmable delay and select the delayed loopback clock (SDMMC_FB_CLK) as RX sampling clock if it is needed to adjust the sampling edge.
- Value to be programmed depend on timings of the interface. For functional simulation, either value works.
DDR, NEGEDGE, CLKDIV and SELCLKRX are bitfields in SDMMC_CLKCR register.
The DLL is enabled by writing BYP_EN to 0 and setting EN to 1. The DLL lock state is reached when the status bit LOCK is equal to 1. Once the DLL is locked, a delay value can be selected by programming RX_TAP_SEL[5:0]. The selected delay is applied to the RX sampling clock when the status bit RX_TAP_SEL_ACK is equal to 1. These control and status bits are located in the SYSCFG_DLYBSDnCR and SYSCFG_DLYBSDnSR registers (n=1,2,3).
Sequencing between SDMMC and DLL programming when the DLL is used
- 1. Enable in SDMMC the generation of the free running clock towards the DLL. This is done as soon as PWRCTRL is set to 0b11.
- 2. Once the memory frequency is increased to high speed (i.e. after the initialization sequence), reset and enable the DLL. The reset of the DLL is controlled by SDMMCnDLLRST (n=1,2,3) bit in the RCC. The enable of the DLL is controlled by EN bit in SYSCFG_DLYBSDnCR (n=1,2,3) register.
- 3. Once the DLL is locked (as indicated by LOCK = 1 in SYSCFG_DLYBSDnSR register), select the delayed feedback clock as the RX sampling clock by writing SELCLKRX to 0b10.
- 4. Select the RX delay value by programming RX_TAP_SEL[5:0] in SYSCFG_DLYBSDnCR.
- 5. Wait for RX_TAP_SEL_ACK bit to be set to 1 in SYSCFG_DLYBSDnSR register before reading data from memory.
At startup a tuning phase is required where steps 4 and 5 are repeated for every RX_TAP_SEL[5:0] values. This enables to determine a range of delays where data are read successfully. The delay value corresponding to the middle of this valid range must be selected for further operation.