RTEMS User Manual (6.9e8141c).¶
The authors have used their best efforts in preparing this material. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. No warranty of any kind, expressed or implied, with regard to the software or the material contained in this document is provided. No liability arising out of the application or use of any product described in this document is assumed. The authors reserve the right to revise this material and to make changes from time to time in the content hereof without obligation to notify anyone of such revision or changes.
The RTEMS Project is hosted at https://www.rtems.org. Any inquiries concerning RTEMS, its related support components, or its documentation should be directed to the RTEMS Project community.
1. Introduction¶
1.1. Overview¶
You are someone looking for a real-time operating system. This document
presents the basic features of RTEMS, so that you can decide if it is worth to look at,
gives you a quick start to install all the tools necessary to work with RTEMS, and
helps you to build an example application on top of RTEMS.
1.2. Features¶
The Real-Time Executive for Multiprocessor Systems (RTEMS) is a multi-threaded, single address-space, real-time operating system with no kernel-space/user-space separation. It is capable to operate in an SMP configuration providing a state of the art feature set.
RTEMS is licensed under a modified GPL 2.0 or later license with an exception for static linking [1]. It exposes no license requirements on application code. The third-party software used and distributed by RTEMS which may be linked to the application is licensed under permissive open source licenses. Everything necessary to build RTEMS applications is available as open source software. This makes you completely vendor independent.
RTEMS provides the following basic feature set:
-
Programming languages
C/C++/OpenMP (RTEMS Source Builder, RSB)
Ada (RSB,
--with-ada
)Erlang
Fortran (RSB,
--with-fortran
)Python and MicroPython
Parallel languages
Thread synchronization and communication
Locking protocols
Scalable timer and timeout support
Lock-free timestamps (FreeBSD timecounters)
Responsive interrupt management
Link-time configurable schedulers
Fixed-priority
Job-level fixed-priority (EDF)
Constant Bandwidth Server (experimental)
Clustered scheduling (SMP feature)
Focus on link-time application-specific configuration
Linker-set based initialization (similar to global C++ constructors)
Operating system uses fine-grained locking (SMP feature)
Dynamic memory allocators
First-fit (default)
Universal Memory Allocator (UMA , libbsd)
File systems
Device drivers
Termios (serial interfaces)
I2C (Linux user-space API compatible)
SPI (Linux user-space API compatible)
Network stacks (legacy, libbsd, lwIP)
USB stack (libbsd)
SD/MMC card stack (libbsd)
Framebuffer (Linux user-space API compatible, Qt)
Application runs in kernel-space and can access hardware directly
libbsd
Port of FreeBSD user-space and kernel-space components to RTEMS
Easy access to FreeBSD software for RTEMS
Support to stay in synchronization with FreeBSD
1.3. Ecosystem¶
The RTEMS Ecosystem is the collection of tools, packages, code, documentation and online content provided by the RTEMS Project. The ecosystem provides a way to develop, maintain, and use RTEMS. It’s parts interact with the user, the host environment, and each other to make RTEMS accessible, useable and predicable.
The ecosystem is for users, developers and maintainers and it is an ongoing effort that needs your help and support. The RTEMS project is always improving the way it delivers the kernel to you and your feedback is important so please join the mailing lists and contribute back comments, success stories, bugs and patches.
What the RTEMS project describes here to develop, maintain and use RTEMS does not dictate what you need to use in your project. You can and should select the work-flow that best suites the demands of your project and what you are delivering.
1.3.1. Rational¶
RTEMS is complex and the focus of the RTEMS Ecosystem is to simplify the complexity for users by providing a stable documented way to build, configure and run RTEMS. RTEMS is more than a kernel running real-time applications on target hardware, it is part of a project’s and therefore team’s workflow and every project and team is different.
RTEMS’s ecosystem does not mandate a way to work. It is a series of parts, components, and items that are used to create a suitable development environment to work with. The processes explained in this manual are the same things an RTEMS maintainer does to maintain the kernel or an experienced user does to build their production system. It is important to keep this in mind when working through this manual. We encourage users to explore what can be done and to discover ways to make it fit their needs. The ecosystem provided by the RTEMS Project will not install in a single click of a mouse because we want users to learn the parts they will come to depend on as their project’s development matures.
The RTEMS Ecosystem provides a standard interface that is the same on all supported host systems. Standardizing how a user interacts with RTEMS is important and making that experience portable is also important. As a result the ecosystem is documented at the command line level and we leave GUI and IDE integration for users and integrators.
Standardizing the parts and how to use them lets users create processes and procedures that are stable over releases. The RTEMS Ecosystem generates data that can be used to audit the build process so their configuration can be documented.
The ecosystem is based around the source code used in the various parts, components and items of the RTEMS development environment. A user can create an archive of the complete build process including all the source code for long term storage. This is important for projects with a long life cycle.
1.3.2. Open Source¶
RTEMS is an open source operating system and an open source project and this extends to the ecosystem. We encourage users to integrate the processes to build tools, the kernel and any third-party libraries into their project’s configuration management processes.
All the parts that make up the ecosystem are open source. The ecosystem uses a package’s source code to create an executable on a host so when an example RTEMS executable is created and run for the first time the user will have built every tool as well as the executable from source. The RTEMS Project believes the freedom this gives a user is as important as the freedom of having access to the source code for a package.
1.3.3. Deployment¶
The RTEMS Project provides the ecosystem as source code that users can download to create personalised development environments. The RTEMS Project does not provide packaging and deployment for a specific host environment, target architecture or BSP. The RTEMS Project encourages users and organizations to fill this role for the community. The RTEMS Source Builder provides some aid to build and deploy tool binaries.
1.4. Real-time Application Systems¶
Real-time application systems are a special class of computer applications. They have a complex set of characteristics that distinguish them from other software problems. Generally, they must adhere to more rigorous requirements. The correctness of the system depends not only on the results of computations, but also on the time at which the results are produced. The most important and complex characteristic of real-time application systems is that they must receive and respond to a set of external stimuli within rigid and critical time constraints referred to as deadlines. Systems can be buried by an avalanche of interdependent, asynchronous or cyclical event streams.
Deadlines can be further characterized as either hard or soft based upon the value of the results when produced after the deadline has passed. A deadline is hard if the results have no value after the deadline has passed, or a catastrophic event results from their intended use if not completed on time. In contrast, results produced after a soft deadline may still have some value.
Another distinguishing requirement of real-time application systems is the ability to coordinate or manage a large number of concurrent activities. Since software is a synchronous entity, this presents special problems. One instruction follows another in a repeating synchronous cycle. Even though mechanisms have been developed to allow for the processing of external asynchronous events, the software design efforts required to process and manage these events and tasks are growing more complicated.
The design process is complicated further by spreading this activity over a set of processors instead of a single processor. The challenges associated with designing and building real-time application systems become very complex when multiple processors are involved. New requirements such as interprocessor communication channels and global resources that must be shared between competing processors are introduced. The ramifications of multiple processors complicate each and every characteristic of a real-time system.
1.5. Real-time Executive¶
Fortunately, real-time operating systems, or real-time executives, serve as a cornerstone on which to build the application system. A real-time multitasking executive allows an application to be cast into a set of logical, autonomous processes or tasks which become quite manageable. Each task is internally synchronous, but different tasks execute independently, resulting in an asynchronous processing stream. Tasks can be dynamically paused for many reasons resulting in a different task being allowed to execute for a period of time. The executive also provides an interface to other system components such as interrupt handlers and device drivers. System components may request the executive to allocate and coordinate resources, and to wait for and trigger synchronizing conditions. The executive system calls effectively extend the CPU instruction set to support efficient multitasking. By causing tasks to travel through well-defined state transitions, system calls permit an application to demand-switch between tasks in response to real-time events.
By properly grouping stimuli responses into separate tasks a system can now asynchronously switch between independent streams of execution. This allows the system to directly respond to external stimuli as they occur, as well as meet critical performance specifications that are typically measured by guaranteed response time and transaction throughput. The multiprocessor extensions of RTEMS provide the features necessary to manage the extra requirements introduced by a system distributed across several processors. It removes the physical barriers of processor boundaries from the world of the system designer, enabling more critical aspects of the system to receive the required attention. Such a system, based on an efficient real-time, multiprocessor executive, is a more realistic model of the outside world or environment for which it is designed. As a result, the system will always be more logical, efficient, and reliable.
By using the directives provided by RTEMS, the real-time applications developer is freed from the problem of controlling and synchronizing multiple tasks and processors. In addition, one need not develop, test, debug, and document routines to manage memory, pass messages, or provide mutual exclusion. The developer is then able to concentrate solely on the application. By using standard software components, the time and cost required to develop sophisticated real-time applications are significantly reduced.
2. Quick Start¶
Follow the sections of this chapter step by step to get started developing applications on top of RTEMS. You will create a set of tools and an RTEMS kernel for your selected Board Support Package (BSP).
2.1. Preparation¶
You need to perform some basic preparation to get started with RTEMS development. You need tools from your host’s operating system to build the RTEMS tool suite from source. The RTEMS tools you build are used to build the Board Support Package (BSP) libraries for your target hardware from source. The BSP libraries contain the RTEMS operating system. All RTEMS tools and runtime libraries are built from source on your host machine. The RTEMS Project does not maintain binary builds of the tools. This may appear to be the opposite to what you normally experience with host operating systems, and it is, however this approach works well. RTEMS is not a host operating system and it is not a distrbution. Providing binary packages for every possible host operating system is too big a task for the RTEMS Project and it is not a good use of core developer time. Their time is better spent making RTEMS better and faster. This is not a one-click installation process, but there are good reasons to build everything from source. The RTEMS Project base installation sets up the tools and the RTEMS kernel for the selected BSPs. The tools run on your host computer are used to compile, link, and format executables so they can run on your target hardware.
During this Quick Start guide you will:
Select a suitable place to install RTEMS.
Select if you download all the source code before you start building RTEMS or the source is downloaded on demand as it is needed. If you do not have a reliable internet connection we recommend you download all the source before starting a build.
Build a tool suite.
Build and test a BSP.
Optionally build additional packages.
Alternatively you can build a BSP as a package using the RSB. This is covered in Build an RSB Package
2.1.1. Host Computer¶
The host computer is a computer you use to develop applications. It runs all your tools, editors, documentation viewers, etc. You need a native C, C++, and Python development environment. The following procedure assumes you have installed and configured your host operating system. It also assumes you have installed any dependent packages needed when building the tools and the kernel. Please make sure you can build native C/C++ applications on your host computer. You must be able to build native Python C modules as some RTEMS tools contain these modules. Usually, you have to install a Python development package for this. The Python scripts of the RTEMS Project expect on POSIX systems that a python
command is available [1]. Please have a look at the Host Computer chapter for the gory details. In particular Microsoft Windows users should do this.
2.1.2. Selecting a BSP¶
If you are new to RTEMS and you are looking to try RTEMS then the best suited Board Support Package (BSP) is the SPARC ERC32 (erc32
). The SPARC ERC32 BSP has a robust simulator that runs the example and test executables on your host computer. This Quick Start guide will build the erc32
BSP and run RTEMS tests executables in the simulator. The ERC32 BSP is a SPARC architecture BSP so the tool suite name is sparc-rtems5
.
If you are looking for a hardware target to run RTEMS on we recommend the BeagleBone Black (beagleboneblack
) BSP. The BeagleBone Black support includes the RTEMS BSD Library (libbsd
) and networking. The BeagleBone Black BSP is an ARM architecture BSP so the tool suite name is arm-rtems5
.
2.1.3. Selecting a Version of RTEMS¶
In the examples of this manual we will often refer to a specific version of RTEMS, which will usually be the version that accompanied the publication of this documentation manual. That may not be the appropriate version for you to use, for example, it may be too old (or too new) depending on what you are trying to do. If you’re not sure what version to use, we generally recommend using the most recent release or the development head (master), and you may want to consult with the same version of the documentation. We hope that newer is better.
An RTEMS release involves the creation of a single downloadable file, normally a compressed tarball, that packages the source of all the repositories in a state consistent with the time the release is created. A release branch is a git branch pushed to the repositories named with the numeric identifier of the branch. A release branch release is a git tag on a release branch with the tags pushed to the repositories.
Numbering for RTEMS versions beginning with RTEMS 5 uses a format as follows. The master branch has the version N.0.0 with N being the next major release number. The first release of this series has the version number N.1.0. and there is exactly one commit with this version number in the corresponding repository. The first bugfix release (minor release) of this series will have the version number N.2.0. The release branch will have the version number N.M.1 with M being the last minor release of this series.
For example:
5.0.0 is the version number of the development master for the 5 series.
5.1.0 is the first release of the 5 series.
5.1.1 is the version number of the 5 series release branch right after the 5.1.0 release until 5.2.0 is released.
5.2.0 is the first bugfix release of the 5 series
5.2.1 is the version number of the 5 series release branch right after the 5.2.0 release until 5.3.0 is released.
6.0.0 is the version number of the development master for the 6 series.
RTEMS development tools use N as the version number and are expected to work with all releases and the release branch of the N series. So to build tools for compiling RTEMS version number 5.1.0 for SPARC use sparc-rtems5
. Despite the number not increasing, the tools may change within a release branch, for example the tools packaged with 5.1.1 still use the sparc-rtems5
moniker, but are likely not the same as the tools used in version 5.1.0. This tool mismatch can be a source of confusion. Be sure to use the toolchain that matches your release.
The Python scripts use a shebang of #!/usr/bin/env python
.
2.2. Choose an Installation Prefix¶
You will see the term prefix referred to throughout this documentation and in a wide number of software packages you can download from the internet. It is also used in the GNU Coding Standard. A prefix is the path on your host computer a software package is installed under. Packages that have a prefix will place all parts under the prefix path. Packages for your host computer typically use a default prefix of /usr/local
on FreeBSD and Linux.
You have to select a prefix for your installation. You will build and install the RTEMS tool suite, an RTEMS kernel for a BSP, and you may build and install third party libraries. You can build all the parts as a stack with a single prefix or you can separate various parts by providing different prefixes to each part as it is built. Using separate prefixes is for experienced RTEMS users.
Do not select a prefix that is under the top of any of the source trees. The prefix collects the install output of the various build steps you take in this guide and need to be kept separate from the sources used.
The RTEMS tool suite consists of a cross tool chain (Binutils, GCC, GDB, Newlib, etc.) for your target architecture and RTEMS tools provided by the RTEMS Project. The RTEMS Tools are a toolkit that help create the RTEMS ecosystem and help support the building of embedded real-time applications and systems. The RTEMS tool chain changes less often than the RTEMS kernel. One method of working with development releases is to have a separate prefix for the RTEMS tools and a different one for the RTEMS kernel. You can then update each without interacting with the other. You can also have a number of RTEMS versions available to test with.
You build and install the tool suite with the RTEMS Source Builder (RSB). By default, the RSB will start the prefix path with a host operating system specific path plus rtems
, and the RTEMS version, e.g. /opt/rtems/6
on Linux, and /usr/local/rtems/6
on FreeBSD and macOS. Placing the RTEMS version number in the path lets you manage and migrate RTEMS versions as they are released. It is best to have a prefix for each different version of RTEMS you are using. If you are using RTEMS in production it is not a good idea to install a development version of over the top by using the same prefix. A separate prefix for each version avoids this.
It is strongly recommended to run the RSB as a normal user and not with root privileges (also known as super user or Administrator). You have to make sure that your normal user has sufficient privileges to create files and directories under the prefix. For example, you can create a directory /opt/rtems
and give it to a developer group with read, write, and execute permissions. Alternatively, you can choose a prefix in your home directory, e.g. $HOME/rtems/6
or with a project-specific component $HOME/project-x/rtems/6
. For more ideas, see the project sandboxing section. In this quick start chapter, we will choose $HOME/quick-start/rtems/6
for the RTEMS tool suite prefix.
Warning
The prefix must not contain space characters.
2.3. Obtain the Sources¶
You have considered and chosen a suitable installation prefix in the previous section. We have chosen $HOME/quick-start/rtems/6
as the installation prefix. We will show how to use a released version of RTEMS and then as an alternative we will show you using the RSB Git repository. Consider using a Git clone if you wish to make contributions to the RTEMS Project.
You need the RTEMS Source Builder (RSB) to work with RTEMS and we prefer you use a released version. A released version of the RSB downloads all source code from the RTEMS servers. Each release archives all the referenced source providing long term stability as changes in upstream projects do not effect a release’s build.
You will need approximately 1.5G bytes of disk space to build the tools, RTEMS kernel, network stack and 3rd party packages for the ERC32 BSP.
2.3.1. Releases¶
You can download the source archives for a released RTEMS version from RTEMS’ servers. Releases can be view at https://ftp.rtems.org/pub/rtems/releases with the releases listed as a series under a release’s major number. For RTEMS 5.1 the release series is 5 and the release path is https://ftp.rtems.org/pub/rtems/releases/6/6.0.
To work with the archives of a released RTEMS version, simply replace the version number 5
used throughout this chapter with the version number you selected, e.g. sparc-rtems4.11
, sparc-rtems6
, and so on.
Download and unpack using the curl
and tar
command with these commands:
mkdir -p $HOME/quick-start/src
cd $HOME/quick-start/src
curl https://ftp.rtems.org/pub/rtems/releases/6/6.0/sources/rtems-source-builder-6.0.tar.xz | tar xJf -
If curl
does not work consider using wget
or a browser.
The RSB is unpacked under the path rtems-source-builder-6.0
. Rename this to rsb
to get shorter paths during the tool suite build. To do this run these commands:
cd $HOME/quick-start/src
mv rtems-source-builder-6.0 rsb
If you wish to build the RTEMS kernel from source obtain the RTEMS kernel sources:
cd $HOME/quick-start/src
curl https://ftp.rtems.org/pub/rtems/releases/6/6.0/sources/rtems-6.0.tar.xz | tar xJf -
2.3.2. Git¶
Alternatively, clone the Git repositories into $HOME/quick-start/src
.
A Git repository clone gives you some flexibility with the added complexity of needing to use a Git branch to build a released version. With Git you can switch between branches to try out different RTEMS versions and you have access to the RTEMS source history. The RTEMS Project welcomes contributions. The Git repositories enable you to easily create patches and track local changes.
You can clone the Git repository to get all versions of RTEMS including the development head. Release branches in Git are kept stable however they may differ from a release’s source archive.
mkdir -p $HOME/quick-start/src
cd $HOME/quick-start/src
git clone https://gitlab.rtems.org/rtems/tools/rtems-source-builder.git rsb
git clone https://gitlab.rtems.org/rtems/rtos/rtems.git
The rsb
repository clone contains the RTEMS Source Builder (RSB). We clone it into rsb
to get shorter paths during the tool suite build. The rtems
repository clone contains the RTEMS sources. These two repositories are enough to get started. There are more repositories available.
Warning
The development version is not for use in production and it can break from time to time.
2.3.3. Offline Download¶
If you have limited Internet access you can download the source before you start building. If you are permanently connected to the Internet you do not need to do this and the sources will be automatically download on demand when needed.
Once the sources have been downloaded you could disconnect your host computer from the Internet. It is no longer required to work with RTEMS. To download the sources to build the ERC 32 BSP before building run the following commands:
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --source-only-download 6/rtems-sparc
This command should output something like this (omitted lines are denoted by ...
):
RTEMS Source Builder - Set Builder, 6 (5e449fb5c2cb)
Build Set: 6/rtems-sparc
Build Set: 6/rtems-autotools.bset
Build Set: 6/rtems-autotools-internal.bset
...
download: https://gitlab.rtems.org/rtems-tools/snapshot/rtems-tools-90342feb4dd63d188ce945adfb0a769...<see log> -> sources/rtems-tools-90342feb4dd63d188ce945adfb0a7694a42a65cd.tar.bz2
...
Build Sizes: usage: 0.000B total: 264.228MB (sources: 264.186MB, patches: 43.468KB, installed 0.000B)
Build Set: Time 0:06:34.357125
If you encounter errors, check your internet connection, firewall settings, virus scanners and the availability of the download servers.
2.4. Install the Tool Suite¶
You have chosen an installation prefix, the BSP to build, the tool’s architecure and prepared the source for the RSB in the previous sections. We have chosen $HOME/quick-start/rtems/6
as the installation prefix, the erc32
BSP and the SPARC architecture name of sparc-rtems6
, and unpacked the RSB source in $HOME/quick-start/src
.
The tool suite for RTEMS and the RTEMS sources are tightly coupled. For example, do not use a RTEMS version 6 tool suite with RTEMS version 4.11 or 5 sources and vice versa.
If you are unsure how to specify the build set for the architecture you wish to build, just ask the tool:
$ ../source-builder/sb-set-builder --list-bsets
Build and install the tool suite:
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --prefix=$HOME/quick-start/rtems/6 6/rtems-sparc
This command should output something like this (omitted lines are denoted by …). The build host appears as part of the name of the package being built. The name you see may vary depending on the host you are using:
RTEMS Source Builder - Set Builder, 6 (5e449fb5c2cb)
Build Set: 6/rtems-sparc
...
config: tools/rtems-binutils-2.36.cfg
package: sparc-rtems6-binutils-fbb9a7e-x86_64-linux-gnu-1
building: sparc-rtems6-binutils-fbb9a7e-x86_64-linux-gnu-1
sizes: sparc-rtems6-binutils-fbb9a7e-x86_64-linux-gnu-1: 716.015MB (installed: 163.538MB)
cleaning: sparc-rtems6-binutils-fbb9a7e-x86_64-linux-gnu-1
reporting: tools/rtems-binutils-2.36.cfg -> sparc-rtems6-binutils-fbb9a7e-x86_64-linux-gnu-1.txt
reporting: tools/rtems-binutils-2.36.cfg -> sparc-rtems6-binutils-fbb9a7e-x86_64-linux-gnu-1.xml
config: tools/rtems-gcc-10-newlib-head.cfg
package: sparc-rtems6-gcc-6051af8-newlib-d10d0d9-x86_64-linux-gnu-1
building: sparc-rtems6-gcc-6051af8-newlib-d10d0d9-x86_64-linux-gnu-1
....
Build Sizes: usage: 9.607GB total: 2.244GB (sources: 264.186MB, patches: 43.468KB, installed 1.986GB)
installing: 6/rtems-sparc -> $HOME/quick-start/rtems/6
clean staging: 6/rtems-sparc
Staging Size: 5.292MB
Build Set: Time 1:01:48.019157
Once the build has successfully completed you can check if the cross C compiler works with the following command:
$HOME/quick-start/rtems/6/bin/sparc-rtems6-gcc --version
This command should output something like below. The version informtion helps you to identify the exact sources used to build the cross compiler of your RTEMS tool suite. In the output you see the version of RTEMS or the hash from the RSB repository if you are building using a Git repository clone. The Newlib hash is the version of Newlib in the RTEMS’s github sourceware-mirror-newlib-cygwin repository. The sources
and patches
directories created by the RSB contain all the source code used.
sparc-rtems6-gcc (GCC) 10.2.1 20210309 (RTEMS 6, RSB 5e449fb5c2cb6812a238f9f9764fd339cbbf05c2, Newlib d10d0d9)
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Add --verbose
to the GCC command for the verbose version details.
2.4.1. Creating a Tool Archive¶
Add --bset-tar-file
to the sb-set-builder
command line to create tar files of the built package set.
2.4.2. Need for RTEMS-Specific Cross-Compiler¶
New users are often confused as to why they cannot use their distribution’s cross-compiler for their target on RTEMS, e.g., the riscv64-linux-gnu or the arm-none-eabi-gcc. Below mentioned are some of the reasons for using the RTEMS cross-compiler.
- Correct configuration of Newlib
Newlib is a C standard library implementation intended for use on embedded systems. Most of the POSIX and libc support for RTEMS is derived from Newlib. The RTEMS cross-compiler configures Newlib correctly for RTEMS.
- Threading in GCC support libraries
Several threading packages in GCC such as Go threads (libgo), OpenMP (libgomp), and OpenACC need to be customized according to RTEMS. This is done by the RTEMS specific cross-compiler.
- Provide preprocessor define __rtems__
The
__rtems__
preprocessor define is used to provide conditional code compilation in source files that are shared with other projects e.g. in Newlib or imported code from FreeBSD.- Multilib variants to match the BSP
RTEMS configures GCC to create separate runtime libraries for each supported instruction set, floating point unit, vector unit, word size (e.g. 32-bit and 64-bit), endianness, ABI, processor errata workarounds, and so on in the architecture. These libraries are termed as Multilib variants. Multilib variants to match the BSP are set by selecting a specific set of machine options using the RTEMS cross-compiler.
2.4.3. Project Sandboxing¶
Project specific sandboxes let you have a number of projects running in parallel with each project in its own sandbox. You simply have a prefix per project and under that prefix you create a simple yet repeatable structure.
As an example lets say I have a large disk mounted under /bd
for Big Disk. As root
create a directory called projects
and give the directory suitable permissions to be writable by you as a user.
Lets create a project sandbox for my Box Sorter project. First create a project directory called /bd/projects/box-sorter
. Under this create rtems
and under that create rtems-6.9e8141c
. Under this path you can follow the released-version procedure to build a tool set using the prefix of /bd/projects/box-sorter/rtems/6.9e8141c
. You are free to create your project specific directories under /bd/projects/box-sorter
. The top level directories would be:
/bd/projects
Project specific development trees.
/bd/projects/box-sorter
Box Sorter project sandbox.
/bd/projects/box-sorter/rtems/6.9e8141c
Project prefix for RTEMS 6.9e8141c compiler, debuggers, tools and installed Board Support Package (BSP).
A variation is to use the --without-rtems
option with the RSB to not build the BSPs when building the tools and to build RTEMS specifically for each project. This lets you have a production tools installed at a top level on your disk and each project can have a specific and possibly customised version of RTEMS. The top level directories would be:
/bd/rtems
The top path to production tools.
/bd/rtems/6.9e8141c
Production prefix for RTEMS 6.9e8141c compiler, debuggers and tools.
/bd/projects
Project specific development trees.
/bd/projects/box-sorter
Box Sorter project sandbox.
/bd/projects/box-sorter/rtems
Box Sorter project’s custom RTEMS kernel source and installed BSP.
A further varation if there is an RTEMS kernel you want to share between projects is it to move this to a top level and share. In this case you will end up with:
/bd/rtems
The top path to production tools and kernels.
/bd/rtems/6.9e8141c
Production prefix for RTEMS 6.9e8141c.
/bd/rtems/6.9e8141c/tools
Production prefix for RTEMS 6.9e8141c compiler, debuggers and tools.
/bd/rtems/6.9e8141c/bsps
Production prefix for RTEMS 6.9e8141c Board Support Packages (BSPs).
/bd/projects
Project specific development trees.
/bd/projects/box-sorter
Box Sorter project sandbox.
Finally you can have a single set of production tools and RTEMS BSPs on the disk under /bd/rtems
you can share between your projects. The top level directories would be:
/bd/rtems
The top path to production tools and kernels.
/bd/rtems/6.9e8141c
Production prefix for RTEMS 6.9e8141c compiler, debuggers, tools and Board Support Packages (BSPs).
/bd/projects
Project specific development trees.
/bd/projects/box-sorter
Box Sorter project sandbox.
The project sandoxing approach allows you move a specific production part into the project’s sandbox to allow you to customise it. This is useful if you are testing new releases. The typical dependency is the order listed above. You can test new RTEMS kernels with production tools but new tools will require you build the kernel with them. Release notes with each release will let know what you need to update.
If the machine is a central project development machine simply replace projects
with users
and give each user a personal directory.
2.5. Build a Board Support Package (BSP)¶
You installed the tool suite in your installation prefix, made ready the source for two RTEMS source packages and if you are using a Git clone bootstrapped the RTEMS sources in the previous sections. We installed the tool suite in $HOME/quick-start/rtems/6
and unpacked the source in $HOME/quick-start/src
.
You are now able to build Board Support Packages (BSPs) for all architectures you have an installed RTEMS tool suite. To build applications on top of RTEMS, you have to build and install a BSP for your target hardware. To select a proper BSP for your target hardware consult the BSPs chapter. We select the erc32 BSP. The erc32
BSP uses approximately 2.3G bytes of disk space when the testsuite is built and 44M bytes of space when installed.
We will first show how to build the BSP using the RSB and then we will show how to build the same BSP manually. You only need to use one of the listed methods to build the BSP.
In the output in this section the base directory $HOME/quick-start
was replaced by $BASE
.
2.5.1. RSB BSP Build¶
The RSB build of RTEMS does not use the RTEMS source we made ready. It uses the RSB source you downloaded in a previous section. If you are using a release RSB source archive the BSP built is the released kernel image. If you are using a Git clone of the RSB the BSP will be version referenced in the RSB clone.
To build the BSP with all the tests run this command:
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --prefix=$HOME/quick-start/rtems/6 \
--target=sparc-rtems6 --with-rtems-bsp=sparc/erc32 --with-rtems-tests=yes 6/rtems-kernel
This command should output something like:
RTEMS Source Builder - Set Builder, @rtems-ver-majminver@
Build Set: 6/rtems-kernel
config: tools/rtems-kernel-6.cfg
package: sparc-rtems6-kernel-erc32-1
building: sparc-rtems6-kernel-erc32-1
sizes: sparc-rtems6-kernel-erc32-1: 2.279GB (installed: 44.612MB)
cleaning: sparc-rtems6-kernel-erc32-1
reporting: tools/rtems-kernel-6.cfg -> sparc-rtems6-kernel-erc32-1.txt
reporting: tools/rtems-kernel-6.cfg -> sparc-rtems6-kernel-erc32-1.xml
installing: sparc-rtems6-kernel-erc32-1 -> $BASE/
cleaning: sparc-rtems6-kernel-erc32-1
Build Set: Time 0:03:09.896961
The RSB BSP build can be customised with following RSB command line options:
--with-rtems-tests
:Build the test suite. If
yes
is provided all tests in the testsuite are build. Ifno
is provided no tests are built and ifsamples
is provided only the sample executables are built, e.g.--with-rtems-tests=yes
. The test executables are install under the BSP in thetests
directory and you can execute them with the tester and run command.--with-rtems-smp
:Build with SMP support. The BSP has to have SMP support or this option will fail with an error.
--with-rtems-legacy-network
:Build the legacy network software. We recommend you use the current network support in the RTEMS BSP Library (libbsd) unless you need to maintain a legacy product. Do not use the legacy networking software for new developments.
--with-rtems-bspopts
:Build the BSP with BSP specific options. This is an advanced option. Please refer to the BSP specific details in the Board Support Packages (BSPs) of this manual or the BSP source code in the RTEMS source directory. To supply a list of options quote then list with
"
, e.g.--with-rtems-bspopts="BSP_POWER_DOWN_AT_FATAL_HALT=1"
If you have built a BSP with the RSB, you can move on to Test a Board Support Package (BSP).
2.5.2. Manual BSP Build¶
We manually build the BSP in four steps. The first step is to set your path. Prepend the RTEMS tool suite binary directory to your $PATH
throughout the remaining steps. Run the command:
export PATH=$HOME/quick-start/rtems/6/bin:"$PATH"
Check your installed tools can be found by running:
command -v sparc-rtems6-gcc && echo "found" || echo "not found"
The output should be:
found
If not found
is printed the tools are not correctly installed or the path has not been correctly set. Check the contents of the path $HOME/quick-start/rtems/6/bin
manually and if sparc-rtems6-gcc
is present the path is wrong. If the file cannot be found return to Install the Tool Suite and install the tools again.
The second step is to configure the BSP. There are various BSP build configuration options available. Some options are BSP-specific. Each section in the INI-style configuration file config.ini
instructs the build system to build a particular BSP variant (sparc/erc32 in our case). We enable the build of the tests with the BUILD_TESTS = True
option and use default values for everything else. For detailed information about the BSP build system, see BSP Build System.
cd $HOME/quick-start/src/rtems
echo "[sparc/erc32]" > config.ini
echo "BUILD_TESTS = True" >> config.ini
./waf configure --prefix=$HOME/quick-start/rtems/6
The first invocation of ./waf
needs a bit of time (e.g. 10 seconds) since an internal cache file is populated. This command should output something like this. In this output the base directory $HOME/quick-start
was replaced by $BASE
.
Setting top to : $BASE/quick-start/src/rtems
Setting out to : $BASE/quick-start/src/rtems/build
Configure board support package (BSP) : sparc/erc32
Checking for program 'sparc-rtems6-gcc' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-gcc
Checking for program 'sparc-rtems6-g++' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-g++
Checking for program 'sparc-rtems6-ar' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-ar
Checking for program 'sparc-rtems6-ld' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-ld
Checking for program 'ar' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-ar
Checking for program 'g++, c++' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-g++
Checking for program 'ar' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-ar
Checking for program 'gas, gcc' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-gcc
Checking for program 'ar' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-ar
Checking for program 'gcc, cc' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-gcc
Checking for program 'ar' : $BASE/quick-start/rtems/6/bin/sparc-rtems6-ar
Checking for asm flags '-MMD' : yes
Checking for c flags '-MMD' : yes
Checking for cxx flags '-MMD' : yes
Checking for program 'rtems-bin2c' : $BASE/quick-start/rtems/6/bin/rtems-bin2c
Checking for program 'gzip' : /usr/bin/gzip
Checking for program 'rtems-ld' : $BASE/quick-start/rtems/6/bin/rtems-ld
Checking for program 'rtems-syms' : $BASE/quick-start/rtems/6/bin/rtems-syms
Checking for program 'xz' : $BASE/anaconda3/bin/xz
'configure' finished successfully (0.414s)
Building the BSP is the third step.
cd $HOME/quick-start/src/rtems
./waf
This command should output something like this (omitted lines are denoted by …).
Waf: Entering directory `$BASE/quick-start/src/rtems/build'
Waf: Leaving directory `$BASE/quick-start/src/rtems/build'
'build' finished successfully (0.085s)
Waf: Entering directory `$BASE/quick-start/src/rtems/build/sparc/erc32'
[ 1/4093] Compiling bsps/shared/dev/serial/mc68681_reg2.c
[ 2/4093] Compiling bsps/shared/dev/rtc/mc146818a_ioreg.c
[ 3/4093] Compiling bsps/shared/dev/flash/am29lv160.c
...
[4093/4093] Processing link: build/sparc/erc32/testsuites/libtests/dl01/dl01-tar.o build/sparc/erc32/testsuites/libtests/dl01/init.o build/sparc/erc32/testsuites/libtests/dl01/dl-load.o build/sparc/erc32/testsuites/libtests/dl01/dl01-sym.o -> build/sparc/erc32/testsuites/libtests/dl01.exe
Waf: Leaving directory `$BASE/quick-start/src/rtems/build/sparc/erc32'
'build_sparc/erc32' finished successfully (2m14.111s)
The last step is to install the BSP.
cd $HOME/quick-start/src/rtems
./waf install
This command should output something like this (omitted lines are denoted by …). In this output the base directory $HOME/quick-start
was replaced by $BASE
.
Waf: Entering directory `$BASE/quick-start/src/rtems/build'
Waf: Leaving directory `$BASE/quick-start/src/rtems/build'
'install' finished successfully (0.081s)
Waf: Entering directory `$BASE/quick-start/src/rtems/build/sparc/erc32'
+ install $BASE/quick-start/rtems/6/sparc-rtems6/erc32/lib/include/libchip/am29lv16.h (from bsps/include/libchip/am29lv1.h)
+ install $BASE/quick-start/rtems/6/sparc-rtems6/erc32/lib/include/libchip/mc146818a.h (from bsps/include/libchip/mc146818a.h)
+ install $BASE/quick-start/rtems/6/sparc-rtems6/erc32/lib/include/libchip/mc68681.h (from bsps/include/libchip/mc68681.h))
...
+ install $BASE/quick-start/rtems/6/sparc-rtems6/erc32/lib/include/rtems/score/watchdogticks.h (from cpukit/include/rtems/score/watchdogticks.h)
+ install $BASE/quick-start/rtems/6/sparc-rtems6/erc32/lib/include/rtems/score/wkspace.h (from cpukit/include/rtems/score/wkspace.h)
+ install $BASE/quick-start/rtems/6/sparc-rtems6/erc32/lib/include/rtems/score/wkspacedata.h (from cpukit/include/rtems/score/wkspacedata.h)
Waf: Leaving directory `$BASE/quick-start/src/rtems/build/sparc/erc32'
'install_sparc/erc32' finished successfully (1.834s))
2.6. Test a Board Support Package (BSP)¶
You built a BSP with tests in the previous section. We built the sparc/erc32
BSP in $HOME/quick-start/src/rtems
.
You should run the RTEMS test suite on your target hardware. The RTEMS Project provides some support to do this, see the Testing chapter for the details.
On the sparc/erc32
BSP we selected for this quick start chapter this is easy. Just run this command:
cd $HOME/quick-start/src/rtems
rtems-test --rtems-bsp=erc32-sis build/sparc/erc32
This command should output something like this (omitted lines are denoted by …). In this output the base directory $HOME/quick-start
was replaced by $BASE
.
RTEMS Testing - Tester, 6.0.not_released
Command Line: $BASE/rtems/6/bin/rtems-test --rtems-bsp=erc32-sis build/sparc/erc32
Host: Linux 5.8.0-44-generic #50~20.04.1-Ubuntu SMP Wed Feb 10 21:07:30 UTC 2021 x86_64
Python: 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
Host: Linux-5.8.0-44-generic-x86_64-with-glibc2.29 (Linux 5.8.0-44-generic #50~20.04.1-Ubuntu SMP Wed Feb 10 21:07:30 UTC 2021 x86_64 x86_64)
[ 1/570] p:0 f:0 u:0 e:0 I:0 B:0 t:0 L:0 i:0 W:0 | sparc/erc32: dhrystone.exe
...
[570/570] p:554 f:2 u:6 e:1 I:0 B:3 t:0 L:0 i:0 W:0 | sparc/erc32: ts-validation-1.exe
Passed: 558
Failed: 2
User Input: 6
Expected Fail: 1
Indeterminate: 0
Benchmark: 3
Timeout: 0
Test too long: 0
Invalid: 0
Wrong Version: 0
Wrong Build: 0
Wrong Tools: 0
------------------
Total: 570
Failures:
dl06.exe
minimum.exe
User Input:
dl10.exe
monitor.exe
termios.exe
top.exe
capture.exe
fileio.exe
Expected Fail:
psxfenv01.exe
Benchmark:
dhrystone.exe
linpack.exe
whetstone.exe
Average test time: 0:00:00.371256
Testing time : 0:03:31.616055
2.7. Build Your Application¶
You tested a BSP in the previous section. We built the erc32
BSP and it is installed under $HOME/quick-start/rtems/6
.
We will now create a simple Hello World application with a Git repository and using the Waf build system.
The application is be created in $HOME/quick-start/app/hello
.
In the output in this section the base directory $HOME/quick-start
was replaced by $BASE
.
The steps in this section assume you are in the directory $HOME/quick-start/app/hello
after the first step changes to it.
Setup the application work space. Create a new Git repository, download the Waf build system, and the RTEMS Waf.
Create the application directory and change into it:
mkdir -p $HOME/quick-start/app/hello
cd $HOME/quick-start/app/hello
Download the Waf build system and set it to executable:
curl https://waf.io/waf-2.0.19 > waf
chmod +x waf
Initialise a new Git repository:
git init
Add RTEMS Waf support as a Git sub-module and initialise it:
git submodule add https://gitlab.rtems.org/rtems/tools/rtems_waf.git rtems_waf
Create the application source files. Three files are created with an editor of your choice.
First create a C file that configures RTEMS. Using an editor create a file called init.c
and copy the following configuration settings:
/*
* Simple RTEMS configuration
*/
#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
#define CONFIGURE_UNLIMITED_OBJECTS
#define CONFIGURE_UNIFIED_WORK_AREAS
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
#define CONFIGURE_INIT
#include <rtems/confdefs.h>
Create the Hello World application source file. Using an editor create hello.c
and copy the follow code:
/*
* Hello world example
*/
#include <rtems.h>
#include <stdlib.h>
#include <stdio.h>
rtems_task Init(
rtems_task_argument ignored
)
{
printf( "\nHello World\n" );
exit( 0 );
}
Finally create the Waf script. Using an editor create wscript
and copy the Waf script:
#
# Hello world Waf script
#
from __future__ import print_function
rtems_version = "6"
try:
import rtems_waf.rtems as rtems
except:
print('error: no rtems_waf git submodule')
import sys
sys.exit(1)
def init(ctx):
rtems.init(ctx, version = rtems_version, long_commands = True)
def bsp_configure(conf, arch_bsp):
# Add BSP specific configuration checks
pass
def options(opt):
rtems.options(opt)
def configure(conf):
rtems.configure(conf, bsp_configure = bsp_configure)
def build(bld):
rtems.build(bld)
bld(features = 'c cprogram',
target = 'hello.exe',
cflags = '-g -O2',
source = ['hello.c',
'init.c'])
Configure the application using Waf’s configure
command:
./waf configure --rtems=$HOME/quick-start/rtems/6 --rtems-bsp=sparc/erc32
The output will be something close to:
Setting top to : $BASE/app/hello
Setting out to : $BASE/app/hello/build
RTEMS Version : 6
Architectures : sparc-rtems6
Board Support Package (BSP) : sparc-rtems6-erc32
Show commands : no
Long commands : no
Checking for program 'sparc-rtems6-gcc' : $BASE/rtems/6/bin/sparc-rtems6-gcc
Checking for program 'sparc-rtems6-g++' : $BASE/rtems/6/bin/sparc-rtems6-g++
Checking for program 'sparc-rtems6-gcc' : $BASE/rtems/6/bin/sparc-rtems6-gcc
Checking for program 'sparc-rtems6-ld' : $BASE/rtems/6/bin/sparc-rtems6-ld
Checking for program 'sparc-rtems6-ar' : $BASE/rtems/6/bin/sparc-rtems6-ar
Checking for program 'sparc-rtems6-nm' : $BASE/rtems/6/bin/sparc-rtems6-nm
Checking for program 'sparc-rtems6-objdump' : $BASE/rtems/6/bin/sparc-rtems6-objdump
Checking for program 'sparc-rtems6-objcopy' : $BASE/rtems/6/bin/sparc-rtems6-objcopy
Checking for program 'sparc-rtems6-readelf' : $BASE/rtems/6/bin/sparc-rtems6-readelf
Checking for program 'sparc-rtems6-strip' : $BASE/rtems/6/bin/sparc-rtems6-strip
Checking for program 'sparc-rtems6-ranlib' : $BASE/rtems/6/bin/sparc-rtems6-ranlib
Checking for program 'rtems-ld' : $BASE/rtems/6/bin/rtems-ld
Checking for program 'rtems-tld' : $BASE/rtems/6/bin/rtems-tld
Checking for program 'rtems-syms' : $BASE/rtems/6/bin/rtems-syms
Checking for program 'rtems-bin2c' : $BASE/rtems/6/bin/rtems-bin2c
Checking for program 'tar' : /usr/bin/tar
Checking for program 'gcc, cc' : $BASE/rtems/6/bin/sparc-rtems6-gcc
Checking for program 'ar' : $BASE/rtems/6/bin/sparc-rtems6-ar
Checking for program 'g++, c++' : $BASE/rtems/6/bin/sparc-rtems6-g++
Checking for program 'ar' : $BASE/rtems/6/bin/sparc-rtems6-ar
Checking for program 'gas, gcc' : $BASE/rtems/6/bin/sparc-rtems6-gcc
Checking for program 'ar' : $BASE/rtems/6/bin/sparc-rtems6-ar
Checking for c flags '-MMD' : yes
Checking for cxx flags '-MMD' : yes
Compiler version (sparc-rtems6-gcc) : 10.2.1 20210309 (RTEMS 6, RSB 5e449fb5c2cb6812a238f9f9764fd339cbbf05c2, Newlib d10d0d9)
Checking for a valid RTEMS BSP installation : yes
Checking for RTEMS_DEBUG : no
Checking for RTEMS_MULTIPROCESSING : no
Checking for RTEMS_NEWLIB : yes
Checking for RTEMS_POSIX_API : no
Checking for RTEMS_SMP : no
Checking for RTEMS_NETWORKING : no
'configure' finished successfully (1.142s)
Build the application:
./waf
The output will be something close to:
Waf: Entering directory `$BASE/app/hello/build/sparc-rtems6-erc32'
[1/3] Compiling init.c
[2/3] Compiling hello.c
[3/3] Linking build/sparc-rtems6-erc32/hello.exe
Waf: Leaving directory `$BASE/app/hello/build/sparc-rtems6-erc32'
'build-sparc-rtems6-erc32' finished successfully (0.183s)
Run the executable:
rtems-run --rtems-bsps=erc32-sis build/sparc-rtems6-erc32/hello.exe
The output will be something close to:
RTEMS Testing - Run, @rtems-ver-mjminrev@
Command Line: $BASE/quick-start/rtems/6/bin/rtems-run --rtems-bsps=erc32-sis build/sparc-rtems6-erc32/hello.exe
Host: Linux 5.8.0-44-generic #50~20.04.1-Ubuntu SMP Wed Feb 10 21:07:30 UTC 2021 x86_64
Python: 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]
Host: Linux-5.8.0-44-generic-x86_64-with-glibc2.29 (Linux 5.8.0-44-generic #50~20.04.1-Ubuntu SMP Wed Feb 10 21:07:30 UTC 2021 x86_64 x86_64)
SIS - SPARC/RISCV instruction simulator 2.26, copyright Jiri Gaisler 2020
Bug-reports to jiri@gaisler.se
ERC32 emulation enabled
Loaded build/sparc-rtems6-erc32/hello.exe, entry 0x02000000
Hello World
*** FATAL ***
fatal source: 5 (RTEMS_FATAL_SOURCE_EXIT)
fatal code: 0 (0x00000000)
RTEMS version: 6.0.0.586e06ec6222f1cd1f005aa8f4a34a8b33f5d862
RTEMS tools: 10.2.1 20210309 (RTEMS 6, RSB 5e449fb5c2cb6812a238f9f9764fd339cbbf05c2, Newlib d10d0d9)
executing thread ID: 0x08a010001
executing thread name: UI1
cpu 0 in error mode (tt = 0x101)
158479 0200d500: 91d02000 ta 0x0
Run time : 0:00:00.259136
Commit the application to the repository:
git add init.c hello.c wscript
git commit -m "My first RTEMS application."
2.8. Build an RSB Package¶
This section describes how to build an RTEMS package using the RSB. Before we start to build a package with the RSB you need to complete these steps:
Return to here once you have completed these steps.
You have chosen an installation prefix, the BSP to build, the tool’s architecure and prepared the source for the RSB in the previous sections. We have chosen $HOME/quick-start/rtems/5
as the installation prefix, the erc32
BSP and the SPARC architecture name of sparc-rtems5
, and unpacked the RSB source in $HOME/quick-start/src
.
You are now able to build BSP Packages or 3rd party libraries of code if you have built a BSP.
2.8.1. RTEMS Packages¶
RTEMS Packages are source packages the RSB build to run on RTEMS. An installed package is a set of header files and libraries. Your application include the packages header files to make calls to the package’s code and include the libraries in it’s linker options.
RTEMS packages can be part of the RTEMS Project or they can be external packages from 3rd parties. RTEMS Project packages include the BSPs and BSD Library package called libbsd
. External 3rd party packages include networking such has curl
or libcurl
to graphics libraries.
Packages can depend on other packages and need to be build in the corret order. For example the FreeBSD Library package depends on the BSP package and a 3rd party library such as curl
depends on the FreeBSD Library package. We call this layering a vertical software stack.
RTEMS applications are cross-compiled and this adds complexity when building libraries of code. RTEMS Packages build with the RSB manage this complexity for you.
Package are libraries so they will not be linked into your application until you make calls to the the code and add the library to your application’s linker command line.
2.8.2. BSP Stack Build¶
A BSP stack build is a single command that uses the RSB to build a BSP software stack of:
Tool suite
BSP
Packages
The packages built depend on the BSP and the default will build all packages for a BSP.
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --prefix=$HOME/quick-start/rtems/5 \
--with-rtems-tests=yes bsps/erc32
This command should output something like this:
RTEMS Source Builder - Set Builder, 5.1.0
Build Set: bsps/erc32
Build Set: 5/rtems-sparc.bset
Build Set: 5/rtems-autotools.bset
Build Set: 5/rtems-autotools-internal.bset
config: tools/rtems-autoconf-2.69-1.cfg
package: autoconf-2.69-x86_64-freebsd12.1-1
building: autoconf-2.69-x86_64-freebsd12.1-1
sizes: autoconf-2.69-x86_64-freebsd12.1-1: 7.505MB (installed: 0.000B)
...
building: protobuf-2.6.1-sparc-rtems5-1
sizes: protobuf-2.6.1-sparc-rtems5-1: 228.079MB (installed: 84.408MB)
cleaning: protobuf-2.6.1-sparc-rtems5-1
reporting: net/protobuf-2.6.1-1.cfg -> protobuf-2.6.1-sparc-rtems5-1.txt
reporting: net/protobuf-2.6.1-1.cfg -> protobuf-2.6.1-sparc-rtems5-1.xml
staging: protobuf-2.6.1-sparc-rtems5-1 -> $HOME/quick-start/src/rsb/rtems/build/tmp/sb-500-staging
cleaning: protobuf-2.6.1-sparc-rtems5-1
Build Set: Time 0:00:23.564992
Build Set: Time 0:02:27.380299
installing: bsps/erc32 -> $HOME/quick-start/rtems/
clean staging: bsps/erc32
Staging Size: 1.372GB
Build Set: Time 0:24:17.83979
The RSB BSP build can be customised with following RSB command line options:
--with-rtems-tests
:Build the test suite. If
yes
is provided all tests in the testsuite are build. Ifno
is provided no tests are built and ifsamples
is provided only the sample executables are built, e.g.--with-rtems-tests=yes
.--with-rtems-smp
:Build with SMP support. The BSP has to have SMP support or this option will fail with an error.
--with-rtems-bspopts
:Build the BSP with BSP specific options. This is an advanced option. Please refer to the BSP specific details in the Board Support Packages (BSPs) of this manual or the BSP source code in the RTEMS source directory. To supply a list of options quote then list with
"
, e.g.--with-rtems-bspopts="BSP_POWER_DOWN_AT_FATAL_HALT=1"
Only a limited number of BSPs have RSB support to build as a software stack. To see which BSPs are supported run this command:
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --list-bsets | grep bsps
2.8.3. Package Build¶
Packages are built using RSB build sets. A build set is a set of builds need to build a packages. The build steps can be dependencies a package has or it could be a stack of software to provide specific functionality, i.e. a build set can be a list of build sets. To view the avaliable build sets run this command:
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --list-bsets
RTEMS package naming is based on the naming FreeBSD uses in its ports collection.
This Quick Start Guide will build the BSD Library or 5/rtems-libbsd
.
An RTEMS package is hosted on RTEMS so the tool suite name needs to be supplied using the --host
option, e.g. --host=sparc-rtem5
. The BSP needs to be provided using the --with-rtems-bsp
option, e.g. --with-rtems-bsp=erc32
. The commands to build libbsd
for the erc32
BSP are:
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --prefix=$HOME/quick-start/rtems/5 \
--host=sparc-rtems5 --with-rtems-bsp=erc32 5/rtems-libbsd
This command should output something like this:
RTEMS Source Builder - Set Builder, 5.1.0
Build Set: 5/rtems-libbsd
config: tools/rtems-libbsd-5.cfg
package: rtems-libbsd-v3cc039cdac77272a8e16b33ae5a53ccd89edf989-sparc-rtems5-1
building: rtems-libbsd-v3cc039cdac77272a8e16b33ae5a53ccd89edf989-sparc-rtems5-1
sizes: rtems-libbsd-v3cc039cdac77272a8e16b33ae5a53ccd89edf989-sparc-rtems5-1: 1.199GB (installed: 116.541MB)
cleaning: rtems-libbsd-v3cc039cdac77272a8e16b33ae5a53ccd89edf989-sparc-rtems5-1
reporting: tools/rtems-libbsd-5.cfg -> rtems-libbsd-v3cc039cdac77272a8e16b33ae5a53ccd89edf989-sparc-rtems5-1.txt
reporting: tools/rtems-libbsd-5.cfg -> rtems-libbsd-v3cc039cdac77272a8e16b33ae5a53ccd89edf989-sparc-rtems5-1.xml
installing: rtems-libbsd-v3cc039cdac77272a8e16b33ae5a53ccd89edf989-sparc-rtems5-1 -> $HOME/quick-start/rtems/5
cleaning: rtems-libbsd-v3cc039cdac77272a8e16b33ae5a53ccd89edf989-sparc-rtems5-1
Build Set: Time 0:00:51.898231
Note
Not all packages will build or run with all BSPs. Please ask on the Users Mailing List if you have any issues.
2.9. GSoC Getting Started¶
The goal of this page is to help new users, especially students get RTEMS compiled and running so they can start with the real work.
Please join the Users Mailing List and Developers Mailing List and ask questions. Help correct any deficiencies in the code or documentation you spot, including those on the wiki. The ultimate goal of GSoC is to help you become part of the open source community.
This section will help you to quickly setup a development environment without delving into the details. For more information you can go through the other subsections under Quick Start chapter or ask on the Developers Mailing List.
We recommend new student developers use the current development (unreleased) version. The Quick Start Preparation should be consulted for guidance. Some examples shown may use released versions, which may not be recommended for your purposes. If you are unsure, feel free to inquire on the Developers Mailing List.
You will be best served by using a GNU/Linux environment, which could be in a virtual machine, for example that uses Virtualbox and should run on most modern desktop systems. You should also be able to work with a MacOS or Windows system, but might encounter more difficulty than a *nix environment.
Setting up a development environment consists of the following steps.
Installing dependencies for your host operating system.
Choosing an installation prefix.
Downloading the source code.
Installing the tool suite.
Building the Board Support Package (BSP).
Testing the Board Support Package (BSP).
2.9.1. Installing Dependencies¶
You need tools for your host’s operating system to build the RTEMS tool suite from source. Please have a look at the Host Computer chapter for the instructions to install the tools for your OS.
2.9.2. Choosing an installation prefix¶
The term prefix
refers to the path on your computer where the software is to be installed. You can refer to the Prefix section for details on choosing an installation prefix.
2.9.3. Downloading the Sources¶
We will be using Git to clone the sources for RTEMS and RSB. This is the preferred way if you are planning to make contributions to the RTEMS project.
Please refer to the Git section for instructions on obtaining sources using Git.
2.9.4. Installing the Tool Suite¶
The Tools suite is the collection of tools required to build the BSP. This includes the compiler, debugger, assembler and other tools. These tools are architecture-specific. We will be installing the SPARC tool suite since we are building a SPARC based BSP.
Please refer to the Install the Tool Suite section for instructions on building and installing the tool suite. Remember to use the current version associated with the RTEMS development head, see Selecting a Version of RTEMS.
2.9.5. Building the Board Support Package¶
There are two ways of building a BSP. We could either ask RSB to build the BSP or manually build it. In this section will we be building it manually. Please refer the Manual BSP Build section for the instructions.
2.9.6. Testing the Board Support Package¶
Testing is an essential part of RTEMS development process. The main reason for choosing the SPARC erc32 BSP is that, it has very good simulator support. This will allow you to test your changes without the need for SPARC hardware.
Please refer to Test a Board Support Package (BSP) for instructions on testing the BSP.
2.9.7. Prove You Can Work On RTEMS¶
This section is only for students interested in Google Summer of Code.
You have to finish the following task to prove that you can work on RTEMS.
Modify the hello world example to include a new different print statement. Something like “Hello from The Dark Side!”. Then send us enough to prove to us that you did this. We want to know you can work with RTEMS.
Create a patch of your changes and send it to Developers Mailing List along with the screenshot of the output.
If you followed this guide, this hello world modification will likely need to be made in $HOME/quick-start/src/rtems/testsuites/samples/hello/init.c
. To test your changes, you have to build the BSP again. This could be done by running make in the BSP build directory.
cd $HOME/quick-start/src/rtems
./waf
If you are happy with your changes you can commit the changes and send the patch to Developers Mailing List.
2.9.8. Creating and Sending Patches¶
Before sending patches, make sure that the changes you have made conforms to RTEMS coding standards. You can refer to Contributing section for instruction on creating and sending patches.
Here are a few pointers to keep in mind while creating the patches.
Make sure not to commit changes in the master branch. This is to avoid merge conflicts when you are pulling the latest changes from the remote branch.
Avoid trailing whitespace errors.
The author name of the patch is your full name.
The author email of the patch is your valid email address.
Ensure that your patches build before sending them for review.
3. Support and Contributing¶
3.1. RTEMS Project Support¶
3.1.1. Users Mailing List¶
RTEMS offers a variety of support options and ways to contribute to the project. Users can ask their questions on the Users Mailing List. This is a low frequency mailing list intended for topics related to the use of RTEMS. If you are new to RTEMS, please join the list and ask whatever you want.
3.1.2. Documentation¶
You find the latest set of manuals at the Documentation Site.
3.1.3. All Mailing Lists¶
We have several mailing lists for RTEMS users and developers:
Announce Mailing List: Announcements for major and other project-related issues.
Bugs Mailing List: Emails generated by the Bugs Database.
Developers Mailing List: For developers of RTEMS itself.
Build Logs: Results from building and testing of RTEMS.
Users Mailing List: For users of RTEMS.
Version Control Mailing List: Commits to the RTEMS Project repositories.
3.1.4. Discord¶
The RTEMS Discord server is available at https://www.rtems.org/discord
We have several channels available for discussion please be kind. The purpose of each channel is listed in thier discriptions.
For support with GitLab there is also the #gitlab-support channel.
3.2. Report Bugs¶
The RTEMS Project uses a ticket system to deal with bugs, organize enhancement requests, and manage small tasks and projects. You can submit a bug report to the RTEMS Project ticket system. Before you do this, please read the following information. Good bug reports are more likely to get addressed quickly. If you have patches not specifically related to bugs or existing tickets, please have a look at the Contributing guidelines.
3.2.1. Search for Existing Bugs¶
You can search for existing bugs in the RTEMS Project ticket system. Please try to avoid duplicate bug reports and search for an existing bug before you report a new bug. If you are unsure, please ask on the Users Mailing List and we will help you sort it out.
3.2.2. Not RTEMS Bugs¶
Some issues appear to be an RTEMS bug to you, but are actually the intended behaviour or in the scope of other projects.
Bugs in the assembler, the linker, or the C library (Newlib) are not RTEMS bugs. These are separate projects, with separate mailing lists and different bug reporting procedures. The RTEMS Project is happy to work with you and those projects to resolve the problem but we must work with those projects. Bugs in those products must be addressed in the corresponding project. Report assembler, linker, and GDB bugs to sourceware.org, compiler bugs to GCC, and Newlib bugs to the Newlib mailing list. If the bug was fixed, then you can update the Source Builder to pick up the fix.
Questions about the correctness or the expected behaviour of programming language constructs or calls to library routines that are not part of RTEMS belong somewhere else.
The POSIX standard does not specify the default set of thread attributes. Thus, when passing a NULL for attributes to pthread_create(), the application is not guaranteed any particular thread behaviour.
The defaults for all RTEMS Application Configuration parameters are intentionally small, see Configuring a System chapter of the RTEMS Classic API Guide. Thus, it is common for RTEMS tasking and file related calls to return errors indicating out of resources until the configuration parameters are properly tuned for the application. For example, there are only three file descriptors available by default: stdin, stdout, and stderr. Any attempt to open a socket or file will fail unless more file descriptors are configured.
When first developing a BSP, many users encounter an unexpected interrupt or exception immediately upon completion of RTEMS initialization. This occurs because interrupts are disabled during RTEMS initialization and are automatically initialized as part of switching to the first task. The interrupted user code will be in either _CPU_Context_switch() or _Thread_Handler(). This indicates that an interrupt source has not been properly initialized or masked.
Some users encounter a random reset during BSP initialization. This usually indicates that the board has a watchdog timer that is not being properly serviced during the BSP initialization.
Bugs in releases or snapshots of RTEMS not issued by the RTEMS Project. Report them to whoever provided you with the release.
3.2.3. Creating Good Bug Reports¶
Please open a page to the RTEMS Project ticket system and follow the guidelines below to write a good bug report.
Click the “Select project to create issue” button for the relevant repository.
Click the New Issue button for the selected project repository.
Provide a useful single line Summary in the Title.
Fill out a description with target details, reproduction steps, build environment, exact versions, etc. Use MarkDown to structure the information you provide. It does help the readability of the information you provide.
Add a description of the expected behaviour. The expected behaviour may be obvious to you, but maybe not to someone else reading the bug report.
Add a description of the actual undesired behaviour.
Name the target hardware (processor architecture, chip family or model, and BSP) in the description. In addition, select the appropriate arch:: label if the bug is hardware-specific.
Add the toolchain version used (GCC, Binutils, Newlib) to the description. Custom toolchain builds are discouraged. To avoid problems caused by custom builds of the toolchain, please build your toolchain with the Source Builder. If you use a custom build of the toolchain, then try to reproduce the bug first using a toolchain built by the RSB.
Provide the configuration options used to build the RTEMS BSP in the description. This helps to reproduce the issue.
Make the bug reproducible by others. Write a self-contained piece of source code which can be compiled and reproduces the bug. Avoid adding assembly files (*.s) produced by the compiler, or any binary files, such as object files, executables, core files, or precompiled header files. If it is difficult or time consuming to reproduce the bug, then it may not get the attention it deserves from others. Developing and debugging real-time embedded systems can be difficult. Exercise caution in reporting an error that occurs only some of the times a certain program is executed, such that retrying a sufficient number of times results in a successful compilation; this is often a symptom of a hardware problem or application issue, not of a RTEMS bug (sorry). We do recognise that sometimes a timing bug will exist in RTEMS, but we want you to exercise due diligence before pointing fingers.
Only when your bug report requires multiple source files to be reproduced should you attach an archive. Otherwise, the uploaded individual source file or diff should contain the minimal source code needed to reproduce the bug. In any case, make sure the above are included in the body of your bug report as plain text, even if needlessly duplicated as part of an archive.
Please try to reproduce the bug on the current Git main branch. If it is not reproducible on main, you should figure out if the bug was already fixed. You can search the existing bugs once again, ask on the Users Mailing List, or do a Git bisect to find a commit which fixed the bug.
Include only information relevant to the bug.
Write separate bug reports for different bugs.
Select the Milestone to which this bug applies. It should be the nearest unreleased Milestone from the affected branch. Ask for help if you are not sure.
Select a set of appropriate Labels for the issue.
Select whether the issue is confidential. This is only expected in the potential context of security bugs.
Some fields should only be set by the maintainers, as it is not always clear what they should be set to. Feel free to make your own choices.
When you have checked that your report meets the criteria for a good bug report, please submit it.
If you fail to supply enough information for a bug report to be reproduced, someone will probably ask you to post additional information. In this case, please post the additional information and not just to the person who requested it, unless explicitly told so.
3.2.4. Nobody Fixes my Bug¶
Sometimes, you may notice that after some time your bug report gets no attention and the bug is not magically fixed. This may have several reasons
the bug report is incomplete or confusing,
the target hardware is not available to others,
the bug is not reproducible on the Git master,
the bug is not reproducible at all,
the RTEMS version is quite old and no longer used by RTEMS maintainers, or
fixing the bug has a low priority for others.
Please note that you do not have a service contract with the RTEMS Project. The RTEMS Project is run by volunteers and persons who take care about how RTEMS performs in their application domain. If your bug does not affect the interest of someone else, then you should try to fix the bug on your own, see the Contributing guidelines. To change the priorities of others with respect to your bug, you may refer to the Commercial Support Services.
3.3. Contributing¶
3.3.1. How to Contribute?¶
You can contribute to the RTEMS Project in various ways, for example:
participation in mailing list discussions, helping other users
documentation updates, clarifications, consolidation, fixes
bug fixes, bug report consolidation
new BSPs
new device drivers
new CPU (processor architecture) ports
improvements in the existing code base (code size, code clarity, test coverage, performance optimizations)
new features
RTEMS Tools improvements
Most contributions will end up in patches of the RTEMS source code or documentation sources. The patch integration into the RTEMS repositories is done through a patch review process on Gitlab.
3.3.2. Preparing and Submitting Merge Requests¶
The RTEMS Project uses Git for version control and uses Gitlab for managing changes. Contributions are made by creating a Merge Request (MR) on Gitlab. The Gitlab merge request documentation comprehensively explains the concepts of using merge requests. RTEMS will only accept changes via a Merge Request. Most merge requests should have one or more Issues associated with them, unless it is a simple, isolated change. Please do not use merge requests to introduce new code, concepts, styles or to change existing behaviours such as APIs or internal interfaces. Please create an issue before you start the work so the community is aware of the changes coming. The merge requests can then focus on the details of the implementation and approval does not need to be about approval of change at a functional level.
We use project forks as the base of our workflow and outside of that there is no workflow we mandate. What works for one task or work package may not work for another. Complex tasks may affect a number of our GitLab Projects with issues and merge requests in a number of projects. You may want to use an Epic to bring work together.
With our GitLab instance, you fork a repo into your personal workspace and use that to manage your changes. This means you need to keep your forked project up to date. See the Gitlab forking workflow documentation <https://docs.gitlab.com/ee/user/project/merge_requests/authorization_for_merge_requests.html#forking-workflow> for details. If you are part of a team working on a change you can collaborate on merge requests <https://docs.gitlab.com/ee/user/project/merge_requests/allow_collaboration.html>. GitLab enforces branch naming rules and provides branch naming patterns <https://docs.gitlab.com/ee/user/project/repository/branches/#prefix-branch-names-with-issue-numbers> that simplifies code review and software change management. You can create merge requests from your fork <https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html#when-you-work-in-a-fork> back to the upstream repository. We do not normally squash merge requests. A merge request with more than one commit should be buildable at each commit so a bisect of main does not break.
3.3.3. Checklist for Merge Requests¶
Check the following items before you publish your merge requests:
The author name of each commit is a full name of the author.
The author email of each commit is a valid email address for the author.
The licence conditions of the contributed content allow an integration into the RTEMS code base.
If you are the copyright holder of the entire patch content, then please contribute it under the BSD-2-Clause license. For documentation use CC BY-SA 4.0.
Make sure you have a meaningful title which does not exceed 50 characters in one line. Use a “topic: The meaningful title” style. A topic could be the main component of the commit. Just have a look at existing commit messages.
Each patch has a good commit message. It should describe the reason for the change. It should list alternative approaches and why they were not chosen.
The code changes honour the coding style. At least do your changes in the style of the surrounding code.
Each patch contains no spelling mistakes and grammar errors.
Each patch is easy to review. It changes one thing only and contains no unrelated changes. Format changes should be separated from functional changes.
If commits correspond to Issues, the merge request should have “Close #X.” or “Update #X.” to update status once it is merged.
Each patch builds. All RTEMS tests link with every patch.
Each patch does not introduce new compiler warnings.
Each patch does not introduce new test failures in existing tests.
3.3.4. Review Process¶
Merge requests sent to the RTEMS Gitlab undergo a public review process. At least two approvals are required before a merge request can be pushed to the RTEMS repository. It helps if you follow the Checklist for Merge Requests. An easy to review patch series which meets the quality standards of the RTEMS Project will be more likely to get integrated quickly.
The review process includes both objective and subjective feedback. You should reflect upon and consider all feedback before making or refusing changes. It is important to note that some feedback may be relevant at one point in time, but less relevant in the future. Also, what concerns one developer may not concern another. Just because you address all the feedback in one round of review does not mean your submission will be approved, as someone (even the same reviewer) may notice something that was not seen before. It is important to have patience, humility, and open-mindedness when engaging in open-source software review and approval processes. This is true for both contributors and reviewers.
Reviews should be conducted primarily via the GitLab interface using the in-line commenting feature. Follow-up comments to the same line should be threaded, while new comments should be added to the specific, relevant line of modified code. Although high-level comments about the entire patch set are allowed, the most useful commments are those that are specifically targeted to problematic lines of code.
3.3.5. Updating a Merge Request¶
As you make changes to your merge request through the review process, you will either be layering additional patches on top of your current patch set, or you will be rebasing your patch set. Either approach is acceptable, but remember that every patch in your patch set must pass continuous integration testing and adhere to the Checklist for Merge Requests. Most often, this means that you should rebase the patch set in your merge request to include the updates.
There are several ways you can rebase the patch set. The following is one suggested workflow:
- # Before making changes, create a new local branch of your merge request. Make
your changes on this branch, so that you can always go back to your previous state. Always keep your original branch until you have pushed a new, clean version that supersedes it. Even then, you may want to keep your original branch around in case something went wrong that you did not notice, such as you accidentally removed a necessary commit while rebasing.
# Make and commit changes locally until you are satisfied with your code
- # Interactively rebase your local branch using git rebase –interactive
to allow you to select the order of commits and to reword or fixup commits. One good strategy here is to reorder and fixup commits in one round and then reword them in a second round, so that you get your commits in the right order and shape you want before finalizing the patch descriptions.
- # Force-push your local branch to your merge request branch on your fork. If
something goes wrong, you can revert back to your local version.
3.3.6. Rebasing a Merge Request¶
You can follow a similar process as Updating a Merge Request to rebase your merge request branch to an updated target branch, e.g., to pick up changes on main. In this case, after creating a local branch, use git pull –rebase stopping to fix merge conflicts along the way. If it gets out of hand, you can either abort the rebase or you can go back to your original branch.
When merge conflicts are too much to handle doing a rebase, you may instead like to create a fresh branch from main and then use git-cherry-pick to pull commits from your merge request branch on to the head of main. If you are having too much trouble, ask for help.
3.3.7. Approvers¶
Merge Request approvals must be from a code owner, identified by the CODEOWNERS file and by sub-groups beneath Approvers. Any one who has requested approval permission can approve a merge request. Once a patch series is approved for integration into the RTEMS code base it can be merged by anyone with merge rights, which may include an automated bot.
Approvers are volunteering their time so be polite. If you do not get a response to a merge request after five working days, please send a reminder on the merge request or send email to the Developers Mailing List.
3.3.8. Why Contribute?¶
If you are writing a major extension to RTEMS, such as a port to a new CPU family (processor architecture) or model, a new target board, a major rewrite of some existing component, or adding some missing functionality, please keep in mind the importance of keeping other developers informed. Part of being a good cooperating member of the RTEMS development team is the responsibility to consider what the other developers need in order to work effectively.
Nobody likes to do a lot of work and find it was duplicated effort. So when you work on a major new feature, you should tell Developers Mailing List what you are working on, and give occasional reports of how far you have come and how confident you are that you will finish the job. This way, other developers (if they are paying attention) will be aware which projects would duplicate your effort, and can either join up with you, or at least avoid spending time on something that will be unnecessary because of your work. If, for whatever reason, you are not in a position to publicly discuss your work, please at least privately let other developers know about it so they can look out for duplicated effort or possible collaborators.
You should also monitor the Users Mailing List and Developers Mailing List to see if someone else mentions working on a similar project to yours. If that happens, speak up!
If you are thinking of taking a contract to develop changes under a temporary delayed-release agreement, please negotiate the agreement so that you can give progress reports before the release date, even though you cannot release the code itself. Also please arrange so that, when the agreed-on date comes, you can release whatever part of the job you succeeded in doing, even if you have not succeeded in finishing it. Someone else may be able to finish the job.
Many people have done RTEMS ports or BSPs on their own, to a wide variety of processors, without much communication with the RTEMS development team. However, much of this work has been lost over time, or have proven very hard to integrate. So, what we are asking is that, to the maximum extent possible, you communicate with us as early on and as much as possible.
3.3.9. Common Questions and Answers¶
Here are some questions RTEMS porters may have with our answers to them. While the focus here is on new ports and BSPs, we believe that the issues are similar for other RTEMS development efforts including student efforts to implement new algorithmic optimizations.
Our engineers understand our target environment better than anyone else, and we have a tight schedule. Why should we work with the RTEMS developers, when we can get the code out faster by whacking it out on our own?
You understand your target environment better than anyone else. However, the RTEMS developers understand RTEMS better than anyone else; furthermore, the RTEMS developers tend to have a wide breadth of experience across a large number of processors, boards, peripherals, and application domains. It has been our experience that few problems encountered in embedded systems development are unique to a particular processor or application. The vast majority of the time an issue that arises in one project has also shown up in other projects.
The intimate knowledge of RTEMS internals as well as a wide breadth of embedded systems knowledge means that there is a good chance that at least one RTEMS developer has already addressed issues you are likely to face when doing your port, BSP, or application. The developers can help guide you towards a workable long term solution, possibly saving you significant time in your development cycle.
If getting the sources into the official RTEMS distributions is one of your goals, then engaging other RTEMS developers early will also likely shorten your development time. By interacting as early as possible you are more likely to write code which can be easily accepted into the official sources when you are finished. If you wait until you think you are done to begin interacting with the RTEMS team, you might find that you did some things wrong and you may have to rewrite parts of your RTEMS port, which is a waste of your valuable time.
Why should we care if our port is integrated into the official RTEMS sources? We can distribute it ourselves to whoever is interested.
Yes, the RTEMS licenses allows you to do that. But by doing so, you end up having to maintain that code yourself; this can be a significant effort over time as the RTEMS sources change rapidly.
You also lose the advantage of wider exposure by including your port in the official RTEMS sources maintained by the RTEMS Project. The wider exposure in the RTEMS developer and tester community will help keep your work up to date with the current sources. You may even find that volunteers will run the ever-growing test suite on your port and fix problems during the development cycle – sometimes without your intervention.
It has been our experience that integrated ports tend to ultimately be of better quality and stay up to date from release to release.
Why should we communicate up front? We are happy to let the RTEMS developers integrate our stuff later.
See above. It will save work for you over both the short and the long term, and it is the right thing to do.
Aspects of my target environment that my application exploits are still under NDA.
Nevertheless, if the target hardware is built of any commercial parts that are generally available including, but not limited to, the CPU or peripherals, then that portion of your work is still of general use. Similarly, if you have written software that adheres to existing API or interface standards, then that portion is also of general use. Our experience is that most embedded applications do utilize a custom mix of hardware and application, but they are built upon layers of hardware and software components that are in no way unique to the project.
If you are porting to an unreleased CPU family or model, then just announcing it is important because other RTEMS users may be planning to use it and some of them may already be trying to port RTEMS on their own. Your customers might be happier to know that your port will eventually be available. Also, there is no requirement that RTEMS include all features or ports at any particular time, so you are encouraged to submit discrete pieces of functionality in stages.
Assume that your processor has some new functionality or peripherals. However that functionality is still covered by NDA, but the basic core architecture is not. It is still to your advantage to go ahead and work with the developers early to provide a “base port” for the CPU family. That base port would only use the publicly available specifications until such time as the NDA is lifted. Once the NDA is lifted you can work with the developers to provide the code necessary to take advantage of the new functionality.
Ultimately, cooperating with the free software community as early as possible helps you by decreasing your development cycle, decreasing your long term maintenance costs and may help raise interest in your processor by having a free compiler implementation available to anyone who wants to take a look.
3.4. Commercial Support Services¶
The wider RTEMS community has developers and organizations who can provide commercial support services. These services range from training, implementing new features in RTEMS, deployment of RTEMS, helping establish a new project environment for a team, to application and system design.
The RTEMS Project does not endorse or promote any provider of these services and we recommend you use a search engine to locate a suitable provider. If you are unsure please contact a provider and see what is available.
If you develop a new feature or you have someone do this for you we recommend you have the work submitted to the project and merged. Once accepted into the project the work will be maintained as part of the development process within the project and this is a benefit for.
4. Host Computer¶
RTEMS applications are developed using cross-development tools running on a development computer, more often called the host computer. These are typically your desktop machine or a special build server. All RTEMS tools and runtime libraries are built from source on your host machine. The RTEMS Project does not maintain binary builds of the tools. This differs to what you normally experience with host operating systems however this approach works well. RTEMS is not a host operating system and it is not a distrbution. Deploying binary packages for every possible host operating system is too big a task for the RTEMS Project and it is not a good use of core developer time. Their time is better spent making RTEMS better and faster.
The RTEMS Project’s aim is to give you complete freedom to decide on the languages used in your project, which version control system, and the build system for your application.
The rule for selecting a computer for a developer is more is better but we do understand there are limits. Projects set up different configurations, some have a development machine per developer while others set up a tightly controlled central build server. RTEMS Ecosystem is flexible and lets you engineer a development environment that suites you. The basic specs are:
Multicore processor
8G bytes RAM
256G harddisk
RTEMS makes no demands on graphics.
If you are using a VM or your host computer is not a fast modern machine do not be concerned. The tools may take longer to build than faster hardware however building tools is something you do once. Once the tools and RTEMS are built all your time can be spent writing and developing your application. It may take longer than an hour for the ARM architecture and with all BSPs it can be many hours.
4.1. Python¶
RTEMS uses Python in a range of host tools for users and developer. RTEMS supports:
Python3 and Python2 for user tools,
Python3 for developer tools.
Python2 is now end of life however the RTEMS Project will continue to provide support for its user commands. We do this to support older host operating systems some users may be forced to use. At some point the project will drop support for Python2 so we recommend users look at ways to transition to Python3 if it is not easily available.
Developers of RTEMS are required to have Python3 available. RTEMS tools used by developers for the development and maintenance of RTEMS are Python3 only.
All RTEMS Tools that can be invoked from the command line start with the following line:
#! /usr/bin/env python
The env
command is available on all POSIX host operating systems and it searches the $PATH
environment variable for the python
command invoking it with the script as the first argument. This means you need to have a suitable python
command on your host to run the RTEMS user tools. Not all hosts provide a python
command. If your host does not you need to find a way to provide one. The following are some examples you can use to solve this problem.
Python2 by default always provides a python
command.
4.1.1. Virtual Environment¶
Python3 provides virtual environment support. This is a great way to manage Python on a single host. You can have a number of virtual environments with a different mix of installed Python packages with different versions that do not clash.
Virtual environment always provide a python
command. This makes it ideal if your host only provides Python3 and there is no default python
command.
A virtual environment is created once and when you need to use it you activate it and when finished you deactivate it.
The following shows how to create a virtual environment using different methods. You can select the method that best suites you.
To create a virtual environment using the Python3 venv
module:
python3 -m venv rtems-py
To create a virtual environment for a specific version of Python3 you can enter the command:
python3.7 -m venv rtems-py
You can also install the virtualenv
package on your host if it is avaliable then enter the following create command:
virtualenv rtems-py
To activate the virtual environment:
. rtems-py/bin/activate
You will see your prompt change to reflect the virtual environment you have active. To check if you now have a python
command enter:
type python
The output will be something similar to the following:
(rtems-py) $ type python
python is /home/chris/development/rtems-py/bin/python
4.1.2. Symbolic Link¶
If your host does not provide the python
command you can add a symbolic link to it.
Note
We recommend you do not add the symbolic link in any of your operating system controlled directories as it is changing your operating system.
We suggest you add the symbolic link to a directory under your home directory adding that directory to your environment’s PATH
variable. The following commands show how to do this:
cd
mkdir bin
cd bin
ln -s `command -v python3` python
export PATH=$HOME/bin:$PATH
Note
You will need to modify your shell’s initialization scripts to make the PATH
change permanent.
4.1.3. Directly Invoking Python¶
It is valid to specifically invoke any python script directly. To do this simply prepend the specific version of python you wish to use. For example to run the waf
build system command with Python3 use:
python3 ./waf
4.2. Host Operating Systems¶
RTEMS uses Python in GDB to aid debugging which means GDB needs to be built with Python development libraries. Please check the RSB documentation and install the packages specified for your host. Make sure a python development package is included.
A wide range of host operating systems and hardware can be used. The host operating systems supported are:
Linux
FreeBSD
NetBSD
Apple OS X
Windows
Solaris
The functionality on a POSIX operating such as Linux and FreeBSD is similar and most features on Windows are supported but you are best to ask on the Users Mailing List if you have a specific question.
We recommend you maintain your operating system by installing any updates.
We also recommend you keep your environment to the bare minimum, particularly the PATH variable. Using environment variables has been proven over the years to be difficult to manage in production systems.
Warning
The RSB assumes your host is set up and the needed packages are installed and configured to work. If your host has not been set up please refer to section that covers your host’s packages you need to install.
Path to use when building applications:
Do not forget to set the path before you use the tools, for example to build the RTEMS kernel.
The RSB by default will install (copy) the executables to a directory tree under the prefix you supply. To use the tools once finished just set your path to the bin
directory under the prefix you use. In the examples that follow the prefix is $HOME/development/rtems/6.0
and is set using the --prefix
option so the path you need to configure to build applications can be set with the following in a BASH shell:
$ export PATH=$HOME/development/rtems/6.0/bin:$PATH
Make sure you place the RTEMS tool path at the front of your path so they are searched first. RTEMS can provide newer versions of some tools your operating system provides and placing the RTEMS tools path at the front means it is searched first and the RTEMS needed versions of the tools are used.
Warning
Do not put spaces or special characters in the directories you use to build RTEMS. Many of the packages built by the RSB use GNU make, which cannot handle spaces in pathnames. If there is a space in the pathname the build will fail. Special characters are also likely to confuse build systems.
Note
RSB and RTEMS have a matching git branch for each version of RTEMS. For example, if you want to build a toolchain for 4.11, then you should checkout the 4.11 branch of the RSB:
$ git checkout -t origin/6.0
Branches are available for the 4.9, 4.10, 4.11 and 5 versions of RTEMS.
4.3. POSIX Hosts¶
POSIX hosts are most Unix operating systems such as Linux, FreeBSD and NetBSD. RTEMS development works well on Unix and can scale from a single user and a desktop machine to a team with decentralised or centralised development infrastructure.
4.3.1. Root Access¶
You either have root
access to your host development machine or you do not. Some users are given hardware that is centrally managed. If you do not have root
access you can create your work environment in your home directory. You could use a prefix of $HOME/development/rtems
or $HOME/rtems
. Note, the $HOME
environment variable can be substituted with ~
.
Choose an Installation Prefix details using Prefixes to manage the installation.
RTEMS Tools and packages do not require root
access to be built and we encourage you to not build the tools as root
. If you need to control write access then it is best to manage this with groups assigned to users.
If you have root
access you can decide to install the tools under any suitable prefix. This may depend on the hardware in your host development machine. If the machine is a centralised build server the prefix may be used to separate production versions from the test versions and the prefix paths may have restricted access rights to only those who manage and have configuration control of the machine. We call this project sandboxing and Project Sandboxing explains this in more detail.
4.3.2. Linux¶
BSP Build will require pax
package if RTEMS is configured with the --enable-tests
option, see Building RTEMS Tests. This package is not installed , by default, on many Linux distributions, you can check for it using your package manager. Install it, if it is not present on your system.
A number of different Linux distrubutions are known to work. The following have been tested and report as working.
4.3.2.1. ArchLinux¶
The following packages are required on a fresh Archlinux 64bit installation:
# pacman -S base-devel gdb xz unzip ncurses git zlib
Archlinux, by default installs texinfo-5
which is incompatible for building GCC 4.7 tree. You will have to obtain texinfo-legacy
from AUR
and provide a manual override:
# pacman -R texinfo
$ yaourt -S texinfo-legacy
# ln -s /usr/bin/makeinfo-4.13a /usr/bin/makeinfo
4.3.2.2. CentOS¶
The following packages are required on a minimal CentOS 6.3 or CentOS 7 64-bit installation:
# yum install autoconf automake binutils gcc gcc-c++ gdb make patch pax \
bison flex xz unzip ncurses-devel texinfo zlib-devel python-devel git
On CentOS 8, the pax
command is now provided by the spax
package, you need to enable the PowerTools repository. and use Python3. On a fresh install, the following commands should install everything you need for RTEMS development:
# dnf install yum-utils
# dnf config-manager --set-enabled PowerTools
# dnf update
# dnf groupinstall "Development Tools"
# dnf install python3 python3-pip python3-setuptools python3-devel
# dnf install texinfo spax
# alternatives --set python /usr/bin/python3
The minimal CentOS distribution is a specific DVD that installs a minimal system. If you use a full system some of these packages may have been installed.
4.3.2.3. Fedora¶
The RTEMS Source Builder has been tested on Fedora 19 64bit with the following packages:
# yum install ncurses-devel python-devel git bison gcc cvs gcc-c++ \
flex texinfo patch perl-Text-ParseWords zlib-devel
4.3.2.4. Raspbian¶
The is the Debian distribution for the Raspberry Pi. The following packages are required:
$ sudo apt-get install autoconf automake bison flex binutils gcc g++ gdb \
texinfo unzip ncurses-dev python-dev git
It is recommended you get Model B of the Pi with 512M of memory and to mount a remote disk over the network. The tools can be built on the network disk with a prefix under your home directory as recommended and end up on the SD card.
4.3.2.5. Ubuntu¶
The latest version is Ubuntu 22.04 LTS 64-bit. This section also includes Xubuntu. A minimal installation was used and the following packages installed:
$ sudo apt install build-essential g++ gdb unzip pax bison flex texinfo \
python3-dev python-is-python3 libpython2-dev libncurses5-dev zlib1g-dev \
ninja-build pkg-config
Note that in older versions of Ubuntu, the package libpython2-dev was python2.7-dev. The name of packages changes over time. You need the package with Python development libraries for C/C++ programs. The following is needed for recent versions:
$ sudo apt-get install python git
It is likely necessary that you will have to enable the Ubuntu Source Repositories. Users have suggested the following web pages which have instructions:
4.3.2.6. Linux Mint¶
zlib package is required on Linux Mint. It has a different name (other than the usual zlib-dev):
# sudo apt-get install zlib1g-dev
4.3.2.7. openSUSE¶
The RTEMS Source Builder has been tested on openSUSE Leap 15.4 64bit. Starting with a clean install with source repositories enabled, the following zypper command installs the required packages:
# sudo zypper in -t pattern devel_C_C++ devel_python3
In addition, the following command can set python3 as the default python interpreter:
# sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 1
4.3.3. FreeBSD¶
The RTEMS Source Builder has been tested on FreeBSD 9.1, 10.3, 11 and 12 64bit versions. You need to install some ports. They are:
# pkg install -y python
# pkg install -y gsed
For FreeBSD 13, you will need to install the packages listed above, as well as the following additional ones. They are:
# pkg install -y bison texinfo gmake binutils
FreeBSD’s default C compiler is LLVM and installing the host’s GCC compiler package may break building GCC. We recommend you do not install the GCC package and you use the default C compiler.
If you wish to build Windows (mingw32) tools please install the following ports:
# pkg install -y mingw32-binutils mingw32-gcc
# pkg install -y mingw32-zlib mingw32-pthreads
The zlip and pthreads ports for MinGW32 are used when builiding a Windows QEMU.
Check if your kernel has a /dev/fd
directory. If it does not we recommend you run as root the following command to speed up Python 3’s subprocess support:
# mount -t fdescfs none /dev/fd
The support speeds up closing file descriptors when creating subprocesses.
4.3.4. NetBSD¶
The RTEMS Source Builder has been tested on NetBSD 6.1 i386. Packages to add are:
# pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1/devel/gmake-3.82nb7.tgz
# pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1/devel/bison-2.7.1.tgz
# pkg_add ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/i386/6.1/archivers/xz-5.0.4.tgz
4.4. Apple macOS¶
Apple’s macOS is supported. You need to download and install a recent version of the Apple developer application Xcode. Xcode is available in the App Store. Make sure you install the Command Line Tools add on available for download within Xcode and once installed open a Terminal shell and enter the command cc
and accept the license agreement.
The normal prefix when working on macOS as a user is under your home directory. Prefixes of $HOME/development/rtems
or $HOME/rtems
are suitable.
Choose an Installation Prefix details using Prefixes to manage the installation.
Homebrew and Macports should work but are not tested by the project as they are rolling releases making it difficult to reproduce any problems there may be. We recommend reaching out to those projects for support.
Intel and Apple silicon is supported.
4.4.1. Python¶
Building GDB requires the installation of Python’s development libraries. Building GDB includes the Python runtime header Python.h
and linking to the Python runtime libraries. The RSB detects a valid header and libraries before starting a GDB build.
It is recommended you run the RSB in a Python virtual environment. A virtual environment manages paths for you, provides a python
executable mapped to the version the virtual environment is built with and a command to find the appropiate runtime header and library files GDB needs. Virtual environments make it easier to update Python to a newer version if this is needed.
Apple has removed support for Python’s development libraries from recent versions of MacOS as users can manage Python using the installer packages provided by the Python project.
To install:
Download a Python installer for MacOS from https://www.python.org/.
Run the installer and install Python.
Open a terminal and update your shell profile using the command Python provides. For Python 3.12 the command is:
/Applications/Python\ 3.12/Update\ Shell\ Profile.command
Check with:
% type python3.12 python3.12 is /Library/Frameworks/Python.framework/Versions/3.12/bin/python3.12
Create a virtual environment:
mkdir $HOME/development/rtems cd $HOME/development/rtems python3.12 -m venv py3.12
Activate the virtual environment:
. $HOME/development/rtems/py3.12/bin/activate
You are now ready to the build the tools within the virtual environment.
4.4.2. Sonoma¶
The RSB is supported on Sonoma and Applie silicon.
4.4.3. Ventura¶
The RSB is supported on Ventura and Intel silicon.
4.4.4. Monterey¶
The RSB is supported on Ventura and Intel silicon.
4.4.5. Catalina¶
In the macOS Catalina 10.15 Release Notes Apple deprecated several scripting language runtimes such as Python 2.7. See also Xcode 11 Release Notes. Due to the deprecated Python 2.7 support, we recommend to install and use the latest Python 3 release from python.org.
4.4.6. Sierra¶
The RSB works on Sierra with the latest Xcode.
4.4.7. Mavericks¶
The RSB works on Mavericks and the GNU tools can be built for RTEMS using the Mavericks clang LLVM tool chain. You will need to build and install a couple of packages to make the RSB pass the sb-check
. These are CVS and XZ. You can get these tools from a packaging tool for macOS such as MacPorts or HomeBrew.
I do not use third-party packaging on macOS and prefer to build the packages from source using a prefix of /usr/local
. There are good third-party packages around however they sometimes bring in extra dependence and that complicates my build environment and I want to know the minimal requirements when building tools. The following are required:
- . The XZ package’s home page is http://tukaani.org/xz/ and I use version
5.0.5. XZ builds and installs cleanly.
4.5. Microsoft Windows¶
RTEMS supports Windows as a development host and the tools for most architectures are available. The RTEMS Project relies on the GNU tools for compilers and debuggers and we use the simulators that come with GDB and QEMU. The Windows support for these tools varies and the RTEMS Project is committed to helping the open source community improve the Windows experience. If something is not working or supported please email the Users Mailing List.
The RTEMS Project’s Windows tools can be native Windows executables which give the user the best possible experience on Windows. Native Windows programs use the standard Windows DLLs and paths. Integration with standard Windows integrated development tools such as editors is straight forward. POSIX emulation environments such as Cygwin and the MSYS2 shell have special executables that require a POSIX emulation DLL and these emulation DLLs add an extra layer of complexity as well as a performance over-head. The RTEMS Project uses these POSIX emulation shells to run configure scripts that come with various open source packages such as gcc so they form an important and valued part of the environment we describe here. The output of this procedure forms the tools you use during your application development and they do not depend on the emulation DLLs.
The performance of a native Windows compiler is as good as you can have on Windows and the performance compiling a single file will be similar to that on a host like Linux or FreeBSD given the same hardware. Building the tools from source is much slower on Windows because POSIX shells and related tools are used and the POSIX emulation overhead it much much slower than a native POSIX operating system like Linux and FreeBSD. This overhead is only during the building of the tools and the RTEMS kernel and if you use a suitable build system that is native to Windows your application development should be similar to other operating systems.
Building is known to work on Windows 7 64bit Professional and Windows 10 64bit.
4.5.1. Windows Path Length¶
Windows path length is limited and can cause problems when building the tools. The standard Windows API has a MAX_PATH
length of 260 characters. This can effect some of the tools used by RTEMS. It is recommended you keep the top level directories as short as possible when building the RTEMS tools and you should also keep an eye on the path length when developing your application. The RTEMS built tools can handle much longer path lengths however some of the GNU tools such as those in the binutils
package cannot.
The release packages of the RSB when unpacked have top level file names that are too big to build RTEMS. You need to change or rename that path to something smaller to build. This is indicated in released-version.
4.5.2. Windows Spaces In Paths¶
Occasionally, a program will fail on Windows with errors that appear as if a directory or file name was partially parsed by some utility or program. This can be caused by having directories of file names with spaces. Programs written in scripting languages sometimes fail to properly quote file names and the space is incorrectly interpreted.
Parts of the PATH inherited from the native Windows environment often include directory names with spaces. Sometimes it is necessary to set the PATH explicitly to avoid these.
4.5.3. Parallel Builds with Make¶
The MSYS2 GNU make
has problems when using the jobs option. The RSB defaults to automatically using as many cores as the host machine has. To get a successful build on Windows it is recommended you add the --jobs=none
option to all RSB build set commands.
4.5.4. POSIX Support¶
Building the RTEMS compilers, debugger, the RTEMS kernel and a number of other third-party packages requires a POSIX environment. On Windows you can use Cygwin or MSYS2. This document focuses on MSYS2. It is smaller than Cygwin and comes with the Arch Linux package manager pacman
.
MSYS2 provides MinGW64 support as well as a POSIX shell called MSYS2. The MinGW64 compiler and related tools produce 64bit native Windows executables. The shell is a standard Bourne shell and the MSYS2 environment is a stripped Cygwin shell with enough support to run the various configure
scripts needed to build the RTEMS tools and the RTEMS kernel.
MSYS2 is built around the pacman
packaging tool. This makes MSYS2 a distribution and that is a welcome feature on Windows. You get a powerful tool to manage your development environment on Windows.
4.5.5. Python¶
We need Python to build the tools as the RSB is written in Python and we need suitable Python libraries to link to GDB as RTEMS makes use of GDB’s Python support. This places specific demands on the Python we need installed and available and MSYS2 provides suitable Python versions we can use. You need to make sure you have the correct type and version of Python installed.
We cannot use the Python executables created by the Python project (python.org) as they are built by Microsoft’s C (MSC) compiler. Linking the MSC Python libraries with the MinGW64 executables is not easy and MSYS provides us with a simple solution so we do not support linking MSC libraries.
MSYS2 provides two types and two versions of Python executables, MinGW and MSYS and Python version 2 and 3. For Windows we need the MinGW executable so we have suitables libraries and we have to have Python version 2 because on Windows GDB only builds with Python2.
You also need to install the MSYS version of Python along with the MinGW64 Python2 package. The MSYS Python is version 3 and the RSB can support version 2 and 3 of Python and it helps handle some of the long paths building GCC can generate.
4.5.6. MSYS2¶
MSYS2 is installed on a new machine using the MSYS2 installer found on https://msys2.github.io/. Please select the x86_64
variant for 64bit support. Run the installer following the 7 steps listed on the page.
MSYS2 uses the pacman
package manager. The Arch Linux project has detailed documentation on how to use pacman
. What is shown here is a just few examples of what you can do.
Pin the MSYS2 64bit Shell to the Taskbar so you always use it rather than the 32bit Shell.
Open a 64bit MSYS shell from the Start Menu:
Note
If you ever see error: no hosts defaults found; please add
you have probably opened an MSYS2 32bit Shell. Close all 32bit Shell windows and open the MSYS2 64bit Shell.
The packages we require are:
python
mingw-w64-x86_64-python2
mingw-w64-x86_64-python3
mingw-w64-x86_64-gcc
flex
git
bison
cvs
diffutils
make
patch
tar
texinfo
unzip
Note
The actual output provided may vary due to changes in the dependent packages or newer package versions.
Install the packages using pacman
:
$ pacman -S python mingw-w64-x86_64-python3 mingw-w64-x86_64-python2 \
mingw-w64-x86_64-gcc \
bison flex cvs diffutils git make patch tar texinfo unzip
resolving dependencies...
looking for conflicting packages...
.... output shortened for brevity ....
The base installer executable puts the compiler you want to use in /mingw64/bin
which needs to be added to the beginning of your PATH
. You can do that for example by adding this line to the end of ${HOME}/.bashrc
:
export PATH=/mingw64/bin:$PATH
You will also likely want to add to PATH
the bin
directory of the prefix where you plan to install RTEMS.
4.5.7. Cygwin¶
Building on Windows is a little more complicated because the Cygwin shell is used rather than the MSYS2 shell. The MSYS2 shell is simpler because the detected host triple is MinGW so the build is a standard cross-compiler build. A Canadian cross-build using Cygwin is supported if you would like native tools or you can use a Cygwin built set of tools.
Install a recent Cygwin version using the Cygwin setup tool. Select and install the groups and packages listed:
Group | Package |
Archive | bsdtar |
Archive | unzip |
Archive | xz |
Devel | autoconf |
Devel | autoconf2.1 |
Devel | autoconf2.5 |
Devel | automake |
Devel | binutils |
Devel | bison |
Devel | flex |
Devel | gcc4-core |
Devel | gcc4-g++ |
Devel | git |
Devel | make |
Devel | mingw64-x86_64-binutils |
Devel | mingw64-x86_64-gcc-core |
Devel | mingw64-x86_64-g++ |
Devel | mingw64-x86_64-runtime |
Devel | mingw64-x86_64-zlib |
Devel | patch |
Devel | zlib-devel |
MinGW | mingw-zlib-devel |
Python | python |
The setup tool will add a number of dependent package and it is ok to accept them.
Disabling Windows Defender improves performance if you have another up to date virus detection tool installed and enabled. The excellent Process Hacker 2
tool can monitor the performance and the Windows Defender service contributed a high load. In this case a third-party virus tool was installed so the Windows Defender service was not needed.
To build a MinGW tool chain a Canadian cross-compile (Cxc) is required on Cygwin because the host is Cygwin therefore a traditional cross-compile will result in Cygiwn binaries. With a Canadian cross-compile a Cygwin cross-compiler is built as well as the MinGW RTEMS cross-compiler. The Cygwin cross-compiler is required to build the C runtime for the RTEMS target because we are building under Cygiwn. The build output for an RTEMS 4.10 ARM tool set is:
chris@cygwin ~/development/rtems/src/rtems-source-builder/rtems
$ ../source-builder/sb-set-builder --log=l-arm.txt \
--prefix=$HOME/development/rtems/6.0 4.10/rtems-arm
RTEMS Source Builder - Set Builder, v0.2
Build Set: 4.10/rtems-arm
config: expat-2.1.0-1.cfg
package: expat-2.1.0-x86_64-w64-mingw32-1
building: expat-2.1.0-x86_64-w64-mingw32-1
reporting: expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-w64-mingw32-1.html
config: tools/rtems-binutils-2.20.1-1.cfg
package: arm-rtems4.10-binutils-2.20.1-1 <1>
building: arm-rtems4.10-binutils-2.20.1-1
package: (Cxc) arm-rtems4.10-binutils-2.20.1-1 <2>
building: (Cxc) arm-rtems4.10-binutils-2.20.1-1
reporting: tools/rtems-binutils-2.20.1-1.cfg ->
arm-rtems4.10-binutils-2.20.1-1.html
config: tools/rtems-gcc-4.4.7-newlib-1.18.0-1.cfg
package: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
building: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
package: (Cxc) arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
building: (Cxc) arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
reporting: tools/rtems-gcc-4.4.7-newlib-1.18.0-1.cfg ->
arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1.html
config: tools/rtems-gdb-7.3.1-1.cfg
package: arm-rtems4.10-gdb-7.3.1-1
building: arm-rtems4.10-gdb-7.3.1-1
reporting: tools/rtems-gdb-7.3.1-1.cfg -> arm-rtems4.10-gdb-7.3.1-1.html
config: tools/rtems-kernel-4.10.2.cfg
package: arm-rtems4.10-kernel-4.10.2-1
building: arm-rtems4.10-kernel-4.10.2-1
reporting: tools/rtems-kernel-4.10.2.cfg -> arm-rtems4.10-kernel-4.10.2-1.html
installing: expat-2.1.0-x86_64-w64-mingw32-1 -> /cygdrive/c/Users/chris/development/rtems/6.0
installing: arm-rtems4.10-binutils-2.20.1-1 -> /cygdrive/c/Users/chris/development/rtems/6.0 <3>
installing: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1 -> /cygdrive/c/Users/chris/development/rtems/6.0
installing: arm-rtems4.10-gdb-7.3.1-1 -> /cygdrive/c/Users/chris/development/rtems/6.0
installing: arm-rtems4.10-kernel-4.10.2-1 -> /cygdrive/c/Users/chris/development/rtems/6.0
cleaning: expat-2.1.0-x86_64-w64-mingw32-1
cleaning: arm-rtems4.10-binutils-2.20.1-1
cleaning: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1
cleaning: arm-rtems4.10-gdb-7.3.1-1
cleaning: arm-rtems4.10-kernel-4.10.2-1
Build Set: Time 10:09:42.810547 <4>
Items:
The Cygwin version of the ARM cross-binutils.
The +(Cxc)+ indicates this is the MinGW build of the package.
Only the MinGW version is installed.
Cygwin is slow so please be patient. This time was on an AMD Athlon 64bit Dual Core 6000+ running at 3GHz with 4G RAM running Windows 7 64bit.
Warning
Cygwin documents the ‘Big List Of Dodgy Apps’ or ‘BLODA’. The link is http://cygwin.com/faq/faq.html#faq.using.bloda and it is worth a look. You will see a large number of common pieces of software found on Windows systems that can cause problems. My testing has been performed with NOD32 running and I have seen some failures. The list is for all of Cygwin so I am not sure which of the listed programs effect the RTEMS Source Biulder. The following FAQ item talks about fork failures and presents some technical reasons they cannot be avoided in all cases. Cygwin and it’s fork MSYS are fantastic pieces of software in a difficult environment. I have found building a single tool tends to work, building all at once is harder.
5. Deployment¶
Deployment is a process companies, organizations or teams use to control and manage delivery of RTEMS tools, kernels and third party libraries. Deployed tools, kernels and libraries are packaged and controlled so the same tools and libraries are used in all phases of a project.
The Quick Start guide details how tools are built using the RSB. The tools are installed on your development computer and available for you to build applications. That build can be viewed as the simplest form of deployment because it is simple and easy however it does not scale. Building the tools and kernel on each development machine in a project or company is time consuming, difficult to get right and costly to audit.
This section covers the building of tools, kernels and third party libraries using the RSB for deployment. Custom RSB buildset files are supported across releases giving you an easy update path. The RSB can generate a single tarfile for any prefix without needing to install the pieces built helping ease integration with packaging systems and continuous integration (CI) for automated workflows.
5.1. RSB Deployment¶
The RSB provides support for deployment using custom buildset files. A custom buildset file resides outside the RSB and can build tools for a number of architectures and kernels for BSPs. Deployment can include third party libraries if a single BSP is being built.
The RSB --no-install
option builds the tools and kernel without the final installation phase. A prefix that is not accessible when running the RSB can be used. This is important if a CI flow is being used.
The buildset tar file option --bset-tar-file
packages the build’s staging directory tree into a single tar file. The tar file can be used as the input source to a packaging system.
Buildset configuration files can be tested by adding the --dry-run
option to the sb-set-builder
command line.
The buildset examples that follow assume the prefix path used does not exist or is not writable and the environment path does not include any RTEMS tools.
5.1.1. Deployment Repository¶
Create a repository to hold a project’s buildset configuration files:
$ mkdir a-project
$ cd a-project
$ git init
Add the RSB as a sub-module:
$ git submodule add \
ssh://git@gitlab.rtems.org:2222/rtems/tools/rtems-source-builder.git
Create a configuration directory:
$ mkdir config
$ git add config
5.1.2. Tools Configuration¶
This example will build a single tool set with a local configuration file.
Create a configuration file for the project
:
$ vi config/project-tools.bset
Add the following to the buildset configuration file:
#
# Project Tools
#
6/rtems-aarch64
Commit the changes to the repository:
$ git add config/project-tools.bset
$ git commit -m "Add project aarch64 tools buildset"
Build a tarfile containing the tools using the RSB submodule:
$ ./rtems-source-builder/source-builder/sb-set-builder \
--prefix=/opt/project --log=project.txt \
--bset-tar-file --no-install \
project-tools
Once the build has finished the tar
directory will contain the project
tools in a tarfile:
$ ls tar
project-tools.tar.bz2
Inspect the tarfile to check the path matches the prefix used to build the tools (sizes may vary):
$ tar Jtvf tar/project-tools.tar.bz2 | less
drwxr-xr-x 0 chris eng 0 Sep 6 14:27 opt/project/bin/
-rwxr-xr-x 0 chris eng 1320888 Sep 6 14:20 opt/project/bin/aarch64-rtems6-addr2line
-rwxr-xr-x 0 chris eng 1358688 Sep 6 14:20 opt/project/bin/aarch64-rtems6-ar
-rwxr-xr-x 0 chris eng 2381976 Sep 6 14:20 opt/project/bin/aarch64-rtems6-as
-rwxr-xr-x 0 chris eng 1328440 Sep 6 14:27 opt/project/bin/aarch64-rtems6-c++
-rwxr-xr-x 0 chris eng 1316240 Sep 6 14:20 opt/project/bin/aarch64-rtems6-c++filt
-rwxr-xr-x 0 chris eng 1328440 Sep 6 14:27 opt/project/bin/aarch64-rtems6-cpp
-rwxr-xr-x 0 chris eng 60792 Sep 6 14:20 opt/project/bin/aarch64-rtems6-elfedit
-rwxr-xr-x 0 chris eng 1328440 Sep 6 14:27 opt/project/bin/aarch64-rtems6-g++
-rwxr-xr-x 0 chris eng 1328440 Sep 6 14:27 opt/project/bin/aarch64-rtems6-gcc
-rwxr-xr-x 0 chris eng 1328440 Sep 6 14:27 opt/project/bin/aarch64-rtems6-gcc-12.1.1
-rwxr-xr-x 0 chris eng 48568 Sep 6 14:27 opt/project/bin/aarch64-rtems6-gcc-ar
-rwxr-xr-x 0 chris eng 48568 Sep 6 14:27 opt/project/bin/aarch64-rtems6-gcc-nm
-rwxr-xr-x 0 chris eng 48576 Sep 6 14:27 opt/project/bin/aarch64-rtems6-gcc-ranlib
.....
5.1.3. Tools and Kernel¶
This example builds a single tool set and an RTEMS kernel for a BSP using a buildset defined BSP settings.
We use the same a-project
repository from the previous example and add a new configuration. Add a configuration file to build the tools and a BSP:
$ vi config/project-tools-bsp.bset
Add the following to the buildset configuration file and save:
#
# Project Tools and BSP
#
%define with_rtems_bsp aarch64/versal_aiedge
%define with_rtems_bspopts BSP_XILINX_VERSAL_NOCACHE_LENGTH=0x4000000 \
BSP_XILINX_VERSAL_RAM_LENGTH=0x200000000
6/rtems-aarch64
6/rtems-kernel
The configuration provides BSP options. Commit the changes to the repository:
$ git add config/project-tools-bsp.bset
$ git commit -m "Add project tools and BSP buildset"
Build a tarfile of the tools and BSP using the RSB submodule:
$ ./rtems-source-builder/source-builder/sb-set-builder \
--prefix=/opt/project --log=project.txt \
--bset-tar-file --no-install \
project-tools-bsp
A buildset configuration file that uses buildset BSP defines is limited to a single architecture and the tools built need to match the architecture of the BSP.
You can specify more than one BSP to be built. An updated configuration could be:
%define with_rtems_bsp aarch64/versal_aiedge \
aarch64/zynqmp_apu
This is useful when deploying more than one BSP. If you need multiple architectures and BSPs consider the Tools and Kernel With Config example.
Buildset BSP options are applied to all BSPs in the BSP list. If they are specific to a BSP only specify a single BSP in the BSP define.
RTEMS 5 supports this type of buildset file.
5.1.4. Tools and Kernel with Config¶
This example builds tool sets for different architectures and multiple BSPs for the architectures using a kernel configuration INI file.
Tools for the arch64
and arm
architectures are built and three BSPs each with different options.
We use the same a-project
repository from the previous example and add the new configurations. Add a configuration file to build the tools and BSPs:
$ vi config/project-tools-bsp-config.bset
Add the following to the buildset configuration file and save:
#
# Project Tools and BSPs
#
%define with_rtems_bsp_config config/project-bsps.ini
6/rtems-aarch64
6/rtems-arm
6/rtems-kernel
Add a kernel configuration INI file:
$ vi config/project-bsps.bset
Add the following to the kernel configuration INI file and save:
#
# Project BSPs
#
[DEFAULT]
RTEMS_POSIX_API = True
BUILD_SAMPLES = True
BUILD_TESTS = False
[aarch64/versal_aiedge]
BSP_XILINX_VERSAL_NOCACHE_LENGTH = 0x4000000
BSP_XILINX_VERSAL_RAM_LENGTH = 0x200000000
[aarch64/zynqmp_apu]
RTEMS_SMP = True
[arm/xilinx_zynq_zc706]
RTEMS_SMP = True
BSP_XILINX_VERSAL_NOCACHE_LENGTH = 0x4000000
BSP_XILINX_VERSAL_RAM_LENGTH = 0x200000000
Commit the changes to the repository:
$ git add config/project-tools-bsp-config.bset
$ git add config/project-bsps.ini
$ git commit -m "Add project tools and BSPs buildset and kernel config"
Build a tarfile of the tools and BSPs using the RSB submodule:
$ ./rtems-source-builder/source-builder/sb-set-builder \
--prefix=/opt/project --log=project.txt \
--bset-tar-file --no-install \
project-tools-bsp-config
5.1.5. Tools, Kernel and Packages¶
Third party libraries can be built as part of a single RSB configuration if only one BSP is built at a time. The RSB support for building packages does not support building for multiple BSPs.
We use the same a-project
repository from the previous example and add a new configuration. Add a configuration file to build the tools, BSPs and LibBSD:
$ vi config/project-aarch64-tools-bsp-libbsd.bset
Add the following to the buildset configuration file and save:
#
# Project Tools, BSP and LibBSD
#
%define with_rtems_bsp aarch64/versal_aiedge
%define with_rtems_bspopts BSP_XILINX_VERSAL_NOCACHE_LENGTH=0x4000000 \
BSP_XILINX_VERSAL_RAM_LENGTH=0x200000000
6/rtems-aarch64
6/rtems-kernel
6/rtems-libbsd
Commit the changes to the repository:
$ git add config/project-aarch64-tools-bsp-libbsd.bset
$ git commit -m "Add project aarch64 tools, BSP and libbsd"
Build a tarfile of the tools, BSP and LibBSD using the RSB submodule:
$ ./rtems-source-builder/source-builder/sb-set-builder \
--prefix=/opt/project --log=project.txt \
--bset-tar-file --no-install \
project-aarch64-tools-bsp-libbsd
The tarfile can be reviewed to see the BSP libraries built (sizes may vary):
$ tar jtvf tar/project-aarch64-tools-bsp-libbsd.tar.bz2 | \
grep -e '\.a$' | grep -e 'versal_aiedge'
-rw-r--r-- 0 chris eng 138936312 Sep 7 14:58 opt/project/aarch64-rtems6/versal_aiedge/lib/libbsd.a
-rw-r--r-- 0 chris eng 686190 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/libdebugger.a
-rw-r--r-- 0 chris eng 164086 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/libftpd.a
-rw-r--r-- 0 chris eng 107560 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/libftpfs.a
-rw-r--r-- 0 chris eng 978812 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/libjffs2.a
-rw-r--r-- 0 chris eng 412354 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/libmghttpd.a
-rw-r--r-- 0 chris eng 2099962 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/librtemsbsp.a
-rw-r--r-- 0 chris eng 29693496 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/librtemscpu.a
-rw-r--r-- 0 chris eng 435236 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/librtemscxx.a
-rw-r--r-- 0 chris eng 141234 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/librtemsdefaultconfig.a
-rw-r--r-- 0 chris eng 856514 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/librtemstest.a
-rw-r--r-- 0 chris eng 159004 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/libtelnetd.a
-rw-r--r-- 0 chris eng 137386 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/libtftpfs.a
-rw-r--r-- 0 chris eng 476692 Sep 7 14:56 opt/project/aarch64-rtems6/versal_aiedge/lib/libz.a
5.1.6. Tools, Kernel with Config and Packages¶
This example builds the tools, kernel and LibBSD using an RSB configuration file and a kernel configuration file. The kernel configuration provides easier kernel and BSP option management.
Third party libraries can be built as part of a single RSB configuration if only one BSP is built at a time. The RSB support for building packages does not support building for multiple BSPs.
We use the same a-project
repository from the previous example and add a new configuration. Add a configuration file to build the tools, BSPs and LibBSD:
$ vi config/project-aarch-tools-bsp-libbsd-config.bset
Add the following to the buildset configuration file and save:
#
# Project Tools, BSP and LibBSD
#
%define with_rtems_bsp_config config/project-aarch64-bsp.ini
6/rtems-aarch64
6/rtems-kernel
6/rtems-libbsd
Add a kernel configuration INI file:
$ vi config/project-aarch64-bsp.bset
Add the following kernel configuration INI file and save:
#
# Project Versal AI Edge BSP
#
[DEFAULT]
RTEMS_POSIX_API = True
BUILD_SAMPLES = True
BUILD_TESTS = False
[aarch64/versal_aiedge]
BSP_XILINX_VERSAL_NOCACHE_LENGTH = 0x4000000
BSP_XILINX_VERSAL_RAM_LENGTH = 0x200000000
Commit the changes to the repository:
$ git add config/project-aarch64-tools-bsp-libbsd-config.bset
$ git add config/project-aarch64-bsp.ini
$ git commit -m "Add project aarch64 tools, BSP (with config) and libbsd"
Build the tarfile of the tools, BSP and LibBSD using the RSB submodule:
$ ./rtems-source-builder/source-builder/sb-set-builder \
--prefix=/opt/project --log=project.txt \
--bset-tar-file --no-install \
project-aarch64-tools-bsp-libbsd-config
6. Target Hardware¶
6.1. Targets¶
Target hardware that can run RTEMS is often referred to simply as the target because RTEMS is specifically aimed at that target hardware. An RTEMS executable is statically linked and executes in a single address space on the target hardware. A statically linked executable means the RTEMS Kernel, drivers, third-party packages and application code is linked into a single executable image. A single address space means no virtual memory and no memory protected process address space is running within the RTEMS arena and the RTEMS executive, drivers and application have unprotected access to the whole address space and all hardware.
Target hardware supported by RTEMS has a Board Support Package or BSP. A BSP is a specific instance of an RTEMS architecture that allows the creation of an RTEMS executable. You can view the layering as:
RTEMS targets are grouped by architectures and within an architecture there are a number of Board Support Packages or BPSs. An architecture is a specific class or family of processors and can be large such as ARM or specific such as the NIOS-II or Microblaze.
RTEMS is designed to be ported to new target hardware easily and efficiently.
6.2. Architectures¶
An RTEMS architecture is a class or family of a processor architecture that RTEMS supports. The RTEMS architecture model follows the architecture model of GCC. An architecture in GCC results in a specific RTEMS GCC compiler. This compiler may support a range of processors in the family that may have differences in instructions sets, floating point support or other aspects. RTEMS configures GCC to create separate runtime libraries for each supported instruction set, floating point unit, vector unit, word size (e.g. 32-bit and 64-bit), endianess, code model, ABI, processor errata workarounds, and so on in the architecture. This is termed multilib. Multilibs are chosen automatically by GCC via selecting a specific set of machine options.
You can query the multilibs of a specific RTEMS GCC compiler via the -print-multi-lib
option:
$ sparc-rtems5-gcc -print-multi-lib
.;
soft;@msoft-float
v8;@mcpu=v8
leon3;@mcpu=leon3
leon3v7;@mcpu=leon3v7
leon;@mcpu=leon
leon3/gr712rc;@mcpu=leon3@mfix-gr712rc
leon3v7/gr712rc;@mcpu=leon3v7@mfix-gr712rc
leon/ut699;@mcpu=leon@mfix-ut699
leon/at697f;@mcpu=leon@mfix-at697f
soft/v8;@msoft-float@mcpu=v8
soft/leon3;@msoft-float@mcpu=leon3
soft/leon3v7;@msoft-float@mcpu=leon3v7
soft/leon;@msoft-float@mcpu=leon
soft/leon3/gr712rc;@msoft-float@mcpu=leon3@mfix-gr712rc
soft/leon3v7/gr712rc;@msoft-float@mcpu=leon3v7@mfix-gr712rc
soft/leon/ut699;@msoft-float@mcpu=leon@mfix-ut699
soft/leon/at697f;@msoft-float@mcpu=leon@mfix-at697f
Each printed line represents a multilib. The .
corresponds to the default multilib. It is used if a set of machine options does not match to a specialized multilib. The string before the ;
describes the directory in the GCC installation used for the particular multilib. After the ;
the set of machine options for this multilib follows separated by @
characters.
You can figure out the multilib selected by GCC for a set of machine options with the -print-multi-directory
option:
$ sparc-rtems5-gcc -print-multi-directory -mcpu=leon3
leon3
It is crucial that the RTEMS BSP, support libraries and the application code are compiled consistently with a compatible set of machine options. Otherwise, in the best case errors during linking will occur or you may end up silently with undefined behaviour which results in sporadic run-time crashes. A wrong set of machine options may result in a running application, however, with degraded performance, e.g. hardware floating point unit is not used by the mathematical library.
For a list of architectures supported by RTEMS please have a look at the sections of the Board Support Packages chapter.
RTEMS executables are statically linked for a specific target therefore a precise and exact match can be made for the hardware that extracts the best possible performance. The compiler supports the variants to the instruction set and RTEMS extends the specialization to specific processors in an architecture. This specialization gives RTEMS a finer resolution of features and capabilities a specific device may offer allowing the kernel, drivers and application to make the most of those resources. The trade off is portability however this is not important because the executable are statically linked for a single target.
Note
RTEMS support dynamically load code through the dlopen
interface. Loading code via this interface results in an executable image that is equivalent to statically linked executable of the same code. Dynamic loading is a system level tool for system architects.
6.3. Tiers¶
RTEMS has a tiered structure for architecture and BSPs. It provides:
A way to determine the state of a BSP in RTEMS.
A quaility measure for changes entering the RTEMS source code.
The RTEMS project supports RTEMS Architecture Tiers. Each architecture resided in one of the numbered tiers. The tiers are number 1 to 4 where Tier 1 is the highest tier and Tier 4 is the lowest. Architectures move between tiers based on the level of support and the level of testing that is performed. An architecture requires continual testing and reporting of test results to maintain a tier level. The RTEMS Project’s continuous integration testing program` continually monitors and reports the test results.
The RTEMS Architecture Tier system provides a defined way to determine the state of an architecture in RTEMS. Architectures age and support for them drops off and the RTEMS Project needs a way to determine if an architecture should stay and be supported or depreciated and removed. The tier system also provides users with a clear understanding of the state of an architecture in RTEMS, often useful when deciding on a processor for a new project. It can also let a user know the RTEMS Project needs support to maintain a specific architecture. Access to hardware to perform testing is a large and complex undertaking and the RTEMS Project is always looking for user support and help. If you can help please contact someone and let us know.
The tier structure in RTEMS is support by the Buildbot continuous integration server. Changes to RTEMS are automatically built and tested and the results indicate if a BSP currently meets its tier status. As the RTEMS Project does not own hardware for every BSP, it is critical that users provide test results on hardware of interest.
The rules for Tiers are:
A BSP can only be in one of the following tiers:
Tier
Description
1
The RTEMS Kernel must build without error.
Tests are run on target hardware.
2
The RTEMS Kernel must build without error.
Tests can be run on simulation.
3
The RTEMS Kernel must build without error.
There are no test results.
4
The RTEMS Kernel does not build.
5
The BSP is to be removed after the next release.
An architecuture’s tier is set by the highest BSP tier reached.
The tier level for a BSP is set by the RTEMS Project team. Movement of BSP between tier level requires agreement. The Buildbot results indicate the minimum current tier level.
Changes to RTEMS may result in a BSP not meeting its tier are acceptable if the change is accompanied by an announcement and a plan on how this is to be resolved. Temporary drops in tier are expected and should be brief.
Test results are set on a per BSP basis by the RTEMS Project team. Changes to the test result values requires agreement. The test results are defined as:
Passes
Expected Failures
Expected failures must be explicitly listed. A BSP is required to have a valid test result entry on target hardware to reach tier 1.
7. BSP Build System¶
The purpose of the build system is to produce and install artefacts from the RTEMS sources such as static libraries, start files, linker command files, configuration header files, header files, test programs, package description files, and third-party build system support files for a specific BSP in a user controlled configuration.
7.1. Overview¶
The build system consists of three components which are all included in the RTEMS sources
the waf meta build system command line tool,
a wscript file used by
waf
, anda set of build specification items maintained by a text editor just like other source files.
The build system is controlled by the user through
commands passed to the
waf
command line tool,command line options passed to
waf
, andconfiguration files (e.g.
config.ini
) used bywscript
throughwaf
invocations.
Configurable things which are subject to a local installation variant such as paths to tools are intended to be passed as command line options to the waf
command line tool. Which BSPs are built and how they are configured by means of options is placed in configuration files (e.g. config.ini
). The configuration files may reside anywhere in the file system and the goal is to have it under version control by the user.
7.2. Work Flow¶
There are five steps necessary to build and install one or more BSPs.
Select which BSPs you want to build. See also Deployment and
./waf bsplist
.Write a BSP build configuration file (e.g.
config.ini
) which determines which BSPs are built and how they are configured.Run the
./waf configure
command to generate the build environment.Build the BSP artefacts with
./waf
. The build uses the build environment created by./waf configure
. The BSP build configuration file (e.g.config.ini
) is no longer used and may be deleted.Install the BSP artefacts with
./waf install
.
7.3. Commands¶
The build system is controlled by invocations of the ./waf
command line tool instead of the well known make
. Since waf is written in Python, a standard Python 2.7 or 3 installation without third-party packages is required to run it. The ./waf
command line tool must be invoked in the RTEMS source tree top-level directory.
Some commands accept the --rtems-specs
command line option. This option specifies paths to build specification items. It is an advanced option and there is normally no need to use it. It may be used to customize the build at the level of the build specification. For more information see the Build System chapter of the RTEMS Software Engineering guide.
7.3.1. Help¶
Use ./waf --help
to get a list of commands and options.
7.3.2. BSP List¶
The BSP list command ./waf bsplist
loads the build specification items and generates a list of base BSPs from it. The list is sorted by architecture and base BSP name. Which base BSPs are listed can be controlled by the --rtems-bsps
command line option. It expects a comma-separated list of Python regular expressions which select the desired BSP variants. The path to the build specification items can be specified by the --rtems-specs
command line option.
$ ./waf bsplist --rtems-bsps=sparc/
sparc/at697f
sparc/erc32
sparc/gr712rc
sparc/gr740
sparc/leon2
sparc/leon3
sparc/ut699
sparc/ut700
$ ./waf bsplist --rtems-bsps='/leon,/rv64imac$'
riscv/rv64imac
sparc/leon2
sparc/leon3
7.3.3. BSP Defaults¶
The BSP defaults command ./waf bspdefaults
loads the build specification items and generates a list options with default values for each base BSP from it. The list is sorted by architecture and base BSP name. Which base BSPs are listed can be controlled by the --rtems-bsps
command line option. Default values may depend on the selected compiler. The compiler can be specified by the --rtems-compiler
command line option. The path to the build specification items can be specified by the --rtems-specs
command line option.
$ ./waf bspdefaults --rtems-bsps=gr712rc --rtems-compiler=gcc | grep ABI_FLAGS
ABI_FLAGS = -mcpu=leon3 -mfix-gr712rc
$ ./waf bspdefaults --rtems-bsps=gr712rc --rtems-compiler=clang | grep ABI_FLAGS
ABI_FLAGS = -mcpu=gr712rc
7.3.4. Configure¶
The configure command ./waf configure
loads the BSP build configuration files and the build specification items and configures the build environment accordingly. The configuration files can be specified by the --rtems-config
command line option. It expects a comma-separated list of paths to the configuration files. By default, the file config.ini
is used. The paths to RTEMS tools can be specified by the --rtems-tools
command line option. It expects a comma-separated list of prefix paths to tools, e.g. compiler, linker, etc. By default, the installation prefix is used for the RTEMS tools. Tools are searched in the prefix path and also in a bin
subdirectory of the prefix path. The path to the build specification items can be specified by the --rtems-specs
command line option.
7.3.5. Build, Clean, and Install¶
The commands ./waf
, ./waf clean
, and ./waf install
load the build specification items according to the specification paths stored in the build environment. The BSP build configuration files (e.g. config.ini
) used by the ./waf configure
command to create the build environment are not longer used and may be deleted. The build commands perform a dependency tracking and re-build artefacts if input sources changed. Input sources are also the build specification.
7.4. Configuration¶
The BSP build configuration is done via INI-style configuration files. The configuration files are consumed by the ./waf configure
command. By default, the file config.ini
is used. You can specify other configuration files with the --rtems-config
command line option. The configuration files consist of sections and options (key-value pairs).
To build a particular BSP, you have to create a section with the BSP variant name.
[sparc/erc32]
This one line configuration file is sufficient to build the base BSP sparc/erc32 with default values for all options. The base BSPs are determined by the build specification. The ./waf bsplist
command lists all base BSPs. You can create your own BSP names. However, in this case you have to inherit from a base BSP. The inheritance works only within an architecture, e.g. a riscv BSP cannot inherit options from an arm BSP.
[sparc/foobar]
INHERIT = erc32
The inheritance works recursively and must end up in a base BSP.
[sparc/foo]
INHERIT = erc32
[sparc/bar]
INHERIT = foo
A child BSP variant inherits all options from the parent BSP variant. The child BSP can override the inherited options.
You can determine the compiler used to build the BSP with the COMPILER
option.
[sparc/gr740_gcc]
INHERIT = gr740
COMPILER = gcc
[sparc/gr740_clang]
INHERIT = gr740
COMPILER = clang
Use the ./waf bspdefaults
command to get a list of all configuration options with default values.
$ ./waf bspdefaults --rtems-bsps=sparc/erc32
[sparc/erc32]
# Flags passed to the library archiver
ARFLAGS = crD
# Warning flags passed to the C compiler
CC_WARNING_FLAGS = -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs
# Warning flags passed to the C++ compiler
CXX_WARNING_FLAGS =
# Flags passed to the linker (GNU ld)
LDFLAGS = -Wl,--gc-sections
# Enable the Ada support
__RTEMS_ADA__ = False
# Enable the RTEMS internal debug support
RTEMS_DEBUG = False
...
# Install the legacy application Makefile framework.
INSTALL_LEGACY_MAKEFILES = True
It is not recommended to blindly add all the options obtained through the ./waf bspdefaults
command to custom configuration files. The specified options should be kept at the necessary minimum to get the desired build.
Some projects may still want to specify all options in a configuration file to be independent of changes in the base BSP. You can review differences between the user and base BSP values with the diff
command.
$ ./waf bspdefaults --rtems-bsps=sparc/erc32 > config.ini
$ sed -i 's/BUILD_TESTS = False/BUILD_TESTS = True/' config.ini
$ ./waf bspdefaults --rtems-bsps=sparc/erc32 | diff -u - config.ini
--- config.ini 2019-12-04 08:21:36.049335872 +0100
+++ - 2019-12-04 08:21:41.187432405 +0100
@@ -31,7 +31,7 @@
# Build the Ada test programs (may be also enabled by BUILD_TESTS)
BUILD_ADATESTS = False
# Build the test programs
-BUILD_TESTS = False
+BUILD_TESTS = True
# Build the benchmark programs (may be also enabled by BUILD_TESTS)
BUILD_BENCHMARKS = False
# Build the file system test programs (may be also enabled by
There is a special section DEFAULT
which can be used to specify default values for all other sections of the configuration file. In the following example configuration file, building of the tests is enabled for the sparc/erc32 and the riscv/griscv BSP.
[DEFAULT]
BUILD_TESTS = True
[sparc/erc32]
[riscv/griscv]
7.5. Migration from Autoconf/Automake¶
The Autoconf/Automake based build system used a configure
command to configure a single target architecture and one or more BSPs. The make
command was used to build it. The configure
command is replaced by a ./waf configure
invocation with configuration file. The make
command is replaced by ./waf
and make install
is replaced by ./waf install
.
Here are some hints for how a configure command line can be converted to options in the configuration file of the waf
based build system. BSP options given at the configure command line have to be added to the BSP section in the configuration file.
--target=${arch}-rtems6
--enable-rtembsp=${bsp}
To build a BSP add
[${arch}/${bsp}]
to the configuration file.--enable-ada
|--disable-ada
Set
__RTEMS_ADA__
toTrue
orFalse
in the BSP section of the configuration file.--enable-multiprocessing
|--disable-multiprocessing
Set
RTEMS_MULTIPROCESSING
toTrue
orFalse
in the BSP section of the configuration file.--enable-paravirt
|--disable-paravirt
Set
RTEMS_PARAVIRT
toTrue
orFalse
in the BSP section of the configuration file.--enable-profiling
|--disable-profiling
Set
RTEMS_PROFILING
toTrue
orFalse
in the BSP section of the configuration file.--enable-posix
|--disable-posix
Set
RTEMS_POSIX_API
toTrue
orFalse
in the BSP section of the configuration file.--enable-rtems-debug
|--disable-rtems-debug
Set
RTEMS_DEBUG
toTrue
orFalse
in the BSP section of the configuration file.--enable-smp
|--disable-smp
Set
RTEMS_SMP
toTrue
orFalse
in the BSP section of the configuration file.--enable-tests
|--disable-tests
Set
BUILD_TESTS
toTrue
orFalse
in the BSP section of the configuration file.--enable-tests=samples
Set
BUILD_SAMPLES
toTrue
orFalse
in the BSP section of the configuration file.
Please have a look at the following example configuration file.
# --target=sparc-rtems6 --enable-rtemsbsp=erc32
[sparc/erc32]
# --enable-ada
__RTEMS_ADA__ = True
# --enable-multiprocessing
RTEMS_MULTIPROCESSING = False
# --disable-paravirt
RTEMS_PARAVIRT = False
# --enable-profiling
RTEMS_PROFILING = True
# --disable-posix
RTEMS_POSIX_API = False
# --enable-rtems-debug
RTEMS_DEBUG = True
# --disable-smp
RTEMS_SMP = False
# --enable-tests
BUILD_TESTS = True
# BSP_POWER_DOWN_AT_FATAL_HALT=
BSP_POWER_DOWN_AT_FATAL_HALT = False
8. Board Support Packages¶
A Board Support Package or BSP is the software that glues a specific target or board or piece of hardware to RTEMS so it’s services are available to applications.
RTEMS contains a large number of BSPs for commonly available simulators and target hardware.
You can see the current BSP list in the RTEMS sources by asking RTEMS with:
$ ./rtems-bsps
8.1. aarch64 (AArch64)¶
8.1.1. Qemu A53¶
This BSP supports two variants, qemu_a53_ilp32 and qemu_a53_lp64. The basic hardware initialization is performed by the BSP. These BSPs support the GICv3 interrupt controller.
8.1.1.1. Boot via ELF¶
The executable image is booted by Qemu in ELF format.
8.1.1.2. Clock Driver¶
The clock driver uses the ARM Generic Timer.
8.1.1.3. Console Driver¶
The console driver supports the default Qemu emulated ARM PL011 PrimeCell UART.
8.1.1.4. Running Executables¶
Executables generated by these BSPs can be run using the following command:
qemu-system-aarch64 -no-reboot -nographic -serial mon:stdio \
-machine virt,gic-version=3 -cpu cortex-a53 -m 4096 -kernel example.exe
8.1.2. Qemu A72¶
This BSP supports two variants, qemu_a72_ilp32 and qemu_a72_lp64. The basic hardware initialization is performed by the BSP. These BSPs support the GICv3 interrupt controller.
8.1.2.1. Boot via ELF¶
The executable image is booted by Qemu in ELF format.
8.1.2.2. Clock Driver¶
The clock driver uses the ARM Generic Timer.
8.1.2.3. Console Driver¶
The console driver supports the default Qemu emulated ARM PL011 PrimeCell UART.
8.1.2.4. Running Executables¶
Executables generated by these BSPs can be run using the following command:
- qemu-system-aarch64 -no-reboot -nographic -serial mon:stdio
-machine virt,gic-version=3 -cpu cortex-a72 -m 4096 -kernel example.exe
8.1.3. Qemu Xilinx Versal¶
This BSP supports three variants: versal-qemu, versal-aiedge and versal-vck190. The basic hardware initialization is performed by the BSP. These BSPs support the GICv3 interrupt controller present in the Xilinx Versal Adaptive Compute Acceleration Platform (ACAP) systems. The BSPs currently only work when started in the secure mode.
8.1.3.1. Boot via ELF¶
The executable image is booted by Qemu in ELF format.
8.1.3.2. Clock Driver¶
The clock driver uses the ARM Generic Timer.
8.1.3.3. Console Driver¶
The console driver supports the default Qemu emulated ARM PL011 PrimeCell UART. There are some differences between the PL011 and the UART used by actual Versal ACAP hardware systems.
8.1.3.4. Running Executables¶
Executables generated by these BSPs can be run using the following command:
- qemu-system-aarch64 -no-reboot -nographic -serial mon:stdio
-machine xlnx-versal-virt -m 4096 -kernel example.exe
8.1.4. Xilinx ZynqMP¶
This BSP family supports the following variants:
zynqmp_qemu_ilp32
zynqmp_qemu
zynqmp_apu_ilp32
zynqmp_apu
zynqmp_cfc400x
Platform-specific hardware initialization is performed by ARM Trusted Firmware (ATF). Other basic hardware initialization is performed by the BSP. These BSPs support the GICv2 interrupt controller present in all ZynqMP systems. The zynqmp_apu BSP has been tested on zu2cg, zu3eg, and zu9cg chip variants and should also work on any other ZynqMP chip variant since the Processing Subsystem (PS) does not vary among chip variants other than the number of CPU cores available.
This BSP family has been tested on the following hardware:
Avnet UltraZed-EG SOM
Innoflight CFC-400X
Trenz TE0802
Xilinx ZCU102
8.1.4.1. Boot on QEMU¶
The executable image is booted by Qemu in ELF format.
8.1.4.2. Boot on ZynqMP Hardware¶
On ZynqMP hardware, RTEMS can be started at EL1, EL2, or EL3 by u-boot or directly as part of BOOT.bin. Regardless of the exception level at boot, RTEMS will drop to EL1 for execution. For quick turnaround during testing, it is recommended to use the u-boot BOOT.bin that comes with the PetaLinux prebuilts for the board in question.
Some systems such as the CFC-400X may require a bitstream to be loaded into the FPGA portion of the chip to operate as expected. This bitstream must be loaded before RTEMS begins operation since accesses to programmable logic (PL) memory space can cause the CPU to hang if the FPGA is not initialized. This can be performed as part of BOOT.bin or by a bootloader such as u-boot. Loading bitstreams from RTEMS has not been tested on the ZynqMP platform and requires additional libraries from Xilinx.
8.1.4.3. Hardware Boot Image Generation¶
RTEMS expects some hardware initialization to be performed by ATF and expects the services it provides to be present, so this must be included when generating a direct-boot RTEMS BOOT.bin.
When booting via u-boot, RTEMS must be packaged into a u-boot image or booted as a raw binary since u-boot does not currently support ELF64 which is required for AArch64 ELF binaries.
8.1.4.4. Example: Booting a RTEMS image on the ZCU102 ZynqMP board¶
This example will walk through the steps needed for booting RTEMS from a SD card on the ZCU102 ZynqMP board. The reference for setting up a SD card and obtaining pre-built boot images is here.
8.1.4.4.1. Hardware Setup¶
Set the dip switch SW6 according to the table below. This will allow the board to boot from the SD card. Connect a Micro-USB cable to the USB UART interface J83. This is a quad USB UART interface which will show up on the development host computer as four different serial or tty devices. Use the first channel for the console UART. It should be set to 115k baud.
Dip Switch JW6 | |||
ON | OFF | OFF | OFF |
8.1.4.4.2. Prepare a SD card with a bootable partition¶
The goal is to have a bootable SD card with a partition that is formatted with the FAT file system. The file system will contain the boot artifacts including BOOT.bin and the u-boot image. The RTEMS image will be placed on this volume. To create the bootable SD card, follow the directions here.
Once you have the card formatted correctly, you need to place the files from this archive on the FAT partition. The following file was used for this example: xilinx-vck190-v2021.2-final.bsp
In order to download these files, you need to have a Xilinx account login. As an alternative, you can download a bootable image for Ubuntu 20.04 and write it to an SD card using a utility such as Balena Etcher or dd. The Ubuntu image is available here. Download the image for the Zynq Ultrascale+ MPSoC Development boards, uncompress it and write it to the SD card. This image creates multiple partitions, but we only need to use the FAT partition with the boot artifacts on it.
8.1.4.4.3. Verify that the board can boot from the SD card¶
It is worth booting the board from the SD card before trying to boot RTEMS. Insert the card and power on the board. You should see the messages on the first console indicating the various boot loader stages and eventually the Linux kernel. The goal is to interrupt u-boot when given the chance to access the u-boot command prompt.
8.1.4.4.4. Build RTEMS with examples¶
Build the RTEMS zynqmp_apu BSP. Use the ticker.exe sample which can be found in the directory:
build/aarch64/zynqmp_apu/testsuites/samples
8.1.4.4.5. Prepare the RTEMS image¶
Prepare your RTEMS image to boot from u-boot with the following commands:
$ aarch64-rtems@rtems-ver-major@-objcopy -Obinary ticker.exe ticker.bin
$ gzip -9 ticker.bin
$ mkimage -A arm64 -O rtems -T kernel -a 0x10000 -e 0x10000 -n RTEMS -d ticker.bin.gz rtems.img
Note: If the start address has been changed in the BSP configuration, you have to adapt the -a and -e parameters accordingly. To find out the start address of an application, aarch64-rtems6-nm ticker.exe | grep _start can be used. That will show the address of the _start symbol which is the value that has to be used for the two parameters.
8.1.4.4.6. Boot the RTEMS image¶
Copy the prepared RTEMS image to the SD card and insert the SD crd in the ZCU102 board. Power on the board. When you see the prompt on the console to interupt u-boot, hit a key to bring up the u-boot command prompt. On the u-boot command prompt you can boot your RTEMS image:
Zynq-MP> fatload mmc 0:1 0x1000 rtems.img
Zynq-MP> bootm 0x1000
This is the entire boot sequence:
Pre-FSBL boot Started
Xilinx Zynq MP First Stage Boot Loader
Release 2020.2 Nov 18 2020 - 11:46:01
NOTICE: ATF running on XCZU9EG/silicon v1/RTL5.1 at 0xfffea000
NOTICE: BL31: v2.2(release):xilinx_rebase_v2.2_2020.1-10-ge6eea88b1
NOTICE: BL31: Built : 12:28:45, Nov 17 2020
U-Boot 2020.01 (Jun 15 2021 - 14:24:32 +0000)
Model: ZynqMP ZCU102 Rev1.0
Board: Xilinx ZynqMP
DRAM: 4 GiB
PMUFW: v1.1
EL Level: EL2
Chip ID: zu9eg
NAND: 0 MiB
MMC: mmc@ff170000: 0
In: serial@ff000000
Out: serial@ff000000
Err: serial@ff000000
Bootmode: SD_MODE1
Reset reason: SOFT
Net:
ZYNQ GEM: ff0e0000, mdio bus ff0e0000, phyaddr 12, interface rgmii-id
Warning: ethernet@ff0e0000 (eth0) using random MAC address - 82:32:1d:80:d9:c9
eth0: ethernet@ff0e0000
Hit any key to stop autoboot: 0
ZynqMP> fatload mmc 0:1 0x1000 rtems.img
46669 bytes read in 27 ms (1.6 MiB/s)
ZynqMP> bootm 0x1000
## Booting kernel from Legacy Image at 00001000 ...
Image Name: RTEMS
Image Type: AArch64 RTEMS Kernel Image (gzip compressed)
Data Size: 46605 Bytes = 45.5 KiB
Load Address: 10000000
Entry Point: 10000000
Verifying Checksum ... OK
Uncompressing Kernel Image
## Transferring control to RTEMS (at address 10000000) ...
*** BEGIN OF TEST CLOCK TICK ***
*** TEST VERSION: @rtems-version@.f381e9bab29278e4434b1a93e70d17a7562dc64c
*** TEST STATE: EXPECTED_PASS
*** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP
*** TEST TOOLS: 10.3.1 20210409 (RTEMS 6, RSB ad54d1dd3cf8249d9d39deb1dd28b2f294df062d, Newlib eb03ac1)
TA1 - rtems_clock_get_tod - 09:00:00 12/31/1988
TA2 - rtems_clock_get_tod - 09:00:00 12/31/1988
TA3 - rtems_clock_get_tod - 09:00:00 12/31/1988
TA1 - rtems_clock_get_tod - 09:00:05 12/31/1988
TA2 - rtems_clock_get_tod - 09:00:10 12/31/1988
TA1 - rtems_clock_get_tod -