This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Jump to App from boot



I have a very trivial boot code[just a PLL init and checking if a valid app is present]. How can I make a jump to the App. Can some one share how you jump from boot to App.

  • Hi ecoder,

     

    To answer your question, I have to make some assumption.

    I assume your init code is assembly code, and your App is C code. (your main routine)

    In your assembly code, at the end of your initialization, the way to jump to main() is:

          BL   _main

    The BL instruction will branch to the symbol main. This symbol has to be defined at the top of your assembly file (before it is used)  with the following syntax:

         .global   _main

    Note: All C symbol, function name can be reference in assembly code with the prefix _

    Func1()

    {

    }

    The function Func1() can be called from assembly using the symbol _Func1.

    Best Regards,

    Jean-Marc

     

     

     

  • Thank you for that.

    But I am compiling and linking  my bootloader seperate. So I guess, I have to instruct my bootloader linker script  about the start address of the Application and then make a jump.  Thats what I am looking at.

  • One way I do this is hard code an address to a symbol in the command linker file for the boot code.

    /* SPECIFY THE SYSTEM MEMORY MAP ********************************************/
    MEMORY
    {
      RAM    (RWX)  :  origin=0x08000000   length=0x00001100
      STACK  (RW)   :  origin=0x08001100   length=0x00001400
    }

    /****************************************************************************************/
    /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY                                          */
    /****************************************************************************************/
    SECTIONS
    {
      GROU
    P    :
      {

            .text : { $Init_code = 0x08000301;}         /* CODE                              */

            .const         /* CONSTANT DATA                     */
            .bss           /* GLOBAL & STATIC VARS              */
            .sysmem        /* DYNAMIC MEMORY ALLOCATION AREA    */
      } > 0x08000000
      .stack  : {} > STACK       /* SOFTWARE SYSTEM STACK             */
      .cinit   : { } > 0x08001400      /* INITIALIZATION TABLES (must be 0) */
    }

    and then in the code I use the appropriate branch to $Init_code .  My app code is in Thumb mode, therefore I added 1 to the actual RAM address of the app code.

    In my app code, I then define the command linker file as follows:

    /* SPECIFY THE SYSTEM MEMORY MAP ********************************************/
    MEMORY
    {
      RAM    (RWX)  :  origin=0x08000300   length=0x00000E00
      STACK  (RW)   :  origin=0x08001100   length=0x00001400
    }

    /****************************************************************************************/
    /* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY                                          */
    /****************************************************************************************/
    SECTIONS
    {

     
      GROUP    :
      {

            .entry: {debug\InitRuncode.obj(.text)}
            .text          /* CODE                              */
            .const         /* CONSTANT DATA                     */
            .bss           /* GLOBAL & STATIC VARS              */
            .sysmem        /* DYNAMIC MEMORY ALLOCATION AREA    */
      } > RAM
      .stack  : {} > STACK       /* SOFTWARE SYSTEM STACK             */
      .cinit   : { } > 0x08001400      /* INITIALIZATION TABLES (must be 0) */
    }

    I defined the start of RAM to be where the entry point is and added the .entry statement with the entry code obj file.

  • Hi

    that was informative. thanks. Do you have any document which describes in general the details of the liker script syntax and commands ?

  • Also can you show how the boot code and app code looks like ?

  • Here is the code used for the boot code.  Note:  The function being called, Init_code() will be decorated in TI's COFF format as $Init_code which is what the symbol is referred to in the command linker file.   Using EABI format, there is no decoration and the symbol would be Init_code in the command linker file.

    extern UINT32 Init_code();

    void main(void)
    {

     Init_code();  // This will be a static code location where the code from the config file is downloaded.  This is a fixed address for the function pointer

    }

    The app code follows:


    typedef unsigned long int UINT32;

    UINT32 InitCode(void)
    {
      /* some code goes here */

      return 0;
    }

    The description of the command linker files can be found in the ARM Assembly Language Tools User's Guide in chapter 7.