Hello Carlos,
Thanks for engaging to help.
"the bin blob contains the stack pointer (SP) at the beginning of the file (offset 0), and the program counter (PC) info at offset 4."
What I mean is, the _desired_ or target SP and PC values for this specific application code I build to be loaded by M4.
"...Not exactly, when M4 boots, the program Counter has reset value of 0x0, so it looks in this address and it will find the Vectors Table .."
Yes. On p. 1060 of Vybrid manual, Sec. 8.4.2 describes, that for M4 the first two words of the exception vector table are remapped by Hw to 0x00016000 and 0x00016004. This is the location of the default SP, and PC respectively. The core, by default, boots from ROM as mentioned on that page.
Looking at those addresses after the module reset, on my SoC at least, the 0x00016000 (SP) has value 0x3f07ffb4 - end of OCRAM - sysRAM1 - while 0x00016004 (PC) contains 0x0000f4b9 - in Boot ROM, as expected. So those are the values good for whatever the default M4 boot code is to do.
Thus after reset, it's the Boot ROM code that runs first, with no initial idea of my application needed SP and PC values.
(And for my MQX based example, my SP is very, very very far off the Boot ROM's code SP value. As per my example above, my SP is in 0x1f807ef0, MQX linking script sets it to CM4 TCML area)
On p.990 of Vybrid manual, sec. 7.5.11 Running Secondary Core, it says:
" ... The Boot ROM code checks the validity of the application entry address pointed to by SRC_GPR2 and, if valid, jumps to that address"
So the Boot ROM code jumps to whatever I've set as entry point into the application in the SRC_GPR2 register. How if at all the Boot ROM code gets the new SP value for the application code...?
( I know it's somehow obvious, but I don't see it :smileysad: )
Per my previous example, the app entry point is 0x3f00ca89 (in my case matching MQX's __boot function). That's the value set into SRC_GPR2. App also needs it's initial SP value (in my case 0x1f807ef0, per previous example, that's MQX's __BOOT_STACK_ADDRESS).
If the app binary - of the format as per my example, where first 4 bytes contain value for SP, and next 4 bytes value for app's entry point PC - got loaded into memory at 0x3f000000, then initial SP value to be fetched is from address 0x3f000000.
So how is that SP value fetched from there? (If it's Boot ROM code's job, it only knows where app entry (which by the App note I assume is the app's entry point / PC value) to jump to. .. Does it assume the initial vector table must be at the beginning of SysRAM0 based on app entry point given in SRC_GPR2 .... ? )
Thanks in advance.. Cheers.
(I Do feel a bit stupid by asking about this, but I rather have this cleared out in my head with someone's help, then not to ask and have an incomplete picture of how this works .)