Semihosting

Semihosting provides an interface for the debugger to be able to execute system calls in the embedded application on the host machine. The debugger detects system calls, halts the debugged board, then executes the proper system call on the host, pass back the system call’s result for the board, and resumes the board’s execution. The debugger supports a limited amount of system calls, which are the following:

  • Close

  • Lseek

  • Read

  • Write

  • Unlink

  • Fstat

These system calls can be used by calling the appropriate system call function, or by using a library call to printf, fopen, fclose, etc..

Creating a new file

When creating/opening a file, the current active project path is considered, but the file name can be an absolute path too.

new file
Fig. 1. Creating a new file using the open system call

Reading/Writing

For writing, the debugger console can be used.

writing
Fig. 2. Example of writing on the console

The same is true for reading, the input value is read from the console, and the debugger will wait until it gets the prompt from the user.

read before
Fig. 3. Before the scanf the value is 5
read after
Fig. 4. After the user entered 13 in the console, the value changed to 13