1. 程式人生 > >IAR cortex-M3 +ucos-III問題集

IAR cortex-M3 +ucos-III問題集

移植:IAR cortex-M3 +ucos-III 時遇到的一些問題,歸根到底是編譯器不是很熟悉,這裡記錄下....

下載方式:

IAR設定的下載連結方式 與 板子的實際環境不統一,同樣報錯:"Failed to get CPU status after 4 retries retry?"


我的板子下載介面SWD方式,對應的IAR設定如下:


新建的IAR工程,莫名進入App_Fault_ISR異常處理程式:

之前移植的ucos-III,帶著ST的V3.5庫,稍微動一些程式碼,就會進入App_Fault_ISR,然那些程式碼與記憶體資料結構並無關係,著實鬱悶。。。

多方比對,除錯+++,定位到IAR設定問題。最後找到options-Debugger-download這塊。

常規設定如下:


試著理解下這幾項的含義,跑偏勿怪。。。

Attach to program:

"Makes the debugger attach to a running application at its current location, without resetting or halting (for J-Link only) the target system. To avoid unexpected behavior when using this option, the Debugger>Setup option Run to should be deselected. "

附加到程式:使偵錯程式附加到一個正在執行的應用程式在其當前位置,無需重置或停止(僅供J-Link)目標系統。為了避免意想不到的行為,當使用此選項時,Debugger>Setup option "Run to" 應該去掉。

Verify download:

"Verifies that the downloaded code image can be read back from target memory with the correct contents"

驗證下載:驗證下載的程式碼映像可以從目標記憶體中讀取正確的內容

Suppress download:

"Disables the downloading of code, while preserving the present content of the flash. This command is useful if you want to debug an application that already resides in target memory.
If this option is combined with the Verify download option, the debugger will read back the code image from non-volatile memory and verify that it is identical to the debugged application.
Note: It is important that the image that resides in target memory is linked consistently with how you use C-SPY for debugging. This applies, for example, if you first link your application using an output format without debug information, such as Intel-hex, and then load the application separately from C-SPY. If you then use C-SPY only for debugging without downloading, you cannot build the debugged application with any of the options Semihosted or IAR breakpoint—on the General Options>Library Configuration page—as that would add extra code, resulting in two different code images."

抑制下載:禁用下載程式碼,同時保留目前的flash內容。這個命令是有用的,如果您想要除錯一個應用程式,該應用程式已經在目標記憶體駐留。
如果這個選項結合驗證下載選項,偵錯程式會讀回程式碼映像從非易失性記憶體,並驗證它是與被除錯的應用程式相同。

注意:It is important that the image that resides in target memory is linked consistently with how you use C-SPY for debugging.

例如,如果你第一次聯絡您的應用程式使用一個沒有除錯資訊輸出格式,如Intel-hex,,則 C-SPY與載入應用程式分開的。

如果你然後使用C-SPY只有除錯沒有下載,你不能用任何構建除錯應用程式關於Semihosted選項或IAR斷點,在the General Options>Library Configuration 頁,新增額外的程式碼,從而導致兩種不同的圖片程式碼。

Use flash loader(s) :

"Use this option to use one or several flash loaders for downloading your application to flash memory. If a flash loader is available for the selected chip, it is used by default. Press the Edit button to display the Flash Loader Overview dialog box."

使用flash載入程式:使用這個選項使用一個或多個快閃記憶體flash應用程式載入器下載。如果一個flash載入程式可供選擇的晶片,在預設情況下使用它。按下編輯按鈕對話方塊顯示Flash載入程式概述。

關於'CSTACK':(stack)棧指標

IAR中debug程式,斷點位置會提示:"Tue Dec 15, 2015 14:06:55: The stack pointer for stack 'CSTACK' (currently 0x2000161C) is outside the stack range (0x20002878 to 0x20003078) " ,這很正常。

網友給出的解釋:

應用程式啟動時要有一個堆疊,不管是裸機,還是基於uCOS,,那就是CSTACK堆疊uCOS-III執行起來後,每個任務有自己的堆疊,所以,當任務執行的時候,IAR編譯器會識別到堆疊指標不在CSTACK之內,所以會報The stack pointer for stack 'CSTACK' (currently 0x20007A1C) is outside the stack range (0x20008B88 to 0x20009B88) 這個不是問題,是正常的,,當然,uCOS-III官方移植中,中斷堆疊也是獨立的,專門用於處理中斷,這個好處就是:每個任務堆疊不必考慮中斷巢狀層數,從而不用為中斷巢狀增加堆疊大小。所以執行中斷程式時,也會報The stack pointer for stack 'CSTACK' (currently 0x20007A1C) is outside the stack range (0x20008B88 to 0x20009B88) CSTACK只是在系統啟動時使用,之後就沒用了,所以可以配置的小一點,以免造成太大的浪費。