cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader + Two applications

Santhosh KM
Associate II
Posted on September 07, 2017 at 08:19

Hi, 

I have to download second application and enter second application from the first application.

Bootloader to First application jump is happening and working fine.

I have problem to jump to second application from the first application ( downloaded second application from the bootloader same as first application) using the same approach as jump is made from bootloader to first application.

Bootloader -> jump to first application -> Jump to Second application.  I am getting this error

The stack pointer for stack 'CSTACK' (currently 0xF000FB64) is outside the stack range (0x2000DFC0 to 0x2000FFC0) and followed by first application restarts and enters booloader

I have this changes in the linker file ( .icf file)

Bootloader:

define symbol __ICFEDIT_intvec_start__ = 0x08000000;   f

define symbol __ICFEDIT_size_cstack__ = 0x4000;

define symbol __ICFEDIT_size_heap__ = 0x200;

First application:

define symbol __ICFEDIT_intvec_start__ = 0x08010000;   for first application

define symbol __ICFEDIT_size_cstack__ = 0x4000;

define symbol __ICFEDIT_size_heap__ = 0x200;

Second application: 

define symbol __ICFEDIT_intvec_start__ = 0x08020000;   for second application 

define symbol __ICFEDIT_size_cstack__ = 0x6000;

define symbol __ICFEDIT_size_heap__ = 0x200;

Using this code to jump to second application, used same from bootloader to first application:

JumpAddress = *(__IO uint32_t*) (ApplicationAddress + 4);

SCB->VTOR = ApplicationAddress;

Jump_To_Application = (pFunction) JumpAddress;

__set_MSP(*(__IO uint32_t*) ApplicationAddress);

Jump_To_Application();

Any help is welcome, I think I have problem with the linker settings 

Thanks

Santosh

#cstack-error-while-jumping-to-application
13 REPLIES 13
Santhosh KM
Associate II
Posted on September 13, 2017 at 10:42

Single step is not possible to debug, it will not show anything after few steps to see how it enters main().  I can see VTOR is changing and reset is happening after jump to second application

Posted on September 13, 2017 at 13:00

Ok, and your supervisor is satisfied with that answer? 

With the data you're seeing why would it reset? Do you have a watchdog timer? Does the code look like the Reset Handler for App2? 

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Francois Baratin
Associate II
Posted on September 14, 2017 at 10:15

Hello,

I was also unable to jump to an application, I fixed it by disabling everything before doing the jump, like this:

void fn_jump_to_application(void)

{

SCB_DisableICache();

SCB_DisableDCache();

HAL_MspDeInit();

HAL_DeInit();

HAL_RCC_DeInit();

__HAL_RCC_PWR_CLK_DISABLE();

__HAL_RCC_GPIOE_CLK_DISABLE();

__HAL_RCC_GPIOB_CLK_DISABLE();

__HAL_RCC_GPIOG_CLK_DISABLE();

__HAL_RCC_GPIOD_CLK_DISABLE();

__HAL_RCC_GPIOA_CLK_DISABLE();

__HAL_RCC_GPIOC_CLK_DISABLE();

__HAL_RCC_GPIOI_CLK_DISABLE();

__HAL_RCC_GPIOH_CLK_DISABLE();

__HAL_RCC_GPIOF_CLK_DISABLE();

/* Jump to user application */

JumpAddress = *(__IO uint32_t*) (FLASH_APPLICATION_START_ADDRESS + 4);

Jump_To_Application = (pFunction) JumpAddress;

/* Initialize user application's Stack Pointer */

__set_MSP(*(__IO uint32_t*) FLASH_APPLICATION_START_ADDRESS);

Jump_To_Application();

}

+ don't forget to update the VECT_TAB_OFFSET, like this:

#ifdef BOOTLOADER_MODE

#define VECT_TAB_OFFSET 0x00000000       //start address = 0x08000000

#elif APPLICATION_MODE

#define VECT_TAB_OFFSET 0x00080000       //start address = 0x08080000

#endif

...

SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */)

Francois

Santhosh KM
Associate II
Posted on September 18, 2017 at 05:13

Turvey.Clive.002

Yes I was having watch dog timer it jumps to application ( disabled watchdog for time being) now. Thanks