2023-10-23 12:13 PM - edited 2023-10-23 12:14 PM
Hi,
I need the project used to generate the external loader: MX25LM51245G_STM32H573I-DK.stldr. My custom board uses a STM32H563VIT6 and the same octo-spi flash from Macronix used in the STM32H573I-DK board. But with different gpios connections. So this project would be of great help to develop the external flash loader for my board.
Ari
2024-07-27 10:51 PM
Hello!
i have followed your advise , i have instrumented with UART
i found someting really strange to me:
the problem occours in this piece of code (that work without problem in the main):
2024-07-28 12:39 AM
Make sure hospi1 structure has the instance defined, there is not static initialization in loaders. Perhaps Hard Faulting or delays not working
2024-07-29 10:39 PM
Hi!
you were right!
the problem was the call to the HAL_XSPI_DeInit(&hospi1) before the call to MX_OCTOSPI1_Init()!
its not possible to just remove the HAL_XSPI_DeInit(&hospi1), because during the sectors erase the init is called before each sector erase by the st programmer
so i use this method:
now i am able to read an sector erase the external memory!!!
but not to write....
the write function is called multiple times.. but only the first is going OK
2024-07-30 01:53 AM
found the issue..
the HAL_XSPI_Abort(&hospi1) if don't have anything to abort return an error..
hospi->ErrorCode = HAL_OSPI_ERROR_INVALID_SEQUENCE;
the first time we call it the memory is in memory mapped mode.. so it is necessary and it work.. the second time it is not necessary and return error..
i have added a check on the status of the periferal before call the abort function and added the function that enable memory mapped mode at the end of the write (i do'n know if is necessary the last call of the write)..
so .. only the chip erase now is missing (its optional)
2024-07-30 06:52 AM
finally all is working!
the chip erase was a problem of timeout , the default autopolling have HAL_XSPI_TIMEOUT_DEFAULT_VALUE for timeout that is 5s, my memory have a typical erasing time of 140s to max 200s so i have increased the value to 200s and now its working!
i have tried to remove the offset to RAM (xrw) : ORIGIN = 0x20003004, LENGTH = 256K - 12292 but its actually necessary .. i think only ST could explain why!
i attache to this comment my working linker file and loader_src.c
thank you to everyone for the really precious advise!
2024-07-30 10:00 AM
Yes, the 0x20003004 needs a bit more documentation from ST, but is what other working H5 loaders use.
The +4 offset comes from the fact that ST stuffs opcodes at +0 to call the entry point functions, ie Init(), Read(), etc.
/**
* @brief Initializes the QSPI interface.
* @retval QSPI memory status
*/
static uint8_t BSP_XSPI_Init(XSPI_HandleTypeDef *hospi)
{
//memset(hospi, 0, sizeof(XSPI_HandleTypeDef));
hospi->Instance = OCTOSPI1; // For DeInit to bite on
/* Call the DeInit function to reset the driver */
if (HAL_XSPI_DeInit(hospi) != HAL_OK)
{
return(XSPI_ERROR);
}
/* System level initialization */
BSP_XSPI_MspInit(hospi, NULL);
/* OSPI initialization */
hospi->Init.FifoThresholdByte = 1; // 1..32 Interrupt threshold
...