cancel
Showing results for 
Search instead for 
Did you mean: 

IAP in stm32F101 using IDE IAR,unable to jump to new application

sagarpadwal1991
Associate II
Posted on July 17, 2015 at 12:08

Hi,

I started for IAP with stm32 using iDE KEIL which works fine.

But now when i switch to iDE IAR using STM32F101VCT6 the IAP not working,

for switching from one code to another code written in the flash memory space.

Following is the part of my code whichc i used for switching from one code space to another as follows:

&sharpdefine ApplicationAddress      0x08020000

typedef void(*pFunction)(void);

pFunction Jump_To_Application;

uint32_t uliJumpAddress;

void jump_to_app(void);

.

.

.

.

.

/* Set system control register SCR->VTOR  */

NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x00020000);

uliJumpAddress = *( uint32_t*) (ApplicationAddress + 0x04);

Jump_To_Application = (pFunction) uliJumpAddress;

__set_MSP(*( uint32_t*) ApplicationAddress);

Jump_To_Application(); 

#stm32 #usb #- #iap #iar-workbenc #stm32l1xx
6 REPLIES 6
Posted on July 17, 2015 at 13:46

I don't understand what ''not working'' means. What exactly is happening, use a debugger and step in and understand what's happening, and why, and what you think should be going on.

I would let SCB->VTOR be set in SystemInit() in the application code.

Don't hand over control with random Interrupts firing/functional. The app isn't going to be ready to deal with any of that. Watch for things like SysTick. And if using an RTOS understand system/user context.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sagarpadwal1991
Associate II
Posted on July 20, 2015 at 12:02

Hi Clive,

thanx for response and suggestions.

I tried to debug the code and found that values of PC and MSP 

which reuired for switching to new application code are set to 

proper values but after executing last statement 

'Jump_To_Application();' from code

program suddendly jumps to ramdom location of my code which function is not called in my code but function definition is there.

do any one have any clues about it????

Posted on July 20, 2015 at 16:02

do any one have any clues about it????

Interrupts?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sagarpadwal1991
Associate II
Posted on July 20, 2015 at 16:17

Posted on July 20, 2015 at 17:34

I'm not an IAR user/expert

You'll have to refine ''random'' a bit, perhaps you can illustrate in dissembly form (address/instruction/registers) exactly what gets stepped through, and when it vectors to the unknown/random instructions.

You've provided a dozen lines of C code, I can't solve this problem with that.

Are you disabling interrupts globally, or are you tearing down and turning off all the individual sources you created in the boot loader? Things like SysTick, Watchdogs, and other timer or usb interrupts? Again my perspective on your problem is very narrow.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
sagarpadwal1991
Associate II
Posted on July 24, 2015 at 11:50

Hi,

After debugging for 2 days we found the solution for this.

For IAP in IAR whatever the second code at which you want to jump from your main code have to follow following things:

1. for second code change the following line in generic_cortex.icf for IAR

define symbol __ICFEDIT_intvec_start__ = 0x00000000;

 /*starting location of main code*/

to

define symbol __ICFEDIT_intvec_start__ = 0x000

2

0000;/*starting location of

 your second code

*/

2.also go to options->Linker->Config

in Linker configuration file box select override default and you can make new .icf file to store your new code address.

note: save this file with new name and use it only for second code

Hope this will help someone.....