Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@micro-os-plus/semihosting

micro-os-plus68MIT8.0.0

A source library xPack with the µOS++ portable semihosting definitions

readme

license CI on Push

A source library xPack with the µOS++ semihosting support

This project provides the XXXX YYYY source library as an xPack 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 xPack, 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.

For details please follow the instructions in the xPack install page.

xpm

Note: the package will be available from npmjs.com at a later date.

For now, it can be installed from GitHub:

cd my-project
xpm init # Unless a package.json is already present

xpm install github:micro-os-plus/semihosting-xpack

When ready, this package will be 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-semihosting

Git 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-semihosting

Branches

Apart from the unused master branch, there are two active branches:

  • xpack, with the latest stable version (default)
  • xpack-develop, with the current development version

All development is done in the xpack-develop branch, and contributions via Pull Requests should be directed to this branch.

When new releases are published, the xpack-develop 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:

static 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:

  static inline __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.cpp
  • src/semihosting-syscalls.cpp
  • src/semihosting-trace.cpp

Preprocessor definitions

  • MICRO_OS_PLUS_INCLUDE_CONFIG_H - to include <micro-os-plus/config.h>
  • MICRO_OS_PLUS_INCLUDE_SEMIHOSTING_SYSCALLS
  • MICRO_OS_PLUS_INTEGER_SEMIHOSTING_MAX_OPEN_FILES (20)
  • MICRO_OS_PLUS_DEBUG_SYSCALLS_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_CHDIR_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_CHMOD_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_CHOWN_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_CLOSEDIR_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_EXECVE_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_FCNTL_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_FORK_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_FSYNC_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_FTRUNCATE_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_IOCTL_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_KILL_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_LINK_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_OPENDIR_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_RAISE_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_READDIR_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_READLINK_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_REWINDDIR_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_RMDIR_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_SELECT_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_SYMLINK_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_SYNC_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_TRUNCATE_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_UTIME_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_WAIT_BRK
  • MICRO_OS_PLUS_DEBUG_SYSCALL_WRITEV_BRK
  • MICRO_OS_PLUS_INCLUDE_SEMIHOSTING_STARTUP
  • MICRO_OS_PLUS_INTEGER_SEMIHOSTING_CMDLINE_ARRAY_SIZE (80)
  • MICRO_OS_PLUS_INTEGER_SEMIHOSTING_ARGV_ARRAY_SIZE (10)

Compiler options

  • -std=c++20 or higher for C++ sources
  • -std=c11 for C sources

C++ Namespaces

  • micro_os_plus::semihosting

C++ Classes

  • none

Dependencies

  • the @micro-os-plus/diag-trace package, 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:

  • 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

The original content is released under the MIT License, with all rights reserved to Liviu Ionescu.

changelog

Change & release log

Releases in reverse chronological order.

Please check GitHub and close existing issues and pull requests.

2022-08-04

  • v8.0.0
  • 4425dc3 rename MICRO_OS_PLUS_INTEGER_TRACE_SEMIHOSTING_BUFFER_ARRAY_SIZE
  • d11f17e .vscode/settings.json: cmake.ignoreCMakeListsMissing
  • 6942748 .vscode/settings.json: makefile.configureOnOpen

2022-07-28

  • v7.1.0
  • 38d818b #7: rework, implement the newlib underscore functions
  • 94c139c semihosting.h: add feature magic numbers
  • 56799d5 update response to signed_register_t

2022-07-25

  • be0bea9 semihosting.h: explain C declaration not here
  • 22c9f3d add preliminary xpack.json

2022-07-24

2022-07-24 * bf2f2be xpack.json: add missing *-brk options 2022-07-24 * 61de2db xpack.json: no more camelCase for option names 2022-07-24 * 3b41c6f #6: rename startup cmdline & argv 2022-07-24 * 6dd77bb #5: remove socket functions

2022-07-23

  • v7.0.0 (not published on npmjs)
  • 80c09e8 add experimental xpack.json
  • 430bbbb #4: get rid of the C++ posix namespace

2022-07-22

  • v6.0.0 (not published on npmjs)
  • 209fe7c reformat namespaces
  • 0e96151 split semihosting-startup.cpp
  • d0c8d25 rename semihosting-trace.cpp

2022-05-24

  • v5.0.0
  • 25123f9 use param_block_t; rename SYS_GETCMDLINE
  • 2a7e329 semihosting.h: add extra numbers

2022-02-15

  • v4.0.0
  • f815aee trace-semihosting.cpp: add flush()

2022-02-10

  • 0eb2ebb .c* include <micro-os-plus/config.h>

2022-02-09

  • 7a079af rename MICRO_OS_PLUS_DEBUG
  • 0a59d26 rename MICRO_OS_PLUS_TRACE

2022-02-05

  • v3.2.1

2022-02-04

  • v3.2.0
  • 2a3d08b cmake: add xpack_display_target_lists

2022-02-02

  • edadab4 add meson support
  • b9bbe9b trace-semihosting.cpp: fix casts

2022-01-28

  • 2072ae4 rework CMake, top config, no sources

2022-01-27

  • 99fd5b7 syscalls: move initialise_monitor_handles to startup

2022-01-26

  • v3.1.0
  • rework CMake

2022-01-02

  • v3.0.3
  • avoid select alias, it fails with arm-none-eabi-gcc 10.3 on Ubuntu

2022-01-02

  • v3.0.2

2021-03-09

  • v3.0.1
  • fix/silence warnings

2021-03-01

  • v3.0.0

2021-02-28

  • rename micro_os_plus

2021-02-04

  • v2.1.0
  • first restructured release

2018-04-16

  • v2.0.2
  • cleanup deps
  • update README developer info

2018-01-25

  • v2.0.1
  • [#3] use void* field_t

2018-01-24

  • v2.0.0

2018-01-23

  • Use the posix:: namespace
  • add debug breaks for unimplemented calls

2018-01-21

  • [#1] Update semihosting after OpenOCD new definitions; remove report_exception()
  • [#2] Add syscall functions

2018-01-15

  • v1.0.0
  • initial version, copied from µOS++.