cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F746NGH6 Discovery + MT25QL128 QSPI External Flash Init Failing (HAL Error)

Midhul_Pk
Associate II

I’m currently working with the STM32F746NGH6 Discovery Kit and trying to interface it with the MT25QL128 NOR Flash via the QUADSPI interface, with the goal of creating an external flash loader.

I’m using the official STMicroelectronics driver from GitHub:  https://github.com/STMicroelectronics/stm32-external-loader/tree/896df94da5fa6dc3532d302c8f942f40bdb22bd1/QSPI_Drivers/MT25QL128AMT25QL128A QSPI Driver – ST GitHub

I’ve tried using this code  without any changes.   

When I run my project, the CSP_QUADSPI_Init() function always returns HAL_ERROR.
As a result, the flash operations like erase, write, and memory-mapped access do not execute.

I’ve confirmed this by adding debug messages through UART – the initialization fails right at the start.

#define SECTORS_COUNT 100
#define MEMORY_SECTOR_SIZE 4096 // or as per your flash config

uint8_t buffer_test[MEMORY_SECTOR_SIZE];
uint32_t var = 0;
unsigned char DisplayBuffer[100];

if (CSP_QUADSPI_Init() != HAL_OK)
{
    sprintf((char*) DisplayBuffer,"Init Error\n\r");
    HAL_UART_Transmit(&huart6, DisplayBuffer, strlen((const char*) DisplayBuffer), 100);
}
else
{
    sprintf((char*) DisplayBuffer,"Init Done\n\r");
    HAL_UART_Transmit(&huart6, DisplayBuffer, strlen((const char*) DisplayBuffer), 100);
}

for (var = 0; var < MEMORY_SECTOR_SIZE; var++)
{
    buffer_test[var] = (var & 0xff);
}

for (var = 0; var < SECTORS_COUNT; var++)
{
    if (CSP_QSPI_EraseSector(var * MEMORY_SECTOR_SIZE, (var + 1) * MEMORY_SECTOR_SIZE - 1) != HAL_OK)
    {
        while(1); // breakpoint - error
    }

    if (CSP_QSPI_WriteMemory(buffer_test, var * MEMORY_SECTOR_SIZE, sizeof(buffer_test)) != HAL_OK)
    {
        while(1); // breakpoint - error
    }
}

if (CSP_QSPI_EnableMemoryMappedMode() != HAL_OK)
{
    while(1); // breakpoint - error
}

for (var = 0; var < SECTORS_COUNT; var++)
{
    if (memcmp(buffer_test, (uint8_t*)(0x90000000 + var * MEMORY_SECTOR_SIZE), MEMORY_SECTOR_SIZE) != 0)
    {
        while(1); // error - data mismatch
    }
}

sprintf((char*) DisplayBuffer,"TEST OKAY\n\r");
HAL_UART_Transmit(&huart6, DisplayBuffer, strlen((const char*) DisplayBuffer), 100);

 

  • Has anyone successfully used the MT25QL128 with the STM32F746 Discovery board

  • Are there any known issues or adjustments needed when using the GitHub reference driver?

  • Could this be related to QSPI timing or clock configuration?

  • Is an explicit command like enter quad mode required before initialization?

 

I'd really appreciate any pointers or suggestions from those who’ve worked with similar setups.

Thanks in advance!

Best regards,
Midhul    Screenshot 2025-07-07 160216.pngScreenshot 2025-07-07 160225.pngScreenshot 2025-07-07 160236.png

1 REPLY 1
Saket_Om
ST Employee

Hello @Midhul_Pk 

Please refer to this example below:

STM32CubeH7/Projects/STM32H745I-DISCO/Examples/QSPI/QSPI_MemoryMappedDual at master · STMicroelectronics/STM32CubeH7 · GitHub

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Saket_Om