Question
How to Disable all Interrupts before jumping to Application.
Posted on November 12, 2015 at 19:13
Hi All,
I am working on boot loader for STM32 and using DMA interrupts on USART1 for receiving and Transmitting Data. The same USART is used in Application as well with the same settings. I was using below code to jump to application:LOG_INFO(''BootLoader Jumping to Application'');
timer_->Timer_Sleep(100);
// deinit interrupts, set address to reset handler, set stack pointer, and jump
uint32_t jumpAddress = 0x00000000;
__disable_irq();
typedef void (*pFunction)(void);
pFunction jumpToApp;
uint32_t startAddress = bootloaderUtilities_.getApplicationStartAddress();
NVIC_SetVectorTable(NVIC_VectTab_FLASH, startAddress - 0x08000000);
jumpAddress = *(__IO uint32_t*)(startAddress + 4);
jumpToApp = (pFunction)jumpAddress;
__set_MSP(*(__IO uint32_t*)startAddress);
jumpToApp();
But THIS does not work. when I jump to Application, it does jump to application but stuck in the application itself.
if i change the code and disable that particular USART Rx Interrupt , Code works flawless
below is the working code:
LOG_INFO(''BootLoader Jumping to Application'');
timer_->Timer_Sleep(100);
NVIC_InitTypeDef NVIC_InitStructure;
/* Disable the USART DMA Rx Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = DMA2_Stream2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
NVIC_Init(&NVIC_InitStructure);
uint32_t jumpAddress = 0x00000000;
typedef void (*pFunction)(void);
pFunction jumpToApp;
uint32_t appStartAddress = getApplicationStartAddress();
NVIC_SetVectorTable(NVIC_VectTab_FLASH, appStartAddress - USER_FLASH_START_ADDRESS);
jumpAddress = *(__IO uint32_t*)(appStartAddress + 4);
jumpToApp = (pFunction)jumpAddress;
__set_MSP(*(__IO uint32_t*)appStartAddress);
jumpToApp();
But this is not the correct way to disable . Any one has any idea how can I disable all interrupts in Bootloader and then jump to Application and configure again.
#stm32 #stm32 #dma #bootloader #usart