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

startup files in Keil

Can You explain me something. Why in ARM microcontrollers each IDE use startup files?
Where from the compiler knows that the first think is to execude the code from startup. Each C language programms should start from main() funcion and here the program starts from startup?
If the startup does not exists it works fine too but we have to make Heap, stack and other by ourself but in main()?
If I add different startup called whatever i want and add it to group in project in will be done the as first too so it means that the name of the startupp file is not important.

Can you explain me how does it work? (for example in Keil)

Parents
  • As I mentioned, there is a linker configuration file telling the linker how to order things.

    It may look like:

    ; *************************************************************
    ; *** Scatter-Loading Description File generated by uVision ***
    ; *************************************************************
    
    LR_IROM1 0x00000000 0x00001000  {    ; load region size_region
      ER_IROM1 0x00000000 0x00001000  {  ; load address = execution address
       *.o (RESET, +First)
       *(InRoot$$Sections)
       .ANY (+RO)
      }
      RW_IRAM1 0x40000000 0x00008000  {  ; RW data
       .ANY (+RW +ZI)
      }
      RW_IRAM2 0x7FE00000 0x00004000  {
        adc.o (+ZI)
        fram.o (+ZI)
       .ANY (+RW +ZI)
      }
    }
    
    LR_IROM2 0x00003000 0x0003D000  {
      ER_IROM2 0x00003000 0x0003D000  {  ; load address = execution address
       .ANY (+RO)
      }
    }
    


    Notice the "(RESET, +First)" part?

    Match that up with the line in the startup assembler file:

                    AREA    RESET, CODE, READONLY
    


    So it doesn't matter what the startup file is named - if it contains an area "RESET" it will match the region placement of the linker configuration file.

    But you can use the IDE to specify segment namings for C files too, and add other sorting orders in the linker configuration (scatter) file.

    All that is required, is that you have a suitable startup code located where the physical processor initially jumps or reads a reset vector.

Reply
  • As I mentioned, there is a linker configuration file telling the linker how to order things.

    It may look like:

    ; *************************************************************
    ; *** Scatter-Loading Description File generated by uVision ***
    ; *************************************************************
    
    LR_IROM1 0x00000000 0x00001000  {    ; load region size_region
      ER_IROM1 0x00000000 0x00001000  {  ; load address = execution address
       *.o (RESET, +First)
       *(InRoot$$Sections)
       .ANY (+RO)
      }
      RW_IRAM1 0x40000000 0x00008000  {  ; RW data
       .ANY (+RW +ZI)
      }
      RW_IRAM2 0x7FE00000 0x00004000  {
        adc.o (+ZI)
        fram.o (+ZI)
       .ANY (+RW +ZI)
      }
    }
    
    LR_IROM2 0x00003000 0x0003D000  {
      ER_IROM2 0x00003000 0x0003D000  {  ; load address = execution address
       .ANY (+RO)
      }
    }
    


    Notice the "(RESET, +First)" part?

    Match that up with the line in the startup assembler file:

                    AREA    RESET, CODE, READONLY
    


    So it doesn't matter what the startup file is named - if it contains an area "RESET" it will match the region placement of the linker configuration file.

    But you can use the IDE to specify segment namings for C files too, and add other sorting orders in the linker configuration (scatter) file.

    All that is required, is that you have a suitable startup code located where the physical processor initially jumps or reads a reset vector.

Children
No data