2018-01-02 08:30 PM
Hi,
i am trying to flash two different codes on same controller at different memory locations, at power-on condition code-1 will be executed, from that code i want to call code-2. i tried below method which is not working (ONLY CODE-1 IS GETTING EXECUTED), can anyone suggest any other method or any modifications needed to this code.
code-1: at memory location 0x8000000
int main (void)
{
fp = (int(*)(void))0x80400000; //Here i am using function pointer to call another code
while(1)
{
printf(' this is code-1 \n');
int (*fp)(void);
}
}
code-2:at memory location 0x8040000
int main (void)
{
printf(' this is code-2 \n');
}
#multiple-codes-on-single-controller #stm32 #flash #stm32f7 #function-pointer2018-01-02 11:03 PM
Hi
faizahmed7799
,I recommend you to have a look to ready examples under the STM32CUBEF7,it may help you to start:
-Nesrine-
2018-01-04 04:31 AM
Is the code actually starting at 0x08040000 or is that the vector table for the secondary image?
Jumping to an EVEN address on an Cortex-M is going to Hard Fault, have a handler that outputs some diagnostics.
Maybe review a manual, or two, on the Cortex-M parts so your understanding of how they work is clearer.
Use a debugger and step the code to understand what happens.
2018-01-04 05:49 AM
The second image can certainly be loaded at 0x8040000 (in either single/dual-bank mode) but as Clive indicated, 0x8040000 will be the vector table. You will need to look at the linker map file to determine where the second main() is located to compute the address to call from the first main().
Do you have the Option Bytes set for dual-bank mode? I assume from the use of address 0x8040000 for the second image that you are using STM32F7 with 512K of flash. If you are interested in dual-bank mode, in addition to the examples code references from Nesrine, look at
.2018-01-04 06:59 AM
...I should have included this
as well. Even though it references STM32L4, most of the information is applicable to STM32F7 as well.