2010-09-16 101 views
7

我正在尋找一種方法來確定ARM處理器是否從冷啓動(即,初始加電)與熱啓動(即沒有實際功率損失的復位斷言)進行引導。具體而言,我使用的是ARM968內核,將使用C或彙編進行確定,並且我將使用確定,以便某些操作僅在初始開機時運行,而不是在後續重置時運行。在以前的項目中,我利用外部電路(例如FPGA)來檢測不同的啓動場景,但在這種情況下,我僅限於ARM內核。如何檢測冷啓動與ARM處理器上的熱啓動?

回答

5

您可以將RAM中的全局變量初始化爲冷啓動時不太可能出現的值,並在啓動過程中檢查該值。

對於微控制器,通常情況下,特定芯片的復位邏輯提供狀態寄存器,指示覆位的來源。我不知道這個更大的核心是否存在,以及你是否可以使用它。

+4

內存可以保存值在關機後的一個驚人的很長一段時間。 – caf 2010-09-17 00:14:54

+1

RAM變量方法奏效。我將SRAM的4字節部分分成了一個引導簽名,並將其從鏈接器指令中的SRAM大小中排除,因此除了簽名寫入/檢查代碼外,沒有任何內容會初始化或覆蓋它。 – 2010-09-20 21:53:42

2

這很可能是困難的,也許你不是真的只是核心本身。核心應該已經得到重置,但外部的內存(但可能還在芯片內部)沒有。如果內存是基於dram的,那麼它在啓動時可能仍會被擦除。我不知道通用的一個尺寸適合所有的答案。儘管你和starblue都有,但你必須在某個地方找到一些在復位時未被清除的寄存器,並將其設置爲「可能」不會在加電時隨機發生的事情。讀它然後設置它。認爲像在板級管理復位邏輯的fpga或pld(如果有的話)是最好的,因爲在上電覆位時它們也會被重置,並且在熱重置時它們是導致它並保持其狀態的那個。

挖掘TRM爲您的核心或通過芯片的寄存器規範,並查看是否有任何寄存器的復位狀態是未定義的,一個通常不使用並且不會傷害芯片,如果您將其設置爲某種,看看它的功能,那就是我開始尋找的地方。

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.