ARM Cortex-M3的启动code [英] ARM Cortex-M3 Startup Code

查看:758
本文介绍了ARM Cortex-M3的启动code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解如何初始化code工作,对于STM32微附带凯尔(的RealView V4)。具体来说,我想了解堆栈初始化方式。

I'm trying to understand how the initialization code works that ships with Keil (realview v4) for the STM32 microcontrollers. Specifically, I'm trying to understand how the stack is initialized.

文档 ARM的网站就提到,startup_xxx.s例程之一的 __ user_initial_stack_heap ,不应该使用超过88字节的栈。你知道这种限制是哪里来的?

In the documentation on ARM's website it mentions that one of the routines in startup_xxx.s, __user_initial_stack_heap, should not use more than 88 bytes of stack. Do you know where that limitation is coming from?

看来,当复位处理程序的调用System_Init它正在执行在C环境,我相信意味着它是使用某种形式的临时堆叠的一对夫妇函数(它分配几个自动变量)。然而,所有这些stack'd项目应该是超出了范围,一旦返回回来,然后调用 __主这就是 __ user_initial_stack_heap 从调用。

It seems that when the reset handler calls System_Init it is executing a couple functions in a C environment which I believe means it is using some form of a temporary stack (it allocates a few automatic variables). However, all of those stack'd items should be out of scope once it returns back and then calls __main which is where __user_initial_stack_heap is called from.

那么,为什么会出现这一要求为 __ user_initial_stack_heap 不要使用超过88个字节?是否 __主其余使用一吨堆栈或什么的?

So why is there this requirement for __user_initial_stack_heap to not use more than 88 bytes? Does the rest of __main use a ton of stack or something?

因为它涉及到的启动顺序的Cortex-M3的堆栈架构的任何解释,将是非常美妙。

Any explanation of the cortex-m3 stack architecture as it relates to the startup sequence would be fantastic.

推荐答案

您会从的 __ user_initial_stackheap()文件,该功能对的传统支持的,它是通过的 __ user_setup_stackheap();后者的文档提供了一个线索ragarding你的问题:

You will see from the __user_initial_stackheap() documentation, that the function is for legacy support and that it is superseded by __user_setup_stackheap(); the documentation for the latter provides a clue ragarding your question:

与__user_initial_stackheap(),__user_setup_stackheap()与作品 ,其中应用程序与SP(R13)的值开始系统的已是正确,例如,Cortex- M3

Unlike __user_initial_stackheap(), __user_setup_stackheap() works with systems where the application starts with a value of sp (r13) that is already correct, for example, Cortex-M3

[..]

使用__user_setup_stackheap()而不是__user_initial_stackheap()提高了code尺寸的原因是因为没有需求的 临时堆栈

Using __user_setup_stackheap() rather than __user_initial_stackheap() improves code size because there is no requirement for a temporary stack.

在Cortex-M的该属是从存储在矢量表,在较旧的ARM7和ARM9器件的值初始化复位由硬件不是这种情况下,这是必要的,设置在软件堆栈指针。启动code需要使用一小叠用户定义堆栈施加之前 - 这可能是如果用户堆栈均在外部存储器中,不能使用,直到存储器控制器进行初始化的情况为例。 88字节的限制被简单地施加,因为这<青霉>临时堆的的尺寸尽可能小,因为它是在启动后可能未被使用。

On Cortex-M the sp is initialised on reset by the hardware from a value stored in the vector table, on older ARM7 and ARM9 devices this is not the case and it is necessary to set the stack-pointer in software. The start-up code needs a small stack for use before the user defined stack is applied - this may be the case for example if the user stack were in external memory and could not be used until the memory controller were initialised. The 88 byte restriction is imposed simply because this temporary stack is sized to be as small as possible since it is probably unused after start-up.

在STM32(一个Cortex-M的设备)的情况下,可能存在其实没有这样的限制,但你或许应该更新你的启动code使用较新的功能是肯定的。也就是说,鉴于此功能,而其结果在寄存器中返回的事实,要求的行为,我建议88个字节将是相当奢侈的,如果你需要那么多!此外,你只需要重新实现它,如果你使用的是分散加载文件的描述。

In your case in STM32 (a Cortex-M device), it is likely that there is in fact no such restriction, but you should perhaps update your start-up code to use the newer function to be certain. That said, given the required behaviour of this function and the fact that its results are returned in registers, I would suggest that 88 bytes would be rather extravagant if you were to need that much! Moreover, you only need to reimplement it if you are using scatter loading file as described.

这篇关于ARM Cortex-M3的启动code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