cancel
Showing results for 
Search instead for 
Did you mean: 

MX25L51245G external loader & driver for STM32H7

Emilmart
Senior

Hi everyone,

I'm working on a custom display board with a STM32H7A3ZI MCU. I have the same QSPI Flash than the STM32F769I-DISCO board, which is the MX25L51245G, except that I use the 16 pin package for my custom board. The H7 has an Octospi interface compared to the F7 which has a QSPI interface.

I have set the OSPI interface of my H7 to QSPI mode to have the same board config.

Here's my hardware schematic :

0693W000007EHVvQAO.pngAnd the MCU pinout/config with the OSPI :

0693W000007EHWUQA4.png 

I'm struggling with the external loader and getting the QSPI work. I'm a beginner with QSPI/OSPI flash interfaces.

I tried to follow the external loader ST tutorial, which also contains a simple test in the main file for testing the QSPI/OSPI.

The ST tutorial use the STM32F769I-DISCO board for the example, which is convenient because it use the same QSPI than mine, except that I have the STM32H7 libraries for the octo-spi interface (the example use the F7 HAL libraries, so it uses slightly different structs and HAL functions).

I notice also that the ST example seems to use a different QSPI datasheet than the MX25L51245G because I don't find the same QSPI timings from the video QSPI datasheet screenshots.

Here's what I've done so far, you can also view the steps in the commits of my github repo :

1) On my project with CubeMX, I set the octo-SPI to QSPI mode, with the same parameters used on a random STM32F769I-DISCO TouchGFX template example, except that I have dedicate RESET pin and my QSPI clock is set to 83.5 MHz (with prescaler)

2) I've added the different user code provided by ST on the external loader example for the F7.

3) Of course it does not build because the user code is adapted to the F7 lib and not the H7 lib. So I adapt the code so that it fits the H7 HAL libraries and my OSPI parameters. You can see my modifications on that commit :

https://github.com/pa0694/MX25L512_H7/commit/9f434633947abc7970a04005d134526ebcb2329e

The structs are almost the same between the H7 and the F7, except that on the OSPI_AutoPollingTypeDef there is no StatusBytesSize parameter so I had to comment that. H7 structs also has more parameters for the DtrMode, so I also add theses parameters in my functions.

Also HAL_OSPI_AutoPolling and HAL_OSPI_MemoryMapped functions had less arguments on the H7 than on the F7, but I assume that ST has improved some code.

Well, it’s a bit hard to pinpoint if my edited functions are correct, but at the end it build correctly.

Thought, the debug fails here:

0693W000007EHZiQAO.png 0693W000007EHZ9QAO.png 

I wanted to check with you if my config was correct and if I missed something/mistaken somewhere.

I also looked for the ST external loader H7 examples using the MX25LM51245G, adapting it with my QSPI chip and MCU, but it’s a mess.

Thanks!

8 REPLIES 8
PChia.2237
Senior

Hi,

have yuo solve?

I try to do this with BSP_OSPI_NOR pack from STM32H735G-DK.

PChia.2237
Senior

I have solve working in SPI and STR.

Loader files are here: https://github.com/STMicroelectronics/stm32-external-loader

sorry no I moved to the MX66LM1G45GXDI00

Freedom_Neo
Senior

I have similar problems. How do yuo solved this problem?

I am using below development tools

MCU: STM32H7B3IIT6

IDE: STM32CubeIDE Version: 1.8.0

GUI: TouchGFX Version: 4.18.1

SDRAM: IS45S16800F-7CTLA1-TR

FLASH: MX25LM51245GMI00

I work on external FLASH. Because I have few pins I use QSPI, I am not use OSPI. STM32H7B3-DK develeopment board use OSPI it connected MX25U51245GMI00. There is OSPI example but dont have QSPI. How can I adapt the OSPI example made with MX25U51245GMI00 to QSPI.

PChia.2237
Senior

Hi,

my micro has OSPI. I not use OctoSPI but i use only single SPI.

BPS from STM32H735G-DK

Importat difference is this:

ospi_nor_int.InterfaceMode = BSP_OSPI_NOR_SPI_MODE;//SPI not qspi!!

