Hello,
I am trying to develop a second stage bootloader for the MPC5744P that would perform some checks and then load the actual application and start it. Is there some kind of example that shows how this could be done? Maybe someone already did something similar and can give me some hits.
Also any documentation that could help with this would be great!
Thanks in advance. Cheers!
Solved! Go to Solution.
Hi Vladimir,
program counter can be accessed by means of jump instructions, not directly. There's an example in startup file of the bootloader:
...\AN5319SW.zip\MPC5748G-Serial_Bootloader-GHS614\ghs\tgt\libstartup\crt0.ppc
;if the boot header is valid, execute application
;load address of reset vector to r12
e_lis r12,0x00F9
e_or2i r12,0x4010
;load reset vector to r0
e_lwz r0,0(r12)
;move reset vector to link register
mtlr r0
;branch to address in link register
se_blrl
Regards,
Lukas
Thank you very much for the information. I will check it out!
Hi,
we have this application note written for MPC5748G:
https://www.nxp.com/docs/en/application-note/AN5319.pdf
https://www.nxp.com/docs/en/application-note-software/AN5319SW.zip
However, the principles are still the same, so it can be a nice starting point.
Regards,
Lukas
Hi Lukas,
As I've seen, this application loads the new image over the serial to the flash and then restarts with the new application. In my case, I would like to have the application already on some location in the flash. Then, I would perform some checks in the bootloader and jump to the location of the application to execute it.
I had the idea just to put the address of the application into the program counter register with an assembly command but I haven't been able to find a way to access the program counter. Do you have any idea how to do that?
Cheers,
Vladimir
Hi Vladimir,
program counter can be accessed by means of jump instructions, not directly. There's an example in startup file of the bootloader:
...\AN5319SW.zip\MPC5748G-Serial_Bootloader-GHS614\ghs\tgt\libstartup\crt0.ppc
;if the boot header is valid, execute application
;load address of reset vector to r12
e_lis r12,0x00F9
e_or2i r12,0x4010
;load reset vector to r0
e_lwz r0,0(r12)
;move reset vector to link register
mtlr r0
;branch to address in link register
se_blrl
Regards,
Lukas