2024-08-16 12:46 AM
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.
Solved! Go to Solution.
2024-09-06 06:10 AM
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;
}
2024-08-16 01:02 AM
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.
2024-08-16 01:08 AM
This is an application project setting.
I think it does not affect. It works on another board.
2024-08-16 01:21 AM
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.
2024-08-16 01:32 AM
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.
2024-08-16 01:59 AM
A simple LED blinking project, it also doesn't load with my bootloader.
And it doesn't load with your bootloader either.
2024-09-06 06:10 AM
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;
}