EasyManua.ls Logo

Segger J-Link - Communication Protocol

Segger J-Link
480 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
458 CHAPTER 19 Semihosting
J-Link / J-Trace (UM08001) ©
2004-2017 SEGGER Microcontroller GmbH & Co. KG
19.4 Communication protocol
Semihosting defines a standardized set of semihosting commands that need to be
supported by a debugger, claiming that it supports semihosting. In the following, the
communication protocol for semihosting as well as the specified commands are
explained.
19.4.1 Register R0
Right before the operation that halts the CPU for semihosting, is performed, the tar-
get application needs to prepare CPU register R0 and (depending on the command)
also some other CPU registers.
On halt, R0 will hold the semihosting command, so the debugger can determine fur-
ther parameters and operation to be performed, from it.
19.4.2 Command SYS_OPEN (0x01)
Opens a file on the host system.
Register R1 holds a pointer to an address on the target, that specifies a 3-word (32-
bit each) buffer where additional information for the command can be found.
Word 0
Pointer to a null-terminated string that specifies the file to open.
Special: The string ":tt" specifies the console input/output (usually stdin / stdout).
Which one is selected depends on if the stream is opened for reading or writing.
Word 1
A number that specifies how the file is to be opened (reading/writing/appending
etc.). In the following, the corresponding ISO C fopen() modes for the numbers are
listed.
Word 2
Integer that specifies the length of the string (excluding the terminating null charac-
ter) pointed to by word 0.
Return value
Operation result is written to register R0 by the debugger.
Word1 ISO C fopen() mode
0r
1rb
2r+
3r+b
4w
5wb
6w+
7w+b
8a
9ab
10 a+
11 a+b
Table 19.1: ISO C fopen() modes
!= 0 O.K., handle of the file (needed for SYS_CLOSE etc.)
== -1 Error

Table of Contents

Other manuals for Segger J-Link

Related product manuals