Skip to main content
totoro
Associate II
August 14, 2025
Question

xspi problem on stm32h7r7(read again the SFDP header failed)

  • August 14, 2025
  • 1 reply
  • 1092 views

Hi,

I used cubemx to generate three projects (Boot, Appli and ExtMemLoader) of STM32H7R7, the boot project was responsible for initializing Octol SPI FLASH, but the initialization failed, and I couldn't jump to the app.

I followed this tutorial to configure cubemx:

https://community.st.com/t5/stm32-online-courses/stm32h7rs-and-ospi-in-practice/ba-p/810411 

the hardware:

board: art-pi2 (art-pi2 )
mcu: STM32H7R7L8HxH
Octal Spi Flash: W35T51NW (datasheet )

development env:

STM32CubeMX 6.15.0
STM32CubeCLT 1.19.0
STM32Cube for Visual Studio Code  2.1.1
STM32CubeProgrammer 2.20.0

the attachment is the project included cubemx project

In stm32_extmem_conf.h file, print debugging is turned on

#define EXTMEM_DRIVER_NOR_SFDP_DEBUG_LEVEL 4
#define EXTMEM_MACRO_DEBUG printf

  Boot print log:

 SFDP::1 - reset data SFDPObject to zero
 SFDP::2 - initialize the SFDPObject
 SFDP::3 - set memory link and speed to 50Mhz maximum
 SFDP::4 - analyze the SFPD structure to get driver information
 SFDP::SFDP_GetHeader
 SFDP::try a command configuration
 SFDP::SFDP_ReadHeader
 SFDP::SFDP signature::0x50444653
 SFDP::signature of the header: OK
 SFDP::param_number=0x2
 SFDP::AccessProtocol=0xff
 SFDP::5 - reset the memory
 SFDP::SFDP_MemoryReset
 SFDP::sfdp_get_paraminfo
 SFDP::-> type SFPD_PARAMID_FUNCTION_JEDEC
 SFDP::-> info SFPD_PARAMID_BASIC_SPIPROTOCOL
 SFDP::::reset 0x66 0x99
 SFDP::6 - analyze the SFPD structure to get driver information
 SFDP::SFDP_GetHeader
 SFDP::try a command configuration
 SFDP::SFDP_ReadHeader
 SFDP::SFDP signature::0x50444653
 SFDP::signature of the header: OK
 SFDP::param_number=0x2
 SFDP::AccessProtocol=0xff
 SFDP::7 - read the flash ID
 SFDP:: Flash ID(0xef:0x5b:0x1a:0x2)
 SFDP::8 - collect the SFDP data
 SFDP::SFDP_CollectData
 SFDP::sfdp_get_paraminfo
 SFDP::-> type SFPD_PARAMID_FUNCTION_JEDEC
 SFDP::-> info SFPD_PARAMID_BASIC_SPIPROTOCOL
 SFDP::sfdp_get_paraminfo
 SFDP::-> type SFPD_PARAMID_FUNCTION_JEDEC
 SFDP::-> info SFPD_PARAMID_4BYTE_ADDRESS_INSTRUCTION
 SFDP::sfdp_get_paraminfo
 SFDP::-> info SFPD_PARAMID_XSPI_V1_0
 SFDP::9 - build the generic driver information and prepare the physical layer
 SFDP::SFDP_BuildGenericDriver
 SFDP::-> flash size: 2^0x1a
 SFDP::10 - adjust the frequency if required
 SFDP::11 - read again the SFDP header to adjust memory type if necessary
 SFDP::SFDP_ReadHeader
 SFDP::SFDP signature::0x0
 SFDP::signature of the header: KO
 SFDP::ERROR::EXTMEM_DRIVER_NOR_SFDP_MEMTYPE_CHECK
 art-pi2 bootloader
 booting...

 

1 reply

ST Employee
August 19, 2025

Hello @totoro ,

 

Could you please enable the EXTMEM SALXSPI logging by adding the line #define EXTMEM_SAL_XSPI_DEBUG_LEVEL 2 to the stm32_extmem_conf.h file ?

Additionally, please dump the XSPI configuration registers between steps 9, 10, and 11 for further investigation.

 

Kind regards,

totoro
totoroAuthor
Associate II
August 20, 2025

Thanks for the reply.

I have added the EXTMEMSALXSPIDEBUGLEVEL macro and printed the registers for XSPI2 in steps 9, 10 and 11

The location of the print is shown below.

