This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32F100xx custom bootloader to application jump

hello all,
I have writtten an IAP for STM32F100RBT6B and trying to jump to my LED blinking aplication.

bootloader start address : 0x08000000
application start address:0x08009000

I am using the below code to jump from bootloader to application..
Code:

typedef (void )(*pFunction)(void);
pFunction Jump_To_Application;
uint32_t JumpAddress;

if (((*(__IO uint32_t*)ApplicationAddress) & 0x2FFE0000 ) == 0x20000000) {

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

Jump_To_Application = (pFunction) JumpAddress;

__set_MSP(*(__IO uint32_t*) ApplicationAddress);

Jump_To_Application(); }

when my pointer reaches "Jump_To_Application();" nothing gets updated in PC,SP..
or please suggest how can i see whether my bootloader code is jumping to application or not.

I have gone through a lot of post here but didn't find my answer.
I am running bootloader code in debug mode.
and using Atollic IDE.
Plz help..
thanks in advance..

Parents
  • thanks for the reply let me tell you how am i checking the jump from bootloader code to my application.

    I am dumping my application .bin to the address 0x08009000 and later running my bootloader loader code in debug mode.
    I tried your code but its giving hardfault.

    I also tried the below code sniptt: // get the vector table address u32* vectorTable = (u32*)ApplicationAddress; // set the top of stack (not really needed, the CRT's _start does it anyway) u32 topOfStack = vectorTable[0]; asm ( "mov sp, %0" : : "r" (topOfStack) ); // jump to the reset handler u32 resetHandlerAddr = vectorTable[1]; asm ( "bx %0" : : "r" (resetHandlerAddr) ); // ((void (*)())(resetHandlerAddr))(); return 0;

    on executing the above code i get:
    SP:0x20002000

    And after the last instruction. PC value is 0x800387f(on monitor memory window)
    On looking at the hex file of my application i found out that the value at reset vector address 0x0800004 is 0x75380008(on STM32 ST-LINK).

    please suggest where am i going wrong?

Reply
  • thanks for the reply let me tell you how am i checking the jump from bootloader code to my application.

    I am dumping my application .bin to the address 0x08009000 and later running my bootloader loader code in debug mode.
    I tried your code but its giving hardfault.

    I also tried the below code sniptt: // get the vector table address u32* vectorTable = (u32*)ApplicationAddress; // set the top of stack (not really needed, the CRT's _start does it anyway) u32 topOfStack = vectorTable[0]; asm ( "mov sp, %0" : : "r" (topOfStack) ); // jump to the reset handler u32 resetHandlerAddr = vectorTable[1]; asm ( "bx %0" : : "r" (resetHandlerAddr) ); // ((void (*)())(resetHandlerAddr))(); return 0;

    on executing the above code i get:
    SP:0x20002000

    And after the last instruction. PC value is 0x800387f(on monitor memory window)
    On looking at the hex file of my application i found out that the value at reset vector address 0x0800004 is 0x75380008(on STM32 ST-LINK).

    please suggest where am i going wrong?

Children
  • I am dumping my application .bin to the address 0x08009000 and later running my bootloader loader code in debug mode.

    You mean you use a flashloader to load the binary at address 0x08009000? Sounds right.

    I tried your code but its giving hardfault.

    Well, it works for me. The hard fault could be in your code. You should establish the exact cause of the hard fault.

    On looking at the hex file of my application i found out that the value at reset vector address 0x0800004 is 0x75380008(on STM32 ST-LINK).

    I'm not sure I understood what you mean. If you are saying that the value of the reset vector looks odd, I agree with you.

  • i mean the PC value should be 0x75380008 as per "STM32 ST-LINK" hex editor, but it is 0x753f0008.
    what does it mean. PC should show the exact value 0x75380008.
    Please correct me if i am am wrong..

  • Also i've a small doubt, according to ST the 1st 4 bytes are for stack pointer while the next entry is for reset vector. the reset vector address holds 0x08003875,what is this value exactly..

    thanks

  • the reset vector address holds 0x08003875,what is this value exactly

    It's the program's entry point plus one. So the first instruction is at 0x08003874. Read up on ARM architecture if you want to know where the "plus one" comes from.

  • Thanks for the reply, I've compiled my application which is to be loaded at address 0x08009000.For that I made the following changes:
    Settings done:
    1) Linker script file (.ld): FLASH (rx) : ORIGIN = 0x08009000, LENGTH = 80K
    2) system_stm32f10x.c Line 132: #define VECT_TAB_OFFSET 0x9000

    after all settings after compilation the .isr vector in .map file doesnot change..do i need to make anymore changes?

    thanks

  • do i need to make anymore changes?

    I wouldn't know. I'm using different tools these days. Let's hope someone else answers this.