[SOLVED] startup code SEGGER_ARM_startup.s file

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • [SOLVED] startup code SEGGER_ARM_startup.s file

    In startup code SEGGER_ARM_startup.s file as below,


    START_FUNC _start


    //


    // Call linker init functions which in turn performs the following:


    // * Perform segment init


    // * Perform heap init (if used)


    // * Call constructors of global Objects (if any exist)


    //


    ldr R4, =__SEGGER_init_table__ // Set table pointer to start of initialization table


    L(RunInit):


    ldr R0, [R4] // Get next initialization function from table


    adds R4, R4, #4 // Increment table pointer to point to function arguments


    blx R0 // Call initialization function


    b L(RunInit)


    //


    MARK_FUNC __SEGGER_init_done


    We are not able to understand code function/flow. Need following clarity.
    i) What this piece of code will do?
    ii)we unable to locate _SEGGER_init_table__ . Please let us know in which file this table and related functions are located.
    iii) How it will come out of loop? It looks to be an indefinite loop.
    [/quote]
  • Hello,

    Thank you for your inquiry.
    i) The code is commented very detailed. It should already explain what it does. As you can see from the comments in invokes the linker generated init table for your system. This contains the heap init, constructor init of global objects e.g. classes, and a segment init. If you are unaware of what an ARM CPU or any system does on startup we recommend to check Arm documentation and general literature about computer systems which should explain this in more detail.
    ii) That is expected. The functions are linker generated on demand so there is no source reference.
    iii) See the provided source. It is of course not an infinite loop otherwise you application would never launch. You have all information needed to understand what is happening. You have the sources, target application and a debugger. So debug.

    Best regards,
    Nino
    Please read the forum rules before posting.

    Keep in mind, this is *not* a support forum.
    Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
    Should you be entitled to support you can contact us via our support system: segger.com/ticket/

    Or you can contact us via e-mail.