如何在ARM处理器上检测冷启动和热启动?

7
我正在寻找一种方法来确定ARM处理器是从冷启动(即初始上电)还是热启动(即重置断言但实际上没有断电)启动。具体来说,我正在使用ARM968核心,将使用C或汇编语言进行判断,并且我将使用此判断使某些操作仅在初始上电时运行,而不在后续重置时运行。在以前的项目中,我利用外部电路(例如FPGA)来检测不同的启动情况,但在这种情况下,我受到ARM核心的限制。
3个回答

10

查看您特定芯片的文档(“ARM968”不够具体)。应该有一个描述重置原因的寄存器。例如,这是LPC23xx的情况:

Reset Source Identification Register (RSIR - 0xE01FC180)

This register contains one bit for each source of Reset. Writing a 1 to any of these bits
clears the corresponding read-side bit to 0. The interactions among the four sources are
described below.

Bit Symbol Description
0 POR Assertion of the POR signal sets this bit, and clears all of the other bits in
this register. But if another Reset signal (e.g., External Reset) remains
asserted after the POR signal is negated, then its bit is set. This bit is not
affected by any of the other sources of Reset.
1 EXTR Assertion of the RESET signal sets this bit. This bit is cleared by POR,
but is not affected by WDT or BOD reset.
2 WDTR This bit is set when the Watchdog Timer times out and the WDTRESET
bit in the Watchdog Mode Register is 1. It is cleared by any of the other
sources of Reset.
3 BODR This bit is set when the 3.3 V power reaches a level below 2.6 V.
If the VDD(DCDC)(3V3) voltage dips from 3.3 V to 2.5 V and backs up, the
BODR bit will be set to 1.
If the VDD(DCDC)(3V3) voltage dips from 3.3 V to 2.5 V and continues to
decline to the level at which POR is asserted (nominally 1 V), the BODR
bit is cleared.
if the VDD(DCDC)(3V3) voltage rises continuously from below 1 V to a level
above 2.6 V, the BODR will be set to 1.
This bit is not affected by External Reset nor Watchdog Reset.
Note: Only in case when a reset occurs and the POR = 0, the BODR bit
indicates if the VDD(DCDC)(3V3) voltage was below 2.6 V or not.

5
你可以在RAM中初始化一个全局变量,赋予一个在冷启动时不太可能出现的值,并在启动过程中进行检查。
对于微控制器,通常特定芯片的重置逻辑提供状态寄存器,指示重置的来源。我不知道这个更大的内核是否存在这样的状态寄存器,以及是否可以使用它。

4
断电后,内存可以保存数值相当长的时间。 - caf
1
RAM变量方法有效。我将SRAM的4字节部分划分为引导签名,并在链接器指令中将其从SRAM大小中排除,以便除了签名编写/检查代码之外,没有其他内容会初始化或覆盖它。 - Andrew Cottrell

2
很可能会比较困难,也许你并不是只针对核心本身。核心应该已经被重置了,但外部内存(但可能仍在芯片内)没有被重置。如果内存是基于DRAM的,则在启动时可能仍会被擦除。我不知道是否有通用的答案。你和starblue都需要找到某个寄存器,它在重置时不会被清除,在其中设置一些“可能”不会在上电时随机发生的内容。读取后再设置。像FPGA或PLD这样在板级上管理重置逻辑(如果有的话)的东西是最好的,因为在上电重置时它们也会被重置,并且在热重置时它们是引起重置并保持其状态的元件。
查阅您的核心的TRM或芯片的寄存器规格,看看是否有任何重置状态未定义的寄存器,您通常不使用且不会损坏芯片的寄存器,并查看其开机状态,这就是我开始寻找的地方。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接