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

call c-function in startup-file

Hi,

is it possible to call a c-function during the initalization of the startup-file? Could you give me one simple example?

; Reset Handler

                EXPORT  Reset_Handler
Reset_Handler


; open lowlevelinit c-function
; IMPORT LowLevelInit

; Setup Power Management Controller (PMC) --------------------------------------

                IF      :DEF:NO_PMC_INIT
                ELSE
                IF      PMC_SETUP != 0

                LDR     R0, =PMC_BASE

Do you know any important things writing this init-function? How do the startup-file know the place / the c-file , where the function is declared?

best regards
Alan

Parents
  • It is perfectly fine using C in your start up code, provided that you
    follow some guidelines:

    1. All (C-)functions that are called from startup code must be located in a root region (load address == exec address)

    Scatter loading has not been taken place, yet.

    2. The supervisor stack has been set up.

    We need some stack for local variables, etc. You never know what the compiler does exactly.

    3. No functions from the C library must be called directly or indirectly.

    The C library initialization has not been executed.

    4. Know what you are doing.

    Some startup tasks might be easier to implement in C, others are not.

    Regards
    Marcus
    http://www.doulos.com/arm/

Reply
  • It is perfectly fine using C in your start up code, provided that you
    follow some guidelines:

    1. All (C-)functions that are called from startup code must be located in a root region (load address == exec address)

    Scatter loading has not been taken place, yet.

    2. The supervisor stack has been set up.

    We need some stack for local variables, etc. You never know what the compiler does exactly.

    3. No functions from the C library must be called directly or indirectly.

    The C library initialization has not been executed.

    4. Know what you are doing.

    Some startup tasks might be easier to implement in C, others are not.

    Regards
    Marcus
    http://www.doulos.com/arm/

Children