Hello,
I have developped a new bootloader for MPC5748G and I use usdhc to mount SD card on bootloader. The problem is when I try to jump application, it does not work, I have tested jump without mouting SD card and it works. It seems usdhc is not well deinitialized.
Here the sequence that I have implemented in my bootloader when usdhc is used:
uSDHC_fatfs_initialize();
status = uSDHC_Init(true);
mountSD(); //is mounted correctly
umountSD(); // is unmounted correctly
uSDHC_DeInit(); // the function is executed correctly
__asm__("e_lis %r12,0x0100");
__asm__("e_or2i %r12,0x0000");
__asm__("mtlr %r12");
__asm__("se_blrl"); // not executed correcly, it seems usdhc is still used.
I have seen in this link https://community.nxp.com/t5/S32-Design-Studio/MPC5748G-bootloader-to-application-jump-issue/m-p/156... that I should reset all peripherals.
How can I do that ?
yes, that's what I recommend to everyone. Either reset the device and jump to the application right after reset (that's the best way) or put everything back to default reset state. The most important is to disable interrupts on all levels - by MSR[EE] bit, by priorities in interrupt controller, by local enable bits in peripherals.
Regards,
Lukas
Hello @lukaszadrapa ,
I have implemented this function in order to jump application after reset, based on your comment click in the link
void AppJump(void)
{
/* Enable e200z4b and e200z2 cores in RUN0-RUN3, DRUN and SAFE modes */
MC_ME->CCTL1 = 0x00FC; /* e200z4a is active */
MC_ME->CCTL2 = 0x00FC; /* e200z4b is active */
MC_ME->CCTL3 = 0x00FC; /* e200z2 is active */
/* Set start address for e200z4b and e200z2 cores */
MC_ME->CADDR1 = (unsigned int)(0x00FA0010) | 0x1;/* e200z4a boot address + RMC bit */
MC_ME->CADDR2 = (unsigned int)(0x00FA0014) | 0x1;/* e200z4b boot address + RMC bit */
MC_ME->CADDR3 = (unsigned int)(0x00FA0004) | 0x1;/* e200z2 boot address + RMC bit */
/* Reset the device to execute user application. Make sure that state
of PA[1] pin is logic 0 (SW3 is not pushed on EVB). */
MC_ME->MCTL = 0x00005AF0; //Functional RESET & Key
MC_ME->MCTL = 0x0000A50F; //Functional RESET & Key
while(MC_ME->GS == 1); /* Wait for mode entry complete */
while(MC_ME->GS != 0x3); /* Check DRUN mode entered */
}
But when it is executed I jump always bootloader. Otherwise how to jump application after reset metionned in your last comment in this discussion "reset the device and jump to the application right after reset (that's the best way) "
Here a part of linker_flash.ld:
/* Entry Point */
ENTRY(_start)
/* define heap and stack size */
__HEAP_SIZE = DEFINED(__heap_size__) ? __heap_size__ : 0x00000000;
__STACK_SIZE = DEFINED(__stack_size__) ? __stack_size__ : 0x00001000;
/* 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;
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 = FLASH_BASE_ADDR, len = FLASH_SIZE
m_data : org = SRAM_BASE_ADDR, len = SRAM_SIZE
}
Regards
It works in different way. My mentioned function only starts other cores. That configuration has no effect if the reset is triggered. In case of reset, standard boot sequence starts – the BAF searches for valid boot header at defined locations. Once valid boot header is found, it stops scanning of other locations and it jumps to reset vector which is found at this boot header. In other words, this leads to execution of the bootloader, so you are facing expected behavior.
Bootloader, which is always started after reset, should make a decision, if an application is started or if it should continue to download new application. What kind of condition do you use for this? Before reset, you should somehow inform the bootloader that application should be executed after reset.
Regards,
Lukas
Hello @lukaszadrapa,
My expectation is to mount sd card and check if we have an srec file if yes we do update otherwise (no srec detected it should jump appication).
Now update is done but I cannot jump to appication using asm code because usdhc :
__asm__("e_lis %r12,0x0100");
__asm__("e_or2i %r12,0x0000");
__asm__("mtlr %r12");
__asm__("se_blrl"); // not executed correcly, it seems usdhc is still used.
And I have tried reset as expained in my last comment and after reset it jump always bootloader.
How can I change jump address to jump before reset ?
well, when you step this code, does R12 contain expected address of entry point of your application? If you step the se_blrl instruction, does it jump to this address?
Regards
Lukas