AnsweredAssumed Answered

MPC5748G bootloader to application jump issue

Question asked by prasad choramale on Sep 12, 2019
Latest reply on Sep 16, 2019 by prasad choramale

I am developing serial Bootloader for MPC57485G. flow of the the process is simple ,after every power on controller goes to bootloader code waits for 1sec to receive an file over serial uart. If the new file is received than its writes the file to application area and after completing its jump to application code. If file is not received than its directly jump to
existing application code.My application is simple of LED toggling.

 

I have divided flash in following manner and have made 2 separate projects for bootloader and application files of same
is also attached .

 

/*BOOTLOADER*/


SRAM_SIZE = 256K;
/* Define SRAM Base Address */
SRAM_BASE_ADDR = 0x40000000;

MEMORY
{

flash_rchw : org = 0x00FA0000, len = 0x4
cpu0_reset_vec : org = 0x00FA0000+0x10, len = 0x4
cpu1_reset_vec : org = 0x00FA0000+0x14, len = 0x4
cpu2_reset_vec : org = 0x00FA0000+0x04, len = 0x4

m_text : org = 0x014C0000, len = 256K
m_vectors_ram : org = 0x40000000, len = 0xC00
m_data : org = 0x40000000+0xC00, len = 256K-0xC00
}


/*APPLICATION*/

 

SRAM_SIZE = 256K;
/* Define SRAM Base Address */
SRAM_BASE_ADDR = 0x40000000;

MEMORY
{

flash_rchw : org = 0x00FA4000, len = 0x4
cpu0_reset_vec : org = 0x00FA4000+0x10, len = 0x4
cpu1_reset_vec : org = 0x00FA4000+0x14, len = 0x4
cpu2_reset_vec : org = 0x00FA4000+0x04, len = 0x4

m_text : org = 0x01000000, len = 4800K
m_vectors_ram : org = 0x40000000, len = 0xC00
m_data : org = 0x40000000+0xC00, len = 256K-0xC00
}


I have used following asm code to jump to application code
//Jump to app address 0x01000000
asm("e_lis %r12,0x0100");
asm("e_or2i %r12,0x0000");
asm("mtlr %r12");
asm("se_blrl");



I am using S32 IDE and MPC57485G Devkit board for development purpose and open SDA is used for debugging.
I have loaded both app and bootloader together by giving bootloader elf object file reference in application code.

 

I am facing an issue that whenever i make execution jump from bootloader to application its take some time to configure
the core clock in application and whenever I try to configure any other module like uart it goes in hard fault(IVOR6_handler) and remains there only refer below image for details and highlighted code from where its goes to IVOR6_handler. Same is the case whenever I initialize any other module .

 


However if i removes all modules from application and just keep clock and pin initialization ,though it take some time to
configure clock here also but application work as expected

Also i have following queries
1.Is there any restriction that clock speed for the core must me same in both bootloader and application code because
i need to re initialize complete controller altogether in different manner in application.
2.Is there any mandatory housekeeping work(like resting some important registers,modules etc ) need to done before
jumping to application.If there is anything please let me know any reference for the same.
3.Is it mandatory to divide ram also for this kind of use case if yes than any reference to do it will be really helpful
4.Is method in which flash is divided is correct

Outcomes