AnsweredAssumed Answered

What is stm32fxx_xx.s startup file for?

Question asked by lao.jian on Mar 3, 2016
Latest reply on Mar 3, 2016 by Clive One
Hi all,

Thanks in advance for your time spent on this topic.

I have spent several months on STM32 project, fine with software coding, but keep confusion on the startup file, which would appear in
almost every project as below. I think everyone of you also should be very familiar with it.

ProjectStructure.png  

I have spent time reading this code. It is like, I can understand every part of the code itself from grammar, but know nothing on big picture.
For example, I know it is the first code would be run after power on,it setup the stack, heap, interrupt entry address,
and then load main() function.

However, is there anything that I can play with it? Such as the stack and heap setup code below:

------------------------------------------------------------------------------------------------
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
;   <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>


Stack_Size      EQU     0x00000400

            AREA    STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem      SPACE   Stack_Size
__initial_sp
                                                  
; <h> Heap Configuration
;   <o>  Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>


Heap_Size       EQU     0x00000200

             AREA    HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem        SPACE   Heap_Size
__heap_limit
--------------------------------------------------------------------------------------------------

The code above set stack size to 0x00000400, heap size to 0x00000200, but why? Can I change it? Based on what criteria?

Is this .s code specified to MCU core or board level? Do I need to modify the code if I design a different board with different peripherals but with same MCU?

In other words, When, and how, must I make modifications to this .s startup file? 

Thanks~~ 






 


Outcomes