how to write in QSPI flash while in xip mode with FreeRTOS
Hello,
I am trying to do an OTA upgrade on my STM32H750. I am using QSPI flash in dual mode as the IC does not have so much internal flash for my application. My application is running FreeRTOS and does have a LCD screen. So I build a bootloader to configure the QSPI and then jump to my application located on the external QSPI flash. That is working fine.
Now I need to be able to upgrade the FW. The idea is to download a part of the FW, store it in RAM, jump back to bootloader, unmapped the flash, write the data, remapped the flash and go back to my main application as fast as possible so that the user may not really see it.
The problem I am facing, is that I am stuck when I am back from the function that write the data. The execution continue properly in XIP mode, but not as it was.
for the testing purpose the external function that is suppose to write the data does not do anything for now except returning a value.
#define jumpToInternalFlashFunction_ADDR 0x08018000
typedef int (*pFunction)(void);
pFunction JumpToSpecialApplication;
int InternalFlashFunctionTest()
{
int a;
SCB_DisableICache();
SCB_DisableDCache();
/* Disable Systick interrupt */
HAL_SuspendTick();
// Disable all interrupt
__disable_irq();
// Change for the internal ISR vector (has tick will be required)
SCB->VTOR = FLASH_BANK1_BASE;
/* Initialize user application's Stack Pointer & Jump to user application */
JumpToSpecialApplication = (pFunction) (jumpToInternalFlashFunction_ADDR + 1);
a = JumpToSpecialApplication();
// Restore the system (ISR vector, interrupt, cache, tick)
SCB->VTOR = (QSPI_BASE + 0xA00000);
__enable_irq();
SCB_EnableICache();
SCB_EnableDCache();
HAL_ResumeTick();
return a;
}If I call this function at the begining of my main() in the application, it works fine, execute the function in the internal flash and go back to this application exactly where it was. However, if my HW and the OS is initialized, it does not work properly. when I get back, FreeRTOS seems "lost" and do not call my threads anymore. Maybe because the tick was stopped ? or because I loose some context information ? the Tick does not seems to run anymore.
Hope some of you will be inspired by my problem and may be able to help.
Regards,
