MPC5744P Bootloader Address Jump Code

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MPC5744P Bootloader Address Jump Code

Jump to solution
4,129 Views
jiajiawu
Contributor II

We developed a bootloader program to download application program to the MPC5744P.

The application program is generated by S32DS. The linker file is the default one, as follows:

MEMORY
{
flash_rchw : org = 0x00FA0000, len = 0x4
cpu0_reset_vec : org = 0x00FA0004, len = 0x4
m_text : org = 0x01000000, len = 2048K
m_data : org = 0x40000000, len = 384K
int_dram : org = 0x50800000, len = 64K
}

 

The bootloader program linker file was modified as follows:

MEMORY
{

flash_rchw : org = 0x00F98000, len = 0x4
cpu0_reset_vec : org = 0x00F98004, len = 0x4
m_text : org = 0x00F98008, len = 32K-8
m_data : org = 0x40000000, len = 384K
int_dram : org = 0x50800000, len = 64K
}

 

The bootloader program used the address jump code as follows:

__asm__(" e_lis %r3, 0x00FA");
__asm__(" e_ori %r3,%r3,0x0004");
__asm__(" se_mtlr %r3");
__asm__(" se_blr");

 

But now the address jump fails. Once the bootloader program executes the address jump code, it collapses.

I want to know:

1) Is my address jump code correct? Can you give me the correct address jump code?

2) Is my jump address correct? Can you give me the correct jump address?

3) Why the bootloader program collapses? 

4) What shuould I do to fix the probrom?

 

PS:

1) I didn't modify the Startup_Code file startup.S, both the bootloader program and the application program use the default Startup_Code file generated by S32DS.

2) The address jump code is called in the main(), before the address jump code, there's no other initialization operation.

3) The application program is programed correctly, it can work independently.

4) We use the similar method on other MCUs such as MPC5554, MPC5634, it works correctly. But it failed on MPC5744P.

 

Thank you very much.

Labels (1)
1 Solution
2,307 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

you need to load the value which is at 0x00FA_0004 to link register, not the value 0x00FA_0004 itself.

For example:

    ;load address of reset vector to r12
    e_lis    r12,0x00FA
    e_or2i    r12,0x0004

    ;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

View solution in original post

0 Kudos
Reply
9 Replies
2,307 Views
my_souls
Contributor III

Hello, my application writes to the flash via the boot loader, but the jump application fails;
The following is the relevant code, how can we successfully jump to the application?

The application program linker file was modified as follows:

MEMORY
{

              
    flash_rchw : org = 0x00FB0000,   len = 0x4

                cpu0_reset_vec : org = 0x00FB0004,   len = 0x4
                m_text : org = 0x1100000, len = 256K  
                m_data : org = 0x40000000,   len = 384K
                int_dram  : org = 0x50800000,   len = 64K    

}

 

The bootloader program linker file was modified as follows:

MEMORY
{

  flash_rchw : org = 0x00FA0000,   len = 0x4

                cpu0_reset_vec : org = 0x00FA0004,   len = 0x4
                m_text : org = 0x1000000, len = 256K  
                m_data : org = 0x40000000,   len = 384K
                int_dram  : org = 0x50800000,   len = 64K    


}

 

The bootloader program used the address jump code as follows:

asm("e_lis %r12,0x00FB");

asm("e_or2i %r12,0x0004");
asm("e_lwz %r0,0(%r12)");
asm("se_mtlr %r0");
asm("se_blrl");

Thank you!

0 Kudos
Reply
2,307 Views
dennisyuan
Contributor III

HI Jiajia Wu,

I have a question about bootloader download the program in MPC5634 .

How to erase and write the flash memory which is  the same bank with bootloader ?

thank you !

Regards,

Dennis Yuan

0 Kudos
Reply
2,307 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,

Ok, could you show me your jump address at 0xF98004?

It must looks like:

pastedImage_1.png

Otherwise you code wont after reset jump to your application.

Peter

0 Kudos
Reply
2,307 Views
jiajiawu
Contributor II

Hi Peter:

The bootloader program at 0Xf98004 is as follows:

pastedImage_1.png

The application program at 0XF98004 is as follows:

pastedImage_2.png

Thank you for your reply.

0 Kudos
Reply
2,307 Views
petervlna
NXP TechSupport
NXP TechSupport

Hi,

from your screenshot I see following:

1. Bootloader

SSCM module will find valid RCHW located on address 0xF98000 and the start address at 0xF98400.

First executed instruction after reset is located on address 0xF98400.

If you set debugger breakpoint there, the code will stop on this first instruction.

2. Application

There is no valid RCHW on address 0xF98000.

SSCM won't find valid RCHW and will put device into serial boot mode.

No execution of application is done.

Conclusion:

Make sure you have valid RCHW on bootable addresses and valid pointer to first instruction to be executed.

Like you have in case of bootloader screenshot.

Peter

0 Kudos
Reply
2,307 Views
jiajiawu
Contributor II

Hi Peter:

Our application program is located on address 0XFA0000, as follows:

pastedImage_1.png

So we use the address jump code in the bootloader program as follows:

__asm__(" e_lis %r3, 0x00FA");
__asm__(" e_ori %r3,%r3,0x0004");
__asm__(" se_mtlr %r3");
__asm__(" se_blr");

But the address jump fails. Once the bootloader program executes the address jump code, it collapses.

Thank you for your reply.

0 Kudos
Reply
2,308 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

you need to load the value which is at 0x00FA_0004 to link register, not the value 0x00FA_0004 itself.

For example:

    ;load address of reset vector to r12
    e_lis    r12,0x00FA
    e_or2i    r12,0x0004

    ;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

0 Kudos
Reply
2,307 Views
jiajiawu
Contributor II

Hi Lukas:

I think you are right.

Thank you very much.

0 Kudos
Reply
2,307 Views
petervlna
NXP TechSupport
NXP TechSupport

I am not sure if I understand you.

But I will explain you how SSCM module works.

1. apply power supply.

2. SSCM search for valid RCHW

3. first valid RCHW found is processed by SSCM HW.

4. on address offset 0x4 from first valid RCHW must be located address pointing to first application instruction.

5. SSCM force micro to jump on address on 0x4h offset from valid RCHW location.

All this is done by HW!

Peter

0 Kudos
Reply