Difference between revisions of "Semihosting"

From SEGGER Wiki
Jump to: navigation, search
(Semihosting with GDB)
(Semihosting with GDB)
Line 47: Line 47:
 
* Cortex-M Trace Reference Board (ST STM32F407VE)
 
* Cortex-M Trace Reference Board (ST STM32F407VE)
 
* J-Link V10 or later
 
* J-Link V10 or later
* (optional)Ozone V2.62 or later
+
* (optional) Ozone V2.62 or later
   
 
==Semihosting with EWARM==
 
==Semihosting with EWARM==

Revision as of 13:44, 10 April 2019

Semihosting is a mechanism for ARM based target devices to provide a way to communicate with a host system to allow different operations to be performed. Such operations can be sending and receiving data from and to the host system and file I/O operations. These can also be automated and used for e.g. unit testing. The biggest drawback is that the target device needs to be halted for each interaction between host and target device which will impact the real-time behaviour of a system. Additional information about semihosting can be found in the J-Link user manual (UM08001).

Semihosting with Ozone

Ozone supports the standard Arm implementation for semihosting. So the semihosting handling needs to be done completely in the target application.

An example implementation can be found in the following example project: Semihosting Ozone

The example project will open a file on the host system and write a string to it. Make sure the file path is existing otherwise the project will not run. You can of course change the path by simply editing variable pFilename and rebuild it with Embedded Studio.

Prerequisites for the example project are:

  • Ozone V2.62 or later
  • Embedded Studio V4.16 or later
  • Cortex-M Trace Reference Board (ST STM32F407VE)
  • J-Link V10 or later

Semihosting with Embedded Studio

The implementation of semihosting in Embedded Studio is straight forward. Standard library functions for fopen, fwrite, fread etc. are implemented and just need to be called. It is recommended to use the project wizard when creating a new project so all default settings are set correctly.

The following example project opens a file on your host system and writes a string into it triggered by your target device: Semihosting Embedded Studio

Make sure the file path is existing otherwise the project will not run. You can of course change the path by simply editing variable pFilename and rebuild it with Embedded Studio.

Prerequisites for the example project are:

  • Embedded Studio V4.16 or later
  • Cortex-M Trace Reference Board (ST STM32F407VE)
  • J-Link V10 or later


Semihosting with GDB

This section will cover how semihosting can be used with Eclipse in combination with GDB and newlib. Generally newlib will only provide a rudimentary setup for semihosting so it will not work out-of-thebox except printf calls. All callbacks used by e.g. fopen need to be implemented by the user to utilize semihosting.

The following project will show such an example project and create a file at a certain path, fill it with a string and close that file: Semihosting Eclipse

Make sure the file path is existing otherwise the project will not run. You can of course change the path by simply editing variable pFilename and rebuild it with Embedded Studio. As a base project a default J-Link debug project was created for Cortex-M. Then a debug config with the correct target device was set up. Next make sure that in the debug config semihosting is enabled.

The example project comes also with an Ozone setup that runs out-of-the-box should Eclipse not be the debugger of your choice.

Prerequisites for the example project are:

  • Eclipse Cpp 2019-03
  • Latest GNU ARM Eclipse plugin
  • Cortex-M Trace Reference Board (ST STM32F407VE)
  • J-Link V10 or later
  • (optional) Ozone V2.62 or later

Semihosting with EWARM

The implementation of semihosting in EWARM is generally available but requires some extra steps. Standard library functions for fopen, fwrite, fread etc. are implemented and just need to be called. Under project options semihosting must be enabled as well as the library support must be set to "full" which will drastically increase memory usage of your project.

The project options can be found at the following project settings:

EWARM Library setting.png

Set the library level to "Full" and the library low level implementation to semihosting each.

The following example project opens a file on your host system and writes a string into it triggered by your target device: Semihosting EWARM

Make sure the file path is existing otherwise the project will not run. You can of course change the path by simply editing variable pFilename and rebuild it with Embedded Studio.

Prerequisites for the example project are:

  • EWARM V8.322 or later
  • Cortex-M Trace Reference Board (ST STM32F407VE)
  • J-Link V10 or later