Make MPC5748G Boot Loader Run First

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

Make MPC5748G Boot Loader Run First

926 Views
maharajshreekum
Contributor III

We have developed the MPC5748G serial bootloader which is able to flash the APP at the desired address and also able to execute the APP after jumping to the same.

We are using the default Serial line LINFlexD_UART2 on Devkit for this whole purpose and before jumping to the APP, we are closing the UART line and de-initializing it, so that APP runs smoothly, which is happening.

But, our concern is whenever we press the reset button, it's always the APP that is running first, but not the Bootloader. We want the reverse to happen. We have kept the Bootheader address of BL as 0x00FC0000 and APP as 0x00FA0000 which is searched by BAF where the BL Bootheader comes first (increasing order, high priority)

 

BootLoader linker Setting's :

/* Define FLASH */
FLASH_BASE_ADDR = DEFINED(__flash_base_addr__) ? __flash_base_addr__ : 0x01200000;
FLASH_SIZE = DEFINED(__flash_size__) ? __flash_size__ : 256k;

/* Define SRAM */
SRAM_BASE_ADDR = DEFINED(__sram_base_addr__) ? __sram_base_addr__ : 0x40000000;
SRAM_SIZE = DEFINED(__sram_size__) ? __sram_size__ : 256K;

/* Define RAppID boot data address */
RAPPID_BOOT_APP_DELAY_ADDR = 0x00FC0008;
RAPPID_BOOT_APP_KEY_ADDR = 0x00FC000C;

MEMORY
{
flash_rchw : org = 0x00FC0000, len = 0x4
cpu0_reset_vec : org = 0x00FC0000+0x10, len = 0x4
cpu1_reset_vec : org = 0x00FC0000+0x14, len = 0x4
cpu2_reset_vec : org = 0x00FC0000+0x04, len = 0x4
rappid_boot_data : org = 0x00FC0000+0x08, len = 0x8

m_text : org = FLASH_BASE_ADDR, len = FLASH_SIZE
m_data : org = SRAM_BASE_ADDR, len = SRAM_SIZE
}

 

APP Linker Setting's :

/* Define FLASH */
FLASH_BASE_ADDR = DEFINED(__flash_base_addr__) ? __flash_base_addr__ : 0x01000000;
FLASH_SIZE = DEFINED(__flash_size__) ? __flash_size__ : 1856K;

/* Define SRAM */
SRAM_BASE_ADDR = DEFINED(__sram_base_addr__) ? __sram_base_addr__ : 0x40000000;
SRAM_SIZE = DEFINED(__sram_size__) ? __sram_size__ : 256K;

/* Define RAppID boot data address */
RAPPID_BOOT_APP_DELAY_ADDR = 0x00FA0008;
RAPPID_BOOT_APP_KEY_ADDR = 0x00FA000C;

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
rappid_boot_data : org = 0x00FA0000+0x08, len = 0x8

m_text : org = FLASH_BASE_ADDR, len = FLASH_SIZE
m_data : org = SRAM_BASE_ADDR, len = SRAM_SIZE
}

Where are we doing wrong, it is not clear, we want the Bootloader should run first and then APP,as in the case of normal BL application.

0 Kudos
5 Replies

912 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Hi,

I did quick test to be absolutely sure there's no HW issue and it works as expected. The behavior of the MCU corresponds to the documentation. I placed one boot header at 0xFC0000 and second to 0xFA0000 and I can see that 0xFC0000 is used after reset:

lukaszadrapa_0-1623660038454.png

If this doesn't work, check the boot headers. There's probably something wrong in your project.

Then I saw some mention about Rappid bootloader in your description. Notice that Rappid bootloader does not use the order defined in RM to search valid boot header. It simply search from lowest address of a block to highest:

lukaszadrapa_1-1623660165824.png

Regards,

Lukas

0 Kudos

909 Views
maharajshreekum
Contributor III

We have placed the BL boot header at 0xFC0000 and the application boot header at 0xFA0000. We have also verified it by reading the memory. 

But when we are making the first jump to our app code, the app runs but after subsequent power resets, it always runs the app. Even though we have de-init the UART line and everything.

We are doing jump with below commands,

/*Working Set direct Cmd execute*/
MC_ME->MCTL = 0x00115AF0;
MC_ME->MCTL = 0x0011A50F;
(*(void (*)(void))(*(uint32_t*)0x01000000))();

0 Kudos

899 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

Then it's not a problem of the hardware but it's rather a matter of your software. What can you see in your debugger after reset?

Regards,

Lukas

0 Kudos

891 Views
maharajshreekum
Contributor III

Yes, no issues with the HW. But that's the point, with app image running, there is no going back to bootloader code, since after reset only the app runs.

 

Do we need to erase the boot header or something of the app after it starts running. Maybe the UART line is not allowing the bootloader code to run or something. We read the memory through UART and see the boot headers of both boot loader and app image.

 

DbgConsole_Deinit()..We use this to de-init our uart line before making a jump to the app image.

0 Kudos

880 Views
lukaszadrapa
NXP TechSupport
NXP TechSupport

As I wrote above, I confirmed that the order of possible boot header locations is correct. So, I'm pretty sure that bootloader is executed first. The question is - how do you jump to the application? What is the condition to select if bootloader or application is started?

Regards,

Lukas

0 Kudos