學習筆記-Semihosting

來源:互聯網
上載者:User

如何理解Semihosting?(老帖重發,寫得比較久了)

  Semihosting,顧名思義,就是"半主控",意思就是說,運行在target board上的程式利用主機上的facilities的一種程式調試方式,主要是debug目標板時,利用主機的輸入輸出裝置,例如在AxD的console上列印相應的調試資訊或者用主機的鍵盤輸入相應字元作為target上的程式的輸入。
  C/C++ code預設是可以使用console的,例如,如果只包含C/C++的程式採用ARMulater類比,就可以直接使用console作為程式的輸出裝置;如果程式包含有彙編代碼,要使用主機裝置的話,必須採用semihosting SWI方式。Semihosing SWI(以下簡稱SHS),必須有相應的debug agent的支援,才能截獲SHS,並向software debugger(AxD)請求相應的服務,如列印字元或者接受字元輸入,這樣的agents包括:
 1)ARMulater
 2)debug monitor(Angel)
 3)MultiICE
  由於調試裸板或者沒有Angel可以供目標板使用的時候,主要還是要藉助模擬器進行調試,所以第三種方式最為常用,下面主要就這種方式進行介紹。當然,UART也是一種最常用的調試介面,但是,使用Semihosting,可以獨立地調試各個硬體模組的邏輯功能,確保各段代碼正確後再進行整合,相應地省去了每次都要配置UART和另開一個hyperterminal觀察調試資訊。所以,我在開發的時候傾向於使用semihosting來調試相關的代碼,這些代碼使用C或者C++編寫,也就是說和硬體設定關係不大。

=================================Below from ADS help===============================
Multi-ICE
When using Multi-ICE in default configuration, semihosting is implemented as follows:
1. On ARM7 processors:
 a) A breakpoint is set on the SWI vector.
 b) When this breakpoint is hit, Multi-ICE examines the SWI number.
 c) If the SWI is recognized as a semihosting SWI, Multi-ICE emulates it and transparently restarts execution of the application.
 If the SWI is not recognized as a semihosting SWI, Multi-ICE halts the processor and reports an error.
2. On other processors:
 a) Vector-catch logic traps SWIs.
 b) If the SWI is recognized as a semihosting SWI, Multi-ICE emulates it and transparently restarts execution of the application.
 If the SWI is not recognized as a semihosting SWI, Multi-ICE halts the processor and reports an error.
 This semihosting mechanism can be disabled or changed by the following debugger internal variables:
  $semihosting_enabled
 Set this variable to 0 to disable semihosting. If you are debugging an application running from ROM, this allows you to use an  additional watchpoint unit.
 Set this variable to 1 to enable semihosting. This is the default.
 Set this variable to 2 to enable Debug Communications Channel semihosting.
 The S bit in $vector_catch has no effect unless semihosting is disabled.
 $semihosting_vector
This variable controls the location of the breakpoint set by Multi-ICE to detect a semihosted SWI. It is set to the SWI entry in the exception vector table (0x8) by default.
If your application requires semihosting as well as having its own SWI handler, set $semihosting_vector to an address in your SWI handler. This address must point to an instruction that is only executed if your SWI handler has identified a call to a semihosting SWI. All registers must already have been restored to whatever values they had on entry to your SWI handler.
Multi-ICE handles the semihosted SWI and then examines the contents of lr and returns to the instruction following the SWI instruction in your code.
Regardless of the value of $vector_catch, all exceptions and interrupts are trapped and reported as an error condition.
For details of how to modify debugger internal variables, see the appropriate debugger documentation.

 

最後一次修改2006.3.14

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.