position.jpg

The log as follow:

 SFDP::1 - reset data SFDPObject to zero
 SFDP::2 - initialize the SFDPObject
 SFDP::3 - set memory link and speed to 50Mhz maximum
 SALXSPI::::CLOCK::0x2
 SFDP::4 - analyze the SFPD structure to get driver information
 SFDP::SFDP_GetHeader
 SFDP::try a command configuration
 SALXSPI::::PARAM_PHY_LINK::PHY_LINK_1S1S1S
 SFDP::SFDP_ReadHeader
 SFDP::SFDP signature::0x50444653
 SFDP::signature of the header: OK
 SFDP::param_number=0x2
 SFDP::AccessProtocol=0xff
 SFDP::5 - reset the memory
 SFDP::SFDP_MemoryReset
 SFDP::sfdp_get_paraminfo
 SFDP::-> type SFPD_PARAMID_FUNCTION_JEDEC
 SFDP::-> info SFPD_PARAMID_BASIC_SPIPROTOCOL
 SFDP::::reset 0x66 0x99
 SFDP::6 - analyze the SFPD structure to get driver information
 SFDP::SFDP_GetHeader
 SFDP::try a command configuration
 SALXSPI::::PARAM_PHY_LINK::PHY_LINK_1S1S1S
 SFDP::SFDP_ReadHeader
 SFDP::SFDP signature::0x50444653
 SFDP::signature of the header: OK
 SFDP::param_number=0x2
 SFDP::AccessProtocol=0xff
 SFDP::7 - read the flash ID
 SFDP:: Flash ID(0xef:0x5b:0x1a:0x2)
 SFDP::8 - collect the SFDP data
 SFDP::SFDP_CollectData
 SFDP::sfdp_get_paraminfo
 SFDP::-> type SFPD_PARAMID_FUNCTION_JEDEC
 SFDP::-> info SFPD_PARAMID_BASIC_SPIPROTOCOL
 SFDP::sfdp_get_paraminfo
 SFDP::-> type SFPD_PARAMID_FUNCTION_JEDEC
 SFDP::-> info SFPD_PARAMID_4BYTE_ADDRESS_INSTRUCTION
 SFDP::sfdp_get_paraminfo
 SFDP::-> info SFPD_PARAMID_XSPI_V1_0
 SFDP::9 - build the generic driver information and prepare the physical layer
 XSPI Configuration start
 XSPI Instance: 0x5200a000
 CR = 0x10000001
 DCR1 = 0x01190300
 DCR2 = 0x00000002
 DCR3 = 0x00000000
 DCR4 = 0x00000000
 SR = 0x00000000
 FCR = 0x00000000
 DLR = 0x00000017
 AR = 0x000000E8
 DR = 0x00000000
 PSMKR = 0x00000000
 PSMAR = 0x00000000
 PIR = 0x00000000
 CCR = 0x01002101
 TCR = 0x10000008
 IR = 0x0000005A
 ABR = 0x00000000
 LPTR = 0x00000000
 WPCCR = 0x00000000
 WPTCR = 0x00000000
 WPIR = 0x00000000
 WPABR = 0x00000000
 WCCR = 0x00000000
 WTCR = 0x00000000
 WIR = 0x00000000
 WABR = 0x00000000
 HLCR = 0x00000000
 CALFCR = 0x00120047
 CALMR = 0x00000000
 CALSOR = 0x00120011
 CALSIR = 0x00120011
 XSPI Configuration end


 SFDP::SFDP_BuildGenericDriver
 SFDP::-> flash size: 2^0x1a
 SALXSPI::::PARAM_FLASHSIZE::0x19
 SALXSPI::::PARAM_ADDRESS_4BITS
 SALXSPI::::PARAM_ADDRESS_4BITS
 SALXSPI::::PARAM_PHY_LINK::PHY_LINK_1S8S8S
 SFDP::10 - adjust the frequency if required
 XSPI Configuration start
 XSPI Instance: 0x5200a000
 CR = 0x00000001
 DCR1 = 0x01190300
 DCR2 = 0x00000002
 DCR3 = 0x00000000
 DCR4 = 0x00000000
 SR = 0x00000004
 FCR = 0x00000000
 DLR = 0x00000017
 AR = 0x000000E8
 DR = 0x00000000
 PSMKR = 0x00000000
 PSMAR = 0x00000000
 PIR = 0x00000000
 CCR = 0x00000001
 TCR = 0x10000000
 IR = 0x000000B7
 ABR = 0x00000000
 LPTR = 0x00000000
 WPCCR = 0x00000000
 WPTCR = 0x00000000
 WPIR = 0x00000000
 WPABR = 0x00000000
 WCCR = 0x00000000
 WTCR = 0x00000000
 WIR = 0x00000000
 WABR = 0x00000000
 HLCR = 0x00000000
 CALFCR = 0x00120047
 CALMR = 0x00000000
 CALSOR = 0x00120011
 CALSIR = 0x00120011
 XSPI Configuration end


 SFDP::11 - read again the SFDP header to adjust memory type if necessary
 XSPI Configuration start
 XSPI Instance: 0x5200a000
 CR = 0x00000001
 DCR1 = 0x01190300
 DCR2 = 0x00000002
 DCR3 = 0x00000000
 DCR4 = 0x00000000
 SR = 0x00000004
 FCR = 0x00000000
 DLR = 0x00000017
 AR = 0x000000E8
 DR = 0x00000000
 PSMKR = 0x00000000
 PSMAR = 0x00000000
 PIR = 0x00000000
 CCR = 0x00000001
 TCR = 0x10000000
 IR = 0x000000B7
 ABR = 0x00000000
 LPTR = 0x00000000
 WPCCR = 0x00000000
 WPTCR = 0x00000000
 WPIR = 0x00000000
 WPABR = 0x00000000
 WCCR = 0x00000000
 WTCR = 0x00000000
 WIR = 0x00000000
 WABR = 0x00000000
 HLCR = 0x00000000
 CALFCR = 0x00120047
 CALMR = 0x00000000
 CALSOR = 0x00120011
 CALSIR = 0x00120011
 XSPI Configuration end


 SFDP::SFDP_ReadHeader
 SFDP::SFDP signature::0x0
 SFDP::signature of the header: KO
 SFDP::ERROR::EXTMEM_DRIVER_NOR_SFDP_MEMTYPE_CHECK
 XSPI Configuration start
 XSPI Instance: 0x5200a000
 CR = 0x10000001
 DCR1 = 0x01190300
 DCR2 = 0x00000002
 DCR3 = 0x00000000
 DCR4 = 0x00000000
 SR = 0x00000000
 FCR = 0x00000000
 DLR = 0x00000007
 AR = 0x00000000
 DR = 0x00000000
 PSMKR = 0x00000000
 PSMAR = 0x00000000
 PIR = 0x00000000
 CCR = 0x04003401
 TCR = 0x10000008
 IR = 0x0000005A
 ABR = 0x00000000
 LPTR = 0x00000000
 WPCCR = 0x00000000
 WPTCR = 0x00000000
 WPIR = 0x00000000
 WPABR = 0x00000000
 WCCR = 0x00000000
 WTCR = 0x00000000
 WIR = 0x00000000
 WABR = 0x00000000
 HLCR = 0x00000000
 CALFCR = 0x00120047
 CALMR = 0x00000000
 CALSOR = 0x00120011
 CALSIR = 0x00120011
 XSPI Configuration end


