Understanding C runtime environment (ARM) - where to start

前端 未结 5 1973
青春惊慌失措
青春惊慌失措 2021-02-06 01:54

I\'am embedded developer working with ARM Cortex-M devices mainly. Recently I\'ve switched to Linux and decided to learn more about the build/assemble/link process, how to write

5条回答
  •  不思量自难忘°
    2021-02-06 02:20

    It is not as easy , at least it should not be done such a simple way.

    Because you use C language - it has some requirements for the startup code.

    1. You need to take stack and heap into consideration and set it up rpperly.
    2. At least a minimalistic vector table
    3. C data can be initialized (eg you can declare int a = 5;) so the startup code should provide the copy routine (from flash do that ram segment)
    4. C presumes that the uninitialized global data is zeroed - startup routine should have this function as well
    5. Depending on your application some additional code may be required.

    So you will have to create at least (to be able to use C without special limitations) - a startup routine and the linker script in witch you declare memory sections, their sizes, boundaries, calculate start and end addresses for initialisation routines.

    In my opinion it is pointless to do it form the scratch - you can always amend the supplied scripts and startup files. For ARM uC CMSIS is probably the very best choice as it gives you absolute freedom.

提交回复
热议问题