最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

semihosting of ARM

工作和技术 crifan 2452浏览 0评论

semihosting of ARM【转】

最近想编写一个自动烧写到片外Flash的Bootloader(我用的是周立功的EasyARM2200开发板),在看ADS的开发文档时,经常出现semihosting这个术语,大概查找了一下,是有关调试的一种方法。我对调试方法还是很感兴趣的,因为笔记本没有并口,用不了EasyJTAG仿真器,一直都是用串口直接烧到片内Flash中跑程序的。

介绍一下semihosting的功能:
Semihosting is a mechanism for ARM targets to communicate input/output requests
from application code to a host computer running a debugger. This mechanism could be
used, for example, to allow functions in the C library, such as printf() and scanf(), to use the screen and keyboard of the host rather than having a screen and keyboard on the target system.
This is useful because development hardware often does not have all the input and
output facilities of the final system. Semihosting allows the host computer to provide these facilities.
Semihosting is implemented by a set of defined software interrupt (SWI) operations.
The application invokes the appropriate SWI and the debug agent then handles the SWI
exception. The debug agent provides the required communication with the host.
In many cases, the semihosting SWI will be invoked by code within library functions. The application can also invoke the semihosting SWI directly. Refer to the C library descriptions in the ADS Compilers and Libraries Guide for more information on support for semihosting in the ARM C library.
下面列出部分semihosted operations
SYS_OPEN (0x01) Open a file on the host
SYS_CLOSE (0x02) Close a file on the host
SYS_WRITEC (0x03) Write a character to the console
SYS_WRITE (0x05) Write to a file on the host
SYS_READ (0x06) Read the contents of a file into a buffer
SYS_ISERROR (0x08) Determine if a return code is an error
SYS_ISTTY (0x09) Check whether a file is connected to an interactive device
SYS_SEEK (0x0A) Seek to a position in a file
SYS_FLEN (0x0C) Return the length of a file
SYS_TMPNAM (0x0D) Return a temporary name for a file
SYS_REMOVE (0x0E) Remove a file from the host
SYS_RENAME (0x0F) Rename a file on the host
SYS_CLOCK (0x10) Number of centiseconds since execution started
SYS_SYSTEM (0x12) Pass a command to the host command-line interpreter
SYS_ERRNO (0x13) Get the value of the C library errno variable
总结一下,semihosting是在调试器里使用,一旦程序使用semihosting,则代码(库函数)直接产生软件中断,调用主机上的函数,用于对主机的操作。例如:程序中可以使用printf()函数,当执行该函数时,代码产生软件中断,调试器捕捉到该特定中断后,调用主机上的函数执行,最后在调试软件的界面中显示该函数的结果。换句话说,semihosting提供了与主机的交互功能,方便调试。直接烧到板子里是用不了的,因为没法与主机通信了。

转载请注明:在路上 » semihosting of ARM

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
79 queries in 0.167 seconds, using 22.08MB memory