ospi_nor_int.TransferRate = BSP_OSPI_NOR_STR_TRANSFER;//single transfer rate!

You need to open and edit BPS files for init Flash in stm32h735g_discovery_ospi.h

This is my code initialization in MAIN:

static void MX_OCTOSPI1_Init(void)

{

 /* USER CODE BEGIN OCTOSPI1_Init 0 */

 BSP_OSPI_NOR_Init_t ospi_nor_int;

 /* USER CODE END OCTOSPI1_Init 0 */

 OSPIM_CfgTypeDef sOspiManagerCfg = {0};

 /* USER CODE BEGIN OCTOSPI1_Init 1 */

 /* USER CODE END OCTOSPI1_Init 1 */

 /* OCTOSPI1 parameter configuration*/

 hospi1.Instance = OCTOSPI1;

 hospi1.Init.FifoThreshold = 4;

 hospi1.Init.DualQuad = HAL_OSPI_DUALQUAD_DISABLE;

 hospi1.Init.MemoryType = HAL_OSPI_MEMTYPE_MACRONIX;

 hospi1.Init.DeviceSize = 32;

 hospi1.Init.ChipSelectHighTime = 2;

 hospi1.Init.FreeRunningClock = HAL_OSPI_FREERUNCLK_DISABLE;

 hospi1.Init.ClockMode = HAL_OSPI_CLOCK_MODE_0;

 hospi1.Init.WrapSize = HAL_OSPI_WRAP_NOT_SUPPORTED;

 hospi1.Init.ClockPrescaler = 2;

 hospi1.Init.SampleShifting = HAL_OSPI_SAMPLE_SHIFTING_NONE;

 hospi1.Init.DelayHoldQuarterCycle = HAL_OSPI_DHQC_DISABLE;

 hospi1.Init.ChipSelectBoundary = 0;

 hospi1.Init.ClkChipSelectHighTime = 0;

 hospi1.Init.DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_BYPASSED;

 hospi1.Init.MaxTran = 0;

 hospi1.Init.Refresh = 0;

 if (HAL_OSPI_Init(&hospi1) != HAL_OK)

 {

  Error_Handler();

 }

 sOspiManagerCfg.ClkPort = 1;

 sOspiManagerCfg.DQSPort = 1;

 sOspiManagerCfg.NCSPort = 1;

 sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;

 sOspiManagerCfg.IOHighPort = HAL_OSPIM_IOPORT_1_HIGH;

 if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK)

 {

  Error_Handler();

 }

 /* USER CODE BEGIN OCTOSPI1_Init 2 */

// HAL_OSPI_DeInit(&hospi1);

 ospi_nor_int.InterfaceMode = BSP_OSPI_NOR_SPI_MODE;

 ospi_nor_int.TransferRate = BSP_OSPI_NOR_STR_TRANSFER;

 BSP_OSPI_NOR_DeInit(0);

 if(BSP_OSPI_NOR_Init(0, &ospi_nor_int) != BSP_ERROR_NONE)

 {

  Error_Handler();

 }

 if(BSP_OSPI_NOR_EnableMemoryMappedMode(0) != BSP_ERROR_NONE)

 {

  Error_Handler();

 }

 /* USER CODE END OCTOSPI1_Init 2 */

}

My flash pin mapping in stm32h735g_discovery_ospi.h

/* Definition for OSPI NOR Pins */

//NCS

#define OSPI_NOR_CS_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOG_CLK_ENABLE()

#define OSPI_NOR_CS_PIN            GPIO_PIN_6

#define OSPI_NOR_CS_GPIO_PORT         GPIOG

#define OSPI_NOR_CS_PIN_AF          GPIO_AF10_OCTOSPIM_P1

//CLK

#define OSPI_NOR_CLK_GPIO_CLK_ENABLE()    __HAL_RCC_GPIOF_CLK_ENABLE()

#define OSPI_NOR_CLK_PIN           GPIO_PIN_10

#define OSPI_NOR_CLK_GPIO_PORT        GPIOF

#define OSPI_NOR_CLK_PIN_AF          GPIO_AF9_OCTOSPIM_P1

