2013-10-21

CooCox semihostig - CooCox

What is semihosting? - ARM Info Center 

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0471c/Bgbjjgij.html

Semihosting is a mechanism that enables code running on an ARM target to communicate and use the Input/Output facilities on a host computer that is running a debugger.

Examples of these facilities include keyboard input, screen output, and disk I/O. For example, you can use this mechanism to enable functions in the C library, such as printf() and scanf(), to use the screen and keyboard of the host instead of 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 enables the host computer to provide these facilities.

Semihosting is implemented by a set of defined software instructions, for example, SVCs, that generate exceptions from program control. The application invokes the appropriate semihosting call and the debug agent then handles the exception. The debug agent provides the required communication with the host.

The semihosting interface is common across all debug agents provided by ARM. Semihosted operations work when you are debugging applications on your development platform, as shown in the following figure:

Figure 16. Semihosting overview


In many cases, semihosting is invoked by code within library functions. The application can also invoke the semihosting operation directly.

Note

ARM processors prior to ARMv7 use the SVC instructions, formerly known as SWI instructions, to make semihosting calls. However, if you are compiling for an ARMv6-M or ARMv7-M, for example a Cortex-M1 or Cortex-M3 processor, semihosting is implemented using the BKPT instruction.

...


Coocox Components Semihosting Committer: CooCox Updated: 2011-10-19

http://www.coocox.org/show_comp/semihosting-c33.html

Description:

Implementation of Semihosting GetChar/SendChar

Support Chip:

Cortex-M0  Cortex-M0Plus  Cortex-M3  Cortex-M4  ...

Overview

Implementation of Semihosting GetChar/SendChar.

What is Semihosting?

Semihosting provides a mechanism for code running on the MCU to put/get data to/from IDE through USB Adapter.

How to use:

enable Semihosting Project properties.

checked "Semihosting" in components page

checked "Retarget printf" in components page, then implement PrintChar in printf.c <Optional >

use Semihostting API or Retargeted printf/scanf to transmit data between MCU & IDE

API Reference

SH_SendChar

Transmit a char on semihosting mode.

SH_SendString

Transmit a null-terminated string on semihosting mode.

SH_GetChar

Read a char on semihosting mode.

SH_DoCommand

Semihosting functions prototype


Semihosting retarget Author: CooCox

http://www.coocox.org/show_exam/Semihosting/8.html

Description:

This example shows how to retarget printf to semihosting output. It cannot be add directly.you need to copy the content of PrintChar to the PrintChar function in printf.c

Example Code

#include "semihosting.h"

void PrintChar(char c)
{
        /* Send a char like: 
           while(Transfer not completed);
           Transmit a char;
        */      
        SH_SendChar(c);
}

.END

No comments:

Post a Comment