@micro-os-plus/semihosting
v11.0.0
Published
A source code library with the µOS++ portable semihosting definitions
Downloads
376
Readme
A source code library with the µOS++ semihosting support
This project provides the µOS++ semihosting source library as an xpm
dependency and includes support for semihosting.
It complements the newlib implementation (arm/librdimon) with a more complete set of POSIX functions, and also includes debugging support.
The project is hosted on GitHub as micro-os-plus/semihosting-xpack.
Maintainer info
This page is addressed to developers who plan to include this source library into their own projects.
For maintainer info, please see the README-MAINTAINER file.
Install
As a source library xpm package, the easiest way to add it to a project is via xpm, but it can also be used as any Git project, for example as a submodule.
Prerequisites
A recent xpm, which is a portable Node.js command line application.
It is recommended to update to the latest version with:
npm install --global xpm@latestFor details please follow the instructions in the xPack install page.
xpm
This package is available as
@micro-os-plus/semihosting
from the npmjs.com registry:
cd my-project
xpm init # Unless a package.json is already present
xpm install @micro-os-plus/semihosting@latest
ls -l xpacks/@micro-os-plus/semihostingGit submodule
If, for any reason, xpm is not available, the next recommended
solution is to link it as a Git submodule below an xpacks folder.
cd my-project
git init # Unless already a Git project
mkdir -p xpacks
git submodule add https://github.com/micro-os-plus/semihosting-xpack.git \
xpacks/@micro-os-plus/semihostingBranches
Apart from the unused master branch, there are two active branches:
xpack, with the latest stable version (default)xpack-development, with the current development version
All development is done in the xpack-development branch, and contributions via
Pull Requests should be directed to this branch.
When new releases are published, the xpack-development branch is merged
into xpack.
Developer info
Overview
This project provides several components, which can be enabled separately:
- the declarations for the basic semihosting calls
- implementations for the system calls
- implementations for the initialisations required during the startup
- implementations for the debug trace channels via semihosting
Status
The semihosting source library is fully functional.
C++ API
The C++ methods available to call semihosting functions are:
namespace micro_os_plus::semihosting
{
response_t
call_host (int reason, param_block_t* arg);
}C API
The same functionality is available from a similar C function, defined in the architecture package:
micro_os_plus_semihosting_response_t
micro_os_plus_semihosting_call_host (
int reason,
micro_os_plus_semihosting_param_block_t* arg);Implementation
The architecture should provide a definition of the following function:
__attribute__ ((always_inline)) int
micro_os_plus_semihosting_call_host (int reason, void* arg);Build & integration info
The project is written in C++, and it is expected to be used in C and C++ projects.
The source code was compiled with GCC 11, clang 12, clang 13 arm-none-eabi-gcc 11, riscv-none-elf-gcc 12, and should be warning free.
To ease the integration of this package into user projects, there are already made CMake and meson configuration files (see below).
For other build systems, consider the following details:
Include folders
The following folders should be passed to the compiler during the build:
include
The header files to be included in user projects are:
#include "micro-os-plus/semihosting.h"Source files
The source files to be added to the build are:
src/semihosting-startup.cppsrc/semihosting-syscalls.cppsrc/semihosting-trace.cpp
Preprocessor definitions
MICRO_OS_PLUS_SEMIHOSTING_SYSCALLS_ENABLEDMICRO_OS_PLUS_SEMIHOSTING_SYSCALLS_MAX_OPEN_FILES_INTEGER(20)MICRO_OS_PLUS_SEMIHOSTING_SYSCALLS_DEBUG_BRK_ENABLEDMICRO_OS_PLUS_DEBUG_SYSCALL_CHDIR_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_CHMOD_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_CHOWN_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_CLOSEDIR_BRKMICRO_OS_PLUS_SEMIHOSTING_SYSCALLS_DEBUG_EXECVE_BRK_ENABLEDMICRO_OS_PLUS_DEBUG_SYSCALL_FCNTL_BRKMICRO_OS_PLUS_SEMIHOSTING_SYSCALLS_DEBUG_FORK_BRK_ENABLEDMICRO_OS_PLUS_DEBUG_SYSCALL_FSYNC_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_FTRUNCATE_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_IOCTL_BRKMICRO_OS_PLUS_SEMIHOSTING_SYSCALLS_DEBUG_KILL_BRK_ENABLEDMICRO_OS_PLUS_SEMIHOSTING_SYSCALLS_DEBUG_LINK_BRK_ENABLEDMICRO_OS_PLUS_DEBUG_SYSCALL_OPENDIR_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_RAISE_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_READDIR_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_READLINK_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_REWINDDIR_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_RMDIR_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_SELECT_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_SYMLINK_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_SYNC_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_TRUNCATE_BRKMICRO_OS_PLUS_DEBUG_SYSCALL_UTIME_BRKMICRO_OS_PLUS_SEMIHOSTING_SYSCALLS_DEBUG_OPENDIR_BRK_ENABLEDMICRO_OS_PLUS_DEBUG_SYSCALL_WRITEV_BRKMICRO_OS_PLUS_SEMIHOSTING_STARTUP_ENABLEDMICRO_OS_PLUS_SEMIHOSTING_STARTUP_CMDLINE_BUFFER_ARRAY_SIZE_INTEGER(80)MICRO_OS_PLUS_SEMIHOSTING_STARTUP_ARGV_BUFFER_ARRAY_SIZE_INTEGER(10)
Compiler options
-std=c++20or higher for C++ sources-std=c11for C sources
C++ Namespaces
micro_os_plus::semihosting
C++ Classes
- none
Dependencies
- the
@micro-os-plus/diag-tracepackage, for the declarations of the debug trace channels
CMake
To integrate the semihosting source library into a CMake application, add this folder to the build:
add_subdirectory("xpacks/@micro-os-plus/semihosting")`The result is an interface library that can be added as an application dependency with:
target_link_libraries(your-target PRIVATE
micro-os-plus::semihosting
)meson
To integrate the semihosting source library into a meson application, add this folder to the build:
subdir('xpacks/@micro-os-plus/semihosting')The result is a dependency object that can be added to an application with:
exe = executable(
your-target,
link_with: [
# Nothing, not static.
],
dependencies: [
micro_os_plus_semihosting_dependency,
]
)Examples
TBD
Known problems
- none
Tests
TBD
Change log - incompatible changes
According to semver rules:
Major version X (X.y.z | X > 0) MUST be incremented if any backwards incompatible changes are introduced to the public API.
The incompatible changes, in reverse chronological order, are:
- v11.x: rename micro_os_plus_startup_exit_terminate_hook
- v10.x: rename micro_os_plus_startup_initialise_args_hook
- v9.x: update for xcdl macros
- v8.x: rename MICRO_OS_PLUS_INTEGER_TRACE_SEMIHOSTING_BUFFER_ARRAY_SIZE
- v7.x: get rid of the C++
posix::namespace - v6.x: rename source files
- v5.x: rename SYS_GETCMDLINE; use param_block_t
- v4.x: rename MICRO_OS_PLUS_DEBUG, MICRO_OS_PLUS_TRACE
- v3.x: rename the micro_os_plus namespace
- v2.x: update for new OpenOCD implementation; use the posix:: namespace
- v1.x: the code was extracted from the mono-repo µOS++ project
License
Unless otherwise stated, the content is released under the terms of the MIT License, with all rights reserved to Liviu Ionescu.