//DQS

#define OSPI_NOR_DQS_GPIO_CLK_ENABLE()    __HAL_RCC_GPIOA_CLK_ENABLE()

#define OSPI_NOR_DQS_PIN           GPIO_PIN_1

#define OSPI_NOR_DQS_GPIO_PORT        GPIOA

#define OSPI_NOR_DQS_PIN_AF          GPIO_AF12_OCTOSPIM_P1

//D0

#define OSPI_NOR_D0_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOF_CLK_ENABLE()

#define OSPI_NOR_D0_PIN            GPIO_PIN_8

#define OSPI_NOR_D0_GPIO_PORT         GPIOF

#define OSPI_NOR_D0_PIN_AF          GPIO_AF10_OCTOSPIM_P1

//D1

#define OSPI_NOR_D1_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOF_CLK_ENABLE()

#define OSPI_NOR_D1_PIN            GPIO_PIN_9

#define OSPI_NOR_D1_GPIO_PORT         GPIOF

#define OSPI_NOR_D1_PIN_AF          GPIO_AF10_OCTOSPIM_P1

//D2

#define OSPI_NOR_D2_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOE_CLK_ENABLE()

#define OSPI_NOR_D2_PIN            GPIO_PIN_2

#define OSPI_NOR_D2_GPIO_PORT         GPIOE

#define OSPI_NOR_D2_PIN_AF          GPIO_AF9_OCTOSPIM_P1

//D3

#define OSPI_NOR_D3_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOF_CLK_ENABLE()

#define OSPI_NOR_D3_PIN            GPIO_PIN_6

#define OSPI_NOR_D3_GPIO_PORT         GPIOF

#define OSPI_NOR_D3_PIN_AF          GPIO_AF10_OCTOSPIM_P1

//D4

#define OSPI_NOR_D4_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOE_CLK_ENABLE()

#define OSPI_NOR_D4_PIN            GPIO_PIN_7

#define OSPI_NOR_D4_GPIO_PORT         GPIOE

#define OSPI_NOR_D4_PIN_AF          GPIO_AF10_OCTOSPIM_P1

//D5

#define OSPI_NOR_D5_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOC_CLK_ENABLE()

#define OSPI_NOR_D5_PIN            GPIO_PIN_2

#define OSPI_NOR_D5_GPIO_PORT         GPIOC

#define OSPI_NOR_D5_PIN_AF          GPIO_AF4_OCTOSPIM_P1

//D6

#define OSPI_NOR_D6_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOC_CLK_ENABLE()

#define OSPI_NOR_D6_PIN            GPIO_PIN_3

#define OSPI_NOR_D6_GPIO_PORT         GPIOC

#define OSPI_NOR_D6_PIN_AF          GPIO_AF4_OCTOSPIM_P1

//D7

#define OSPI_NOR_D7_GPIO_CLK_ENABLE()     __HAL_RCC_GPIOE_CLK_ENABLE()

#define OSPI_NOR_D7_PIN            GPIO_PIN_10

#define OSPI_NOR_D7_GPIO_PORT         GPIOE

#define OSPI_NOR_D7_PIN_AF          GPIO_AF10_OCTOSPIM_P1

Hi hope this help you

Freedom_Neo
Senior

Hi,

I use 4 pins below like this photo

0693W00000Kb8B1QAJ.png

Freedom_Neo
Senior

Hi Everyone, I need your help.

I have similar problems. How do yuo solved this problem?

I am using below development tools

MCU: STM32H7B3IIT6

IDE: STM32CubeIDE Version: 1.8.0

GUI: TouchGFX Version: 4.18.1

SDRAM: IS45S16800F-7CTLA1-TR

FLASH: MX25LM51245GMI00

I work on external FLASH. Because I have few pins I use QSPI, I am not use OSPI. STM32H7B3-DK develeopment board use OSPI it connected MX25U51245GMI00. There is OSPI example but dont have QSPI. How can I adapt the OSPI example made with MX25U51245GMI00 to QSPI.

PChia.2237
Senior

Hi,

i am not super expert, but in my opinion you need to connect I/O0 to communicate with the device in single SPI