art-pi2 bootloader
booting...

 

ST Employee
August 20, 2025

Hello @totoro ,

Thanks for the dump of registers!

On the second reading of the SFDP signature (step 11), we can see that the memory has been configured in 1S8S8S mode.

By checking the XSPI register, we found the following:

  • IR => 0x5A (Read SFDP command)
  • AR => 0x0 (Address)
  • CCR => 0x04003401
    • DMODE = 1 => Data on one line
    • ADSIZE = 3 => 32-bit address
    • ADMODE = 4 => Address on eight lines
    • ISIZE = 0 => 8-bit instruction
    • IMODE = 1 => Instruction on one line
  • DTR is disabled for Instruction, Address, and Data
  • TCR = 8 => 8 dummy cycles

According to the memory datasheet, the READ SFDP command is only described for standard SPI and octal DDR modes.

Could you try modifying the following line in the function

SAL_XSPI_GetSFDP(SAL_XSPI_ObjectTypeDef *SalXspi, uint32_t Address, uint8_t *Data, uint32_t DataSize) 

if (s_command.AddressMode == HAL_XSPI_ADDRESS_1_LINE)

to

 if ((s_command.AddressMode == HAL_XSPI_ADDRESS_1_LINE) || (s_command.AddressMode == HAL_XSPI_ADDRESS_8_LINES))

Kind regards,