2025-08-14 5:35 AM - edited 2025-08-15 1:05 AM
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...
2025-08-19 6:18 AM
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,
2025-08-20 5:17 AM - edited 2025-08-20 5:40 AM
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.
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...
2025-08-20 8:53 AM - edited 2025-08-20 8:53 AM
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:
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,
2025-08-20 10:01 AM
Hi,
It has been modified to what you said, and there are errors.
EXTMEM_Init
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 = 0x04002401
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...
2025-08-21 3:53 AM
Hello @totoro
Could you please comment out the second reading of the SFDP signature in the EMM driver, as well as the second reading of the ID ?
Kind regards
2025-08-24 9:13 AM
Comment out the second reading of the SFDP signature and the ID in the EMM driver, still can't jump to the app.
EXTMEM_Init
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
EXTMEM_Init
SALXSPI::::CLOCK::0x0
SALXSPI::::PARAM_FLASHSIZE::0x18
SALXSPI::::PARAM_PHY_LINK::PHY_LINK_RAM8
SALXSPI::::PARAM_DUMMY_CYCLES::0x4
SALXSPI::::PARAM_PHY_LINK::PHY_LINK_RAM16
art-pi2 bootloader
booting...
EXTMEM_MemoryMappedMode
EXTMEM_MemoryMappedMode
EXTMEM_GetMapAddress
I transplanted this flash program from somewhere else, into mapping mode.
There are several modifications.
Read Flash ID success:0xef 0x5b 0x1a
Reconfigure Flash clock
Flash Re-Enter Octal DTR and Read ID success:ef 1a 00
Flash XIP success
art-pi2 bootloader
booting...
EXTMEM_GetMapAddress
[info application]Hello main!
Although it is available now, I would like to figure out if there is a bug in the middleware of the STM32_ExtMem_Manager.
The attachment is the whole project.
2025-09-04 7:27 PM
Hello @NesrynELMK
Is there any news on this topic?