HAL Delay function Stalls Code in External QSPI Flash (STM32), Custom Delay Works
I'm working on an STM32 project where I'm jumping to code in external QSPI flash (address 0x90000000) after booting from internal flash. I've configured the QSPI memory-mapped mode correctly, and the jump to the external flash works. The interrupt vector table is set up at the beginning of my external flash memory, and the linker script is configured to place the code in external flash, with VTOR set to the start of external flash memory. The MPU is currently disabled.
When the code is running from external flash, HAL_Delay() causes my program to stall. However, if I replace HAL_Delay() with a simple custom delay loop, the code runs correctly. This strongly indicates that there is an issue with how HAL_Delay() is interacting with the hardware or the HAL itself when the code is running from external memory. I've verified that the clock settings are consistent in both internal and external flash.
I need help in understanding what could be causing HAL_Delay() to cause the code to get stuck, while a custom delay works perfectly. What are the most likely points of failure in my startup code, in how the HAL is initialized, or in any low level settings that might be preventing HAL_Delay() from functioning correctly when code is running in external flash? Any advice would be greatly appreciated.
