cancel
Showing results for 
Search instead for 
Did you mean: 

multiapplications jump

fabrizio2399
Associate II
Posted on November 20, 2014 at 18:19

Hi,

I'm trying to develop kind of a bootloader for STM32F4 (or other) family in a little different way than usual.

I gave a look to the existing discussions and so far none of them was helpful for me.

The idea is to create 3 different Atollic (or any other IDE like coocox) compiled applications to load in different areas of the flash memory of the same microcontroller and jump from one to another.

what i did so far is creating 3 different projects with Atollic, save the bin file with st-link and program to target location always with st-link.

the default application basically jumps to one or the other application in memory depending by a flag.

following the existing discussions and AN from ST I�ve written a code that effectively jumps, but it doesn't jump where i wish.

what happens is a jump to the startup file of the main default application! it's rebooting all the time!

i thought that the mistakes can be in the load in memory procedure or in the way the address has been given (simply given by the memory address of the application and applying the +4 shift as found here).

any help or idea?

thanks!

Fabrizio

#jump-address-stm32l1-flash-bank #atollic
7 REPLIES 7
Posted on November 20, 2014 at 18:46

Found where? You mention a bunch of things, and fail to cite any.

any help or idea?

 

Perhaps an illustrative code fragment of what you're doing now might enlighten as to why it's not working now.

The standard vector table contains the initial PC at offset +4, the vector table is not executable code. The SCB->VTOR, usually set in SystemInit(), needs to point at the Vector Table for the application, if you just used generic code it probably points at the base of FLASH, and your boot loader.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
fabrizio2399
Associate II
Posted on November 20, 2014 at 19:16

hi clive1, thanks for your reply and sorry if i didn't paste code.

things have been found on STM AN and from other discussions in the forum. do you want me to link them?

typedef  void (*pFunction)(void);

pFunction Jump_To_Application;

__IO uint32_t JumpAddress;

JumpAddress = *(__IO uint32_t*) (0x08020004);

          Jump_To_Application = (pFunction) JumpAddress;

          /* Initialize user application's Stack Pointer */

          __ASM volatile (''MSR msp, %0\n'' : : ''r'' (0x08020000) : ''sp'');

          Jump_To_Application();

this is how the code is looking like.

memory is programmed by st-link from 0x08020000.

thanks,

Fabrizio

Posted on November 20, 2014 at 19:25

If they relate to what you've tried, and all the ground I've covered before on the topic.. Normally you'd post against the most relevant thread, or at least cite them with a new one.... No matter...

In things like Keil it's not necessary to change the stack pointer before branching.

So if you step, in the disassembly view, where and how far do you get into your application image?

Have you confirmed the placement of the code via the .MAP file? Using a .HEX from the linker is usually safer than a binary because it passes address information and is harder to screw up in the down load process.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
muhammaduzairafzal45
Associate III
Posted on November 21, 2014 at 05:53

Three things are required to jump to application.

1) Set vector table to your required e.g. addressNVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x4000);

2)Set Starting address of compiler with offset e.g. 0x8004000 which will creat hex file starting from this offset.Use hex file to flash or bin file with manually offsetting flash start address.

3) jump to application.

fabrizio2399
Associate II
Posted on November 21, 2014 at 15:23

i'm not using Keil unfortunately but Atollic.

i haven't checked the map file, but i can see by st-link and in the atollic debugger that the memory is written how i wanted to.

the application is not jumping to that memory addres, but when i do the jump is like rebooting!

Posted on November 21, 2014 at 15:56

Conversely I don't use Atollic.

Review the code in the disassembly window, what the code and registers are, and step that. Watch and explain that. Print out the address before you jump to it. You're jumping to the ResetHandler in your Application, or should be.

Saying ''it resets'' doesn't help me remotely debug this.

Do you have interrupts running? Do you run an RTOS in the boot loader? Do have a proper Hard Fault handler in either your Boot Loader or Application?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
fabrizio2399
Associate II
Posted on November 27, 2014 at 16:00

sorry for late answer, i was off from work!

anyway, yes, it jumps to the reset handler.

no i don't have any interrupt or else running. it is just a example program turning on leds to verify if the jump has been done or not.