Hello Team,
Currently I'm working in bootloader development activity for i.MXRT1064, I received the new firmware image from the file system and write into the internal flash memory. After write the new firmware image, I want jump from custom bootloader to application, custom bootloader's address range from 0x70000000 to 0x70080400, rest of address space allocated for application. I've referred the SDK of mcuboot_opensource source and I took jump to application code from this SDK example, there I've updated the ivt, disabled the vector and I tried to execute jump, but unfortunately it is not happening. Please refer my following jump to application code.
#define APP_VECTOR_TABLE_ADDRESS 0x70080400
#define STACK_POINTER_SIZE 0x20001FFFUL
struct arm_vector_table
{
uint32_t msp;
uint32_t reset;
};
//! @brief Exits bootloader and jumps to the user application.
void jump_to_application(void)
{
/*LED*/
gpio_pin_config_t led_config = {kGPIO_DigitalOutput, 0, kGPIO_NoIntmode};
GPIO_PinInit(GPIO3, 4U, &led_config);
GPIO_PinWrite(GPIO3, 4U, 1U); // 6th LED //
/*LED*/
//Jump Implementation//
PRINTF("\nStart Jump process\n");
__asm volatile ("cpsid i");
SCB_DisableDCache();
vt = (struct arm_vector_table *)(APP_VECTOR_TABLE_ADDRESS);
vt->msp = STACK_POINTER_SIZE;
//cleanup();
SCB_DisableICache();
SCB_DisableDCache();
ARM_MPU_Disable();
DbgConsole_Deinit();
//bspstop();
for (long delay = 0; delay < 1000000; delay++)
{
// Do nothing..
for (long delay1 = 0; delay1 < 1000; delay1++)
{
// Do nothing..
}
}
//!<Experimental part>
//PRINTF("\nBefore VTOR init\n");
// Set the VTOR to the application vector table address.
//SCB->VTOR = (uint32_t *)(0x70080400);
//!<Experiment part>
__set_CONTROL(0);
__set_MSP(vt->msp);
__ISB();
((void (*)(void))vt->reset)();
//Should never print this statement//
PRINTF("\nJUMP SUCCESSFUL\n");
//Jump Implementation - END//
//Boot loader end //
}
Please find the attached application's hex file snap for your reference. Please let me know, what I'm missing in the code and give me solution to jump.
Solved! Go to Solution.
Hi,
Thanks for your reply.
The Jay shared function should be suitable for bare-metal or RTOS software mode.
void mfb_jump_to_application(uint32_t vectorStartAddr)
{
#if MFB_APP_JUMP_ENABLE
mfb_printf("\r\nMFB: Jump to Application code at 0x%x.\r\n", EXAMPLE_FLEXSPI_AMBA_BASE + MFB_APP_IMAGE_OFFSET);
mfb_printf("-------------------------------------\r\n");
static uint32_t s_resetEntry = 0;
static uint32_t s_stackPointer = 0;
s_resetEntry = *(uint32_t *)(vectorStartAddr + 4);
s_stackPointer = *(uint32_t *)vectorStartAddr;
// Turn off interrupts.
__disable_irq();
// Set the VTOR.
SCB->VTOR = vectorStartAddr;
// Memory barriers for good measure.
__ISB();
__DSB();
// Set main stack pointer and process stack pointer.
__set_MSP(s_stackPointer);
__set_PSP(s_stackPointer);
// Jump to application entry point, does not return.
static void (*s_entry)(void) = 0;
s_entry = (void (*)(void))s_resetEntry;
s_entry();
#endif
}
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
Hello Team,
Thanks for your great support, now everything working fine it seems. Keep up your good work.
You can refer to mfb_jump_to_application() function in below source, it is standard implementation. vectorStartAddr arg should be 0x70080400 for your case.
https://github.com/JayHeng/RT-MFB/blob/main/boards/mimxrt/mfb_fw/src/mfb.c
Hello Team,
Thanks for your quick response and support.
The solution which you've given, it is working fine it seems. But here, I'm having one observation, currently we are using RTXC RTOS, I'm not able to jump from custom bootloader to application from the RTXC RTOS. Jump to application happens only when RTOS is not initialized. Please let me know the solution to jump from custom bootloader to application from the RTOS task.
Hi,
Thanks for your reply.
The Jay shared function should be suitable for bare-metal or RTOS software mode.
void mfb_jump_to_application(uint32_t vectorStartAddr)
{
#if MFB_APP_JUMP_ENABLE
mfb_printf("\r\nMFB: Jump to Application code at 0x%x.\r\n", EXAMPLE_FLEXSPI_AMBA_BASE + MFB_APP_IMAGE_OFFSET);
mfb_printf("-------------------------------------\r\n");
static uint32_t s_resetEntry = 0;
static uint32_t s_stackPointer = 0;
s_resetEntry = *(uint32_t *)(vectorStartAddr + 4);
s_stackPointer = *(uint32_t *)vectorStartAddr;
// Turn off interrupts.
__disable_irq();
// Set the VTOR.
SCB->VTOR = vectorStartAddr;
// Memory barriers for good measure.
__ISB();
__DSB();
// Set main stack pointer and process stack pointer.
__set_MSP(s_stackPointer);
__set_PSP(s_stackPointer);
// Jump to application entry point, does not return.
static void (*s_entry)(void) = 0;
s_entry = (void (*)(void))s_resetEntry;
s_entry();
#endif
}
Have a great day,
TIC
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!
- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------
is it the same for KW45b41?
It is common for all Cortex-M based MCUs