Skip to main content
Visitor II
August 16, 2024
Solved

Problem with STM32H750VBT6 controller with external W25Q128 QSPI memory.

  • August 16, 2024
  • 3 replies
  • 1372 views

Hi Clive.
I am running a project on the STM32H750VBT6 controller with external W25Q128 QSPI memory.
I need to write data to flash. Your bootloader:
https://github.com/cturvey/stm32extldr/blob/main/h7_w25q128/W25Q128_STM32H7XX-CUSTOM27.FLM
didn't work.
I decided to write my own. It works, but strangely. It works at first, then it can stop working
It can be cured by commenting out an unused function or changing the optimization type.
It works for a while, then it stops. And I have 2 identical boards. It works on one,
on the other it doesn't.

I ask for help. I am attaching my project. What could be the problem?
If not, can you fix your bootloader W25Q128_STM32H7XX-CUSTOM27.FLM ?
It doesn't work for me.

cube1.pngcube2.pngkeil_error.png

    This topic has been closed for replies.
    Best answer by Alex777

    The problem was that I tried to deinitialize hspi before initializing it and the application crashed in assert.

    HAL_StatusTypeDef W25Q128_QSPI_SPI_Init(QSPI_HandleTypeDef *hqspi)
    {
    if (HAL_QSPI_DeInit(hqspi) != HAL_OK) // !!!!!!!!!!! here hqspi also has a random value. Sometimes it is NULL.
    return HAL_ERROR;
    if (MX_QUADSPI_Init() != HAL_OK)
    return HAL_ERROR;
    if (W25Q128_QSPI_ResetChip(hqspi) != HAL_OK)
    return HAL_ERROR;
    HAL_Delay(1);
    if (W25Q128_QSPI_Configuration(hqspi) != HAL_OK)
    return HAL_ERROR;
    if (W25Q128_QSPI_AutoPollingMemReady(hqspi) != HAL_OK) return HAL_ERROR;
    return HAL_OK;
    }
    Solution:
    HAL_StatusTypeDef W25Q128_QSPI_SPI_Init(QSPI_HandleTypeDef *hqspi)
    {
    hqspi.Instance = QUADSPI;
    hqspi.Init.ClockPrescaler = 1;
    hqspi.Init.FifoThreshold = 32;
    hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
    hqspi.Init.FlashSize = 23;
    hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE;
    hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
    hqspi.Init.FlashID = QSPI_FLASH_ID_2;
    hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;

    if (DEF_QUADSPI_Init() != HAL_OK)
    return HAL_ERROR;
    if (HAL_QSPI_DeInit(hqspi) != HAL_OK)
    return HAL_ERROR;
    if (HAL_QSPI_Init(hqspi) != HAL_OK)
    return HAL_ERROR;
    if (W25Q128_QSPI_ResetChip(hqspi) != HAL_OK)
    return HAL_ERROR;
    HAL_Delay(1);
    if (W25Q128_QSPI_Configuration(hqspi) != HAL_OK)
    return HAL_ERROR;
    if (W25Q128_QSPI_AutoPollingMemReady(hqspi) != HAL_OK)
    return HAL_ERROR;
    return HAL_OK;
    }

    3 replies

    Graduate II
    August 16, 2024

    How is it building for the 0x30000000 address space? The loaders header describes the 0x90000000 address space which is why Keil complains there's no Flash algorithm associated with it.

    Alex777Author
    Visitor II
    August 16, 2024

    This is an application project setting.

    cube3.png

    I think it does not affect. It works on another board.

     

    Graduate II
    August 16, 2024

    I'll have to check the manual, is it a secondary mapping for the QSPI address space or RAM?

    I can change the mappings in the loaders header, but you should see the current coverage when selecting the Flash Algorithm tab via the debug settings. 

    Alex777Author
    Visitor II
    August 16, 2024

    Addresses 0x300ххххх are secondary mapping for RAM address space for Ethernet and DMA UART buffers. Keil just complains that there are no algorithms for writing to RAM.
    It doesn't matter. I'm sewing the project from address 0x90000000. And it will work when the application is already launched from address 0x90000000.

    Alex777Author
    Visitor II
    August 16, 2024

    A simple LED blinking project, it also doesn't load with my bootloader.

    keil_1.pngkeil_2.pngkeil_3.png

     

     

     


    And it doesn't load with your bootloader either.

    keil_4.pngkeil_5.png

    Alex777AuthorAnswer
    Visitor II
    September 6, 2024

    The problem was that I tried to deinitialize hspi before initializing it and the application crashed in assert.

    HAL_StatusTypeDef W25Q128_QSPI_SPI_Init(QSPI_HandleTypeDef *hqspi)
    {
    if (HAL_QSPI_DeInit(hqspi) != HAL_OK) // !!!!!!!!!!! here hqspi also has a random value. Sometimes it is NULL.
    return HAL_ERROR;
    if (MX_QUADSPI_Init() != HAL_OK)
    return HAL_ERROR;
    if (W25Q128_QSPI_ResetChip(hqspi) != HAL_OK)
    return HAL_ERROR;
    HAL_Delay(1);
    if (W25Q128_QSPI_Configuration(hqspi) != HAL_OK)
    return HAL_ERROR;
    if (W25Q128_QSPI_AutoPollingMemReady(hqspi) != HAL_OK) return HAL_ERROR;
    return HAL_OK;
    }
    Solution:
    HAL_StatusTypeDef W25Q128_QSPI_SPI_Init(QSPI_HandleTypeDef *hqspi)
    {
    hqspi.Instance = QUADSPI;
    hqspi.Init.ClockPrescaler = 1;
    hqspi.Init.FifoThreshold = 32;
    hqspi.Init.SampleShifting = QSPI_SAMPLE_SHIFTING_NONE;
    hqspi.Init.FlashSize = 23;
    hqspi.Init.ChipSelectHighTime = QSPI_CS_HIGH_TIME_1_CYCLE;
    hqspi.Init.ClockMode = QSPI_CLOCK_MODE_0;
    hqspi.Init.FlashID = QSPI_FLASH_ID_2;
    hqspi.Init.DualFlash = QSPI_DUALFLASH_DISABLE;

    if (DEF_QUADSPI_Init() != HAL_OK)
    return HAL_ERROR;
    if (HAL_QSPI_DeInit(hqspi) != HAL_OK)
    return HAL_ERROR;
    if (HAL_QSPI_Init(hqspi) != HAL_OK)
    return HAL_ERROR;
    if (W25Q128_QSPI_ResetChip(hqspi) != HAL_OK)
    return HAL_ERROR;
    HAL_Delay(1);
    if (W25Q128_QSPI_Configuration(hqspi) != HAL_OK)
    return HAL_ERROR;
    if (W25Q128_QSPI_AutoPollingMemReady(hqspi) != HAL_OK)
    return HAL_ERROR;
    return HAL_OK;
    }