2019-01-16 05:45 AM
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,
2019-01-16 06:44 AM
I may precise, as it can help that If I do a breakpoint before calling the function, and execute step by step for a while after returning in my main application, there is no problem at all. But in Debug but in Run mode, with no breakpoint, it freeze the OS. However, I have interruption on GPIO that toggle an LED when button is pressed, and this is still working. So the code is not just nowhere. While halting the app when frozen, I am cycling in the xTaskIncrementTick() function of the tasks.c OS file.
Here is the Stack at this step:
xTaskIncrementTick() at tasks.c:2 596 0x90a23904
xPortSysTickHandler() at port.c:492 0x90a24d18
osSystickHandler() at cmsis_os.c:1 415 0x90a25122
SysTick_Handler() at BoardConfiguration.cpp:39 0x90a21b0c
<signal handler called>() at 0xfffffffd
prvPortStartFirstTask() at port.c:288 0x90a24b00
xPortStartScheduler() at port.c:374 0x90a24bb2
ucHeap() at 0x24010cf0
2024-07-03 05:04 AM
Hello @SBACO
Currently I am using STM32F746 Discovery board and am able to use TouchGFX along with FreeRTOS. I would like to execute my application from the external flash using XIP. Currently I am storing my application in the internal flash.
Will you please guide me how to do so, or can you provide some guiding material to use XIP with FreeRTOS.
Thanks in advance!!!
Regards,
Pitbull
2024-07-03 05:27 AM
Suspect you can find White Papers and Videos if you need such..
You can't Write in XIP mode, you have to Abort out of Memory Mapped Mode to enter Command Mode to write to the memory. There's a speed/function asymmetry with read/write, as read is used most and critical to run fast, the erase/write processes are orders of magnitude slower.
2024-07-11 03:50 AM
Hello @Tesla DeLorean,
Thankyou for the support and guiding me.
I am now able to execute code in external memory both with and without FreeRTOS. But currently I have just implemented basic testing functionality which includes GPIO pin toggling and UART data transfer in the application side. I want to use TouchGFX along with FreeRTOS in the application side and for that I will also be using External SDRAM for framebuffer. Coming to my question, can I use internal SRAM for data and external SDRAM for framebuffer while I am using qspi in memory mapped mode for code storing and executing in place.
Please correct me if I am saying anything wrong, consider me beginner in this embedded field and please guide me accordingly.
Thankyou once again.
Regards,
Pitbull
2024-07-11 05:31 AM
You can use QSPI and FMC peripherals independently and concurrently. Content from QSPI FLASH can be moved to SDRAM at startup. You'd need to bring up the memory interfaces up prior to the copying in startup.s
2024-07-28 09:39 PM - edited 2024-07-29 08:42 PM
Hello @Tesla DeLorean
First of all thankyou for your help. I am now able to run my whole application from QSPI using XIP mode along with touchGFX and FreeRTOS. But I haven't initialized the SDRAM interface in the startup file but in main that is using the HAL APIs. The problem I am facing right now is that the executing from qspi is little slow (screen rendering is a little slow) and not as smooth as from the internal flash. Will initializing the SDRAM at startup help in this or is there any other approach that I should follow.
How did you know the following " You'd need to bring up the memory interfaces up prior to the copying in startup.s" means through experience or is their any documentation? Sorry to ask such a question but I really want to know to develop myself in this field.
Thankyou once again for your support.
Regards,
Pitbull