cancel
Showing results for 
Search instead for 
Did you mean: 

Exti stop working after jumping to the new firmware stm32L4

raed
Associate II
Posted on March 31, 2017 at 21:28

http://electronics.stackexchange.com/questions/295904/exti-stop-working-after-jumping-to-the-new-firmware-stm32l4

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-bootloader
16 REPLIES 16
raed
Associate II
Posted on April 05, 2017 at 15:28

Problem solved

u23
Senior
Posted on July 18, 2017 at 11:57

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

u23
Senior
Posted on July 18, 2017 at 12:06

sorry,

EXTI_Line6 its ok, else EXTI_Line7 not work!

Posted on July 19, 2017 at 23:29

RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);

  // Clock not Reset

It is important not to jump from interrupt context, but rather unstack yourself.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
u23
Senior
Posted on July 20, 2017 at 17:33

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

Posted on July 20, 2017 at 22:06

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.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
u23
Senior
Posted on July 21, 2017 at 09:05

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!