How do I execute a program previously written in Flash Memory from another program?
Hi all, I'm usina a STM32F479 MCU and I'm tryng to build a software that can write and launch another software located in flash memory.
The idea is that my main program (that handles the update and lanches the other program) shall be located in flash memory at address 0x08000000 (where the MCU starts executing code at power-on) and my child program shall be located at 0x08010000.
Let's call them program A (the main one) and B (the child).
Reading the manual and visiting other posts on the forum I understand that I need to relocate the interrupt vector table, so, in the main() of A i wrote:
int main()
{
SCB->VTOR = 0x08010000; //--relocate interrupt vector tabl
callMainOfProgramB(); //-- Function to jump to 0x08010000
}
In addition to this, i edited the linker script file of A and B with the following:
A: flash starts at 0x08000000, size: 64K
B: flash starts at 0x08010000, size 1984K
The only problem is that if I flash them both at those addresses (I double checked the programming and the memory with STM32CubeProg), I get an hard fault, type Usage fault (INVSTATE) after the jump. The program actually jumps, but there could be something wrong with the code where it jumps to. I don't know what...
Am I missing something? are there other passages that I missed?
Thanks for the help in advance.
