When jumping from a bootloader to the application we usually update the stack pointer to the application stack pointer and then update the program counter to Reset_Handler of application.
void jump_to_application(void)
{
/* Function pointer to the address of the user application. */
fnc_ptr_for_app jump_to_app;
jump_to_app = (fnc_ptr_for_app)(*(volatile uint32_t*) (FLASH_APP_START_ADDRESS+4u));
__CRC_CLK_DISABLE();
HAL_DeInit();
/* Change the main stack pointer. */
__set_MSP(*(volatile uint32_t*)FLASH_APP_START_ADDRESS);
jump_to_app();
}
Reset_Handler's first line of code is below, which initializes the stack pointer to its own stack pointer value
Reset_Handler:
ldr sp, =_estack /* Atollic update: set stack pointer */
/* Copy the data segment initializers from flash to SRAM */
movs r1, #0
b LoopCopyDataInit
But still it's recommended to update the stack pointer with application's one.
Why is it needed, what are the side effects if we jump without updating it