2019-11-07 12:34 PM
2020-01-02 06:48 AM
Hi Ego,
I have HAL_Delay in my final working code. below is MCU_Init() in main.c. You don't need Enter4ByteAddressMode() if you are not using 4-byte Addr mode.
/* USER CODE BEGIN 4 */
uint8_t MCU_Init(uint8_t memMappedMode) {
SystemInit();
memset(&hqspi, 0, sizeof(hqspi));
hqspi.Instance = QUADSPI;
HAL_Init();
MX_GPIO_Init();
SystemClock_Config();
//prepare QSPI peripheral for ST-Link Utility operations
if (HAL_QSPI_DeInit(&hqspi) != HAL_OK) {
return HAL_ERROR;
}
MX_QUADSPI_Init();
if (QSPI_ResetChip() != HAL_OK)
return HAL_ERROR;
HAL_Delay(1);
if (QSPI_AutoPollingMemReady() != HAL_OK)
return HAL_ERROR;
if (QSPI_WriteEnable() != HAL_OK)
return HAL_ERROR;
if (QSPI_Configuration() != HAL_OK)
return HAL_ERROR;
Enter4ByteAddressMode();
if (memMappedMode != 1) {
if (QSPI_WriteEnable() != HAL_OK)
return HAL_ERROR;
if (QSPI_AutoPollingMemReady() != HAL_OK)
return HAL_ERROR;
if (QSPI_EnableMemoryMappedMode() != HAL_OK)
return HAL_ERROR;
}
return HAL_OK;
}
Check HAL_QSPI_MspInit() (created by CubeMX) to make sure the IO lines are assigned to QSPI correctly for your target.
2020-01-02 07:10 AM
Hi Ego,
is your QSPI chip is exactly the same as the one on Disco board? if not, check the commands for read and write, and change it accordingly in the QSPI read, write functions.
2020-01-02 07:26 AM
Thank you JNguy for getting back to me.
I actually just found the problem now and it was that I used in my original loader project calls to BSP_QSPI_*** from within stm32l496g_discovery_qspi.c, and the problem was that the BSP_QSPI_Init has its own QSPI_MspInit that used the wrong lines setup and override my HAL_QSPI_MspInit that was created by CubeMX and fits my QSPI lines.
In my original project I used one of the samples under STM32CubeProgrammer\bin\ExternalLoader, after I saw your conversation here I was able to trace the source code of the project you used (the F769_discovery_QSPI) but when I built it and try to use the stsldr file it generated I was not able to access the F769 QSPI, I'm not sure I fully understand the structure of it since it uses main and the CubeProgrammer\STLinkUtility does not.
Thanks
2020-01-02 07:47 AM
At the end, you will have two projects in your IDE, one for your normal application, one for the loader for CubeProgrammer\STLinkUtility for the QSPI chip on your target board. The loader project will likely have to change if QSPI chip changes and/or CPU changes and/or QPSI lines change. The loader project uses different entry point, Init(), other than main(). Main.c is still needed in loader project, since definitions of QSPI lines and QSPI functions are in main.c
If your application doesn't need pre-stored data on QSPI chip, such as image for LCD..., then you don't need loader project. Your application can still read/write to QSPI chip.