cancel
Showing results for 
Search instead for 
Did you mean: 

link Bootloader to application starts

arunl4g
Associate II
Posted on June 17, 2015 at 10:07

hej ,

i would like to know that, how to link JumpToApplication() to my original code starts?..

can anyone guide me about this?

i have written the code like the below in GCC linker file. 

GCC Linker file:

--------------------------------------------------------

MEMORY

{

BOOT (rx) : ORIGIN = 0x08000000, LENGTH = 0x0000C000

rom (rx)  : ORIGIN = 0x0800C000, LENGTH = 0x000F4000

ram (rwx) : ORIGIN = 0x20000000, LENGTH = 0x00020000

ram1 (rwx) : ORIGIN = 0x10000000, LENGTH = 0x00010000

}

_eram = 0x20000000 + 0x00020000;

SECTIONS

{

.boot :

    {

        KEEP(*(.isr_vector))

        startup_stm32f4??.o(.text)

    } >BOOT

-----------------------------------------------------------

In the main, i have written like the below 

int main(void)

{

typedef void (*pFunction)(void);

pFunction JumpToApplication;

RCC_DeInit();

SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;

__set_PRIMASK(1);   // Disable interrupts  // in the core_cmFunc.h

__set_MSP(*(__IO uint32_t*) APPLICATION_ADDR);     // in the core_cmFunc.h

jumpAddress = *(__IO uint32_t*) (APPLICATION_ADDR);

JumpToApplication = (pFunction) jumpAddress;

JumpToApplication();

}

-------

thank you 

8 REPLIES 8
Posted on June 17, 2015 at 15:21

Review the vector table the initial PC (Program Counter) is at offset +4

jumpAddress = *(__IO u,int32_t*) (APPLICATION_ADDR + 4);

If your application is at 0x0800C000 don't define a linker region for that in the boot loader. Make sure all your code fits on the 0x08000000..0x0800BFFF area, check the .MAP file to confirm.

You should review the IAP examples to see how can be solved.

Now, if you have not separated this into the two pieces (Boot Loader + Application), and you just have one file, you don't need to do any of this jumping.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on June 22, 2015 at 10:14

i have seperated boot loader and application. 

i have taken out the as you said. i dont know why i cant jump from bootloader to application.

the below is what i am doing...

bootloader in main:

int main(void)

{

typedef void (*pFunction)(void);

pFunction JumpToApplication;

RCC_DeInit();

SysTick->CTRL = 0;

SysTick->LOAD = 0;

SysTick->VAL = 0;

__set_PRIMASK(1);   // Disable interrupts  // in the core_cmFunc.h

__set_MSP(*(__IO uint32_t*) APPLICATION_ADDR);     // in the core_cmFunc.h

jumpAddress = *(__IO uint32_t*) (APPLICATION_ADDR + 4);

JumpToApplication = (pFunction) jumpAddress;

JumpToApplication();

}

the below one is the sample application of mine:

JumpToApplication()

{

IS.Version=200;

IS.SerialNO=200;

IS.Type=2000;

IS.EnSens=200;

IS.FreqCorr=200;

IS.CoeffLL=1;

IS.CoeffLH=1;

IS.CoeffRL=1;

IS.CoeffRH=1;

IS.CoeffLLO=100;

IS.CoeffLHO=200;

IS.CoeffRLO=50;

IS.CoeffRHO=80;

WriteBlock(sizeof(InstrumentState), &IS);

}

i cant jump from bootloader to application...

can u tell me whats wrong ?... 

thank you 

Posted on June 22, 2015 at 14:06

It's doesn't literally go into a JumpToApplication() function, it should enter the image via the usual ResetHandler which calls SystemInit() and then initializes the C runtime environment, and finally to your application's main() function.

Use a debugger, and step through the transition, and understand where it's going and what's happening.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on June 22, 2015 at 15:38

when i step through the debugger it stops by HardFault_Handler.

could you help me to how to proceed and what are the things i have to look ?

i would like to know, where to write the boot loader file. 

cant i write inside the main function?...

thank you 

Posted on June 22, 2015 at 18:20

You should review the IAP examples to see how can be solved.

ie some of the USART, ETHERNET and USB FLASH examples of doing this.

And what address is it jumping too that causes the Hard Fault? Are you using an RTOS? Do you leave random interrupts enabled?

Can you code a Hard Fault handler which decodes/deciphers the nature of the fault, and the instructions/registers where it faults? Joseph Yiu has published some handlers that work more effectively than while(1);

Look at the disassembly view of the code as you step through and identify where it first fails.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 22, 2015 at 18:21

Determine if it gets to the Application's SystemInit() function, and that it programs the vector table (SCB->VTOR) to the base your application resides at.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on June 23, 2015 at 08:38

thank u clive for ur messages.

can u post the link for the IAP  examples?... 

Posted on June 23, 2015 at 12:45

http://www.st.com/web/catalog/mmc/FM141/SC1169/SS1577/LN11/PF252140

Select ''Design Resources'', Find ''IAP'' on the page

See also

STM32F4-Discovery_FW_V1.1.0\Project\FW_upgrade

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..