2022-02-07 12:40 AM
Hi,
I build a custom bootloader.
Trying to load app on FreeRTOS and TouchGfx
MCU - STM32H7BIT
The MCU has 2 FLASH banks:
0x08000000 - 1024k
0x08100000 - 1024k
gcc-arm-none-eabi toolchain.
openocd for loading and debuging.
The app works fine when loaded at 0x08000000. FLASH origin.
Next...
Begin Option 1:
-------------------------------------------------- --------------------------------------------------
The application works after loading from the bootloader if stored at 0x08100000.
I do in bootloader:
void Bootloader_JumpToApplication (void)
{
HAL_RCC_DeInit();
HAL_DeInit();
/* Disable SysTick */
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__asm("B 0x0812E700"); // Address obtained from *.map file
// This is the address of Reset_Handler
}
In the application *.ld file
FLASH(rx): ORIGIN=0x08100000, LENGTH=2048K
SCB->VTOR = 0x08100000; By some miracle. Without my participation.
However I do:
SCB->VTOR = 0x08100000; At the very beginning of main(), in the application, just in case.
-------------------------------------------------- --------------------------------------------------
End Option 1:
Begin Option 2:
-------------------------------------------------- --------------------------------------------------
Does not work!
Application downloaded at 0x08060000
In the application *.ld file
FLASH(rx): ORIGIN=0x08060000, LENGTH=2048K
In the bootloader:
void Bootloader_JumpToApplication (void)
{
HAL_RCC_DeInit();
HAL_DeInit();
/* Disable SysTick */
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
__asm("B 0x0808E890"); // Address obtained from *.map file
// This is the address of Reset_Handler
}
SCB->VTOR = 0x08060000; At the very beginning of main(), in the application.
QtCreator memory viewer shows that this measurement value in the SCB->VTOR area is correct.
Application continues to run...
After that, a Hard Fault occurs.
Undefined instruction (UNDEFINSTR)
Invalid function call address 0x58024400 - Very strange address!
XPSR 0x41000003
PC 0x80014FA - Very strange address!
SP 0x2001FFBC
-------------------------------------------------- ----------------------------------
End Option 2:
Begin Option 3:
-------------------------------------------------------------------------------------
If exclude the TouchGfx task from the application, then everything works with any place of the applications.
At the same time, FreeRTOS works:
osThreadDef(touchTask, taskTouch, osPriorityNormal, 0, 128);
touchTaskHandle = osThreadCreate(osThread(touchTask), NULL); // Tracks i2c touchscreen events
osThreadDef(logTask, taskLog, osPriorityNormal, 0, 128); // Send debug strings to UART6
logTaskHandle = osThreadCreate(osThread(logTask), NULL);
I can rewrite all SDRAM by touching the touchscreen.
Screen fill colors change as I conceived and programmed.
UART6 prints my debug lines
-------------------------------------------------------------------------------------
End Option 3:
The problem is in TouchGfx???
Solved! Go to Solution.
2022-02-07 09:55 AM
It seems that the problem was solved by careful selection of smaller stack sizes for FreeRTOS tasks.
Downloads of various applications with a custom loader now work.
2022-02-07 09:55 AM
It seems that the problem was solved by careful selection of smaller stack sizes for FreeRTOS tasks.
Downloads of various applications with a custom loader now work.