1] In the source code file main.c what is the idea behind to check the Flash if it is already programmed.How do we know that this value will always be 0x20000000 for any software? Is this related with compiler?
2] When I do debugging I can see that the function pointer points to 0x08002121 Why? it should point to 0x08000004 (Application address + 4) .
Looks like first compiler gets the value from address 0x08000004
and jumps to the that value not the application address(0x8002000)
what's the idea to read the value from address (Application address + 4) and execute the code from that location.
The idea here is just an tutorial example to check if this new vector table base offset, which contains the Stack Pointer, is really a valid address in the phyiscal RAM or not ?
/* Test if user code is programmed starting from address "ApplicationAddress" */
if( ( (*(vu32*)ApplicationAddress) & 0x2FFF0000 ) == 0x20000000 )
/* Jump to user application */
if( ( (*(vu32*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000 )
max. ram address is 0x2000FFFF (64 KB) and the initial stack pointer can point to 0x20010000.
Retrieving data ...