2017-03-31 12:28 PM
Hi I am new here ,I am working on an application on stm32l4 microcontroller ,
the idea is when I press the user button the bootloader jump from the main application (0x08000000)
to the second one (0x08080000) . THe second firmware is just a blinking led application ,
the jumping is fine and the led start blinking , but my problem is that when I want to go back from the second application to
the first one (0x08000000) the exti won't work ! here's my code :
first firmware :
if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000) {
/* Jump to user application */
JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
JumpToApplication = (pFunction) JumpAddress;
/* Initialize user application's Stack Pointer */
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
__disable_irq;
SCB->VTOR = FLASH_BASE | 0x80000;
HAL_RCC_DeInit();
SysTick->CTRL =0;
SysTick->LOAD=0;
SysTick->VAL=0;
__set_PRIMASK(1);
printf('Starting Firmware 2 . . . \r\n');
HAL_DeInit();
JumpToApplication();}
the beginng of the second firmware :
SCB->VTOR = FLASH_BASE | 0x80000;
__set_PRIMASK(0);
HAL_Init();
SystemClock_Config();
HAL_InitTick(1);
...
this is the exti callback from the second firmware :
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin){
HAL_NVIC_ClearPendingIRQ(EXTI15_10_IRQn);
HAL_NVIC_DisableIRQ(EXTI15_10_IRQn);
if (GPIO_Pin == GPIO_PIN_13)
{
if (((*(__IO uint32_t*)APPLICATION_ADDRESS) & 0x2FFE0000 ) == 0x20000000)
{JumpAddress = *(__IO uint32_t*) (APPLICATION_ADDRESS + 4);
JumpToApplication = (pFunction) JumpAddress;
__set_MSP(*(__IO uint32_t*) APPLICATION_ADDRESS);
HAL_NVIC_DisableIRQ(EXTI15_10_IRQn);
__disable_irq;
SCB->VTOR = FLASH_BASE;
JumpToApplication(); }}}
Can any one please tell me why this is not working ?
#stm32l4-bootloader2017-04-05 06:28 AM
Problem solved
2017-07-18 02:57 AM
Hi,
i have a simil problem!After the jumping bootloader, the EXTI_line6 not work!boot.c
/* Test if user code is programmed starting from address 'APPLICATION_ADDRESS' */
if (((*(__IO uint32_t*)FLASH_USER_START_ADDR) & 0x2FFE0000 ) == 0x20000000) { /* Jump to user application */ JumpAddress = *(__IO uint32_t*) (FLASH_USER_START_ADDR + 4); Jump_To_Application = (pFunction) JumpAddress; /* Initialize user application's Stack Pointer */ __set_MSP(*(__IO uint32_t*) FLASH_USER_START_ADDR); __disable_irq(); /* Jump to application */ Jump_To_Application(); }application.c/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
/* Copy the vector table from the Flash (mapped at the base of the application
load address 0x08003000) to the base address of the SRAM at 0x20000000. */ for(i = 0; i < 48; i++) { VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2)); }/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Remap SRAM at 0x00000000 */ SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);__enable_irq();
/***************** Add your application code here ***************************/Any idea?
thanks
2017-07-18 03:06 AM
sorry,
EXTI_Line6 its ok, else EXTI_Line7 not work!
2017-07-19 04:29 PM
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
// Clock not Reset
It is important not to jump from interrupt context, but rather unstack yourself.
2017-07-20 08:33 AM
Hi,
the istruction
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
// Clock not Reset
is present in the EXTI_line7 configuration (on the application firmware), but not work!
Is the instruction to be inserted shortly after the jump to the application?
thanks
2017-07-20 03:06 PM
You've posted Cortex-M0 specific code against an STM32L4 thread. On the Cortex-M0 parts the SYSCFG clock needs to be enabled prior to remapping the RAM.
I'm afraid I don't understand enough of your code/context to know what might be happening. Consider a new thread documenting your issue more completely.
2017-07-21 12:05 AM
application.c
int main(void)
{ unsigned long ulChk = 0; unsigned int uiLen = 0; GPIO_InitTypeDef GPIO_InitStructure; uint32_t i = 0;RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); // Clock not Reset
/* Relocate by software the vector table to the internal SRAM at 0x20000000 ***/
/* Copy the vector table from the Flash (mapped at the base of the application load address 0x08003000) to the base address of the SRAM at 0x20000000. */ for(i = 0; i < 48; i++) { VectorTable[i] = *(__IO uint32_t*)(APPLICATION_ADDRESS + (i<<2)); }/* Enable the SYSCFG peripheral clock*/
RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE); /* Remap SRAM at 0x00000000 */ SYSCFG_MemoryRemapConfig(SYSCFG_MemoryRemap_SRAM);/***************** Add your application code here ***************************/
/* Unlock the Flash Program Erase controller */
FLASH_Unlock();// main loop...
}
I'm have add SYSCFG clock enabled prior to remapping the RAM (
Look at the bold statement
), but EXTI line 7 not work!