RTEMS User Manual (5.c5749d0-modified).¶
Copyrights and License
This document is available under the Creative Commons Attribution-ShareAlike 4.0 International Public License.
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.
RTEMS Online Resources
Home | https://www.rtems.org |
Documentation | https://docs.rtems.org |
Mailing Lists | https://lists.rtems.org |
Bug Reporting | https://devel.rtems.org/wiki/Developer/Bug_Reporting |
Git Repositories | https://git.rtems.org |
Developers | https://devel.rtems.org |
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.
[1] | The goal is to use the BSD 2-Clause license for new code or code those copyright holder agreed to a license change, see #3053 for the details. |
[2] | See #2832. |
[3] | Thread-local storage requires some support by the tool chain and the RTEMS architecture support, e.g. context-switch code. It is supported at least on ARM, PowerPC, RISC-V, SPARC and m68k. Check the RTEMS CPU Architecture Supplement if it is supported. |
2. Quick Start¶
Follow the sections of this chapter step by step to get started developing applications on top of RTEMS.
2.1. Prepare Your Host Computer¶
The host computer is a computer you use to develop applications. It runs all your tools, editors, documentation viewers, etc. To get started with RTEMS development you need tools from your host’s operating system to build the RTEMS tool suite from source. This is not a one-click installation process, but there are good reasons to build everything from source. You need a native C, C++ and Python development environment. Please make sure that you can build native C/C++ applications on your host computer. You must be able to build native Python C modules. Usually, you have to install a Python development package for this. Please have a look at the Host Computer chapter for the gory details. In particular Microsoft Windows user should do this.
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 them all as a stack with a single prefix or you can
The RTEMS tool suite consists of a cross tool chain (Binutils, GCC, GDB, Newlib, etc.) for your target architecture and other tools provided by the RTEMS Project. The RTEMS
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
plus the RTEMS version, e.g. /opt/rtems/5
on Linux and /usr/local/rtems/5
on FreeBSD and macOS.
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/5
or with a project-specific component $HOME/project-x/rtems/5
. For more ideas, see the project sandboxing section. In this quick start chapter, we will choose $HOME/quick-start/rtems/5
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/5
as the installation prefix.
You need at least two source archives or Git repositories to work with RTEMS. You can download the source archives for a released RTEMS version or you can clone Git repositories to get all versions of RTEMS including the development head.
We will clone the Git repositories into $HOME/quick-start/src
.
mkdir -p $HOME/quick-start/src
cd $HOME/quick-start/src
git clone git://git.rtems.org/rtems-source-builder.git rsb
git clone git://git.rtems.org/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.
Alternatively, you can download the source archives of a released RTEMS version.
mkdir -p $HOME/quick-start/src
cd $HOME/quick-start/src
curl https://ftp.rtems.org/pub/rtems/releases/4.11/4.11.3/rtems-4.11.3.tar.xz | tar xJf -
curl https://ftp.rtems.org/pub/rtems/releases/4.11/4.11.3/rtems-source-builder-4.11.3.tar.xz | tar xJf -
This quick start chapter focuses on working with the Git repository clones since this gives you some flexibility. You can switch between branches to try out different RTEMS versions. 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. If you prefer to work with archives of a released RTEMS version, then simply replace the version number 5 used throughout this chapter with the version number you selected, e.g. 4.11.
2.4. Install the Tool Suite¶
You have chosen an installation prefix and cloned two RTEMS repositories in the previous sections. We have chosen $HOME/quick-start/rtems/5
as the installation prefix and cloned the repositories in $HOME/quick-start/src
.
You must select the target architecture for which you need a tool suite. In this quick start chapter we choose sparc-rtems5. The sparc-rtems5 is the tool suite name for the SPARC architecture and RTEMS version 5. The tool suite for RTEMS and the RTEMS sources are tightly coupled. For example, do not use a RTEMS version 5 tool suite with RTEMS version 4.11 sources and vice versa. We use the RSB in two steps. The first step is to download additional sources and patches. Afterwards, you could disconnect your host computer from the internet. It is no longer required to work with RTEMS.
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --source-only-download 5/rtems-sparc
This command should output something like this (omitted lines are denoted by …):
RTEMS Source Builder - Set Builder, 5 (98588a55961a)
warning: exe: absolute exe found in path: (__unzip) /usr/local/bin/unzip
Build Set: 5/rtems-sparc
...
download: https://ftp.gnu.org/gnu/gcc/gcc-7.4.0/gcc-7.4.0.tar.xz -> sources/gcc-7.4.0.tar.xz
...
Build Sizes: usage: 0.000B total: 141.738MB (sources: 141.559MB, patches: 183.888KB, installed 0.000B)
Build Set: Time 0:01:17.613061
If you encounter errors in the first step, check your internet connection, firewall settings, virus scanners and the availability of the download servers. The seconds step is to build and install the tool suite.
cd $HOME/quick-start/src/rsb/rtems
../source-builder/sb-set-builder --prefix=$HOME/quick-start/rtems/5 5/rtems-sparc
This command should output something like this (omitted lines are denoted by …):
RTEMS Source Builder - Set Builder, 5 (98588a55961a)
warning: exe: absolute exe found in path: (__unzip) /usr/local/bin/unzip
Build Set: 5/rtems-sparc
...
config: tools/rtems-gcc-7.4.0-newlib-3e24fbf6f.cfg
package: sparc-rtems5-gcc-7.4.0-newlib-3e24fbf6f-x86_64-freebsd12.0-1
building: sparc-rtems5-gcc-7.4.0-newlib-3e24fbf6f-x86_64-freebsd12.0-1
sizes: sparc-rtems5-gcc-7.4.0-newlib-3e24fbf6f-x86_64-freebsd12.0-1: 4.651GB (installed: 879.191MB)
cleaning: sparc-rtems5-gcc-7.4.0-newlib-3e24fbf6f-x86_64-freebsd12.0-1
....
Build Sizes: usage: 5.618GB total: 1.105GB (sources: 141.559MB, patches: 185.823KB, installed 989.908MB)
Build Set: Time 0:22:02.262039
In case the seconds step was successful, you can check if for example the cross C compiler works with the following command:
$HOME/quick-start/rtems/5/bin/sparc-rtems5-gcc --version --verbose
This command should output something like below. In this output the actual prefix path was replaced by $PREFIX
. The compiled by
line depends on the native C++ compiler of your host computer. In the output you see the Git hash of the RSB. This helps you to identify the exact sources which were used to build the cross compiler of your RTEMS tool suite.
Using built-in specs.
COLLECT_GCC=$PREFIX/bin/sparc-rtems5-gcc
COLLECT_LTO_WRAPPER=$PREFIX/bin/../libexec/gcc/sparc-rtems5/7.4.0/lto-wrapper
sparc-rtems5-gcc (GCC) 7.4.0 20181206 (RTEMS 5, RSB 98588a55961a92f5d27bfd756dfc9e31b2b1bf98, Newlib 3e24fbf6f)
Copyright (C) 2017 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.
Target: sparc-rtems5
Configured with: ../gcc-7.4.0/configure --prefix=$PREFIX --bindir=$PREFIX/bin --exec_prefix=$PREFIX --includedir=$PREFIX/include --libdir=$PREFIX/lib --libexecdir=$PREFIX/libexec --mandir=$PREFIX/share/man --infodir=$PREFIX/share/info --datadir=$PREFIX/share --build=x86_64-freebsd12.0 --host=x86_64-freebsd12.0 --target=sparc-rtems5 --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --verbose --with-newlib --disable-nls --without-included-gettext --disable-win32-registry --enable-version-specific-runtime-libs --disable-lto --enable-newlib-io-c99-formats --enable-newlib-iconv --enable-newlib-iconv-encodings=big5,cp775,cp850,cp852,cp855,cp866,euc_jp,euc_kr,euc_tw,iso_8859_1,iso_8859_10,iso_8859_11,iso_8859_13,iso_8859_14,iso_8859_15,iso_8859_2,iso_8859_3,iso_8859_4,iso_8859_5,iso_8859_6,iso_8859_7,iso_8859_8,iso_8859_9,iso_ir_111,koi8_r,koi8_ru,koi8_u,koi8_uni,ucs_2,ucs_2_internal,ucs_2be,ucs_2le,ucs_4,ucs_4_internal,ucs_4be,ucs_4le,us_ascii,utf_16,utf_16be,utf_16le,utf_8,win_1250,win_1251,win_1252,win_1253,win_1254,win_1255,win_1256,win_1257,win_1258 --enable-threads --disable-plugin --enable-libgomp --enable-languages=c,c++
Thread model: rtems
gcc version 7.4.0 20181206 (RTEMS 5, RSB 98588a55961a92f5d27bfd756dfc9e31b2b1bf98, Newlib 3e24fbf6f) (GCC)
COLLECT_GCC_OPTIONS='--version' '-v' '-mcpu=v7'
$PREFIX/bin/../libexec/gcc/sparc-rtems5/7.4.0/cc1 -quiet -v -iprefix $PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/ help-dummy -quiet -dumpbase help-dummy -mcpu=v7 -auxbase help-dummy -version --version -o /tmp//ccuAN1wc.s
GNU C11 (GCC) version 7.4.0 20181206 (RTEMS 5, RSB 98588a55961a92f5d27bfd756dfc9e31b2b1bf98, Newlib 3e24fbf6f) (sparc-rtems5)
compiled by GNU C version 4.2.1 Compatible FreeBSD Clang 6.0.1 (tags/RELEASE_601/final 335540), GMP version 6.1.0, MPFR version 3.1.4, MPC version 1.0.3, isl version isl-0.16.1-GMP
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
COLLECT_GCC_OPTIONS='--version' '-v' '-mcpu=v7'
$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/../../../../sparc-rtems5/bin/as -v -s --version -o /tmp//ccFVgRAa.o /tmp//ccuAN1wc.s
GNU assembler version 2.32 (sparc-rtems5) using BFD version (GNU Binutils) 2.32
GNU assembler (GNU Binutils) 2.32
Copyright (C) 2019 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or later.
This program has absolutely no warranty.
This assembler was configured for a target of `sparc-rtems5'.
COMPILER_PATH=$PREFIX/bin/../libexec/gcc/sparc-rtems5/7.4.0/:$PREFIX/bin/../libexec/gcc/:$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/../../../../sparc-rtems5/bin/
LIBRARY_PATH=$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/:$PREFIX/bin/../lib/gcc/:$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/../../../../sparc-rtems5/lib/
COLLECT_GCC_OPTIONS='--version' '-v' '-mcpu=v7'
$PREFIX/bin/../libexec/gcc/sparc-rtems5/7.4.0/collect2 --version $PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/../../../../sparc-rtems5/lib/crt0.o -L$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0 -L$PREFIX/bin/../lib/gcc -L$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/../../../../sparc-rtems5/lib /tmp//ccFVgRAa.o -lgcc -lc -lgcc
collect2 version 7.4.0 20181206 (RTEMS 5, RSB 98588a55961a92f5d27bfd756dfc9e31b2b1bf98, Newlib 3e24fbf6f)
$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/../../../../sparc-rtems5/bin/ld --version $PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/../../../../sparc-rtems5/lib/crt0.o -L$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0 -L$PREFIX/bin/../lib/gcc -L$PREFIX/bin/../lib/gcc/sparc-rtems5/7.4.0/../../../../sparc-rtems5/lib /tmp//ccFVgRAa.o -lgcc -lc -lgcc
GNU ld (GNU Binutils) 2.32
Copyright (C) 2019 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
COLLECT_GCC_OPTIONS='--version' '-v' '-mcpu=v7'
2.5. Bootstrap the RTEMS Sources¶
You installed the tool suite in your installation prefix and cloned two RTEMS repositories in the previous sections. We installed the tool suite in $HOME/quick-start/rtems/5
and cloned the repositories in $HOME/quick-start/src
.
If you use source archives of a released RTEMS version, then you can skip this section.
Before you can build a Board Support Package (BSP) for your target hardware, you have to bootstrap the build system in the RTEMS sources. This is only necessary, if you use a Git repository clone of the RTEMS sources. You have to do this after a fresh repository clone and sometimes after build system file updates (e.g. after a git pull
). If you are not a build system expert, then do the bootstrap after each update of build system files. This is a bit annoying, but improving the build system is a complex and time consuming undertaking. Feel free to help the RTEMS Project to improve it. For the bootstrap it is important that the right version of Autotools (autoconf
and automake
) are in your $PATH
. The right version of Autotools is shipped with the RTEMS tool suite you already installed.
cd $HOME/quick-start/src/rtems
export PATH=$HOME/quick-start/rtems/5/bin:"$PATH"
./bootstrap -c
$HOME/quick-start/src/rsb/source-builder/sb-bootstrap
These commands should output something like this (omitted lines are denoted by …):
removing automake generated Makefile.in files
removing configure files
removing aclocal.m4 files
$ $HOME/quick-start/src/rsb/source-builder/sb-bootstrap
RTEMS Source Builder - RTEMS Bootstrap, 5 (f07504d27192)
1/120: autoreconf: configure.ac
2/120: autoreconf: c/configure.ac
3/120: autoreconf: c/src/configure.ac
4/120: autoreconf: c/src/lib/libbsp/arm/configure.ac
...
120/120: autoreconf: testsuites/tmtests/configure.ac
Bootstrap time: 0:00:48.744222
2.6. Build a Board Support Package (BSP)¶
You installed the tool suite in your installation prefix, cloned two RTEMS repositories and bootstrapped the RTEMS sources in the previous sections. We installed the tool suite in $HOME/quick-start/rtems/5
and cloned the repositories in $HOME/quick-start/src
. We also bootstrapped the RTEMS sources.
You are now able to build Board Support Packages (BSPs) for all architectures where you have an RTEMS tool suite installed. To build applications on top of RTEMS, you have to configure, 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.
We configure, build and install the BSP in four steps. The first step is to create a build directory. It must be separate from the RTEMS source directory. We use $HOME/quick-start/build/b-erc32
.
mkdir -p $HOME/quick-start/build/b-erc32
The second step is to configure the BSP. There are various configuration options available. Some configuration options are BSP-specific. Prepend the RTEMS tool suite binary directory to your $PATH
throughout the remaining steps.
cd $HOME/quick-start/build/b-erc32
export PATH=$HOME/quick-start/rtems/5/bin:"$PATH"
$HOME/quick-start/src/rtems/configure \
--prefix=$HOME/quick-start/rtems/5 \
--enable-maintainer-mode \
--target=sparc-rtems5 \
--enable-rtemsbsp=erc32 \
--enable-tests
This command should output something like this (omitted lines are denoted by …):
checking for gmake... gmake
checking for RTEMS Version... 5.0.0
checking build system type... x86_64-unknown-freebsd12.0
checking host system type... x86_64-unknown-freebsd12.0
checking target system type... sparc-unknown-rtems5
...
config.status: creating Makefile
target architecture: sparc.
available BSPs: erc32.
'gmake all' will build the following BSPs: erc32.
other BSPs can be built with 'gmake RTEMS_BSP="bsp1 bsp2 ..."'
config.status: creating Makefile
Building the BSP is the third step.
cd $HOME/quick-start/build/b-erc32
make
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
.
Configuring RTEMS_BSP=erc32
checking for gmake... gmake
checking build system type... x86_64-unknown-freebsd12.0
checking host system type... sparc-unknown-rtems5
checking rtems target cpu... sparc
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for sparc-rtems5-strip... sparc-rtems5-strip
checking for a thread-safe mkdir -p... $BASE/src/rtems/c/src/../../install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... nawk
checking whether gmake sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking for RTEMS_BSP... erc32
checking whether CPU supports libposix... yes
configure: setting up make/custom
configure: creating make/erc32.cache
gmake[3]: Entering directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32'
...
sparc-rtems5-gcc -mcpu=cypress -O2 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -B./../../lib/libbsp/sparc/erc32 -B$BASE/src/rtems/bsps/sparc/erc32/start -specs bsp_specs -qrtems -L./../../cpukit -L$BASE/src/rtems/bsps/sparc/shared/start -Wl,--wrap=printf -Wl,--wrap=puts -Wl,--wrap=putchar -Wl,--gc-sections -o spwkspace.exe spwkspace/spwkspace-init.o ./../../lib/libbsp/sparc/erc32/librtemsbsp.a ./../../cpukit/librtemscpu.a
gmake[5]: Leaving directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32/testsuites/sptests'
gmake[4]: Leaving directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32/testsuites'
gmake[3]: Leaving directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32'
gmake[2]: Leaving directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32'
gmake[1]: Leaving directory '$BASE/build/b-erc32/sparc-rtems5/c'
gmake[1]: Entering directory '$BASE/build/b-erc32'
gmake[1]: Nothing to be done for 'all-am'.
gmake[1]: Leaving directory '$BASE/build/b-erc32'
The last step is to install the BSP.
cd $HOME/quick-start/build/b-erc32
make 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
.
Making install in sparc-rtems5/c
gmake[1]: Entering directory '$BASE/build/b-erc32/sparc-rtems5/c'
Making install in .
gmake[2]: Entering directory '$BASE/build/b-erc32/sparc-rtems5/c'
gmake[3]: Entering directory '$BASE/build/b-erc32/sparc-rtems5/c'
gmake[3]: Nothing to be done for 'install-exec-am'.
gmake[3]: Nothing to be done for 'install-data-am'.
gmake[3]: Leaving directory '$BASE/build/b-erc32/sparc-rtems5/c'
gmake[2]: Leaving directory '$BASE/build/b-erc32/sparc-rtems5/c'
Making install in erc32
gmake[2]: Entering directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32'
gmake[3]: Entering directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32'
Making install-am in .
Making install-am in cpukit
gmake[4]: Entering directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32/cpukit'
gmake[5]: Entering directory '$BASE/build/b-erc32/sparc-rtems5/c/erc32/cpukit'
gmake[5]: Nothing to be done for 'install-exec-am'.
$BASE/src/rtems/c/src/../../cpukit/../install-sh -c -d '$BASE/rtems/5/sparc-rtems5/erc32/lib/include'
...
$BASE/src/rtems/make/Templates/Makefile.lib '$BASE/rtems/5/share/rtems5/make/Templates'
$BASE/src/rtems/./install-sh -c -d '$BASE/rtems/5/make/custom'
/usr/bin/install -c -m 644 $BASE/src/rtems/make/custom/default.cfg '$BASE/rtems/5/make/custom'
gmake[2]: Leaving directory '$BASE/build/b-erc32'
gmake[1]: Leaving directory '$BASE/build/b-erc32'
2.7. Test a Board Support Package (BSP)¶
You built a BSP with tests in the previous section. We built the erc32
BSP in $HOME/quick-start/build/b-erc32
.
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 erc32
BSP we selected for this quick start chapter this is easy. Just run this command:
cd $HOME/quick-start/build/b-erc32
rtems-test --rtems-bsp=erc32 --rtems-tools=$HOME/quick-start/rtems/5 .
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, 5.0.not_released
Command Line: $BASE/rtems/5/bin/rtems-test --rtems-bsp=erc32 --rtems-tools=$BASE/rtems/5 .
Python: 2.7.15 (default, Jan 10 2019, 01:14:47) [GCC 4.2.1 Compatible FreeBSD Clang 6.0.1 (tags/RELEASE_601/final 335540)]
Host: FreeBSD-12.0-RELEASE-p2-amd64-64bit-ELF (FreeBSD Build_FreeBSD12 12.0-RELEASE-p2 FreeBSD 12.0-RELEASE-p2 GENERIC amd64 amd64)
[ 1/589] p:0 f:0 u:0 e:0 I:0 B:0 t:0 i:0 W:0 | sparc/erc32: dhrystone.exe
...
[589/589] p:574 f:0 u:5 e:0 I:0 B:3 t:0 i:0 W:0 | sparc/erc32: tmtimer01.exe
Passed: 580
Failed: 0
User Input: 5
Expected Fail: 0
Indeterminate: 0
Benchmark: 3
Timeout: 1
Invalid: 0
Wrong Version: 0
Wrong Build: 0
Wrong Tools: 0
------------------
Total: 589
User Input:
monitor.exe
termios.exe
top.exe
fileio.exe
capture.exe
Benchmark:
whetstone.exe
linpack.exe
dhrystone.exe
Timeouts:
pppd.exe
Average test time: 0:00:00.437773
Testing time : 0:04:17.848557
2.8. Build Your Application¶
TODO
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. IRC¶
RTEMS IRC is available on the Freenode network. See the Freenode web site for details on connecting, selecting a nickname, and general usage tips. If you are new to IRC it is recommended reading.
These is currently only one IRC channel available for RTEMS:
#rtems
This is a general channel for all things RTEMS. You can just hang out with other RTEMS users and developers to talk about RTEMS, using RTEMS or to make contact with other RTEMS users.
The #rtems
channel is logged. You can find the logs at:
You can search the logs using Google by adding
site:rtems.org inurl:irclogs
to your search terms.
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. 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. Good Bug Reports¶
Please open the page to submit a bug to the RTEMS Project ticket system and follow the guidelines below to write a good bug report.
- Provide a useful single line Summary.
- Use WikiFormatting 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.
- 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 master. If it is not reproducible on the Git master, 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 a Type for the ticket.
- Use
defect
for a bug. - Use
enhancement
for a feature request in the software or an addition to the documentation. - Note
infra
is used to report issues with the RTEMS servers at OSUOSL.
- Use
- Select a Version for the ticket. This should be the first RTEMS version which is affected by this bug. If this is the current Git master branch use the version of the next release. Please provide the exact version of RTEMS in the description. If you use an RTEMS release, then the release number. If you use a Git clone, then the commit hash. The commit hash should be present in an RTEMS Project repository. Commit hashes of private branches are not interesting.
- Select a Component for the ticket. Use
unspecified
if you are unsure. - Select a Severity for the ticket.
- The fields Milestone and Priority will be most likely set by an RTEMS maintainer.
- You can relate your new bug to existing bugs through the Blocked by and Blocking fields.
- If you have any external files, such as screenshots or examples, please attach these as files to the ticket. Do not use external hosting because if you do use external hosting, then our historical record is broken when those files are no longer available.
- 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 click on the Create ticket
button to submit it to the RTEMS Project ticket system.
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 the Developers Mailing List.
3.3.2. Preparing and Sending Patches¶
The RTEMS Project uses Git for version control. Git has a special command to prepare patches intended for mailing lists: git format-patch. Create logically connected patches as a patch series ideally accompanied by a cover letter (--cover-letter
option). You can send patches via email through a Git command: git send-email.
3.3.3. Checklist for Patches¶
Check the following items before you send a patch to the Developers Mailing List:
- The author name of the patch is your full name.
- The author email of the patch is your valid email address.
- 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 pregnant subject which does not exceed 50 characters in one line. Use a “topic: The pregnant subject” style. A topic could be the main component of patch. Just have a look at existing commit messages.
- The 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.
- The patch contains no spelling mistakes and grammar errors.
- The patch is easy to review. It changes one thing only and contains no unrelated changes. Format changes should be separated from functional changes.
- If the patch corresponds to a ticket, it should have “Close #X.” or “Update #X.” as the last line in the commit message to update status once it is committed to the repository.
- The patch builds. All RTEMS tests link with this patch.
- The patch does not introduce new compiler warnings.
- The patch does not introduce new test failures in existing tests.
3.3.4. Patch Review Process¶
Patches sent to the Developers Mailing List undergo a patch review process. Once a patch series is accepted for integration into the RTEMS code base it is committed by an RTEMS maintainer. The maintainers are usually quite busy with all sorts of stuff. If you do not get a response to a patch series submission to the mailing list after five work days, please send a reminder. It helps if you follow the Checklist for Patches. An easy to review patch series which meets the quality standards of the RTEMS Project will be more likely get integrated quickly.
3.3.5. 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 Users 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 an RTEMS maintainer 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.6. 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, and it is, 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 is built all your time can be spent writing and developing your application. Over an hour can happen and for the ARM architecture and with all BSPs it can be many hours.
4.1. Host Operating Systems¶
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/4.11
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/4.11/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/4.11
Branches are available for the 4.9, 4.10, and 4.11 versions of RTEMS.
4.2. 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.2.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.2.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.2.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.2.2.2. CentOS¶
The following packages are required on a minimal CentOS 6.3 64bit installation:
# yum install autoconf automake binutils gcc gcc-c++ gdb make patch \
bison flex xz unzip ncurses-devel texinfo zlib-devel python-devel git
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.2.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.2.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.2.2.5. Ubuntu¶
The latest version is Ubuntu 18.04.1 LTS 64-bit. This section also includes Xubuntu. A minimal installation was used and the following packages installed:
$ sudo apt-get build-dep gcc-defaults g++ gdb git unzip pax bison \
flex libpython-dev git libncurses5-dev zlib1g-dev
Note that in previous versions of Ubuntu, the package libpython-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-dev
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.2.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.2.2.7. openSUSE¶
This has been reported to work but no instructions were provided. This is an opportunity to contribute. Please submit any guidance you can provide.
4.2.3. FreeBSD¶
The RTEMS Source Builder has been tested on FreeBSD 9.1, 10.3, 11 and 12 64bit version. You need to install some ports. They are:
# cd /usr/ports
# portinstall --batch lang/python27
If you wish to build Windows (mingw32) tools please install the following ports:
# cd /usr/ports
# portinstall --batch devel/mingw32-binutils devel/mingw32-gcc
# portinstall --batch devel/mingw32-zlib devel/mingw32-pthreads
The +zlip+ and +pthreads+ ports for MinGW32 are used for builiding a Windows QEMU.
If you are on FreeBSD 10.0 and you have pkgng installed you can use ‘pkg install’ rather than ‘portinstall’.
We recommend you run as root the following command to speed up Python 3’s subprocess support:
# mount -t fdescfs none /dev/fd
This speeds up closing file descriptors when creating subprocesses.
4.2.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.3. Apple MacOS¶
Apple’s OS X is fully supported. You need to download and install a recent version of the Apple developer application Xcode. Xocde 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 OS X 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.
4.3.1. 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.3.2. Sierra¶
The RSB works on Sierra with the latest Xcode.
4.4. 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.4.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 Releases.
4.4.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.4.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.4.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.4.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.4.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.
Open a 64bit MSYS shell from the Start Menu:
The packages we require are:
- python
- mingw-w64-x86_64-python2
- mingw-w64-x86_64-gcc
- 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-python2 mingw-w64-x86_64-gcc \
bison cvs diffutils git make patch tar texinfo unzip
resolving dependencies...
looking for conflicting packages...
.... output shortened for brevity ....
4.4.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/4.10 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/4.10
installing: arm-rtems4.10-binutils-2.20.1-1 -> /cygdrive/c/Users/chris/development/rtems/4.10 <3>
installing: arm-rtems4.10-gcc-4.4.7-newlib-1.18.0-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
installing: arm-rtems4.10-gdb-7.3.1-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
installing: arm-rtems4.10-kernel-4.10.2-1 -> /cygdrive/c/Users/chris/development/rtems/4.10
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. Installation¶
This section details how to set up and install the RTEMS Ecosystem. You will create a set of tools and an RTEMS kernel for your selected Board Support Package (BSP).
You will be asked to follow a few simple steps and when you have finished you will have a development environment set up you can use to build applications for RTEMS. You will have also created a development environment you and a team can adapt for a project of any size and complexity.
RTEMS applications are developed using cross-development tools running on a development computer, more commonlly referred to as 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 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.
The RTEMS Project base installation set ups 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.
The RTEMS Project supports two set ups, release and developer environments. Release installations create the tools and kernel in a single pass ready for you to use. The tools and kernel are stable and only bug fixes are added creating new dot point releases. The developer set up tracks the Git repositories for the tools and kernel.
5.1. Releases¶
RTEMS releases provide a stable version of the kernel for the supported architectures. RTEMS maintaines the current and previous releases. Support for older releases is provided using the RTEMS support channels.
Please read Host Computer before continuing. The following procedure assumes you have installed and configured your host operating. It also assumes you have installed any dependent packages needed when building the tools and the kernel.
You need to select a location to build and install the RTEMS Tool chain and RTEMS. Make sure there is plenty of disk space and a fast disk is recommended. Our procedure will document building and installing the tools in a base directory called /opt/rtems
. This path will require root access. If you are working on a machine you do not have root access to you can use a home directory, If building on Windows use /c/opt/rtems
to keep the top level paths as short as possible. Windows Path Length provides more detail about path lengths on Windows.
The location used to install the tools and kernel is called the prefix. Choose an Installation Prefix explains prefixes and how to use them. It is best to have a prefix for each different version of RTEMS you are using. If you are using RTEMS 4.11 in production it is not a good idea to install a development version of 5 over the top by using the same prefix as the 4.11 build. A separate prefix for each version avoids this.
Released versions of the RTEMS Source Builder (RSB) downloads all source code for all packages from the FTP File Server rather than from the package’s home site. Hosting all the source on the FTP File Server ensures the source is present for the life of the release on the FTP File Server. If there is a problem accessing the RTEMS FTP the RSB will fall back to the packages home site.
The FTP File Server is hosted at the Oregon State University’s The Open Source Lab (http://osuosl.org/). This is a nonprofit organization working for the advancement of open source technologies and RTEMS is very fortunate to be shosted here. It has excellent internet access and performance.
Note
Controlling the RTEMS Kernel Build
Building releases by default does not build the RTEMS kernel. To build the RTEMS kernel add the --with-rtems
option to the RSB command line.
By default all the BSPs for an architecture are built. If you only wish to have a specific BSP built you can specify the BSP list by providing to the RSB the option --with-rtemsbsp
. For example to build two BSPs for the SPARC architecture you can supply --with-rtemsbsp="erc32 leon3"
. This can speed the build time up for some architectures that have a lot of BSPs.
Once you have built the tools and kernel you can move to the Packages section of the manual.
5.1.1. RTEMS Tools and Kernel¶
This procedure will build a SPARC tool chain. Set up a suitable workspace to build the release in. On Unix:
$ cd
$ mkdir -p development/rtems/releases
$ cd development/rtems/releases
If building on Windows:
$ cd /c
$ mkdir -p opt/rtems
$ cd opt/rtems
Note the paths on Windows will be different to those shown.
Download the RTEMS Source Builder (RSB) from the RTEMS FTP server:
$ wget https://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/rtems-source-builder-4.11.0.tar.xz
--2016-03-21 10:50:04-- https://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/rtems-source-builder-4.11.0.tar.xz
Resolving ftp.rtems.org (ftp.rtems.org)... 140.211.10.151
Connecting to ftp.rtems.org (ftp.rtems.org)|140.211.10.151|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 967056 (944K) [application/x-xz]
Saving to: 'rtems-source-builder-4.11.0.tar.xz'
rtems-source-builder-4.1 100%[====================================>] 944.39K 206KB/s in 5.5s
2016-03-21 10:50:11 (173 KB/s) - 'rtems-source-builder-4.11.0.tar.xz' saved [967056/967056]
On Unix unpack the RSB release tar file using:
$ tar Jxf rtems-source-builder-4.11.0.tar.xz
$ cd rtems-source-builder-4.11.0/rtems/
On Windows you need to shorten the path (See Windows Path Length) after you have unpacked the tar file:
$ tar Jxf rtems-source-builder-4.11.0.tar.xz
$ mv rtems-source-builder-4.11.0 4.110
$ cd 4.11.0
Build a tool chain for the SPARC architecure. We are using the SPARC architecture in our example because GDB has a good simulator that lets us run and test the samples RTEMS builds by default
If building on Windows add --jobs=none
to avoid GNU make issues on Windows discussed in Parallel Builds with Make.
$ ../source-builder/sb-set-builder \
--prefix=/opt/rtems/4.11 4.11/rtems-sparc
Build Set: 4.11/rtems-sparc
Build Set: 4.11/rtems-autotools.bset
Build Set: 4.11/rtems-autotools-internal.bset
config: tools/rtems-autoconf-2.69-1.cfg
package: autoconf-2.69-x86_64-freebsd10.1-1
Creating source directory: sources
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/autoconf-2.69.tar.gz -> sources/autoconf-2.69.tar.gz
downloading: sources/autoconf-2.69.tar.gz - 1.8MB of 1.8MB (100%)
building: autoconf-2.69-x86_64-freebsd10.1-1
config: tools/rtems-automake-1.12.6-1.cfg
package: automake-1.12.6-x86_64-freebsd10.1-1
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/automake-1.12.6.tar.gz -> sources/automake-1.12.6.tar.gz
downloading: sources/automake-1.12.6.tar.gz - 2.0MB of 2.0MB (100%)
Creating source directory: patches
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/automake-1.12.6-bugzilla.redhat.com-1239379.diff -> patches/automake-1.12.6-bugzilla.redhat.com-1239379.diff
downloading: patches/automake-1.12.6-bugzilla.redhat.com-1239379.diff - 408.0 bytes of 408.0 bytes (100%)
building: automake-1.12.6-x86_64-freebsd10.1-1
cleaning: autoconf-2.69-x86_64-freebsd10.1-1
cleaning: automake-1.12.6-x86_64-freebsd10.1-1
Build Set: Time 0:00:32.749337
Build Set: 4.11/rtems-autotools-base.bset
config: tools/rtems-autoconf-2.69-1.cfg
package: autoconf-2.69-x86_64-freebsd10.1-1
building: autoconf-2.69-x86_64-freebsd10.1-1
reporting: tools/rtems-autoconf-2.69-1.cfg -> autoconf-2.69-x86_64-freebsd10.1-1.txt
reporting: tools/rtems-autoconf-2.69-1.cfg -> autoconf-2.69-x86_64-freebsd10.1-1.xml
config: tools/rtems-automake-1.12.6-1.cfg
package: automake-1.12.6-x86_64-freebsd10.1-1
building: automake-1.12.6-x86_64-freebsd10.1-1
reporting: tools/rtems-automake-1.12.6-1.cfg -> automake-1.12.6-x86_64-freebsd10.1-1.txt
reporting: tools/rtems-automake-1.12.6-1.cfg -> automake-1.12.6-x86_64-freebsd10.1-1.xml
installing: autoconf-2.69-x86_64-freebsd10.1-1 -> /opt/work/rtems/4.11.0
installing: automake-1.12.6-x86_64-freebsd10.1-1 -> /opt/work/rtems/4.11.0
cleaning: autoconf-2.69-x86_64-freebsd10.1-1
cleaning: automake-1.12.6-x86_64-freebsd10.1-1
Build Set: Time 0:00:15.619219
Build Set: Time 0:00:48.371085
config: devel/expat-2.1.0-1.cfg
package: expat-2.1.0-x86_64-freebsd10.1-1
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/expat-2.1.0.tar.gz -> sources/expat-2.1.0.tar.gz
downloading: sources/expat-2.1.0.tar.gz - 549.4kB of 549.4kB (100%)
building: expat-2.1.0-x86_64-freebsd10.1-1
reporting: devel/expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-freebsd10.1-1.txt
reporting: devel/expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-freebsd10.1-1.xml
config: tools/rtems-binutils-2.26-1.cfg
package: sparc-rtems4.11-binutils-2.26-x86_64-freebsd10.1-1
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/binutils-2.26.tar.bz2 -> sources/binutils-2.26.tar.bz2
downloading: sources/binutils-2.26.tar.bz2 - 24.4MB of 24.4MB (100%)
building: sparc-rtems4.11-binutils-2.26-x86_64-freebsd10.1-1
reporting: tools/rtems-binutils-2.26-1.cfg ->
sparc-rtems4.11-binutils-2.26-x86_64-freebsd10.1-1.txt
reporting: tools/rtems-binutils-2.26-1.cfg ->
sparc-rtems4.11-binutils-2.26-x86_64-freebsd10.1-1.xml
config: tools/rtems-gcc-4.9.3-newlib-2.2.0-20150423-1.cfg
package: sparc-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-freebsd10.1-1
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/gcc-4.9.3.tar.bz2 -> sources/gcc-4.9.3.tar.bz2
downloading: sources/gcc-4.9.3.tar.bz2 - 85.8MB of 85.8MB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/newlib-2.2.0.20150423.tar.gz -> sources/newlib-2.2.0.20150423.tar.gz
downloading: sources/newlib-2.2.0.20150423.tar.gz - 16.7MB of 16.7MB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/mpfr-3.0.1.tar.bz2 -> sources/mpfr-3.0.1.tar.bz2
downloading: sources/mpfr-3.0.1.tar.bz2 - 1.1MB of 1.1MB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/mpc-0.8.2.tar.gz -> sources/mpc-0.8.2.tar.gz
downloading: sources/mpc-0.8.2.tar.gz - 535.5kB of 535.5kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/gmp-5.0.5.tar.bz2 -> sources/gmp-5.0.5.tar.bz2
downloading: sources/gmp-5.0.5.tar.bz2 - 2.0MB of 2.0MB (100%)
building: sparc-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-freebsd10.1-1
reporting: tools/rtems-gcc-4.9.3-newlib-2.2.0-20150423-1.cfg ->
sparc-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-freebsd10.1-1.txt
reporting: tools/rtems-gcc-4.9.3-newlib-2.2.0-20150423-1.cfg ->
sparc-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-freebsd10.1-1.xml
config: tools/rtems-gdb-7.9-1.cfg
package: sparc-rtems4.11-gdb-7.9-x86_64-freebsd10.1-1
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/gdb-7.9.tar.xz -> sources/gdb-7.9.tar.xz
downloading: sources/gdb-7.9.tar.xz - 17.0MB of 17.0MB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0001-sim-erc32-Disassembly-in-stand-alone-mode-did-not-wo.patch -> patches/0001-sim-erc32-Disassembly-in-stand-alone-mode-did-not-wo.patch
downloading: patches/0001-sim-erc32-Disassembly-in-stand-alone-mode-did-not-wo.patch - 1.9kB of 1.9kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0002-sim-erc32-Corrected-wrong-CPU-implementation-and-ver.patch -> patches/0002-sim-erc32-Corrected-wrong-CPU-implementation-and-ver.patch
downloading: patches/0002-sim-erc32-Corrected-wrong-CPU-implementation-and-ver.patch - 827.0 bytes of 827.0 bytes (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0003-sim-erc32-Perform-pseudo-init-if-binary-linked-to-no.patch -> patches/0003-sim-erc32-Perform-pseudo-init-if-binary-linked-to-no.patch
downloading: patches/0003-sim-erc32-Perform-pseudo-init-if-binary-linked-to-no.patch - 2.6kB of 2.6kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0004-sim-erc32-Use-fenv.h-for-host-FPU-access.patch -> patches/0004-sim-erc32-Use-fenv.h-for-host-FPU-access.patch
downloading: patches/0004-sim-erc32-Use-fenv.h-for-host-FPU-access.patch - 4.9kB of 4.9kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0005-sim-erc32-Remove-unused-defines-in-Makefile-and-swit.patch -> patches/0005-sim-erc32-Remove-unused-defines-in-Makefile-and-swit.patch
downloading: patches/0005-sim-erc32-Remove-unused-defines-in-Makefile-and-swit.patch - 871.0 bytes of 871.0 bytes (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0006-sim-erc32-Fix-incorrect-simulator-performance-report.patch -> patches/0006-sim-erc32-Fix-incorrect-simulator-performance-report.patch
downloading: patches/0006-sim-erc32-Fix-incorrect-simulator-performance-report.patch - 5.6kB of 5.6kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0007-sim-erc32-File-loading-via-command-line-did-not-work.patch -> patches/0007-sim-erc32-File-loading-via-command-line-did-not-work.patch
downloading: patches/0007-sim-erc32-File-loading-via-command-line-did-not-work.patch - 1.0kB of 1.0kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0008-sim-erc32-Added-v-command-line-switch-for-verbose-ou.patch -> patches/0008-sim-erc32-Added-v-command-line-switch-for-verbose-ou.patch
downloading: patches/0008-sim-erc32-Added-v-command-line-switch-for-verbose-ou.patch - 3.6kB of 3.6kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0009-sim-erc32-Removed-type-mismatch-compiler-warnings.patch -> patches/0009-sim-erc32-Removed-type-mismatch-compiler-warnings.patch
downloading: patches/0009-sim-erc32-Removed-type-mismatch-compiler-warnings.patch - 1.9kB of 1.9kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0010-sim-erc32-Switched-emulated-memory-to-host-endian-or.patch -> patches/0010-sim-erc32-Switched-emulated-memory-to-host-endian-or.patch
downloading: patches/0010-sim-erc32-Switched-emulated-memory-to-host-endian-or.patch - 16.0kB of 16.0kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0011-sim-erc32-use-SIM_AC_OPTION_HOSTENDIAN-to-probe-for-.patch -> patches/0011-sim-erc32-use-SIM_AC_OPTION_HOSTENDIAN-to-probe-for-.patch
downloading: patches/0011-sim-erc32-use-SIM_AC_OPTION_HOSTENDIAN-to-probe-for-.patch - 14.8kB of 14.8kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0012-sim-erc32-Use-memory_iread-function-for-instruction-.patch -> patches/0012-sim-erc32-Use-memory_iread-function-for-instruction-.patch
downloading: patches/0012-sim-erc32-Use-memory_iread-function-for-instruction-.patch - 3.8kB of 3.8kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0013-sim-erc32-Fix-a-few-compiler-warnings.patch-> patches/0013-sim-erc32-Fix-a-few-compiler-warnings.patch
downloading: patches/0013-sim-erc32-Fix-a-few-compiler-warnings.patch - 2.2kB of 2.2kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0014-sim-erc32-Use-gdb-callback-for-UART-I-O-when-linked-.patch -> patches/0014-sim-erc32-Use-gdb-callback-for-UART-I-O-when-linked-.patch
downloading: patches/0014-sim-erc32-Use-gdb-callback-for-UART-I-O-when-linked-.patch - 9.2kB of 9.2kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0015-sim-erc32-Access-memory-subsystem-through-struct-mem.patch -> patches/0015-sim-erc32-Access-memory-subsystem-through-struct-mem.patch
downloading: patches/0015-sim-erc32-Access-memory-subsystem-through-struct-mem.patch - 22.9kB of 22.9kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0016-sim-erc32-Use-readline.h-for-readline-types-and-func.patch -> patches/0016-sim-erc32-Use-readline.h-for-readline-types-and-func.patch
downloading: patches/0016-sim-erc32-Use-readline.h-for-readline-types-and-func.patch - 1.5kB of 1.5kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0017-sim-erc32-Move-local-extern-declarations-into-sis.h.patch -> patches/0017-sim-erc32-Move-local-extern-declarations-into-sis.h.patch
downloading: patches/0017-sim-erc32-Move-local-extern-declarations-into-sis.h.patch - 5.8kB of 5.8kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0018-sim-erc32-Add-support-for-LEON3-processor-emulation.patch -> patches/0018-sim-erc32-Add-support-for-LEON3-processor-emulation.patch
downloading: patches/0018-sim-erc32-Add-support-for-LEON3-processor-emulation.patch - 66.7kB of 66.7kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0019-sim-erc32-Add-support-for-LEON2-processor-emulation.patch -> patches/0019-sim-erc32-Add-support-for-LEON2-processor-emulation.patch
downloading: patches/0019-sim-erc32-Add-support-for-LEON2-processor-emulation.patch - 26.1kB of 26.1kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0020-sim-erc32-Updated-documentation.patch -> patches/0020-sim-erc32-Updated-documentation.patch
downloading: patches/0020-sim-erc32-Updated-documentation.patch - 16.1kB of 16.1kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0021-sim-erc32-Add-data-watchpoint-support.patch -> patches/0021-sim-erc32-Add-data-watchpoint-support.patch
downloading: patches/0021-sim-erc32-Add-data-watchpoint-support.patch - 10.1kB of 10.1kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0022-Add-watchpoint-support-to-gdb-simulator-interface.patch -> patches/0022-Add-watchpoint-support-to-gdb-simulator-interface.patch
downloading: patches/0022-Add-watchpoint-support-to-gdb-simulator-interface.patch - 25.5kB of 25.5kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch -> patches/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch
downloading: patches/0023-sim-erc32-ELF-loading-could-fail-on-unaligned-sectio.patch - 1.3kB of 1.3kB (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/gdb-sim-arange-inline.diff -> patches/gdb-sim-arange-inline.diff
downloading: patches/gdb-sim-arange-inline.diff - 761.0 bytes of 761.0 bytes (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/gdb-sim-cgen-inline.diff -> patches/gdb-sim-cgen-inline.diff
downloading: patches/gdb-sim-cgen-inline.diff - 706.0 bytes of 706.0 bytes (100%)
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/sources/patch-gdb-python-python-config.py -> patches/patch-gdb-python-python-config.py
downloading: patches/patch-gdb-python-python-config.py - 449.0 bytes of 449.0 bytes (100%)
building: sparc-rtems4.11-gdb-7.9-x86_64-freebsd10.1-1
reporting: tools/rtems-gdb-7.9-1.cfg ->
sparc-rtems4.11-gdb-7.9-x86_64-freebsd10.1-1.txt
reporting: tools/rtems-gdb-7.9-1.cfg ->
sparc-rtems4.11-gdb-7.9-x86_64-freebsd10.1-1.xml
config: tools/rtems-tools-4.11-1.cfg
package: rtems-tools-4.11.0-1
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/rtems-tools-4.11.0.tar.xz -> sources/rtems-tools-4.11.0.tar.xz
downloading: sources/rtems-tools-4.11.0.tar.xz - 1.6MB of 1.6MB (100%)
building: rtems-tools-4.11.0-1
reporting: tools/rtems-tools-4.11-1.cfg -> rtems-tools-4.11.0-1.txt
reporting: tools/rtems-tools-4.11-1.cfg -> rtems-tools-4.11.0-1.xml
config: tools/rtems-kernel-4.11.cfg
package: sparc-rtems4.11-kernel-4.11.0-1
download: ftp://ftp.rtems.org/pub/rtems/releases/4.11/4.11.0/rtems-4.11.0.tar.xz -> sources/rtems-4.11.0.tar.xz
downloading: sources/rtems-4.11.0.tar.xz - 9.3MB of 9.3MB (100%)
building: sparc-rtems4.11-kernel-4.11.0-1
reporting: tools/rtems-kernel-4.11.cfg -> sparc-rtems4.11-kernel-4.11.0-1.txt
reporting: tools/rtems-kernel-4.11.cfg -> sparc-rtems4.11-kernel-4.11.0-1.xml
installing: expat-2.1.0-x86_64-freebsd10.1-1 -> /opt/work/rtems/4.11.0
installing: sparc-rtems4.11-binutils-2.26-x86_64-freebsd10.1-1 -> /opt/work/rtems/4.11.0
installing: sparc-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-freebsd10.1-1 -> /opt/work/rtems/4.11.0
installing: sparc-rtems4.11-gdb-7.9-x86_64-freebsd10.1-1 -> /opt/work/rtems/4.11.0
installing: rtems-tools-4.11.0-1 -> /opt/work/rtems/4.11.0
installing: sparc-rtems4.11-kernel-4.11.0-1 -> /opt/work/rtems/4.11.0
cleaning: expat-2.1.0-x86_64-freebsd10.1-1
cleaning: sparc-rtems4.11-binutils-2.26-x86_64-freebsd10.1-1
cleaning: sparc-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-freebsd10.1-1
cleaning: sparc-rtems4.11-gdb-7.9-x86_64-freebsd10.1-1
cleaning: rtems-tools-4.11.0-1
cleaning: sparc-rtems4.11-kernel-4.11.0-1
Build Set: Time 0:19:15.713662
You can now build a third-party library or an application as defaulted in TBD.
5.2. Developer (Unstable)¶
RTEMS provides open access to it’s development processes. We call this the developer set up. The project encourages all users to inspect, review, comment and contribute to the code base. The processes described here are the same processes the core development team use when developing and maintaining RTEMS.
Warning
The development version is not for use in production and it can break from time to time.
Please read Host Computer before continuing. 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.
You need to select a location to build and install the RTEMS Tool chain and RTEMS. Make sure there is plenty of disk space and a fast disk is recommended. Our procedure will document building and installing the tools in a home directory called development/rtems
. Using a home directory means you can do this without needing to be root. You can also use /opt/rtems/build
if you have access to that path.
The location used to install the tools and kernel is called the prefix. It is best to have a prefix for each different version of RTEMS you are using. If you are using RTEMS 4.11 in production it is not a good idea to install a development version of 5 over the top. A separate prefix for each version avoids this.
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.
5.2.1. POSIX and OS X Host Tools Chain¶
This procedure will build a SPARC tool chain.
Clone the RTEMS Source Builder (RSB) repository:
$ cd
$ mkdir -p development/rtems
$ cd development/rtems
$ git clone git://git.rtems.org/rtems-source-builder.git rsb
Cloning into 'rsb'...
remote: Counting objects: 5837, done.
remote: Compressing objects: 100% (2304/2304), done.
remote: Total 5837 (delta 4014), reused 5056 (delta 3494)
Receiving objects: 100% (5837/5837), 2.48 MiB | 292.00 KiB/s, done.
Resolving deltas: 100% (4014/4014), done.
Checking connectivity... done.
Check all the host packages you need are present. Current libraries are not checked and this includes checking for the python development libraries GDB requires:
$ cd rsb
$ ./source-builder/sb-check
RTEMS Source Builder - Check, 5 (089327b5dcf9)
Environment is ok
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 <1>
RTEMS Source Builder - Set Builder, v4.11.0
Examining: config
Examining: ../source-builder/config <2>
4.10/rtems-all.bset <3>
4.10/rtems-arm.bset <4>
4.10/rtems-autotools.bset
4.10/rtems-avr.bset
4.10/rtems-bfin.bset
4.10/rtems-h8300.bset
4.10/rtems-i386.bset
4.10/rtems-lm32.bset
4.10/rtems-m32c.bset
4.10/rtems-m32r.bset
4.10/rtems-m68k.bset
4.10/rtems-mips.bset
4.10/rtems-nios2.bset
4.10/rtems-powerpc.bset
4.10/rtems-sh.bset
4.10/rtems-sparc.bset
4.11/rtems-all.bset
4.11/rtems-arm.bset
4.11/rtems-autotools.bset
4.11/rtems-avr.bset
4.11/rtems-bfin.bset
4.11/rtems-h8300.bset
4.11/rtems-i386.bset
4.11/rtems-lm32.bset
4.11/rtems-m32c.bset
4.11/rtems-m32r.bset
4.11/rtems-m68k.bset
4.11/rtems-microblaze.bset
4.11/rtems-mips.bset
4.11/rtems-moxie.bset
4.11/rtems-nios2.bset
4.11/rtems-powerpc.bset
4.11/rtems-sh.bset
4.11/rtems-sparc.bset
4.11/rtems-sparc64.bset
4.11/rtems-v850.bset
4.9/rtems-all.bset
4.9/rtems-arm.bset
4.9/rtems-autotools.bset
4.9/rtems-i386.bset
4.9/rtems-m68k.bset
4.9/rtems-mips.bset
4.9/rtems-powerpc.bset
4.9/rtems-sparc.bset
gnu-tools-4.6.bset
rtems-4.10-base.bset <5>
rtems-4.11-base.bset
rtems-4.9-base.bset
rtems-base.bset <5>
Items:
- Only option required is
--list-bsets
- The paths inspected. See Configuration.
- A build set to build all RTEMS 4.10 supported architectures.
- The build set for the ARM architecture on RTEMS 4.10.
- Support build set file with common functionality included by other build set files.
Build a tool chain for the SPARC architecture. We are using the SPARC architecture because GDB has a good simulator that lets us run and test the samples RTEMS builds by default. The current development version is 5 and is on master:
$ cd rtems
$ ../source-builder/sb-set-builder --prefix=/usr/home/chris/development/rtems/5 5/rtems-sparc
RTEMS Source Builder - Set Builder, 5 (089327b5dcf9)
Build Set: 5/rtems-sparc
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-linux-gnu-1
Creating source directory: sources
download: ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz -> sources/autoconf-2.69.tar.gz
downloading: sources/autoconf-2.69.tar.gz - 1.8MB of 1.8MB (100%)
building: autoconf-2.69-x86_64-linux-gnu-1
config: tools/rtems-automake-1.12.6-1.cfg
package: automake-1.12.6-x86_64-linux-gnu-1
download: ftp://ftp.gnu.org/gnu/automake/automake-1.12.6.tar.gz -> sources/automake-1.12.6.tar.gz
downloading: sources/automake-1.12.6.tar.gz - 2.0MB of 2.0MB (100%)
Creating source directory: patches
download: https://git.rtems.org/rtems-tools/plain/tools/5/automake/automake-1.12.6-bugzilla.redhat.com-1239379.diff -> patches/automake-1.12.6-bugzilla.redhat.com-1239379.diff
downloading: patches/automake-1.12.6-bugzilla.redhat.com-1239379.diff - 408.0 bytes of 408.0 bytes (100%)
building: automake-1.12.6-x86_64-linux-gnu-1
cleaning: autoconf-2.69-x86_64-linux-gnu-1
cleaning: automake-1.12.6-x86_64-linux-gnu-1
Build Set: Time 0:00:12.713221
Build Set: 5/rtems-autotools-base.bset
config: tools/rtems-autoconf-2.69-1.cfg
package: autoconf-2.69-x86_64-linux-gnu-1
building: autoconf-2.69-x86_64-linux-gnu-1
reporting: tools/rtems-autoconf-2.69-1.cfg -> autoconf-2.69-x86_64-linux-gnu-1.txt
reporting: tools/rtems-autoconf-2.69-1.cfg -> autoconf-2.69-x86_64-linux-gnu-1.xml
config: tools/rtems-automake-1.12.6-1.cfg
package: automake-1.12.6-x86_64-linux-gnu-1
building: automake-1.12.6-x86_64-linux-gnu-1
reporting: tools/rtems-automake-1.12.6-1.cfg -> automake-1.12.6-x86_64-linux-gnu-1.txt
reporting: tools/rtems-automake-1.12.6-1.cfg -> automake-1.12.6-x86_64-linux-gnu-1.xml
installing: autoconf-2.69-x86_64-linux-gnu-1 -> /usr/home/chris/development/rtems/5
installing: automake-1.12.6-x86_64-linux-gnu-1 -> /usr/home/chris/development/rtems/5
cleaning: autoconf-2.69-x86_64-linux-gnu-1
cleaning: automake-1.12.6-x86_64-linux-gnu-1
Build Set: Time 0:00:09.105363
Build Set: Time 0:00:21.822083
config: devel/expat-2.1.0-1.cfg
package: expat-2.1.0-x86_64-linux-gnu-1
download: http://downloads.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz -> sources/expat-2.1.0.tar.gz
redirect: https://vorboss.dl.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz
downloading: sources/expat-2.1.0.tar.gz - 549.4kB of 549.4kB (100%)
building: expat-2.1.0-x86_64-linux-gnu-1
reporting: devel/expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-linux-gnu-1.txt
reporting: devel/expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-linux-gnu-1.xml
config: tools/rtems-binutils-2.29-1.cfg
package: sparc-rtems5-binutils-2.29-x86_64-linux-gnu-1
download: ftp://ftp.gnu.org/gnu/binutils/binutils-2.29.tar.bz2 -> sources/binutils-2.29.tar.bz2
downloading: sources/binutils-2.29.tar.bz2 - 27.7MB of 27.7MB (100%)
download: https://devel.rtems.org/raw-attachment/ticket/3091/0001-Fix-Binutils-2.29-PR21884.patch -> patches/0001-Fix-Binutils-2.29-PR21884.patch
downloading: patches/0001-Fix-Binutils-2.29-PR21884.patch - 8.8kB of 8.8kB (100%)
building: sparc-rtems5-binutils-2.29-x86_64-linux-gnu-1
reporting: tools/rtems-binutils-2.29-1.cfg -> sparc-rtems5-binutils-2.29-x86_64-linux-gnu-1.txt
reporting: tools/rtems-binutils-2.29-1.cfg -> sparc-rtems5-binutils-2.29-x86_64-linux-gnu-1.xml
config: tools/rtems-gcc-7.2.0-newlib-2.5.0.20170922-1.cfg
package: sparc-rtems5-gcc-7.2.0-newlib-2.5.0.20170922-x86_64-linux-gnu-1
download: https://ftp.gnu.org/gnu/gcc/gcc-7.2.0/gcc-7.2.0.tar.xz -> sources/gcc-7.2.0.tar.xz
downloading: sources/gcc-7.2.0.tar.xz - 59.4MB of 59.4MB (100%)
download: https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff_plain;h=62ffbcb7502f0ff88ff7566cd6d7c59c0483ecc0 -> patches/gcc-62ffbcb7502f0ff88ff7566cd6d7c59c0483ecc0.patch
downloading: patches/gcc-62ffbcb7502f0ff88ff7566cd6d7c59c0483ecc0.patch - 1.8kB
download: https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff_plain;f=gcc/config.gcc;h=593631849bb5e0df5cc4ff42c1a1cc34b7eec2f8;hp=a9196cd26d9ec24c2e3f6026f63348cae3734861;hb=e840389000b8339a63bee56d8b3...<see log> -> patches/gcc-593631849bb5e0df5cc4ff42c1a1cc34b7eec2f8.patch
downloading: patches/gcc-593631849bb5e0df5cc4ff42c1a1cc34b7eec2f8.patch - 806.0 bytes
download: https://gcc.gnu.org/git/?p=gcc.git;a=blobdiff_plain;f=gcc/config/rs6000/rtems.h;h=7ea9ebdb77b6a9b7060ad2362318e0e12b9058ae;hp=8a62fdcbaf321d616021c4c396619b7f56cf5ed2;hb=e840389000b8339a...<see log> -> patches/gcc-7ea9ebdb77b6a9b7060ad2362318e0e12b9058ae.patch
downloading: patches/gcc-7ea9ebdb77b6a9b7060ad2362318e0e12b9058ae.patch - 3.2kB
download: ftp://sourceware.org/pub/newlib/newlib-2.5.0.20170922.tar.gz -> sources/newlib-2.5.0.20170922.tar.gz
downloading: sources/newlib-2.5.0.20170922.tar.gz - 17.3MB of 17.3MB (100%)
download: https://devel.rtems.org/raw-attachment/ticket/2514/0001-RTEMS-Self-contained-POSIX-objects.patch -> patches/0001-RTEMS-Self-contained-POSIX-objects.patch
downloading: patches/0001-RTEMS-Self-contained-POSIX-objects.patch - 5.7kB of 5.7kB (100%)
download: https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=c165a27c0147471977377acd8918ab3b446f947a -> patches/newlib-cygwin-git-c165a27c0147471977377acd8918ab3b446f947a.patch
downloading: patches/newlib-cygwin-git-c165a27c0147471977377acd8918ab3b446f947a.patch - 986.0 bytes
download: https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=patch;h=ce189d8afef720b0977b5cae7f9eabf5d49b530c -> patches/newlib-cygwin-git-ce189d8afef720b0977b5cae7f9eabf5d49b530c.patch
downloading: patches/newlib-cygwin-git-ce189d8afef720b0977b5cae7f9eabf5d49b530c.patch - 3.4kB
download: https://ftp.gnu.org/gnu/mpfr/mpfr-3.1.4.tar.bz2 -> sources/mpfr-3.1.4.tar.bz2
downloading: sources/mpfr-3.1.4.tar.bz2 - 1.2MB of 1.2MB (100%)
download: https://ftp.gnu.org/gnu/mpc/mpc-1.0.3.tar.gz -> sources/mpc-1.0.3.tar.gz
downloading: sources/mpc-1.0.3.tar.gz - 654.2kB of 654.2kB (100%)
download: https://ftp.gnu.org/gnu/gmp/gmp-6.1.0.tar.bz2 -> sources/gmp-6.1.0.tar.bz2
downloading: sources/gmp-6.1.0.tar.bz2 - 2.3MB of 2.3MB (100%)
building: sparc-rtems5-gcc-7.2.0-newlib-2.5.0.20170922-x86_64-linux-gnu-1
reporting: tools/rtems-gcc-7.2.0-newlib-2.5.0.20170922-1.cfg -> sparc-rtems5-gcc-7.2.0-newlib-2.5.0.20170922-x86_64-linux-gnu-1.txt
reporting: tools/rtems-gcc-7.2.0-newlib-2.5.0.20170922-1.cfg -> sparc-rtems5-gcc-7.2.0-newlib-2.5.0.20170922-x86_64-linux-gnu-1.xml
config: tools/rtems-gdb-8.0.1-1.cfg
package: sparc-rtems5-gdb-8.0.1-x86_64-linux-gnu-1
download: http://ftp.gnu.org/gnu/gdb/gdb-8.0.1.tar.xz -> sources/gdb-8.0.1.tar.xz
downloading: sources/gdb-8.0.1.tar.xz - 18.7MB of 18.7MB (100%)
download: https://gaisler.org/gdb/gdb-8.0.1-sis-leon2-leon3.diff -> patches/gdb-8.0.1-sis-leon2-leon3.diff
downloading: patches/gdb-8.0.1-sis-leon2-leon3.diff - 224.5kB of 224.5kB (100%)
building: sparc-rtems5-gdb-8.0.1-x86_64-linux-gnu-1
reporting: tools/rtems-gdb-8.0.1-1.cfg -> sparc-rtems5-gdb-8.0.1-x86_64-linux-gnu-1.txt
reporting: tools/rtems-gdb-8.0.1-1.cfg -> sparc-rtems5-gdb-8.0.1-x86_64-linux-gnu-1.xml
config: tools/rtems-tools-5-1.cfg
package: rtems-tools-HEAD-1
Creating source directory: sources/git
git: clone: git://git.rtems.org/rtems-tools.git -> sources/git/rtems-tools.git
git: reset: git://git.rtems.org/rtems-tools.git
git: fetch: git://git.rtems.org/rtems-tools.git -> sources/git/rtems-tools.git
git: checkout: git://git.rtems.org/rtems-tools.git => HEAD
git: pull: git://git.rtems.org/rtems-tools.git
building: rtems-tools-HEAD-1
reporting: tools/rtems-tools-5-1.cfg -> rtems-tools-HEAD-1.txt
reporting: tools/rtems-tools-5-1.cfg -> rtems-tools-HEAD-1.xml
config: tools/rtems-kernel-5.cfg
package: sparc-rtems5-kernel-5-1
building: sparc-rtems5-kernel-5-1
reporting: tools/rtems-kernel-5.cfg -> sparc-rtems5-kernel-5-1.txt
reporting: tools/rtems-kernel-5.cfg -> sparc-rtems5-kernel-5-1.xml
installing: expat-2.1.0-x86_64-linux-gnu-1 -> /usr/home/chris/development/rtems/5
installing: sparc-rtems5-binutils-2.29-x86_64-linux-gnu-1 -> /usr/home/chris/development/rtems/5
installing: sparc-rtems5-gcc-7.2.0-newlib-2.5.0.20170922-x86_64-linux-gnu-1 -> /usr/home/chris/development/rtems/5
installing: sparc-rtems5-gdb-8.0.1-x86_64-linux-gnu-1 -> /usr/home/chris/development/rtems/5
installing: rtems-tools-HEAD-1 -> /usr/home/chris/development/rtems/5
installing: sparc-rtems5-kernel-5-1 -> /usr/home/chris/development/rtems/5
cleaning: expat-2.1.0-x86_64-linux-gnu-1
cleaning: sparc-rtems5-binutils-2.29-x86_64-linux-gnu-1
cleaning: sparc-rtems5-gcc-7.2.0-newlib-2.5.0.20170922-x86_64-linux-gnu-1
cleaning: sparc-rtems5-gdb-8.0.1-x86_64-linux-gnu-1
cleaning: rtems-tools-HEAD-1
cleaning: sparc-rtems5-kernel-5-1
Build Set: Time 0:39:33.988995
5.2.2. Windows Host Tool Chain¶
This section details how you create an RTEMS development environment on Windows. The installation documented here is on Windows 7 64bit Professional. Building on Windows 10 has been reported as working.
Please see Microsoft Windows before continuing.
Note
If the RSB reports 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.
5.2.2.1. RTEMS Windows Tools¶
Create a workspace for RTEMS using the following shell command:
~
$ mkdir -p /c/opt/rtems
The /c
path is an internal MSYS2 mount point of the C:
drive. The command creates the RTEMS work space on the C:
drive. If you wish to use another drive please subsitute /c
with your drive letter.
We build and install all RTEMS packages under the prefix we just created. Change to that directory and get a copy of the RSB:
~
$ cd /c/opt/rtems
/c/opt/rtems
$ git clone git://git.rtems.org/rtems-source-builder.git rsb
Cloning into 'rsb'...
remote: Counting objects: 5716, done.
remote: Compressing objects: 100% (2183/2183), done.
remote: Total 5716 (delta 3919), reused 5071 (delta 3494)
Receiving objects: 100% (5716/5716), 2.46 MiB | 656.00 KiB/s, done.
Resolving deltas: 100% (3919/3919), done.
Checking connectivity... done.
Checking out files: 100% (630/630), done.
/c/opt/rtems
$ cd rsb
We are building RTEMS 4.11 tools so select the 4.11 branch:
/c/opt/rtems/rsb
$ git checkout 4.11
Branch 4.11 set up to track remote branch 4.11 from origin.
Switched to a new branch '4.11'
/c/opt/rtems/rsb
$
Check the RSB has a valid environment:
/c/opt/rtems/rsb
$ cd rtems
/c/opt/rtems/rsb/rtems
$ ../source-builder/sb-check
RTEMS Source Builder - Check, 4.11 (01ac76f2f90f)
Environment is ok
/c/opt/rtems/rsb/rtems
$
To build a set of RTEMS tools for the Intel i386
architecture. The build runs a single job rather than a job per CPU in your machine and will take a long time so please be patient. The RSB creates a log file containing all the build output and it will be changing size. The RSB command to build i386
tools is:
/c/opt/rtems/rsb/rtems
$ ../source-builder/sb-set-builder --prefix=/c/opt/rtems/4.11 \
--jobs=none 4.11/rtems-i386
RTEMS Source Builder - Set Builder, 4.11 (01ac76f2f90f)
Build Set: 4.11/rtems-i386
Build Set: 4.11/rtems-autotools.bset
Build Set: 4.11/rtems-autotools-internal.bset
config: tools/rtems-autoconf-2.69-1.cfg
package: autoconf-2.69-x86_64-w64-mingw32-1
Creating source directory: sources
download: ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz -> sources/autoconf-2.69.tar.gz
downloading: sources/autoconf-2.69.tar.gz - 1.8MB of 1.8MB (100%)
building: autoconf-2.69-x86_64-w64-mingw32-1
config: tools/rtems-automake-1.12.6-1.cfg
package: automake-1.12.6-x86_64-w64-mingw32-1
download: ftp://ftp.gnu.org/gnu/automake/automake-1.12.6.tar.gz -> sources/automake-1.12.6.tar.gz
downloading: sources/automake-1.12.6.tar.gz - 2.0MB of 2.0MB (100%)
building: automake-1.12.6-x86_64-w64-mingw32-1
cleaning: autoconf-2.69-x86_64-w64-mingw32-1
cleaning: automake-1.12.6-x86_64-w64-mingw32-1
Build Set: Time 0:00:42.515625
Build Set: 4.11/rtems-autotools-base.bset
config: tools/rtems-autoconf-2.69-1.cfg
package: autoconf-2.69-x86_64-w64-mingw32-1
building: autoconf-2.69-x86_64-w64-mingw32-1
reporting: tools/rtems-autoconf-2.69-1.cfg -> autoconf-2.69-x86_64-w64-mingw32-1.txt
reporting: tools/rtems-autoconf-2.69-1.cfg -> autoconf-2.69-x86_64-w64-mingw32-1.xml
config: tools/rtems-automake-1.12.6-1.cfg
package: automake-1.12.6-x86_64-w64-mingw32-1
building: automake-1.12.6-x86_64-w64-mingw32-1
reporting: tools/rtems-automake-1.12.6-1.cfg -> automake-1.12.6-x86_64-w64-mingw32-1.txt
reporting: tools/rtems-automake-1.12.6-1.cfg -> automake-1.12.6-x86_64-w64-mingw32-1.xml
tarball: tar/rtems-4.11-autotools-x86_64-w64-mingw32-1.tar.bz2
installing: autoconf-2.69-x86_64-w64-mingw32-1 -> C:\opt\rtems\4.11
installing: automake-1.12.6-x86_64-w64-mingw32-1 -> C:\opt\rtems\4.11
cleaning: autoconf-2.69-x86_64-w64-mingw32-1
cleaning: automake-1.12.6-x86_64-w64-mingw32-1
Build Set: Time 0:00:37.718750
Build Set: Time 0:01:20.234375
config: devel/expat-2.1.0-1.cfg
package: expat-2.1.0-x86_64-w64-mingw32-1
download: http://downloads.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz -> sources/expat-2.1.0.tar.gz
redirect: http://iweb.dl.sourceforge.net/project/expat/expat/2.1.0/expat-2.1.0.tar.gz
downloading: sources/expat-2.1.0.tar.gz - 549.4kB of 549.4kB (100%)
building: expat-2.1.0-x86_64-w64-mingw32-1
reporting: devel/expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-w64-mingw32-1.txt
reporting: devel/expat-2.1.0-1.cfg -> expat-2.1.0-x86_64-w64-mingw32-1.xml
config: tools/rtems-binutils-2.24-1.cfg
package: i386-rtems4.11-binutils-2.24-x86_64-w64-mingw32-1
download: ftp://ftp.gnu.org/gnu/binutils/binutils-2.24.tar.bz2 -> sources/binutils-2.24.tar.bz2
downloading: sources/binutils-2.24.tar.bz2 - 21.7MB of 21.7MB (100%)
building: i386-rtems4.11-binutils-2.24-x86_64-w64-mingw32-1
reporting: tools/rtems-binutils-2.24-1.cfg -> i386-rtems4.11-binutils-2.24-x86_64-w64-mingw32-1.txt
reporting: tools/rtems-binutils-2.24-1.cfg -> i386-rtems4.11-binutils-2.24-x86_64-w64-mingw32-1.xml
config: tools/rtems-gcc-4.9.3-newlib-2.2.0-20150423-1.cfg
package: i386-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-w64-mingw32-1
download: ftp://ftp.gnu.org/gnu/gcc/gcc-4.9.3/gcc-4.9.3.tar.bz2 -> sources/gcc-4.9.3.tar.bz2
downloading: sources/gcc-4.9.3.tar.bz2 - 85.8MB of 85.8MB (100%)
download: ftp://sourceware.org/pub/newlib/newlib-2.2.0.20150423.tar.gz -> sources/newlib-2.2.0.20150423.tar.gz
downloading: sources/newlib-2.2.0.20150423.tar.gz - 16.7MB of 16.7MB (100%)
download: http://www.mpfr.org/mpfr-3.0.1/mpfr-3.0.1.tar.bz2 -> sources/mpfr-3.0.1.tar.bz2
downloading: sources/mpfr-3.0.1.tar.bz2 - 1.1MB of 1.1MB (100%)
download: http://www.multiprecision.org/mpc/download/mpc-0.8.2.tar.gz -> sources/mpc-0.8.2.tar.gz
downloading: sources/mpc-0.8.2.tar.gz - 535.5kB of 535.5kB (100%)
download: ftp://ftp.gnu.org/gnu/gmp/gmp-5.0.5.tar.bz2 -> sources/gmp-5.0.5.tar.bz2
downloading: sources/gmp-5.0.5.tar.bz2 - 2.0MB of 2.0MB (100%)
building: i386-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-w64-mingw32-1
reporting: tools/rtems-gcc-4.9.3-newlib-2.2.0-20150423-1.cfg ->
i386-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-w64-mingw32-1.txt
reporting: tools/rtems-gcc-4.9.3-newlib-2.2.0-20150423-1.cfg ->
i386-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-w64-mingw32-1.xml
config: tools/rtems-gdb-7.9-1.cfg
package: i386-rtems4.11-gdb-7.9-x86_64-w64-mingw32-1
download: http://ftp.gnu.org/gnu/gdb/gdb-7.9.tar.xz -> sources/gdb-7.9.tar.xz
downloading: sources/gdb-7.9.tar.xz - 17.0MB of 17.0MB (100%)
download: https://git.rtems.org/rtems-tools/plain/tools/4.11/gdb/gdb-sim-arange-inline.diff -> patches/gdb-sim-arange-inline.diff
downloading: patches/gdb-sim-arange-inline.diff - 761.0 bytes of 761.0 bytes (100%)
download: https://git.rtems.org/rtems-tools/plain/tools/4.11/gdb/gdb-sim-cgen-inline.diff -> patches/gdb-sim-cgen-inline.diff
downloading: patches/gdb-sim-cgen-inline.diff - 706.0 bytes of 706.0 bytes (100%)
building: i386-rtems4.11-gdb-7.9-x86_64-w64-mingw32-1
reporting: tools/rtems-gdb-7.9-1.cfg ->
i386-rtems4.11-gdb-7.9-x86_64-w64-mingw32-1.txt
reporting: tools/rtems-gdb-7.9-1.cfg ->
i386-rtems4.11-gdb-7.9-x86_64-w64-mingw32-1.xml
config: tools/rtems-tools-4.11-1.cfg
package: rtems-tools-4.11-1
Creating source directory: sources/git
git: clone: git://git.rtems.org/rtems-tools.git -> sources/git/rtems-tools.git
git: reset: git://git.rtems.org/rtems-tools.git
git: fetch: git://git.rtems.org/rtems-tools.git -> sources/git/rtems-tools.git
git: checkout: git://git.rtems.org/rtems-tools.git => 4.11
git: pull: git://git.rtems.org/rtems-tools.git
building: rtems-tools-4.11-1
reporting: tools/rtems-tools-4.11-1.cfg -> rtems-tools-4.11-1.txt
reporting: tools/rtems-tools-4.11-1.cfg -> rtems-tools-4.11-1.xml
config: tools/rtems-kernel-4.11.cfg
installing: expat-2.1.0-x86_64-w64-mingw32-1 -> C:\opt\rtems\4.11
installing: i386-rtems4.11-binutils-2.24-x86_64-w64-mingw32-1 -> C:\opt\rtems\4.11
installing: i386-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-w64-mingw32-1 -> C:\opt\rtems\4.11
installing: i386-rtems4.11-gdb-7.9-x86_64-w64-mingw32-1 -> C:\opt\rtems\4.11
installing: rtems-tools-4.11-1 -> C:\opt\rtems\4.11
cleaning: expat-2.1.0-x86_64-w64-mingw32-1
cleaning: i386-rtems4.11-binutils-2.24-x86_64-w64-mingw32-1
cleaning: i386-rtems4.11-gcc-4.9.3-newlib-2.2.0.20150423-x86_64-w64-mingw32-1
cleaning: i386-rtems4.11-gdb-7.9-x86_64-w64-mingw32-1
cleaning: rtems-tools-4.11-1
Build Set: Time 1:32:58.972919
/c/opt/rtems/rsb/rtems
$
5.2.2.2. Building the Kernel¶
We can now build the RTEMS kernel using the RTEMS tools we have just built. First we need to set the path to the tools:
/c
$ cd /c/opt/rtems
/c/opt/rtems
$ export PATH=/c/opt/rtems/4.11/bin:$PATH
/c/opt/rtems
$
We currently build RTEMS from the git release branch for 4.11:
/c/opt/rtems
$ mkdir kernel
/c/opt/rtems
$ cd kernel
/c/opt/rtems/kernel
$ git clone git://git.rtems.org/rtems.git rtems
Cloning into 'rtems'...
remote: Counting objects: 482766, done.
remote: Compressing objects: 100% (88781/88781), done.
remote: Total 482766 (delta 389610), reused 475155 (delta 383437)
Receiving objects: 100% (482766/482766), 69.77 MiB | 697.00 KiB/s, done.
Resolving deltas: 100% (389610/389610), done.
Checking connectivity... done.
Checking out files: 100% (10626/10626), done.
/c/opt/rtems/kernel
$ cd rtems
/c/opt/rtems/kernel/rtems
$ git checkout 4.11
Checking out files: 100% (2553/2553), done.
Branch 4.11 set up to track remote branch 4.11 from origin.
Switched to a new branch '4.11'
/c/opt/rtems/kernel
$
The kernel code cloned from git needs to be bootstrapped. Bootstrapping creates autoconf
and automake
generated files. To bootstrap we first clean away any files, then generate the pre-install header file lists and finally we generate the autoconf
and automake
files using the RSB’s bootstrap tool. First we clean any generated files that exist:
/c/opt/rtems/kernel/rtems
$ ./bootstrap -c
removing automake generated Makefile.in files
removing configure files
removing aclocal.m4 files
Then we generate the pre-install header file automake make files:
/c/opt/rtems/kernel/rtems
$ ./bootstrap -p
Generating ./c/src/ada/preinstall.am
Generating ./c/src/lib/libbsp/arm/altera-cyclone-v/preinstall.am
Generating ./c/src/lib/libbsp/arm/atsam/preinstall.am
Generating ./c/src/lib/libbsp/arm/beagle/preinstall.am
Generating ./c/src/lib/libbsp/arm/csb336/preinstall.am
Generating ./c/src/lib/libbsp/arm/csb337/preinstall.am
Generating ./c/src/lib/libbsp/arm/edb7312/preinstall.am
Generating ./c/src/lib/libbsp/arm/gdbarmsim/preinstall.am
.......
Generating ./cpukit/score/cpu/mips/preinstall.am
Generating ./cpukit/score/cpu/moxie/preinstall.am
Generating ./cpukit/score/cpu/nios2/preinstall.am
Generating ./cpukit/score/cpu/no_cpu/preinstall.am
Generating ./cpukit/score/cpu/or1k/preinstall.am
Generating ./cpukit/score/cpu/powerpc/preinstall.am
Generating ./cpukit/score/cpu/sh/preinstall.am
Generating ./cpukit/score/cpu/sparc/preinstall.am
Generating ./cpukit/score/cpu/sparc64/preinstall.am
Generating ./cpukit/score/cpu/v850/preinstall.am
Generating ./cpukit/score/preinstall.am
Generating ./cpukit/telnetd/preinstall.am
Generating ./cpukit/wrapup/preinstall.am
Generating ./cpukit/zlib/preinstall.am
/c/opt/rtems/kernel/rtems
Finally we run the RSB’s parallel bootstrap
command:
$ /c/opt/rtems/rsb/source-builder/sb-bootstrap
RTEMS Source Builder - RTEMS Bootstrap, 4.11 (76188ee494dd)
1/139: autoreconf: configure.ac
2/139: autoreconf: c/configure.ac
3/139: autoreconf: c/src/configure.ac
4/139: autoreconf: c/src/ada-tests/configure.ac
5/139: autoreconf: c/src/lib/libbsp/arm/configure.ac
6/139: autoreconf: c/src/lib/libbsp/arm/altera-cyclone-v/configure.ac
7/139: autoreconf: c/src/lib/libbsp/arm/atsam/configure.ac
8/139: autoreconf: c/src/lib/libbsp/arm/beagle/configure.ac
9/139: autoreconf: c/src/lib/libbsp/arm/csb336/configure.ac
10/139: autoreconf: c/src/lib/libbsp/arm/csb337/configure.ac
11/139: autoreconf: c/src/lib/libbsp/arm/edb7312/configure.ac
.......
129/139: autoreconf: testsuites/samples/configure.ac
130/139: autoreconf: testsuites/smptests/configure.ac
131/139: autoreconf: testsuites/sptests/configure.ac
132/139: autoreconf: testsuites/tmtests/configure.ac
133/139: autoreconf: testsuites/tools/configure.ac
134/139: autoreconf: testsuites/tools/generic/configure.ac
135/139: autoreconf: tools/build/configure.ac
136/139: autoreconf: tools/cpu/configure.ac
137/139: autoreconf: tools/cpu/generic/configure.ac
138/139: autoreconf: tools/cpu/nios2/configure.ac
139/139: autoreconf: tools/cpu/sh/configure.ac
Bootstrap time: 0:20:38.759766
/c/opt/rtems/kernel/rtems
$
We will build the RTEMS kernel for the i386
target and the pc686
BSP. You can check the available BSPs by running the rtems-bsps
command found in the top directory of the RTEMS kernel source. We build the Board Support Package (BSP) outside the kernel source tree:
/c/opt/rtems/kernel/rtems
$ cd ..
/c/opt/rtems/kernel
$ mkdir pc686
/c/opt/rtems/kernel
$ cd pc686
/c/opt/rtems/kernel/pc686
$
Configure the RTEMS kernel to build pc686
BSP for the i386
target with networking disabled, We will build the external libBSD stack later:
/c/opt/rtems/kernel/pc686
$ /c/opt/rtems/kernel/rtems/configure --prefix=/c/opt/rtems/4.11 \
--target=i386-rtems4.11 --disable-networking --enable-rtemsbsp=pc686
checking for gmake... no
checking for make... make
checking for RTEMS Version... 4.11.99.0
checking build system type... x86_64-pc-mingw64
checking host system type... x86_64-pc-mingw64
checking target system type... i386-pc-rtems4.11
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking that generated files are newer than configure... done
configure: creating ./config.status
configure: configuring in ./tools/build
.......
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
target architecture: i386.
available BSPs: pc686.
'make all' will build the following BSPs: pc686.
other BSPs can be built with 'make RTEMS_BSP="bsp1 bsp2 ..."'
config.status: creating Makefile
/c/opt/rtems/kernel/pc686
$
Build the kernel:
/c/opt/rtems/kernel/pc686
$ make
Making all in tools/build
make[1]: Entering directory '/c/opt/rtems/kernel/pc686/tools/build'
make all-am
make[2]: Entering directory '/c/opt/rtems/kernel/pc686/tools/build'
gcc -DHAVE_CONFIG_H -I. -I/c/opt/rtems/kernel/rtems/tools/build -g -O2 -MT
cklength.o -MD -MP -MF .deps/cklength.Tpo -c -o cklength.o
/c/opt/rtems/kernel/rtems/tools/build/cklength.c
gcc -DHAVE_CONFIG_H -I. -I/c/opt/rtems/kernel/rtems/tools/build -g -O2 -MT
eolstrip.o -MD -MP -MF .deps/eolstrip.Tpo -c -o eolstrip.o
/c/opt/rtems/kernel/rtems/tools/build/eolstrip.c
..........
i386-rtems4.11-objcopy -O binary nsecs.nxe nsecs.bin
../../../../../pc686/build-tools/bin2boot -v nsecs.ralf 0x00097E00
../../../../../pc686/lib/start16.bin 0x00097C00 0 nsecs.bin 0x00100000 0
header address 0x00097e00, its memory size 0xzx
first image address 0x00097c00, its memory size 0x00000200
second image address 0x00100000, its memory size 0x0003d800
rm -f nsecs.nxe
make[6]: Leaving directory '/c/opt/rtems/kernel/pc686/i386-rtems4.11/c/pc686/testsuites/samples/nsecs'
make[5]: Leaving directory '/c/opt/rtems/kernel/pc686/i386-rtems4.11/c/pc686/testsuites/samples'
make[4]: Leaving directory '/c/opt/rtems/kernel/pc686/i386-rtems4.11/c/pc686/testsuites/samples'
make[4]: Entering directory '/c/opt/rtems/kernel/pc686/i386-rtems4.11/c/pc686/testsuites'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/c/opt/rtems/kernel/pc686/i386-rtems4.11/c/pc686/testsuites'
make[3]: Leaving directory '/c/opt/rtems/kernel/pc686/i386-rtems4.11/c/pc686/testsuites'
make[2]: Leaving directory '/c/opt/rtems/kernel/pc686/i386-rtems4.11/c/pc686'
make[1]: Leaving directory '/c/opt/rtems/kernel/pc686/i386-rtems4.11/c'
make[1]: Entering directory '/c/opt/rtems/kernel/pc686'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/c/opt/rtems/kernel/pc686'
/c/opt/rtems/kernel/pc696
$
Install the kernel to our prefix:
$ make install
Making install in tools/build
make[1]: Entering directory '/c/opt/rtems/kernel/pc686/tools/build'
make[2]: Entering directory '/c/opt/rtems/kernel/pc686/tools/build'
/usr/bin/mkdir -p '/c/opt/rtems/4.11/bin'
/usr/bin/install -c cklength.exe eolstrip.exe packhex.exe unhex.exe
rtems-bin2c.exe '/c/opt/rtems/4.11/bin'
/usr/bin/mkdir -p '/c/opt/rtems/4.11/bin'
/usr/bin/install -c install-if-change '/c/opt/rtems/4.11/bin'
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/c/opt/rtems/kernel/pc686/tools/build'
make[1]: Leaving directory '/c/opt/rtems/kernel/pc686/tools/build'
Making install in tools/cpu
make[1]: Entering directory '/c/opt/rtems/kernel/pc686/tools/cpu'
Making install in generic
make[2]: Entering directory '/c/opt/rtems/kernel/pc686/tools/cpu/generic'
make[3]: Entering directory '/c/opt/rtems/kernel/pc686/tools/cpu/generic'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/c/opt/rtems/kernel/pc686/tools/cpu/generic'
make[2]: Leaving directory '/c/opt/rtems/kernel/pc686/tools/cpu/generic'
make[2]: Entering directory '/c/opt/rtems/kernel/pc686/tools/cpu'
make[3]: Entering directory '/c/opt/rtems/kernel/pc686/tools/cpu'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
..........
make[2]: Entering directory '/c/opt/rtems/kernel/pc686'
make[2]: Nothing to be done for 'install-exec-am'.
/usr/bin/mkdir -p '/c/opt/rtems/4.11/make'
/usr/bin/install -c -m 644 /c/opt/rtems/kernel/rtems/make/main.cfg
/c/opt/rtems/kernel/rtems/make/leaf.cfg '/c/opt/rtems/4.11/make'
/usr/bin/mkdir -p '/c/opt/rtems/4.11/share/rtems4.11/make/Templates'
/usr/bin/install -c -m 644
/c/opt/rtems/kernel/rtems/make/Templates/Makefile.dir
/c/opt/rtems/kernel/rtems/make/Templates/Makefile.leaf
/c/opt/rtems/kernel/rtems/make/Templates/Makefile.lib
'/c/opt/rtems/4.11/share/rtems4.11/make/Templates'
/usr/bin/mkdir -p '/c/opt/rtems/4.11/make/custom'
/usr/bin/install -c -m 644 /c/opt/rtems/kernel/rtems/make/custom/default.cfg
'/c/opt/rtems/4.11/make/custom'
make[2]: Leaving directory '/c/opt/rtems/kernel/pc686'
make[1]: Leaving directory '/c/opt/rtems/kernel/pc686'
/c/opt/rtems/kernel/pc686
$
5.3. RTEMS Kernel¶
RTEMS is an open source real-time operating system. As a user you have access to all the source code. The RTEMS Kernel
section will show you how you build the RTEMS kernel on your host.
5.3.1. Development Sources¶
Create a new location to build the RTEMS kernel:
$ cd
$ cd development/rtems
$ mkdir kernel
$ cd kernel
Clone the RTEMS respository:
$ git clone git://git.rtems.org/rtems.git rtems
Cloning into 'rtems'...
remote: Counting objects: 483342, done.
remote: Compressing objects: 100% (88974/88974), done.
remote: Total 483342 (delta 390053), reused 475669 (delta 383809)
Receiving objects: 100% (483342/483342), 69.88 MiB | 1.37 MiB/s, done.
Resolving deltas: 100% (390053/390053), done.
Checking connectivity... done.
5.3.2. Tools Path Set Up¶
We need to set our path to include the RTEMS tools we built in the previous section. The RTEMS tools needs to be first in your path because RTEMS provides specific versions of the autoconf
and automake
tools. We want to use the RTEMS version and not your host’s versions:
$ export PATH=$HOME/development/rtems/5/bin:$PATH
5.3.3. Bootstrapping¶
The developers version of the code from git requires we bootstrap
the source code. This is an autoconf
and automake
bootstrap to create the various files generated by autoconf
and automake
. RTEMS does not keep these generated files under version control. The bootstrap process is slow so to speed it up the RSB provides a command that can perform the bootstrap in parallel using your available cores. We need to enter the cloned source directory then run the bootstrap commands:
$ cd rtems
$ ./bootstrap -c && $HOME/development/rtems/rsb/source-builder/sb-bootstrap
removing automake generated Makefile.in files
removing configure files
removing aclocal.m4 files
RTEMS Source Builder - RTEMS Bootstrap, 5 (089327b5dcf9)
1/139: autoreconf: configure.ac
2/139: autoreconf: cpukit/configure.ac
3/139: autoreconf: tools/cpu/configure.ac
4/139: autoreconf: tools/cpu/generic/configure.ac
5/139: autoreconf: tools/cpu/sh/configure.ac
6/139: autoreconf: tools/cpu/nios2/configure.ac
7/139: autoreconf: tools/build/configure.ac
8/139: autoreconf: doc/configure.ac
......
124/139: autoreconf: c/src/make/configure.ac
125/139: autoreconf: c/src/librtems++/configure.ac
126/139: autoreconf: c/src/ada-tests/configure.ac
127/139: autoreconf: testsuites/configure.ac
128/139: autoreconf: testsuites/libtests/configure.ac
129/139: autoreconf: testsuites/mptests/configure.ac
130/139: autoreconf: testsuites/fstests/configure.ac
131/139: autoreconf: testsuites/sptests/configure.ac
132/139: autoreconf: testsuites/tmtests/configure.ac
133/139: autoreconf: testsuites/smptests/configure.ac
134/139: autoreconf: testsuites/tools/configure.ac
135/139: autoreconf: testsuites/tools/generic/configure.ac
136/139: autoreconf: testsuites/psxtests/configure.ac
137/139: autoreconf: testsuites/psxtmtests/configure.ac
138/139: autoreconf: testsuites/rhealstone/configure.ac
139/139: autoreconf: testsuites/samples/configure.ac
Bootstrap time: 0:02:47.398824
5.3.4. Building a BSP¶
We build RTEMS in a directory outside of the source tree we have just cloned and bootstrapped
. You cannot build RTEMS while in the source tree. Lets create a suitable directory using the name of the BSP we are going to build:
$ cd ..
$ mkdir erc32
$ cd erc32
Configure RTEMS using the configure
command. We use a full path to configure
so the object files built contain the absolute path of the source files. If you are source level debugging you will be able to access the source code to RTEMS from the debugger. We will build for the erc32
BSP with POSIX enabled and the networking stack disabled:
$ $HOME/development/rtems/kernel/rtems/configure --prefix=$HOME/development/rtems/5 \
--target=sparc-rtems5 --enable-rtemsbsp=erc32 --enable-posix \
--disable-networking
checking for gmake... no
checking for make... make
checking for RTEMS Version... 4.11.99.0
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... sparc-unknown-rtems5
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking that generated files are newer than configure... done
......
checking target system type... sparc-unknown-rtems5
checking rtems target cpu... sparc
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for sparc-rtems5-strip... sparc-rtems5-strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether to enable maintainer-specific portions of Makefiles... no
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
target architecture: sparc.
available BSPs: erc32.
'make all' will build the following BSPs: erc32.
other BSPs can be built with 'make RTEMS_BSP="bsp1 bsp2 ..."'
config.status: creating Makefile
Build RTEMS using two cores:
$ make -j 2
Making all in tools/build
make[1]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/build'
make all-am
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/build'
gcc -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/tools/build -g -O2 -MT cklength.o -MD -MP -MF .deps/cklength.Tpo -c -o cklength.o /home/chris/development/rtems/kernel/rtems/tools/build/cklength.c
gcc -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/tools/build -g -O2 -MT eolstrip.o -MD -MP -MF .deps/eolstrip.Tpo -c -o eolstrip.o /home/chris/development/rtems/kernel/rtems/tools/build/eolstrip.c
mv -f .deps/cklength.Tpo .deps/cklength.Po
mv -f .deps/eolstrip.Tpo .deps/eolstrip.Po
gcc -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/tools/build -g -O2 -MT compat.o -MD -MP -MF .deps/compat.Tpo -c -o compat.o /home/chris/development/rtems/kernel/rtems/tools/build/compat.c
gcc -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/tools/build -g -O2 -MT packhex.o -MD -MP -MF .deps/packhex.Tpo -c -o packhex.o /home/chris/development/rtems/kernel/rtems/tools/build/packhex.c
mv -f .deps/compat.Tpo .deps/compat.Po
gcc -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/tools/build -g -O2 -MT unhex.o -MD -MP -MF .deps/unhex.Tpo -c -o unhex.o /home/chris/development/rtems/kernel/rtems/tools/build/unhex.c
mv -f .deps/packhex.Tpo .deps/packhex.Po
gcc -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/tools/build -g -O2 -MT rtems-bin2c.o -MD -MP -MF .deps/rtems-bin2c.Tpo -c -o rtems-bin2c.o /home/chris/development/rtems/kernel/rtems/tools/build/rtems-bin2c.c
mv -f .deps/unhex.Tpo .deps/unhex.Po
gcc -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/tools/build -g -O2 -MT binpatch.o -MD -MP -MF .deps/binpatch.Tpo -c -o binpatch.o /home/chris/development/rtems/kernel/rtems/tools/build/binpatch.c
mv -f .deps/rtems-bin2c.Tpo .deps/rtems-bin2c.Po
gcc -g -O2 -o cklength cklength.o
mv -f .deps/binpatch.Tpo .deps/binpatch.Po
gcc -g -O2 -o eolstrip eolstrip.o compat.o
gcc -g -O2 -o packhex packhex.o
gcc -g -O2 -o rtems-bin2c rtems-bin2c.o compat.o
gcc -g -O2 -o unhex unhex.o compat.o
gcc -g -O2 -o binpatch binpatch.o
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/build'
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/build'
Making all in tools/cpu
make[1]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
Making all in generic
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/cpu/generic'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/cpu/generic'
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
Making all in testsuites/tools
make[1]: Entering directory '/home/chris/development/rtems/kernel/erc32/testsuites/tools'
Making all in generic
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/testsuites/tools/generic'
make[2]: Nothing to be done for 'all'.
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/testsuites/tools/generic'
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/testsuites/tools'
make[2]: Nothing to be done for 'all-am'.
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/testsuites/tools'
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32/testsuites/tools'
Making all in sparc-rtems5/c
make[1]: Entering directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/c'
Making all in .
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/c'
Configuring RTEMS_BSP=erc32
checking for gmake... no
checking for make... make
checking build system type... x86_64-pc-linux-gnu
checking host system type... sparc-unknown-rtems5
......
sparc-rtems5-gcc -B../../../../../erc32/lib/ -specs bsp_specs -qrtems -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/c/src/../../testsuites/samples/nsecs -I.. -I/home/chris/development/rtems/kernel/rtems/c/src/../../testsuites/samples/../support/include -mcpu=cypress -O2 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -MT init.o -MD -MP -MF .deps/init.Tpo -c -o init.o /home/chris/development/rtems/kernel/rtems/c/src/../../testsuites/samples/nsecs/init.c
sparc-rtems5-gcc -B../../../../../erc32/lib/ -specs bsp_specs -qrtems -DHAVE_CONFIG_H -I. -I/home/chris/development/rtems/kernel/rtems/c/src/../../testsuites/samples/nsecs -I.. -I/home/chris/development/rtems/kernel/rtems/c/src/../../testsuites/samples/../support/include -mcpu=cypress -O2 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -MT empty.o -MD -MP -MF .deps/empty.Tpo -c -o empty.o /home/chris/development/rtems/kernel/rtems/c/src/../../testsuites/samples/nsecs/empty.c
mv -f .deps/empty.Tpo .deps/empty.Po
mv -f .deps/init.Tpo .deps/init.Po
sparc-rtems5-gcc -B../../../../../erc32/lib/ -specs bsp_specs -qrtems -mcpu=cypress -O2 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -Wl,--gc-sections -mcpu=cypress -o nsecs.exe init.o empty.o
sparc-rtems5-nm -g -n nsecs.exe > nsecs.num
sparc-rtems5-size nsecs.exe
text data bss dec hex filename
121392 1888 6624 129904 1fb70 nsecs.exe
cp nsecs.exe nsecs.ralf
make[6]: Leaving directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/ c/erc32/testsuites/samples/nsecs'
make[5]: Leaving directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/ c/erc32/testsuites/samples'
make[4]: Leaving directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/ c/erc32/testsuites/samples'
make[4]: Entering directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/ c/erc32/testsuites'
make[4]: Nothing to be done for 'all-am'.
make[4]: Leaving directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/ c/erc32/testsuites'
make[3]: Leaving directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/ c/erc32/testsuites'
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/ c/erc32'
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/c'
make[1]: Entering directory '/home/chris/development/rtems/kernel/erc32'
make[1]: Nothing to be done for 'all-am'.
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32'
5.3.5. Installing A BSP¶
All that remains to be done is to install the kernel. Installing RTEMS copies the API headers and architecture specific libraries to a locaiton under the prefix you provide. You can install any number of BSPs under the same prefix. We recommend you have a separate prefix for different versions of RTEMS. Do not mix versions of RTEMS under the same prefix. Make installs RTEMS with the following command:
$ make install
Making install in tools/build
make[1]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/build'
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/build'
/bin/mkdir -p '/home/chris/development/rtems/5/bin'
/usr/bin/install -c cklength eolstrip packhex unhex rtems-bin2c '/home/chris/development/rtems/5/bin'
/bin/mkdir -p '/home/chris/development/rtems/5/bin'
/usr/bin/install -c install-if-change '/home/chris/development/rtems/5/bin'
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/build'
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/build'
Making install in tools/cpu
make[1]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
Making install in generic
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/cpu/generic'
make[3]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/cpu/generic'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/cpu/generic'
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/cpu/generic'
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
make[3]: Entering directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
make[3]: Nothing to be done for 'install-exec-am'.
make[3]: Nothing to be done for 'install-data-am'.
make[3]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32/tools/cpu'
....
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32/sparc-rtems5/c'
make[1]: Entering directory '/home/chris/development/rtems/kernel/erc32'
make[2]: Entering directory '/home/chris/development/rtems/kernel/erc32'
make[2]: Nothing to be done for 'install-exec-am'.
/bin/mkdir -p '/home/chris/development/rtems/5/make'
/usr/bin/install -c -m 644 /home/chris/development/rtems/kernel/rtems/make/main.cfg /home/chris/development/rtems/kernel/rtems/make/leaf.cfg '/home/chris/development/rtems/5/make'
/bin/mkdir -p '/home/chris/development/rtems/5/share/rtems5/make/Templates'
/usr/bin/install -c -m 644 /home/chris/development/rtems/kernel/rtems/make/Templates/Makefile.dir /home/chris/development/rtems/kernel/rtems/make/Templates/Makefile.leaf /home/chris/development/rtems/kernel/rtems/make/Templates/Makefile.lib '/home/chris/development/rtems/5/share/rtems5/make/Templates'
/bin/mkdir -p '/home/chris/development/rtems/5/make/custom'
/usr/bin/install -c -m 644 /home/chris/development/rtems/kernel/rtems/make/custom/default.cfg '/home/chris/development/rtems/5/make/custom'
make[2]: Leaving directory '/home/chris/development/rtems/kernel/erc32'
make[1]: Leaving directory '/home/chris/development/rtems/kernel/erc32'
5.3.6. Contributing Patches¶
RTEMS welcomes fixes to bugs and new features. The RTEMS Project likes to have bugs fixed against a ticket created on our Developer Site. Please raise a ticket if you have a bug. Any changes that are made can be tracked against the ticket. If you want to add a new a feature please post a message to Developers Mailing List describing what you would like to implement. The RTEMS maintainer will help decide if the feature is in the best interest of the project. Not everything is and the maintainers need to evalulate how much effort it is to maintain the feature. Once accepted into the source tree it becomes the responsibility of the maintainers to keep the feature updated and working.
Changes to the source tree are tracked using git. If you have not made changes and enter the source tree and enter a git status command you will see nothing has changed:
$ cd ../rtems
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
We will make a change to the source code. In this example I change the help message to the RTEMS shell’s halt
command. Running the same git status command reports:
$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: cpukit/libmisc/shell/main_halt.c
no changes added to commit (use "git add" and/or "git commit -a")
As an example I have a ticket open and the ticket number is 9876. I commit the change with the follow git command:
$ git commit cpukit/libmisc/shell/main_halt.c
An editor is opened and I enter my commit message. The first line is a title and the following lines form a body. My message is:
shell: Add more help detail to the halt command.
Closes #9876.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Explicit paths specified without -i or -o; assuming --only paths...
#
# Committer: Chris Johns <chrisj@rtems.org>
#
# On branch master
# Your branch is up-to-date with 'origin/master'.
#
# Changes to be committed:
# modified: cpukit/libmisc/shell/main_halt.c
When you save and exit the editor git will report the commit’s status:
$ git commit cpukit/libmisc/shell/main_halt.c
[master 9f44dc9] shell: Add more help detail to the halt command.
1 file changed, 1 insertion(+), 1 deletion(-)
You can either email the patch to Developers Mailing List with the following git command, and it is minus one on the command line:
$ git send-email --to=devel@rtems.org -1
<add output here>
Or you can ask git to create a patch file using:
$ git format-patch -1
0001-shell-Add-more-help-detail-to-the-halt-command.patch
This patch can be attached to a ticket.
5.4. 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-4.11.0
. Under this path you can follow the Releases procedure to build a tool set using the prefix of /bd/projects/box-sorter/rtems/4.11.0
. 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/4.11.0
- Project prefix for RTEMS 4.11.0 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/4.11.0
- Production prefix for RTEMS 4.11.0 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/4.11.0
- Production prefix for RTEMS 4.11.0.
/bd/rtems/4.11.0/tools
- Production prefix for RTEMS 4.11.0 compiler, debuggers and tools.
/bd/rtems/4.11.0/bsps
- Production prefix for RTEMS 4.11.0 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/4.11.0
- Production prefix for RTEMS 4.11.0 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.
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 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 it’s tier status.
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 current tier level.
Changes to RTEMS may result in a BSP not meeting it’s tier are acceptable if the change is accompanied by an announcement and a plan on how this is to be resolved.
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 to reach tier 1.
7. 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
7.1. aarch64 (AArch64)¶
There are no AArch64 BSPs yet.
7.2. arm (ARM)¶
7.2.1. altera-cyclone-v (Intel Cyclone V)¶
This BSP offers only one variant, the altcycv_devkit. This variant supports the Intel Cyclone V system on chip. The basic hardware initialization is not performed by the BSP. A boot loader with device tree support must be used to start the BSP, e.g. U-Boot.
The BSP is known to run on these boards:
7.2.1.1. Boot via U-Boot¶
The application executable file (ELF file) must be converted to an U-Boot image. Use the following commands:
arm-rtems5-objcopy -O binary app.exe app.bin
gzip -9 -f -c app.bin > app.bin.gz
mkimage -A arm -O linux -T kernel -a 0x00300000 -e 0x00300000 -n RTEMS -d app.bin.gz app.img
Use the following U-Boot commands to boot an application via TFTP download:
tftpboot ${loadaddr} app.img && run loadfdt && bootm ${loadaddr} - ${fdt_addr} ; reset
The loadfdt
command may be not defined in your U-Boot environment. Just replace it with the appropriate commands to load the device tree at ${fdt_addr}
.
7.2.1.2. Clock Driver¶
The clock driver uses the Cortex-A9 MPCore Global Timer.
7.2.1.3. Console Driver¶
The console driver supports up to two on-chip NS16550 UARTs. The console driver does not configure the pins.
7.2.1.4. I2C Driver¶
There is a legacy I2C driver. It should be converted to the I2C driver framework.
7.2.1.5. Network Interface Driver¶
The network interface driver is provided by the libbsd. It is initialized according to the device tree. It supports checksum offload.
7.2.1.6. MMC/SDCard Driver¶
The MMC/SDCard driver is provided by the libbsd. It is initialized according to the device tree. Pin re-configuration according to the serial clock frequency is not supported. DMA transfers are supported.
7.2.1.7. USB Host Driver¶
The USB host driver is provided by the libbsd. It is initialized according to the device tree. The driver works in polled mode.
7.2.1.8. Caveats¶
The clock and pin configuration support is quite rudimentary and mostly relies on the boot loader.
7.2.2. atsam¶
TODO.
7.2.3. beagle¶
This BSP supports four variants, beagleboardorig, beagleboardxm, beaglebonewhite and beagleboneblack. The basic hardware initialization is not performed by the BSP. A boot loader with device tree support must be used to start the BSP, e.g., U-Boot.
TODO(These drivers are present but not documented yet):
- Clock driver.
- Network Interface Driver.
- SDcard driver.
- GPIO Driver.
- Console driver.
- PWM Driver.
- RTC driver.
7.2.3.1. Boot via U-Boot¶
To boot via uboot, the ELF must be converted to a U-Boot image like below:
arm-rtems5-objcopy hello.exe -O binary app.bin
gzip -9 app.bin
mkimage -A arm -O linux -T kernel -a 0x80000000 -e 0x80000000 -n RTEMS -d app.bin.gz rtems-app.img
7.2.3.2. Getting the Device Tree Blob¶
The Device Tree Blob (DTB) is needed to load the device tree while starting up the kernel. We build the dtb from the FreeBSD source matching the commit hash from the libbsd HEAD of freebsd-org. For example if the HEAD is at “19a6ceb89dbacf74697d493e48c388767126d418” Then the right Device Tree Source (DTS) file is: https://github.com/freebsd/freebsd/blob/19a6ceb89dbacf74697d493e48c388767126d418/sys/gnu/dts/arm/am335x-boneblack.dts
Please refer to the Device Tree to know more about building and applying the Device Trees.
7.2.3.3. Writing the uEnv.txt file¶
The uEnv.txt file is needed to set any environment variable before the kernel is loaded. Each line is a u-boot command that the uboot will execute during start up.
Add the following to a file named uEnv.txt:
setenv bootdelay 5
uenvcmd=run boot
boot=fatload mmc 0 0x80800000 rtems-app.img ; fatload mmc 0 0x88000000 am335x-boneblack.dtb ; bootm 0x80800000 - 0x88000000
7.2.3.4. I2C Driver¶
The Beagle has the i2c-0 device registered at initialization. For registering i2c-1 and i2c-2 bbb_register_i2c_1()
and bbb_register_i2c_2()
wrapper functions are respectively used.
For registering an I2C device with a custom path (say /dev/i2c-3) the function am335x_i2c_bus_register()
has to be used.
The function prototype is given below:
int am335x_i2c_bus_register(
const char *bus_path,
uintptr_t register_base,
uint32_t input_clock,
rtems_vector_number irq
);
7.2.3.5. SPI Driver¶
The SPI device /dev/spi-0 can be registered with bbb_register_spi_0()
For registering with a custom path, the bsp_register_spi()
can be used.
The function prototype is given below:
rtems_status_code bsp_register_spi(
const char *bus_path,
uintptr_t register_base,
rtems_vector_number irq
);
7.2.4. csb336¶
TODO.
7.2.5. edb7312¶
TODO.
7.2.6. gdbarmsim¶
TODO.
7.2.7. gumstix¶
TODO.
7.2.8. imx (NXP i.MX)¶
This BSP offers only one variant, the imx7. This variant supports the i.MX 7Dual processor. The basic hardware initialization is not performed by the BSP. A boot loader with device tree support must be used to start the BSP, e.g. U-Boot.
7.2.8.1. Build Configuration Options¶
The following options are available at the configure command line.
BSP_PRESS_KEY_FOR_RESET
- If defined to a non-zero value, then print a message and wait until pressed before resetting board when application terminates.
BSP_RESET_BOARD_AT_EXIT
- If defined to a non-zero value, then reset the board when the application terminates.
BSP_PRINT_EXCEPTION_CONTEXT
- If defined to a non-zero value, then print the exception context when an unexpected exception occurs.
BSP_FDT_BLOB_SIZE_MAX
- The maximum size of the device tree blob in bytes (default is 262144).
CONSOLE_USE_INTERRUPTS
- Use interrupt driven mode for console devices (enabled by default).
IMX_CCM_IPG_HZ
- The IPG clock frequency in Hz (default is 67500000).
IMX_CCM_UART_HZ
- The UART clock frequency in Hz (default is 24000000).
IMX_CCM_AHB_HZ
- The AHB clock frequency in Hz (default is 135000000).
7.2.8.2. Boot via U-Boot¶
The application executable file (ELF file) must be converted to an U-Boot image. Use the following commands:
arm-rtems5-objcopy -O binary app.exe app.bin
gzip -9 -f -c app.bin > app.bin.gz
mkimage -A arm -O linux -T kernel -a 0x80200000 -e 0x80200000 -n RTEMS -d app.bin.gz app.img
Use the following U-Boot commands to boot an application via TFTP download:
tftpboot ${loadaddr} app.img && run loadfdt && bootm ${loadaddr} - ${fdt_addr} ; reset
The loadfdt
command may be not defined in your U-Boot environment. Just replace it with the appropriate commands to load the device tree at ${fdt_addr}
.
7.2.8.3. Clock Driver¶
The clock driver uses the ARMv7-AR Generic Timer.
7.2.8.4. Console Driver¶
The console driver supports up to seven on-chip UARTs. They are initialized according to the device tree. The console driver does not configure the pins.
7.2.8.5. I2C Driver¶
I2C drivers are registered by the i2c_bus_register_imx()
function. The I2C driver does not configure the pins.
#include <assert.h>
#include <bsp.h>
void i2c_init(void)
{
int rv;
rv = i2c_bus_register_imx("/dev/i2c-0", "i2c0");
assert(rv == 0);
}
7.2.8.6. SPI Driver¶
SPI drivers are registered by the spi_bus_register_imx()
function. The SPI driver configures the pins according to the pinctrl-0
device tree property. SPI transfers with a continuous chip select are limited by the FIFO size of 64 bytes. The driver has no DMA support.
#include <assert.h>
#include <bsp.h>
void spi_init(void)
{
int rv;
rv = spi_bus_register_imx("/dev/spi-0", "spi0");
assert(rv == 0);
}
7.2.8.7. Network Interface Driver¶
The network interface driver is provided by the libbsd. It is initialized according to the device tree. It supports checksum offload and interrupt coalescing. IPv6 transmit checksum offload is not implemented. The interrupt coalescing uses the MII/GMII clocks and can be controlled by the following system controls:
dev.ffec.<unit>.int_coal.rx_time
dev.ffec.<unit>.int_coal.rx_count
dev.ffec.<unit>.int_coal.tx_time
dev.ffec.<unit>.int_coal.tx_count
A value of zero for the time or count disables the interrupt coalescing in the corresponding direction.
7.2.8.8. MMC/SDCard Driver¶
The MMC/SDCard driver (uSDHC module) is provided by the libbsd. It is initialized according to the device tree. Pin re-configuration according to the serial clock frequency is not supported. Data transfers are extremely slow. This is probably due to the missing DMA support.
7.2.8.9. Caveats¶
The clock and pin configuration support is quite rudimentary and mostly relies on the boot loader. For a pin group configuration see imx_iomux_configure_pins()
. There is no power management support.
7.2.9. lm3s69xx¶
TODO.
7.2.10. lpc176x¶
TODO.
7.2.11. imx (NXP i.MX)¶
This BSP offers only one variant, the imx7. This variant supports the i.MX 7Dual processor. The basic hardware initialization is not performed by the BSP. A boot loader with device tree support must be used to start the BSP, e.g. U-Boot.
7.2.11.1. Build Configuration Options¶
The following options are available at the configure command line.
BSP_PRESS_KEY_FOR_RESET
- If defined to a non-zero value, then print a message and wait until pressed before resetting board when application terminates.
BSP_RESET_BOARD_AT_EXIT
- If defined to a non-zero value, then reset the board when the application terminates.
BSP_PRINT_EXCEPTION_CONTEXT
- If defined to a non-zero value, then print the exception context when an unexpected exception occurs.
BSP_FDT_BLOB_SIZE_MAX
- The maximum size of the device tree blob in bytes (default is 262144).
CONSOLE_USE_INTERRUPTS
- Use interrupt driven mode for console devices (enabled by default).
IMX_CCM_IPG_HZ
- The IPG clock frequency in Hz (default is 67500000).
IMX_CCM_UART_HZ
- The UART clock frequency in Hz (default is 24000000).
IMX_CCM_AHB_HZ
- The AHB clock frequency in Hz (default is 135000000).
7.2.11.2. Boot via U-Boot¶
The application executable file (ELF file) must be converted to an U-Boot image. Use the following commands:
arm-rtems5-objcopy -O binary app.exe app.bin
gzip -9 -f -c app.bin > app.bin.gz
mkimage -A arm -O linux -T kernel -a 0x80200000 -e 0x80200000 -n RTEMS -d app.bin.gz app.img
Use the following U-Boot commands to boot an application via TFTP download:
tftpboot ${loadaddr} app.img && run loadfdt && bootm ${loadaddr} - ${fdt_addr} ; reset
The loadfdt
command may be not defined in your U-Boot environment. Just replace it with the appropriate commands to load the device tree at ${fdt_addr}
.
7.2.11.3. Clock Driver¶
The clock driver uses the ARMv7-AR Generic Timer.
7.2.11.4. Console Driver¶
The console driver supports up to seven on-chip UARTs. They are initialized according to the device tree. The console driver does not configure the pins.
7.2.11.5. I2C Driver¶
I2C drivers are registered by the i2c_bus_register_imx()
function. The I2C driver does not configure the pins.
#include <assert.h>
#include <bsp.h>
void i2c_init(void)
{
int rv;
rv = i2c_bus_register_imx("/dev/i2c-0", "i2c0");
assert(rv == 0);
}
7.2.11.6. SPI Driver¶
SPI drivers are registered by the spi_bus_register_imx()
function. The SPI driver configures the pins according to the pinctrl-0
device tree property. SPI transfers with a continuous chip select are limited by the FIFO size of 64 bytes. The driver has no DMA support.
#include <assert.h>
#include <bsp.h>
void spi_init(void)
{
int rv;
rv = spi_bus_register_imx("/dev/spi-0", "spi0");
assert(rv == 0);
}
7.2.11.7. Network Interface Driver¶
The network interface driver is provided by the libbsd. It is initialized according to the device tree. It supports checksum offload and interrupt coalescing. IPv6 transmit checksum offload is not implemented. The interrupt coalescing uses the MII/GMII clocks and can be controlled by the following system controls:
dev.ffec.<unit>.int_coal.rx_time
dev.ffec.<unit>.int_coal.rx_count
dev.ffec.<unit>.int_coal.tx_time
dev.ffec.<unit>.int_coal.tx_count
A value of zero for the time or count disables the interrupt coalescing in the corresponding direction.
7.2.11.8. MMC/SDCard Driver¶
The MMC/SDCard driver (uSDHC module) is provided by the libbsd. It is initialized according to the device tree. Pin re-configuration according to the serial clock frequency is not supported. Data transfers are extremely slow. This is probably due to the missing DMA support.
7.2.11.9. Caveats¶
The clock and pin configuration support is quite rudimentary and mostly relies on the boot loader. For a pin group configuration see imx_iomux_configure_pins()
. There is no power management support.
7.2.12. raspberrypi¶
TODO.
7.2.13. realview-pbx-a9¶
TODO.
7.2.14. rtl22xx¶
TODO.
7.2.15. smdk2410¶
TODO.
7.2.16. tms570¶
TODO.
7.2.17. xilinx-zynq¶
TODO.
7.7. m68k (Motorola 68000 / ColdFire)¶
7.7.1. av5282¶
TODO.
7.7.2. csb360¶
TODO.
7.7.3. gen68340¶
TODO.
7.7.4. gen68360¶
TODO.
7.7.5. genmcf548x¶
TODO.
7.7.6. mcf5206elite¶
TODO.
7.7.7. mcf52235¶
TODO.
7.7.8. mcf5225x¶
TODO.
7.7.9. mcf5235¶
TODO.
7.7.10. mcf5329¶
TODO.
7.7.11. mrm332¶
TODO.
7.7.12. mvme147¶
TODO.
7.7.13. mvme147s¶
TODO.
7.7.14. mvme162¶
TODO.
7.7.15. mvme167¶
TODO.
7.7.16. uC5282¶
TODO.
7.8. microblaze (Microblaze)¶
There are no Microblaze BSPs yet.
7.9. mips (MIPS)¶
7.9.1. csb350¶
TODO.
7.9.2. hurricane¶
TODO.
7.9.3. jmr3904¶
TODO.
7.9.4. malta¶
TODO.
7.9.5. rbtx4925¶
TODO.
7.9.6. rbtx4938¶
TODO.
7.13. powerpc (PowerPC)¶
7.13.1. beatnik¶
TODO.
7.13.2. gen5200¶
TODO.
7.13.3. gen83xx¶
TODO.
7.13.4. haleakala¶
TODO.
7.13.5. motorola_powerpc¶
7.13.5.1. Boot Image Generation¶
The application executable file (ELF file) must be converted to a boot image. Use the following commands:
powerpc-rtems5-objcopy -O binary -R .comment -S ticker.exe rtems
gzip -9 -f rtems
powerpc-rtems5-ld -o ticker.boot bootloader.o --just-symbols=ticker.exe -b binary rtems.gz -T ppcboot.lds -no-warn-mismatch
powerpc-rtems5-objcopy -O binary ticker.boot ticker.bin
7.13.6. mpc55xxevb¶
TODO.
7.13.7. mpc8260ads¶
TODO.
7.13.8. mvme3100¶
TODO.
7.13.9. mvme5500¶
TODO.
7.13.10. psim¶
TODO.
7.13.11. qemuppc¶
TODO.
7.13.12. qoriq (QorIQ)¶
The BSP for the QorIQ chip family offers three variants. The qoriq_e500 variant supports the P-series chips such as P1020, P2010 and P2020. The qoriq_e6500_32 (32-bit ISA) and qoriq_e6500_64 (64-bit ISA) variants support the T-series chips such as T2080 and T4240. The basic hardware initialization is not performed by the BSP. A boot loader with device tree support must be used to start the BSP, e.g. U-Boot.
The BSP is known to run on these boards:
- NXP P1020RDB
- MicroSys miriac MPX2020 (System on Module)
- Artesyn MVME2500 (VME64x SBC)
- NXP T2080RDB
- NXP T4240RDB
- MEN G52A (CompactPCI Serial)
The qoriq_core_0 and qoriq_core_1 variants should be used with care. They are inteded for a RTEMS_MULTIPROCESSING configuration on the P1020.
7.13.12.1. Boot via U-Boot¶
The application executable file (ELF file) must be converted to an U-Boot image. Use the following commands:
powerpc-rtems5-objcopy -O binary app.exe app.bin
gzip -9 -f -c app.bin > app.bin.gz
mkimage -A ppc -O linux -T kernel -a 0x4000 -e 0x4000 -n RTEMS -d app.bin.gz app.img
Use the following U-Boot commands to boot an application via TFTP download:
tftpboot ${loadaddr} app.img && run loadfdt && bootm ${loadaddr} - ${fdt_addr} ; reset
7.13.12.2. Clock Driver¶
The clock driver uses two MPIC global timer (QORIQ_CLOCK_TIMER
and QORIQ_CLOCK_TIMECOUNTER
). In case QORIQ_IS_HYPERVISOR_GUEST
is defined, then the PowerPC decrementer is used.
7.13.12.3. Console Driver¶
The console driver supports the on-chip NS16550 compatible UARTs. In case QORIQ_IS_HYPERVISOR_GUEST
is defined, then the EPAPR byte channel is used for the console device.
7.13.12.4. Network Interface Driver¶
The network interface driver is provided by the libbsd. The DPAA is supported including 10Gbit/s Ethernet.
7.13.12.5. Topaz Hypervisor Guest¶
For a Topaz hypervisor guest configuration use:
../configure --enable-rtemsbsp=qoriq_e6500_32 \
QORIQ_IS_HYPERVISOR_GUEST=1 \
QORIQ_UART_0_ENABLE=0 \
QORIQ_UART_1_ENABLE=0 \
QORIQ_TLB1_ENTRY_COUNT=16
You may have to adjust the linker command file according to your partition configuration.
7.13.13. ss555¶
TODO.
7.13.14. t32mppc¶
TODO.
7.13.15. tqm8xx¶
TODO.
7.13.16. virtex¶
TODO.
7.13.17. virtex4¶
TODO.
7.13.18. virtex5¶
TODO.
7.14. riscv (RISC-V)¶
7.14.1. riscv¶
This BSP offers 13 variants:
- rv32i
- rv32iac
- rv32im
- rv32imac
- rv32imafc
- rv32imafd
- rv32imafdc
- rv64imac
- rv64imac_medany
- rv64imafd
- rv64imafd_medany
- rv64imafdc
- rv64imafdc_medany
Each variant corresponds to a GCC multilib. A particular variant reflects an ISA with ABI and code model choice.
The basic hardware initialization is not performed by the BSP. A boot loader with device tree support must be used to start the BSP, e.g. BBL. The BSP must be started im machine mode.
The reference platform for this BSP is the Qemu virt machine.
7.14.1.1. Build Configuration Options¶
The following options are available at the configure command line.
BSP_PRESS_KEY_FOR_RESET
- If defined to a non-zero value, then print a message and wait until pressed before resetting board when application terminates.
BSP_RESET_BOARD_AT_EXIT
- If defined to a non-zero value, then reset the board when the application terminates.
BSP_PRINT_EXCEPTION_CONTEXT
- If defined to a non-zero value, then print the exception context when an unexpected exception occurs.
BSP_FDT_BLOB_SIZE_MAX
- The maximum size of the device tree blob in bytes (default is 65536).
BSP_CONSOLE_BAUD
- The default baud for console driver devices (default 115200).
RISCV_MAXIMUM_EXTERNAL_INTERRUPTS
- The maximum number of external interrupts supported by the BSP (default 64).
RISCV_ENABLE_HTIF_SUPPORT
- Enables the HTIF support if defined to a non-zero value, otherwise it is disabled (disabled by default).
RISCV_CONSOLE_MAX_NS16550_DEVICES
- The maximum number of NS16550 devices supported by the console driver (2 by default).
RISCV_RAM_REGION_BEGIN
- The begin of the RAM region for linker command file (default is 0x70000000 for 64-bit with -mcmodel=medlow and 0x80000000 for all other).
RISCV_RAM_REGION_SIZE
- The size of the RAM region for linker command file (default 64MiB).
7.14.1.2. Interrupt Controller¶
Exactly one Core Local Interruptor (CLINT) and exactly one Platform-Level Interrupt Controller (PLIC) are supported. The maximum number of external interrupts supported by the BSP is defined by the RISCV_MAXIMUM_EXTERNAL_INTERRUPTS
BSP option.
7.14.1.3. Clock Driver¶
The clock driver uses the CLINT timer.
7.14.1.4. Console Driver¶
The console driver supports devices compatible to
- “ucb,htif0” (depending on the
RISCV_ENABLE_HTIF_SUPPORT
BSP option), - “ns16550a” (see
RISCV_CONSOLE_MAX_NS16550_DEVICES
BSP option), and - “ns16750” (see
RISCV_CONSOLE_MAX_NS16550_DEVICES
BSP option).
They are initialized according to the device tree. The console driver does not configure the pins or peripheral clocks. The console device is selected according to the device tree “/chosen/stdout-path” property value.
7.15. sh (SuperH)¶
7.15.1. gensh1¶
TODO.
7.15.2. gensh2¶
TODO.
7.15.3. gensh4¶
TODO.
7.15.4. shsim¶
TODO.
7.19. x86_64¶
7.19.1. amd64¶
This BSP offers only one variant, amd64
. The BSP can run on UEFI-capable systems by using FreeBSD’s bootloader, which then loads the RTEMS executable (an ELF image).
Currently only the console driver and context initialization and switching are functional (to a bare minimum), but this is enough to run the hello.exe
sample in the RTEMS testsuite.
7.19.1.1. Build Configuration Options¶
There are no options available to configure
at build time, at the moment.
7.19.1.2. Testing with QEMU¶
To test with QEMU, we need to:
- Build / install QEMU (most distributions should have it available on the package manager).
- Build UEFI firmware that QEMU can use to simulate an x86-64 system capable of booting a UEFI-aware kernel, through the
--bios
flag.
7.19.1.2.1. Building TianoCore’s UEFI firmware, OVMF¶
Complete detailed instructions are available at TianoCore’s Github’s wiki.
Quick instructions (which may fall out of date) are:
$ git clone git://github.com/tianocore/edk2.git
$ cd edk2
$ make -C BaseTools
$ . edksetup.sh
Then edit Conf/target.txt
to set:
ACTIVE_PLATFORM = OvmfPkg/OvmfPkgX64.dsc
TARGET = DEBUG
TARGET_ARCH = X64
# You can use GCC46 as well, if you'd prefer
TOOL_CHAIN_TAG = GCC5
Then run build
in the edk2
directory - the output should list the location of the OVMF.fd
file, which can be used with QEMU to boot into a UEFI shell.
You can find the OVMF.fd
file like this as well in the edk2 directory:
$ find . -name "*.fd"
./Build/OvmfX64/DEBUG_GCC5/FV/MEMFD.fd
./Build/OvmfX64/DEBUG_GCC5/FV/OVMF.fd # the file we're looking for
./Build/OvmfX64/DEBUG_GCC5/FV/OVMF_CODE.fd
./Build/OvmfX64/DEBUG_GCC5/FV/OVMF_VARS.fd
7.19.1.3. Boot RTEMS via FreeBSD’s bootloader¶
The RTEMS executable produced (an ELF file) needs to be placed in the FreeBSD’s /boot/kernel/kernel
’s place.
To do that, we first need a hard-disk image with FreeBSD installed on it. Download FreeBSD’s installer “memstick” image for amd64 and then run the following commands, replacing paths as appropriate.
$ qemu-img create freebsd.img 8G
$ OVMF_LOCATION=/path/to/ovmf/OVMF.fd
$ FREEBSD_MEMSTICK=/path/to/FreeBSD-11.2-amd64-memstick.img
$ qemu-system-x86_64 -m 1024 -serial stdio --bios $OVMF_LOCATION \
-drive format=raw,file=freebsd.img \
-drive format=raw,file=$FREEBSD_MEMSTICK
The first time you do this, continue through and install FreeBSD. FreeBSD’s installation guide may prove useful if required.
Once installed, build your RTEMS executable (an ELF file), for eg. hello.exe
. We need to transfer this executable into freebsd.img
’s filesystem, at either /boot/kernel/kernel
or /boot/kernel.old/kernel
(or elsewhere, if you don’t mind user FreeBSD’s loader
’s prompt to boot your custom kernel).
If your host system supports mounting UFS filesystems as read-write (eg. FreeBSD), go ahead and:
- Mount
freebsd.img
as read-write - Within the filesystem, back the existing FreeBSD kernel up (i.e. effectively
cp -r /boot/kernel /boot/kernel.old
). - Place your RTEMS executable at
/boot/kernel/kernel
If your host doesn’t support mounting UFS filesystems (eg. most Linux kernels), do something to the effect of the following.
On the host
# Upload hello.exe anywhere accessible within the host
$ curl --upload-file hello.exe https://transfer.sh/rtems
Then on the guest (FreeBSD), login with root
and
# Back the FreeBSD kernel up
$ cp -r /boot/kernel/ /boot/kernel.old
# Bring networking online if it isn't already
$ dhclient em0
# You may need to add the --no-verify-peer depending on your server
$ fetch https://host.com/path/to/rtems/hello.exe
# Replace default kernel
$ cp hello.exe /boot/kernel/kernel
$ reboot
After rebooting, the RTEMS kernel should run after the UEFI firmware and FreeBSD’s bootloader. The -serial stdio
QEMU flag will let the RTEMS console send its output to the host’s stdio
stream.
7.19.1.4. Paging¶
During the BSP’s initialization, the paging tables are setup to identity-map the first 512GiB, i.e. virtual addresses are the same as physical addresses for the first 512GiB.
The page structures are set up statically with 1GiB super-pages.
Note
Page-faults are not handled.
Warning
RAM size is not detected dynamically and defaults to 1GiB, if the configuration-time RamSize
parameter is not used.
7.19.1.5. Interrupt Setup¶
Interrupt vectors 0
through 32
(i.e. 33 interrupt vectors in total) are setup as “RTEMS interrupts”, which can be hooked through rtems_interrupt_handler_install
.
The Interrupt Descriptor Table supports a total of 256 possible vectors (0 through 255), which leaves a lot of room for “raw interrupts”, which can be hooked through _CPU_ISR_install_raw_handler
.
Since the APIC needs to be used for the clock driver, the PIC is remapped (IRQ0 of the PIC is redirected to vector 32, and so on), and then all interrupts are masked to disable the PIC. In this state, the PIC may _still_ produce spurious interrupts (IRQ7 and IRQ15, redirected to vector 39 and vector 47 respectively).
The clock driver triggers the initialization of the APIC and then the APIC timer.
The I/O APIC is not supported at the moment.
Note
IRQ32 is reserved by default for the APIC timer (see following section).
IRQ255 is reserved by default for the APIC’s spurious vector.
Warning
Besides the first 33 vectors (0 through 32), and vector 255 (the APIC spurious vector), no other handlers are attached by default.
7.19.1.6. Clock Driver¶
The clock driver currently uses the APIC timer. Since the APIC timer runs at the CPU bus frequency, which can’t be detected easily, the PIT is used to calibrate the APIC timer, and then the APIC timer is enabled in periodic mode, with the initial counter setup such that interrupts fire at the same frequency as the clock tick frequency, as requested by CONFIGURE_MICROSECONDS_PER_TICK
.
7.19.1.7. Console Driver¶
The console driver defaults to using the COM1
UART port (at I/O port 0x3F8
), using the NS16550
polled driver.
8. Executables¶
This section discusses what an RTEMS executable is and what happens when you execute it in a target. The section discusses how an application executable is created, what happens when an executable is loaded and run, debugging an execiutable, and creating and dynamically loading code.
8.1. RTEMS Executable¶
Running executables is the most important part of working with RTEMS, it is after all how you run your application and use the RTEMS kernel services.
An RTEMS executable is embedded in a target and executing an embedded executable has challenges not faced when executing software on a desktop or server computer. A desktop or server operating system kernel provides all the support needed to bring an executable’s code and data into a process’s address space passing control to it and cleaning up when it exits. An embedded target has to provide similar functionality to execute an embedded executable.
An RTEMS Source Builder (RSB) built RTEMS tool chain is used to create RTEMS executables. The tool chain executable creates a fixed position statically linked Extendable Loader Format (ELF) file that contains the RTEMS kernel, standard libraries, third-party libraries and application code. RTEMS executes in a single address space which means it does not support the fork
or exec
system calls so statically linking all the code is the easiest and best way to create an executable.
An RTEMS application is constructed vertically with the RTEMS kernel, BSP support code and drivers close to the hardware, above which sit the RTEMS Application Programming Interfaces (API) for control of threads, mutex and other resources an application may use. Middle-ware services like networking, interpreted languages, and protocol stacks sit between the RTEMS APIs and the application components. The software built into an executable can be see as a vertical software stack.
8.2. Building an Application¶
RTEMS views any code it is running and using it’s interfaces as an application. RTEMS conforms to a number of international standards such as POSIX and can build and run portable code written in languages such as C, C++ and Ada.
Applications are built from source into ELF object files, third-party packages can be built as libraries or they can be imported as source into an application code base. The application, third-party packages, RTEMS and standard libraries are linked to create the RTEMS executable. The executable is transferred to the target and a bootloader loads it from the non-volatile storage into RAM or the code is executed in place in the non-volatile storage. The target hardware defines what happens.
The standard and third-party libraries are a collection of object files built using the same set of tools the application source is compiled with. The package collects it’s object files into an archive or library.
RTEMS does not provide a standard application build system. The RTEMS ecosystem provides support so a range of build systems can be used. Applications can be built with make
, autotools
, cmake
, waf
and more. User should select a build system that meets their project, system, corporate or personal needs.
8.2.1. Machine Flags and ABI¶
All code in an RTEMS executable must be built with the same machine flags. The machine flags control the instruction set and application binary interface (ABI) the compiler generates. As the executable is statically linked all code must use the same instruction set the hardware is configured to support and all code must conform to the same ABI. Any variation can result in unpredictable behavior such as crashes, failures or lock ups. It is recommend an executable is built with the same or equivalent tool set. Mixing of tool set versions can also result in undefined behavior. The RTEMS tool rtems-execinfo
can audit an RTEMS executable and list the machine flags and compilers used.
RTEMS by default does not support instruction emulation for unsupported instructions. RTEMS applications are normally built from source so binary compatibility is not as important as performance. Instruction emulation is costly to execute and rebuilding the executable with the correct instruction set only needs to be done once.
8.3. Target Execution¶
Fixed position statically linked executables have a fixed address in a target’s address space. The location in the address space for code, data and read-only data is fixed. The BSP defines the memory map and it is set by the BSP developer based on the target’s hardware requirements and it’s bootloader.
Targets typically contains a bootloader that is executed after the target’s processor exits reset. A bootloader is specific to a target’s processor and hardware configuration and is responsible for the low level initialization of the hardware resources needed to load and execute an operating system’s kernel. In the case of RTEMS this is the RTEMS executable.
Bootloaders vary in size, complexity and functionality. Some architectures have a number of bootloader stages and others have only minimal support. An example of a high end system is Xilinx’s Zynq processor with three stages. First a mask ROM in the System On Chip (SOC) executes after reset loading a first stage bootloader (FSBL) from an SD card, QSPI flash or NAND flash depending on signals connected to the device. The FSBL loads a second stage bootloader (SSBL) such as U-Boot and this loads the kernel. U-Boot can be configured to load a kernel from a range of media and file system formats as well as over a network using a number of protocols. This structure provides flexibility at the system level to support development environments such as a workshop or laboratory through to tightly control production configurations.
Bootloaders often have custom formats for the executable image they load. The formats can be simple to keep the bootloader simple or complex to support check-sums, encryption or redundancy in case an image becomes corrupted. A bootloader often provides a host tool that creates the required file from the RTEMS executable’s ELF file.
If RTEMS is to run from RAM the bootloader reads the image and loads the code, initialized data and read-only data into the RAM and then jumps to a known entry point. If the code is executed from non-volatile storage the process to write the image into that storage will have extracted the various binary parts and written those to the correct location.
The important point to note is the binary parts of the executable are somehow loaded into the target’s address space ready to execute. The way this done may vary but the out come is always the same, the binary code, data and read-only data is resident in the processor’s address space at the BSP defined addresses.
8.4. BSP Initialization¶
The bootloader jumps or calls the RTEMS executable’s entry point, normally a fixed address. The BSP entry point or start up code performs:
- Low level processor specific initialization that such as setting control registers so the processor is operating in a mode RTEMS is built for
- Cache flushing, clearing and invalidation
- Memory management unit (MMU) set up if required
- Clear the uninitialized data section
- Process a command line if supported by the bootloader
- Call
bootcard
which disabled interrupts, saves away a command line if the BSP supports it then call the RTEMS kernel early initialize entry pointrtems_initialize_executive
. This call never returns.
Further BSP initialization happens as part of RTEMS kernel’s System Initialization process. The following handlers are declared and if provided are placed at the beginning of the initialization handler list. The BSP can provides:
bsp_work_area_initialize
- This function determines the amount of memory that can be given to RTEMS for the workspace and the C library heap which
malloc
uses. The call typically uses thebsp_work_area_initialize_default
to perform actually perform the initialization. bsp_start
- This function is specialized for each architecture and even for some BSPs. It performs the low level initialization RTEMS needs so it can run on the architecture and BSP.
bsp_predriver_hook
- This function can be used to initialize hardware drivers depend on such as configuring an interrupt controller. The default version is empty and does nothing.
BSPs all perform similar operations with common functionality and the RTEMS kernel provides common code that can be shared between BSPs. The use of the common code is encouraged for all new BSPs.
8.5. RTEMS Initialization¶
The RTEMS kernel initialization is:
- Invoke the registered system initialization handlers
- Set the system state to up
- If the kernel supports SMP request multitasking start. All online cores are transferred to the ready to start multitasking state.
- Start threaded multitasking. RTEMS starts multitasking by getting the first thread to run and dispatching it.
C++ static object constructors are called in the context of the first running thread before the thread body is entered.
8.5.1. System Initialization Handlers¶
RTEMS supports the automatic registration of services used in applications. This method of initialization automatically configures RTEMS with only the services used in an application. There is no manual configuration of services used and no updating of initialization function tables.
RTEMS uses specialized sections in the ELF executable to perform this task. The system is based on the FreeBSD SYSINT Framework. Ordered initialization is performed before multitasking is started.
The RTEMS Tool rtems-exeinfo
can provide some detail about the registered handlers. The following shows the initialization handlers for the hello world sample application in the RTEMS kernel’s testsuite:
.. code-block:: none
$ rtems-exeinfo –init arm-rtems5/c/xilinx_zynq_zedboard/testsuites/samples/hello.exe RTEMS Executable Info 5.5416cfa39dd6 $ rtems-exeinfo –init arm-rtems5/c/xilinx_zynq_zedboard/testsuites/samples/hello.exe exe: arm-rtems5/c/xilinx_zynq_zedboard/testsuites/samples/hello.exe
- Compilation:
- Producers: 2
GNU AS 2.31.1: 14 objectsGNU C11 7.3.0 20180125 (RTEMS 5, RSB e55769c64cf1a201588565a5662deafe3f1ccdcc, Newlib 103b055035fea328f8bc7826801760fb1c055683): 284 objects- Common flags: 4
-march=armv7-a -mthumb -mfpu=neon -mfloat-abi=hard- Init sections: 2
- .init_array
- 0x001047c1 frame_dummy
- .rtemsroset
- 0x00104c05 bsp_work_area_initialize 0x00104c41 bsp_start 0x0010eb45 zynq_debug_console_init 0x0010ec19 rtems_counter_sysinit 0x0010b779 _User_extensions_Handler_initialization 0x0010c66d rtems_initialize_data_structures 0x00107751 _RTEMS_tasks_Manager_initialization 0x0010d4f5 _POSIX_Keys_Manager_initialization 0x0010dd09 _Thread_Create_idle 0x0010cf01 rtems_libio_init 0x001053a5 rtems_filesystem_initialize 0x0010546d _Console_simple_Initialize 0x0010c715 _IO_Initialize_all_drivers 0x001076d5 _RTEMS_tasks_Initialize_user_tasks_body 0x0010cfa9 rtems_libio_post_driver
The section .rtemsroset
lists the handlers called in order. The handlers can be split into the BSP initialization handlers that start the BSP:
bsp_work_area_initialize
bsp_start
zynq_debug_console_init
rtems_counter_sysinit
And the remainder are handlers for services used by the application. The list varies based on the services the application uses.
8.6. Debugging¶
An RTEMS executable is debugged by loading the code, data and read-only data into a target with a debugger connected. The debugger running on a host computer accesses the ELF file reading the debug information it contains.
The executable being debugged needs to be built with the compiler and linker debug options enabled. Debug information makes the ELF executable file large but it does not change the binary footprint of the executable when resident in the target. Target boot loaders and file conversion tools extract the binary code, data and read-only data to create the file embedded on the target.
An ELF executable built with debug information contains DWARF debug information. DWARF is a detailed description of the executable a debugger uses to locate functions, find data, understand the type and structure of a variable, and know how much entry code every call has. The debugger uses this information to set breaks points, step functions, step instructions, view the data and much more.
We recommend the compiler and linker debug options are always enabled. An ELF file with debug information can be used to investigate a crash report from a production system if the production ELF image is archived. The RTEMS tools chain provides tools that can take an address from a crash dump and find the corresponding instruction and source line. The extra size the debug information adds does not effect the target footprint and the extra size on a host is small compared to the benefits it brings.
A desktop or server operating system’s kernel hosts the executable being debugged handling the interaction with the executable and the debugger. The debugger knows how to communicate to the kernel to get the information it needs. Debugging an embedded executable needs an extra piece called an agent to connect the target to the debugger. The agent provides a standard remote interface to the debugger and an agent specific connection to the target.
The RTEMS tool chain provides the GNU debugger GDB. GDB has a remote protocol that can run over networks using TCP and UDP protocols. The GDB remote protocol is available in a number of open source and commercial debugging solutions. Network debugging using the remote protocol helps setting up a laboratory, the targets can be remote from the developers desktop allowing for better control of the target hardware while avoiding the need to plug devices in to an expensive desktop or server machine.
The following are some examples of GDB and GDB server environments RTEMS supports.
QEMU contains a debugging agent for the target being simulated. A QEMU command line option enables a GDB server and the simulator manages the interaction with the target processor and it’s memory and caches.
OpenOCD is a JTAG debugging package that interfaces to a wide of JTAG pods. JTAG is a low level high speed serial interface modern processors provide as a means of controlling the core processing logic. The features available depend on the architecture and processor. Typical functions include:
- Processor control and register access
- System level register access to allow SOC initialization
- General address space access
- Cache and MMU control
- Break and watch points
The RTEMS kernel has a debugging agent called libdebugger
. This is a software based agent that runs within RTEMS using network services to provide a remote GDB protocol interface. A growing number of architectures are supported. The RTEMS debugging agent is for application development providing thread aware stop model debug experience.
8.7. Dynamic Loader¶
RTEMS supports dynamically loading of executable code and data in the form of object files into a running system where the run-time loaded code can be executed and data accessed
This section describes RTEMS loader, preparing and loading executable code into a running system, the supported architectures and any limitation that may exist with an architecture.
The RTEMS operating system contains a link editor that runs on the target. The link editor supports loading Extendable Linker Format (ELF) relocatable executable object files locating the code and data in the target’s address space as it is loaded. An executable object file’s external references to function identifiers and data object identifiers are resolved and any external symbols can be made available in the global symbol table. The executing performance of dynamically loaded code is similar to the same code statically linked into an executable. This is a core requirement of the RTEMS link editor.
The RTEMS operating system’s dynamic loader is not the same as the dynamic shared library support Unix or Windows have. Those operating systems use dynamic loading to share code between processes and this is an important feature in their design. RTEMS is a single address space operating system and that means there is no ability to share code at run-time. As a result code is loaded in a similar manner to static linking removing the need for any overheads sharing code may have.
To load an executable object file it must be resident on a target and accessible by RTEMS’s file system. The executable object file can be a single file or a collection in a library stored using the Unix standard archive format. The RTEMS loader supports the extended GNU format for long file names in archives.
The RTEMS developers do not see dynamically loading of code as a real-time activity. A system should not respond to real-time external events by loading code. The loading of code should happen before a system is considered available and the activity the system is experiencing is low and stable.
The statically linked executable that is loaded and run after reset is called the base image. The base image contains your base application that is used to dynamically load code, a global symbol table, the parts of the RTEMS operating system code used in the base image as well as functions and data from the tool suite libraries and packages you are using. Only the software referenced is used to create the base image. The parts of the libraries not referenced are not part of the executable or present in the global symbol table.
Application software can locate a symbol by name and call the address or reference the data at that address. A function identifier located by a symbol does not have it’s signatures checked, it is the responsibility of the caller to make sure the function is called with the correct arguments. It is the same for data objects, there is no type checking. Symbol versioning is not supported and supporting it does not make sense within the RTEMS operating system. An RTEMS target system is closed to normal users and software needs to be built from the same tool set and header files used to the build the base image.
An executable object file’s text or code has to be built for the target’s architecture it is loaded on and it must be built with the same ABI flags the base image is built with. See Machine Flags and ABI.
8.7.1. System Design¶
The use of dynamic loading in a project is a system design decision. Some systems will have strict requirements where loading code into a live system is not allowed while other projects will benefit from the system level flexibility dynamically loading code provides.
Code loaded at run time needs to be resident or accessible to the target via RTEMS’s file system. Targets that have suitable media or a network interface to NFS servers to hold the executable object and library files are best suited.
Dynamically loading code uses more memory than statically linking the same code into the base image. The link editor maintains symbol tables where each symbol is a string, an address, and some additional data. The executable object files resident in memory each have data to manage them, the memory they use, and any dependencies they might have. The link editor is designed to minimize the memory overheads however only statically linked executables have no memory overhead.
The link editor relocates the code and data into RAM fixing it to the load address as it is loaded. A target needs to have suitably configured memory available for the executable object file to reside in. The memory must be able to support read, write and executable type access. Fine control of the memory and it’s modes can be supported using a customer allocator. Examples are systems that have a custom memory map, specialized memory for the execution of code or a requirement for read-only executable sections.
The load address of an executable object file is determined by the load order and the allocator used. The default allocator for the link editor is the system heap which means the location a specific executable object file is loaded at depends on the memory allocated before it is loaded and when in the load order it is loaded. A statically linked executable’s address map is fixed and this is considered important in some systems. A dynamically loaded system can be loaded in a repeatable manner if the load order is the same and the initialization sequence of the system is controlled. A custom allocator may also help.
Management of dynamically loadable object files and libraries adds to the configuration management of the hosts in a project. The loadable files need to be released and tracked in a suitable configuration management process just like the base image is. Executable object files and libraries are specific to a version of RTEMS and cannot be mixed or moved and this needs to be carefully managed. Currently there are no checks an executable object file matches the version of the base image it is being loaded on. These extra configuration controlled items add to the overheads of a project and need to be considered.
Dynamically loadable systems have a number of features that benefit some systems and products. Systems can be built on a base of trusted or golden modules. A number of projects using a common base of hardware can make use of proven modules reducing the testing and qualification overhead for each new release. A tested base image with libraries for common and available boards provides a simple and fast way for new users to trial and use RTEMS.
A project can use dynamic loading during development, shipping statically linked executables in production. Hardware used by a development team can have more memory, extra media for disk drives, or a network interface.
8.7.2. Loader Interface¶
Run-time executable object file loading and management is via the standard’s based calls provided by the header file <dlfcn.h>
. The details of the calls follow.
void* dlopen(const char* path, int mode);
The
dlopen()
function makes the symbols (function identifiers and data object identifiers) in the executable object file specified by file available to the calling program.The executable object files eligible for this operation are in the ELF format.
The link loader may load embedded dependencies in executable object files. In such cases, a
dlopen()
operation may load those dependencies in addition to the executable object file specified by file.A successful
dlopen()
returns a handle which the caller may use on subsequent calls todlsym()
,dlinfo()
anddlclose()
.The value of the handle should not be interpreted in any way by the caller.
Subsequent calls to
dlopen()
for the same executable object file increases the references to it.The file argument is used to construct a pathname to the executable object file or archive library of executable object files. If the file argument contains a colon (
:
) the name of the executable object file in the library follows and this file name may optionally end with@
followed by a number which is the absolute offset in the library file where the executable object file starts. If an executable object file is not detected at the offset the archive library’s file table is searched.If file is a null pointer,
dlopen()
returns a global symbol table handle. This handle provides access to the global symbols from an ordered set of executable object files consisting of the original base image file, the set of executable object files loaded usingdlopen()
operations with theRTLD_GLOBAL
flag, and any dependencies loaded. As the latter sets of executable object files can change during execution, the set of symbols made available by this handle can also change dynamically.Only a single copy of an executable object file is brought into the address space, even if
dlopen()
is invoked multiple times in reference to the executable object file, and even if different pathnames are used to reference the executable object file.Unresolved external symbols do not cause an error to be returned allowing the loading of jointly dependent executable object files.
If
dlopen()
fails, it returns a null pointer, and sets an error condition which may be interrogated withdlerror()
.The mode parameter describes how
dlopen()
operates upon file with respect to the processing of relocations and the scope of visibility of the symbols provided within file. When an executable object file is brought into the address space, it may contain references to symbols whose addresses are not known until the executable object file is loaded.If a loaded executable object file and any dependent executable object files loaded with it contain any initialiser functions, they are called in the order loaded before
dlopen()
returns.The modes
RTLD_LAZY
andRTLD_NOW
do not effect the type of relocation performed, it is same for both modes. All relocations of an executable object file and any dependent executable object files loaded with it are completed before thedlopen()
call returns. The execution performance of the code loaded can be considered deterministic oncedlopen()
has returned.Any executable object file loaded by
dlopen()
can reference global symbols in the base image, any executable object files loaded included in the samedlopen()
invocation, and any executable object files that were loaded in anydlopen()
invocation and which specified theRTLD_GLOBAL
flag. To determine the scope of visibility for the symbols loaded with adlopen()
invocation, the mode parameter should be a bitwise-inclusiveOR
with one of the following values:RTLD_GLOBAL
- The executable object file’s symbols are made available for relocation processing of any other executable object file. In addition, symbol lookup using
dlopen(NULL,mode)
and an associateddlsym()
allows executable object files loaded with this mode to be searched. RTLD_LOCAL
- The executable object file’s symbols shall not be made available for relocation processing of any other executable object files.
If neither
RTLD_GLOBAL
norRTLD_LOCAL
is specified, the default behavior is unspecified.If
RTLD_GLOBAL
has been specified, the executable object file maintains it’sRTLD_GLOBAL
status regardless of any previous or future specification ofRTLD_LOCAL
, as long as the executable object file remains in the address space.Symbols introduced through calls to
dlopen()
may be used in relocation activities. Symbols that duplicate symbols already defined by the base image or previousdlopen()
calls are treated as an error and the object file is not loaded. Symbols introduced through loading dependent executable object files are ignored or not loaded depending on the method used to build the executable object files.The symbols introduced by
dlopen()
operations and available throughdlsym()
are at a minimum those which are exported as identifiers of global scope by the executable object file. Typically, such identifiers shall be those that were specified in (for example) C source code as havingextern
linkage.
int dlclose(void* handle);
Releases a reference to the executable object file referenced by handle. If the reference count drops to
0
, the executable object file’s global symbol table is made unavailable. When all references to the global symbols the executable object file provided have been removed the object file is removed from the address space.If the executable object being removed has any termination routines in it they are called.
void* dlsym(void* handle, const char* symbol);
The
dlsym()
function obtains the address of a symbol (a function identifier or a data object identifier) defined in the symbol table identified by the handle argument. The handle argument is a symbol table handle returned from a call todlopen()
(and which has not since been released by a call todlclose()
), and name is the symbol’s name as a character string. The return value fromdlsym()
, cast to a pointer to the type of the named symbol, can be used to call (in the case of a function) or access the contents of (in the case of a data object) the named symbol.The
dlsym()
function searches for the named symbol in the symbol table referenced by handle and returns the address of the code or data location specified by the null-terminated character string symbol. Which libraries and objects are searched depends on the handle parameter.Upon successful completion, if name names a function identifier,
dlsym()
returns the address of the function converted from type pointer to function to type pointer tovoid
; otherwise,dlsym()
shall return the address of the data object associated with the data object identifier named by name converted from a pointer to the type of the data object to a pointer tovoid
. If handle does not refer to a valid symbol table handle or if the symbol named by name cannot be found in the symbol table associated with handle,dlsym()
shall return a null pointer.
int dlinfo(void* handle, int request, void* args);
The
dlinfo()
function provides information about dynamically loaded object. The action taken bydlinfo()
and exact meaning and type of the argument args depend on value of the request argument provided by the caller.
RTLD_DI_UNRESOLVED
- Return
1
in an indexer value pointed to by args if the symbol table handle has unresolved relocation records to symbols. If the handle is the global symbol table handle orRTLD_SELF
return1
if any unresolved relocation records to symbols are present in any loaded executable object files..
const char *dlerror(void);
- The
dlerror()
function returns a null-terminated character string (with no trailing<newline>
) that describes the last error that occurred during dynamic linking processing. If no dynamic linking errors have occurred since the last invocation ofdlerror()
,dlerror()
returnsNULL
. Thus, invokingdlerror()
a second time, immediately following a prior invocation, results inNULL
being returned.
This example opens an object file, checks for any unresolved symbols the object file may have, locates a global symbol in the object file, calls it then closes the object file:
#include <stdbool.h>
#include <stdio.h>
#include <dlfcn.h>
typedef int (*call_sig)(void);
bool load_object (void)
{
void* handle;
call_sig call;
int unresolved;
handle = dlopen ("/code.o", RTLD_NOW | RTLD_GLOBAL);
if (handle == NULL)
{
printf ("dlopen failed: %s\n", dlerror ());
return false;
}
if (dlinfo (handle, RTLD_DI_UNRESOLVED, &unresolved) < 0)
{
printf ("dlinfo failed: %s\n", dlerror ());
dlclose (handle);
return false;
}
if (unresolved != 0)
{
printf ("object.o has unresolved external symbols\n");
dlclose (handle);
return false;
}
call = dlsym (handle, "foo");
if (call == NULL)
{
printf("dlsym failed: symbol 'foo' not found\n");
dlclose (handle);
return false;
}
printf ("'foo()' returns: %i\n", call ());
if (dlclose (handle) < 0)
{
printf("dlclose failed: %s\n", dlerror());
return false;
}
return true;
}
8.7.3. Symbols¶
The RTEMS link editor manages the symbols for the base image and all resident executable object files. A symbol is an identifier string and a pointer value to a function identifier or a data object identifier. The symbols held in the symbol tables are used in the relocation of executable object files or they can be accessed by application code using the dlsym() call.
An executable object file’s symbols are removed from the global symbol table when it is closed or orphaned. An executale object file cannot be unloaded if a symbol it provides is referenced by another object and that object is still resident. An executable object file that has no references to any of its symbols and was not explicitly loaded using the dlopen() call is orphaned and automatically removed from the address space.
8.7.3.1. Base Image Symbols¶
The base image symbol table provides access to the function and data objects statically linked into the base image. Loaded executable object files can be directly linked to the code and data resident in the base image.
A statically linked RTEMS executable does not contain a symbol table, it has to be generated and either embedded into the executable or loaded as a specially created executable object file.
The base image symbol table is dependent on the contents of the base image and this is not known until it has been linked. This means the base image symbol table needs to be constructed after the base image executable has been linked and the list of global symbols is known.
The RTEMS Tools command rtems-syms (see RTEMS Symbols) extracts the global and weak symbols from an RTEMS static executable file, creates a C file and compiles it creating a relocatable executable object file. This file can be linked with the static executable’s object files and libraries to create a static executables with an embedded symbol table or the executable file can be loaded dynamically at run-time. The following needs to be observed:
- The option
-e
or--embedded
to rtems-syms creates an executable object file to be embedded in the base image and not providing either of these options creates a symbols executable object file that is loaded at run-time. The same executable object file cannot be used to embedded or load. - The target C compiler and machine options need to be provided to make sure the correct ABI for the target is used. See Machine Flags and ABI.
8.7.3.2. Embedded Symbols¶
An embedded symbol table is embedded within the base image executable file and loaded when the static executable is loaded into memory by the bootloader. The symbol table is automatically added to the link editor’s global symbol table when the first executable object file is loaded.
The process to embed the symbol table requires linking the base image twice. The first link is to create a static executable that collects together the symbols to make the symbol table. The RTEMS Tools command rtems-syms extracts the global and weak symbols from the static executable ELF file, creates a C file and compiles it to create an executable object file. The base image is linked a second time and this time the symbol table executable object file is added to the list of object files.
Embedding the symbol table means the chances of the symbol table and base image not matching is low, however it also means the symbol table is always present in the kernel image when dynamic loading may be optional. A project’s build system is made more complex as it needs to have extra steps to link a second time.
This example shows creating an embedded symbol table object file and linking it into the base image.
$ sparc-rtems5-gcc -mcpu=cypress foo.o -lrtemsbsp -lrtemscpu -o foo.pre
$ rtems-syms -e -C sparc-rtems5-gcc -c "-mcpu=cypress" -o foo-sym.o foo.pre
$ sparc-rtems5-gcc -mcpu=cypress foo.o foo-sym.o -lrtemsbsp -lrtemscpu -o foo.exe
The link command line steps in this example are not complete.
8.7.3.3. Loadable Symbols¶
A run-time loaded symbol table is the default for the command rtems-syms. The symbol table executable object file is packaged with the other files to be dynamically loaded at run-time and placed on the target’s file system. It needs to be loaded before any other executable object file are loaded or unresolved symbols can occur that will not be resolved.
A run-time loaded symbol table does not consume any target resources until it is loaded. This is useful in a system that optionally needs to dynamically load code, for example as a development environment. The symbol table executable needs to exactly match the base image loading it or the behavior is unpredictable. No checks are made.
The example shows creating and loading a symbol table executable object file. First create the symbol table’s executable object file:
$ sparc-rtems5-gcc -mcpu=cypress foo.o -lrtemsbsp -lrtemscpu -o foo.exe
$ rtems-syms -C sparc-rtems5-gcc -c "-mcpu=cypress" -o foo-sym.o foo.exe
The link command line steps in this example are not complete.
Load the symbol table:
#include <stdbool.h>
#include <stdio.h>
#include <dlfcn.h>
bool load (void)
{
void* handle = dlopen ("/foo-sym.o", RTLD_NOW | RTLD_GLOBAL);
if (handle == NULL)
{
printf ("failed to load the symbol table: %s\n", dlerror ());
return false;
}
return true;
}
8.7.4. Unresolved Symbols¶
The RTEMS link editor does not return an error when an executable object file is loaded with unresolved symbols. This allows dependent object files to be loaded. For example an executable object file foo.o
contains the function foo()
and that function calls bar()
and an executable object file bar.o
contains a function bar()
that calls the function foo()
. Either of these executable object files can be loaded first as long both are loaded before any symbols are accessed.
The link editor defers the resolution of unresolved symbols until the symbol is available in the global symbol table. Executing code or accessing data in a loaded executable object file with unresolved external symbols results in unpredictable behavior.
All unresolved symbols are checked after an executable object file has been loaded. If a symbol is found and resolved any relocations that reference the symbol are fixed. If valid library files have been configured the symbol table’s of each library are searched and if the symbol is found the dependent executable object file is loaded. This process repeats until no more symbols can be resolved.
The dlinfo()
call can be used to see if a loaded executable object file has any unresolved symbols:
#include <stdbool.h>
#include <stdio.h>
#include <dlfcn.h>
bool has_unresolved(void* handle)
{
int unresolved;
if (dlinfo (handle, RTLD_DI_UNRESOLVED, &unresolved) < 0)
{
printf ("dlinfo failed: %s\n", dlerror ());
return false;
}
return unresolved != 0;
}
The handle RTLD_SELF
checks for any unresolved symbols in all resident object files:
if (has_unresolved(RTLD_SELF))
printf("system has unsolved symbols\n");
8.7.5. Libraries¶
The RTEMS link editor supports loading executable object files from libraries. Executable object files can be explicitly loaded from a library using a specific path to dlopen() and treated the same as loading a stand alone executable object file. Libraries can be searched and an executable object file containing the search symbol can be loaded automatically as a dependent executable object file. A dependent executable object file loaded from a library with no symbol references to it’s symbols is orphaned and automatically unloaded and removed from the address space.
A library is an archive format file created using the RTEMS architecture prefixed ar command. The RTEMS tool suite provides the ar program and system libraries such as libc.a
and libm.a
for each architecture and ABI. Libraries used by the RTEMS link editor for searching must contain a symbol table created by the ranlib program from the RTEMS tool suite.
Searching a library’s symbol table and loading an executable object file containing the symbol is called dependent loading. Dependent loading provides a simple way to manage the dependencies when loading an executable object file. If code in an executable object file references functions or data objects that are part of a library and the symbols are not part of the base image those symbols will not resolve unless the library is on the target and available for searching and loading. Dependent loading from libraries on the target provides a simple and understandable way to manage the dependency issue between the base image, loaded code and the system libraries.
The RTEMS link editor checks for the configuration file /etc/libdl.conf
on each call to dlopen(). If the file has changed since the last check it is loaded again and the contents processed. The file format is:
- Comments start with the
#
character. - A line is a wildcard path of libraries to search for. The wildcard search uses the
fnmatch()
call. Thefnmatch()
function matches patterns according to the rules used by a shell.
Files that match the search pattern are verified as a library and if a symbol table is found it is loaded and the symbols it contains made search-able.
A call to dlopen() checks the global symbols table and any references to relocation symbols not found are unresolved and added to the unresolved symbol table. Once the executable object file is loaded the link editor attempts to resolve any unresolved symbols. The unresolved symbol resolver checks each unresolved symbol against the global symbol table and if not found the available library symbol tables are searched. If a symbol is found in a library the dependent executable object file is loaded. The process repeats until all unresolved symbols have been resolved and the remaining unresolved symbols are not in the global symbol table or any libraries. The loading of a library executable object file will resolve at least one symbol and it may add more unresolved symbols requiring further searching of the libraries.
A library of executable object files built by the RTEMS Tool suite can contain debug information and this should be stripped before loading on to the target. The tool suite’s command strip can strip all the object files in a library with a single command.
$ sparc-rtems5-strip libc.a
8.7.6. Large Memory¶
The RTEMS link editor supports large memory relocations. Some architectures have instructions where the relative branch or jump offset from the instruction to the target address is limited. These instructions provide improved performance because less code generated compared to larger instructions which contain full address space references. The compact code helps lower cache pressure as well and providing improved performance for localalized functions and loops. The compiler defaults to generating the smaller instruction and as the final address map not known when generating the code, linkers need to provide glue code to extend the small address range to the enitre address space. This is called a trampoline. A trampoline is transparent to the execution of the code.
The link editor parses an executable object file’s relocation records to determine the number of trampolines needed. Added to this value are all unresolved symbols present in an executable object file after it is loaded. There is a slot allocated even if the symbol ends up being within range as there is no way to determine a symbol’s address until it is loaded and the range calculated.
The trampoline table is allocated a separate block of memory to the executable object file’s text, data and constants memory. The trampoline parsing requires the executable object file’s instructions (text) be in memory as the instructions are inspected by the architecture specific relocation support to determine an instruction’s range. As a result the allocation for the trampoline table has to occur after the text memory has been allocated. Most instructions have relative offsets and the trampoline table is allocated at one end limiting the size of an object to half the maximum range.
Trampolines support is available for the ARM and PowerPC architectures. The SPARC and Intel x86 architectures do not need trampolines and MIPS needs support added.
8.7.7. Allocator¶
The RTEMS link editor supports custom allocators. A custom allocator lets you manage the memory used by the RTEMS link editor as it runs. Allocators could provide:
- Support for the various types of memory that can be allocated allowing specialised target support for specific use cases.
- Locking of read-only memory. The link editor unlocks read-only memory when it needs to write to it.
- Separation of memory holding code and data from the heap.
The allocator can be hooked using the rtems_rtl_alloc_hook
call before any calls to dlopen() are made. The hook call returns the current allocate allowing the allocators to be chained.
The default allocator uses the heap.
The allocator tags specify the type of memory the allocator is handling. The tag used to allocate memory at an address must be used when making allocator calls. The rtems_rtl_alloc_tags
are:
RTEMS_RTL_ALLOC_OBJECT
- Allocate a generic object. The link editor uses this memory for data structures it uses to manage the linking process and resident executable object files.
RTEMS_RTL_ALLOC_SYMBOL
- Allocate memory to hold symbol data.
RTEMS_RTL_ALLOC_EXTERNAL
- Allocate memory for unresolved external symbols.
RTEMS_RTL_ALLOC_READ
- Allocate memory for read-only data such as constants and exception tables.
RTEMS_RTL_ALLOC_READ_WRITE
- Allocate memory for read-write data such as a initialised, uninitialized and common variables.
RTEMS_RTL_ALLOC_READ_EXEC
- Allocate memory for code to be executed in. The address space is configure for read and execute.
The commands are used to control the action the allocator performs. The rtems_rtl_alloc_cmd
are:
RTEMS_RTL_ALLOC_NEW
- Allocate memory of the
tag
type. ReturnsNULL
if the allocation fails.
RTEMS_RTL_ALLOC_DEL
- Delete a previous allocation freeing the memory. The
tag
has to match address of the memory being deleted.
RTEMS_RTL_ALLOC_WR_ENABLE
- Enable writes to a region of memory previously allocated. The
tag
has to match the address of the memory being write enabled. The link editor may call issue this command for memory that is already write enabled.
RTEMS_RTL_ALLOC_WR_DISABLE
- Disable writes to a region of memory previously allocated. The
tag
has to match address of the memory being write disabled. The link editor may call issue this command for memory that is writable and not to be write disabled. The allocator need to manage this case.
The allocator handler is a single call to handle all allocator requests. The handler called on evey allocation action made by the link editor. The type of the function you need is:
typedef void (*rtems_rtl_allocator)(rtems_rtl_alloc_cmd cmd,
rtems_rtl_alloc_tag tag,
void** address,
size_t size);
The arguments are:
cmd
- The command to action. See rtems_rtl_alloc_cmd.
tag
The type of memory the command is for. Thetag
must match the address for commands other thanRTEMS_RTL_ALLOC_OBJECT
. See rtems_rtl_alloc_tags.
address
- Pointer to the address. This is set of the
RTEMS_RTL_ALLOC_OBJECT
command and read for the other commands. Thetag
must match the address for commands that read the address from the pointer. size
- The size of the memory to allocate. This is only valid for the
RTEMS_RTL_ALLOC_OBJECT
command.
The call to hook the allocator is:
rtems_rtl_allocator rtems_rtl_alloc_hook (rtems_rtl_allocator handler);
The current allocator is returned. You can provide a full allocator or you can filter commands.
8.7.8. Languages¶
C is supported.
C++ is supported. Initializer functions are called when an object is loaded and finalizer functions are called before it is unloaded and removed. Static constructions are initializer functions and static destructors are finalizer functions.
C++ exceptions are handled across modules. The compiler generated exception tables present in an executable object file are registered with the architecture specific mechanism when loaded and deregistered when unloaded. An exception thrown in loaded code can be caught in the base image or another loaded module. If you are using C++ and exceptions it is recommended some exception code is added to the base image to place the architecture specific support in the base image.
8.7.9. Thread Local Storage¶
Thread local storage (TLS) is currenly not supported by the RTEMS link editor. The RTEMS executive needs to have a special allocator added to manage dynamically allocating TLS variables in a thread.
If you need TLS support in dynamically loaded code please consider the RTEMS support options.
8.7.10. Architectures¶
The following architectures are supported:
- ARM
- Blackfin
- H8300
- Intel x86 (i386)
- LM32
- M68K
- MIPS
- Moxie
- PowerPC
- SPARC
- V850
8.7.10.1. ARM¶
The ARM relocation backend supports veneers which is trampolines.
The veneer implementation is a single instruction and a 32bit target address making the overhead 8 bytes for each veneer. The performance overhead is a single instruction.
8.7.10.2. PowerPC¶
The PowerPC relocation backend support trampolines and small data.
The trampoline is four instructions and uses register 12 which the PowerPC ABI reserves for scratch use. The implementation loads the counter register and branches to the address it contains. The trampoline size is 16 bytes. The performance overhead is four instructions.
The PowerPC relocation backend also supports small data. The sections of an executable object file are parsed and small data are tagged as needing architecture specific allocations. These sections are not allocated as part of the standard section allocation. Small data sections are allocated in the global small data region of memory. The size of this region is defined in the BSP’s linker command file by setting bsp_section_small_data_area_size
variable:
bsp_section_small_data_area_size = 65536;
The maximum size of the small data region is 65536 bytes. It is recommended code built for loading uses the same settings for small base as the base image.
8.8. Device Tree¶
A Device Tree is a data structure that is used to describe properties of non-discoverable hardware instead of hardcoding them in the kernel. The device tree data is generally stored in a .dts or a Device Tree Source (DTS) file. This file is then compiled into a binary format called Device Tree Blob (DTB) with .dtb extension. RTEMS preferably uses a DTB built from the FreeBSD source tree matching the freebsd-org HEAD commit hash in libBSD.
8.8.1. Building the DTB¶
A single DTB file can be built using the dtc tool in libfdt using the following command:
dtc -@ -I dts -O dtb -o my-devicetree.dtb my-devicetree.dts
For building the DTB from the FreeBSD source, the make_dtb.sh script from freebsd/sys/tools/fdt must be used as most of the DTS files in FreeBSD have included .dtsi files from their source tree. An example is given below as a reference for how to build the device tree from the FreeBSD source.
NOTE: The following example uses FreeBSD master branch from github mirror as an example. It is advised to always use the source from the commit matching the freebsd-org HEAD in libBSD.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | #We're using the script from freebsd/sys/tools/make_dtb.sh
#Target device: Beaglebone Black.
#Architecture: Arm.
#DTS source name: am335x-boneblack.dts
#The make_dtb.sh script uses environment variable MACHINE
export MACHINE='arm'
SCRIPT_DIR=$HOME/freebsd/sys/tools/fdt
#The arguments to the script are
# $1 -> Build Tree (This is the path to freebsd/sys/ directory)
# $2 -> DTS source file
# $3 -> output path of the DTB file
${SCRIPT_DIR}/make_dtb.sh ${SCRIPT_DIR}/../../ \
${SCRIPT_DIR}/../../gnu/dts/arm/am335x-boneblack.dts \
$(pwd)
|
8.8.2. Using Device Tree Overlay¶
Device tree overlay is used either to add properties or devices to the existing device tree. Adding any property to DTS using an overlay will override the current values in the DTB. The Overlays enable us to modify the device tree using a small maintainable plugin without having to edit the whole Base Tree.
There are two ways of applying an overlay on top of the built DTB.
- Use fdtoverlay from libfdt
- Add the overlay in the root partition of the SD card and apply it using U-Boot
The fdtoverlay command can be used as follows:
fdtoverlay -i my-base-tree.dtb -o output-tree.dtb my-overlay.dtbo
To apply it from U-Boot during system initialization we have to add the device tree overlay file in the root directory of the SD card and use U-Boot commands to apply the overlay.
Below is given the series of U-Boot commands that can be used to apply the overlay, given that the overlay blob (.dtbo) file is already in the card.
fatload mmc 0:1 0x80800000 rtems-app.img
fatload mmc 0:1 0x88000000 my-base-tree.dtb
fdt addr 0x88000000
fatload mmc 0:1 0x88100000 my-overlay.dtbo
fdt resize 0x1000
fdt apply 0x88100000
bootm 0x80800000-0x88000000
9. Testing¶
RTEMS developers run test executables when adding new features or testing a bug fix. All tests are run to make sure changes do not introduce regressions. Users can run the RTEMS tests to be certain the build of the kernel they have is functioning.
The section describes using and configuring the RTEMS Tester and RTEMS Run tools, the types of laboratory set ups supported and how to add your BSP to the framework. The tools command line interfaces are detailed in RTEMS Tester and Run.
An RTEMS Test is an RTEMS executable where the application code is a test. Tests in RTEMS print banners to the console to indicate the configuration of the test and if it has start and finished.
The RTEMS Tools Project provides the RTEMS Tester and RTEMS Run tools. The RTEMS Tester command is rtems-test
and the RTEMS Run command is rtems-run
. These commands manage the complexity of running embedded executables. The commands provide a consistent command line interface to a testing framework that supports the various run time and testing scenarios we encounter such as simulators, GDB and executing directly on target hardware.
The RTEMS kernel code contains an extensive set of tests to exercise and test the RTEMS kernel. The tests check functionality, provide coverage testing and make sure the kernel is operating as intended on your target system. The testsuite has support to make creating a test simple and uniform.
The tests are built by adding --enable-tests
to the RTEMS build configuration command line. There are over 600 tests and building them does extend the RTEMS kernel’s build time and use more disk space but it worth building and running them. The RTEMS test executables have the .exe
file extension.
9.1. Test Banners¶
All test output banners or strings are embedded in each test and the test outputs the banners to the BSP’s console as it executes. The RTEMS Tester captures the BSP’s console and uses this information to manage the state of the executing test. The banner strings are:
*** BEGIN TEST <name> ***
- The test has loaded, RTEMS has initialized and the test specific code is about to start executing. The
<name>
field is the name of the test. The test name is internal to the test and may not match the name of the executable. The test name is informative and not used by the RTEMS Tester.
*** END TEST <name> ***
- The test has finished without error and has passed. The
<name>
field is the name of the test. See the Test Begin Banner for details about the name.
*** TEST VERSION: <version>
- The test prints the RTEMS version return by the RTEMS Version API as
<version>
. All tests must match the first test’s version or the Wrong Version error count is incremented.
*** TEST STATE: <state>
- The test is tagged in the RTEMS sources with a special
<state>
for this BSP. See Test States for the list of possible states. The state banner lets the RTEMS Tester categorize and manage the test. For example a user input test typically needing user interaction may never complete producing an invalid test result. A user input test is terminated to avoid extended delays in a long test run.
*** TEST BUILD: <build>
- The test prints the RTEMS build as a space separated series of labels as
<build>
. The build labels are created from the configuration settings in the Super Score header filertems/score/cputops.h
. All tests must match the first test’s build or the Wrong Build error count is incremented.
*** TEST TOOLS: <version>
- The test prints the RTEMS tools version returned the GGC internal macro
_VERSION_
as<version>
. All tests must match the first test’s tools version string or the Wrong Tools error count is incremented.
9.2. Test Controls¶
The tests in the RTEMS kernel testsuite can be configured for each BSP. The expected state of the test can be set as well as any configuration parameters a test needs to run on a BSP.
The test states are:
passed
- The test start and end banners have been sent to the console.
failure
- The test start banner has been sent to the console and no end banner has been seen when a target restart is detected.
excepted-fail
- The test is tagged as
expected-fail
in the RTEMS sources for this BSP and outputs the banner*** TEST STATE: EXPECTED_FAIL
. The test is known not to pass on this BSP. The RTEMS Tester will let the test run as far as it can and if the test passes it is recorded as a pass in the test results otherwise it is recorded as expected-fail.
indeterminate
- The test is tagged as
indeterminate
in the RTEMS sources for this BSP and outputs the banner*** TEST STATE: INDETERMINATE
. The test may or may not pass so the result is not able to be determined. The RTEMS Tester will let the test run as far as it can and record the result as indeterminate.
user-input
- The test is tagged as
user-input
in the RTEMS sources and outputs the banner*** TEST STATE: USER_INPUT
. The RTEMS Tester will reset the target if the target’s configuration provides a target reset command.
benchmark
- The test is tagged as
benchmark
in the RTEMS sources and outputs the banner*** TEST STATE: BENCHMARK
. Benchmarks can take a while to run and performance is not regression tested in RTEMS. The RTEMS Tester will reset the target if the target’s configuration provides a target reset command.
timeout
- The test start banner has been sent to the console and no end banner is seen within the timeout period and the target has not restart. A default timeout can be set in a target configuration, a user configuration or provide on the RTEMS Tester’s command line using the
--timeout
option.
invalid
- The test did not output a start banner and the RTEMS Tester has detected the target has restarted. This means the executable did not load correctly, the RTEMS kernel did not initialize or the RTEMS kernel configuration failed for this BSP.
9.2.1. Expected Test States¶
A test’s expected state is set in the RTEMS kernel’s testsuite. The default for a tested is to pass
. If a test is known to fail it can have it’s state set to expected-fail
. Setting tests that are known to fail to expected-fail
lets everyone know a failure is not to be countered and consider a regression.
Expected test states are listed in test configuration files
9.2.2. Test Configuration¶
Tests can be configured for each BSP using test configuration files. These files have the file extension .tcfg
. The testsuite supports global test configurations in the testsuite/testdata
directory. Global test states are applied to all BSPs. BSPs can provide a test configuration that applies to just that BSP and these files can include subsets of test configurations.
The configuration supports:
- Including test configuration files to allow sharing of common configurations.
- Excluding tests from being built that do not build for a BSP.
- Setting the test state if it is not
passed
. - Specifing a BSP specific build configuration for a test.
The test configuration file format is:
state: test
where the state
is state of the test and test
is a comma separated list of tests the state applies too. The configuration format is:
flags: test: configuration
where flags
is the type of flags being set, the test
is a comma separate list of regular expresions that match the test the configuration is applied too and the configuration
is the string of flags.
The state
is one of:
include
- The test list is the name of a test configuration file to include
exclude
- The tests listed are not build. This can happen if a BSP cannot support a test. For example it does not have enough memory.
expected-fail
- The tests listed are set to expected fail. The test will fail on the BSP being built.
user-input
- The tests listed require user input to run and are not supported by automatic testers.
indeterminate
- The tests listed may pass or may not, the result is not reliable.
benchmark
- The tests listed are benchmarks. Benchmarks are flagged and not left to run to completion because they may take too long.
Specialized filtering using regular expressions is supported using:
rexclude
- The test matching the regular expression are excluded.
rinclude
- The tests matching the regular expression are included.
By default all tests are included, specific excluded tests using the exclude
state are excluded and cannot be included again. If a test matching a rexclude
regular it is excluded unless it is included using a rinclude
regular expression. For example to build only the hello
sample application you can:
rexclude .*
rinclude hello
Test configuration flags can be applied to a range of tests using flags. Currently only cflags
is support. Tests need to support the configuration for it to work. For example to configure a test:
cflags: tm.*: -DTEST_CONFIG=42
cflags: sp0[456]: -DA_SET_OF_TESTS=1
Flags setting are joined together and passed to the compiler’s command line. For example:
cflags: tm.*: -DTEST_CONFIG=42
cflags: tm03: -DTEST_TM03_CONFIG=1
would result in the command line to the test tm03
being:
-DTEST_CONFIG=42 -DTEST_TM03_CONFIG=1
Specific flags can be set for one test in a group. For example to set a configuration for all timer tests and a special configuraiton for one test:
cflags: (?!tm02)tm.*: -DTEST_CONFIG=one
cflags: tm02: -DTEST_CONFIG=two
9.3. Test Builds¶
The test reports the build of RTEMS being tested. The build are:
default
- The build is the default. No RTEMS configure options have been used.
posix
- The build includes the POSIX API. The RTEMS configure option
--enable-posix
has been used. Thecpuopts.h
defineRTEMS_POSIX
has defined and it true.
smp
- The build is an SMP kernel. The RTEMS configure option
--enable-smp
has been used. Thecpuopts.h
defineRTEMS_SMP
has defined and it true.
mp
- The build is an MP kernel. The RTEMS configure option
--enable-multiprocessing
has been used. Thecpuopts.h
defineRTEMS_MULTIPROCESSING
has defined and it true.
paravirt
- The build is a paravirtualization kernel. The
cpuopts.h
defineRTEMS_PARAVIRT
has defined and it true.
debug
- The build includes kernel debugging support. The RTEMS configure option
--enable-debug
has been used. Thecpuopts.h
defineRTEMS_DEBUG
has defined and it true.
profiling
- The build include profiling support. The RTEMS configure option
--enable-profiling
has been used. Thecpuopts.h
defineRTEMS_PROFILING
has defined and it true.
9.4. Tester Configuration¶
The RTEMS Tester and RTEMS Run are controlled by configuration data and scripts. The user specifies a BSP on the command line using the --rtems-bsp
option as well as optionally specifying a user configuration file using --user-config
.
The Figure RTEMS Tester and Run Configuration Files shows the various sources of configuration data and their format. The ini
files are the standard INI format, the mc
are the internal RTEMS Toolkit’s Macro format, and cfg
is the RTEMS Toolkit’s Configuration script format, the same format used by the RTEMS Source Builder.
Configuration data is held in a macro database keyed on the macro name. Macros can be expanded in configuration scripts using the syntax %{name}
. The macro database is layered using maps. The defaults and values created when a configure script runs live the in the global
map. Values read from the BSP and User INI configuration files are loaded into maps based on the BSP name. This lets a single User configuration file contain specialized configuration values for a number of BSPs and the tester and run commands select the values based on the selected BSP. Macros are expanded using the BSP map first giving those values the highest priority. User defined values are loaded after the BSP configuration values overwriting them letting a user speckles a BSP’s default configuration for their local needs.
Figure RTEMS Tester and Run Configuration Load and Execute Sequence shows the configuration loading and script execution order.
9.4.1. Defaults¶
The RTEMS Tester and RTEMS Run are primed using defaults from the file rtems/testing/testing.mc
. All default settings can be overridden in a BSP or User configuration file.
9.4.2. BSP and User Configuration¶
The BSP and User configuration files are INI format files. The BSP configuration file has to have an INI section that is the name of the BSP passed on the command line. The section has the following mandatory values:
bsp
- The name of the BSP. The BSP name is used to create a macro map to hold the BSP’s configuration data. Typically this is the same as the BSP name used on the command line.
arch
- The name of the BSP architecture. This is need for the GDB configuration scripts where the architecture specific GDB needs to run. It is mandatory so the arch/bsp standard RTEMS BSP string can be used.
tester
- The tester or run configuration script. This is the name of the configuration script the RTEMS Tester or RTEMS Run executes as a back end. The
tester
value is typically of the form%{_rtscripts}/<script>
where<script>
is name of the back end script to be run.
Target commands support expansion of specific tags to provide a convenient way for users to customize a local test environment. The parameters expanded are:
@ARCH@
- The BSP architecture.
@BSP@
- The BSP’s name set by the
bsp
value.
@EXE@
- The executable name as an absolute path
@FEXE@
- The filtered executable if a
target_exe_filter
is provided else the executable’s file name.
The following are optional and depend on the back end being used and the local target hardware set up:
jobs
- The jobs value sets the number of jobs that can be run at once. This setting only effects the RTEMS Tester. The tester can run up to the
jobs
value of tests concurrently. If the tester back end is a simulator running a job on each available core lowers the total test time. Overloading a machine with too many simulators running in parallel can slow down each simulation and test timeouts may be recorded.
bsp_tty_dev
- The BSP’s tty device. This can be a real device on the host machine the executable is being run from or it can be a telnet server and port defined using the stand host format. See Consoles for details.
target_pretest_command
- The pre-test command is a host shell command that is called before each test runs. It can be used to construct a suitable environment or image needed by a simulator or target. The RTEMS executate being run is provided as an argument and the bootloader specific format is the output.
target_posttest_command
- The post-test command is a host shell command that is called after each test has finished. It can be used to destroy any environment or image created by the pre-test command.
target_exe_filter
- The target executable filter transforms the executable name into a filtered executable name. This filter lets the tester or run command track the name of any generated file a pre-test command may generate. The syntax is a simplified
sed
regular expression. The first character is a delimiter and there must be 2 sections therefore 3 delimiter. The first section is a Python regular expression and the second section is plain text that replaces anywhere the regular expression matches. For example/\.exe/.exe.img/
will search for.exe
in the executable name and replace it with.exe.img
. Note, there is no need to escape the text in the second part, it is just plain test.
test_restarts
- The number of restarts before the test is considered
invalid
. Currently not used.
target_reset_regex
- The target reset regular expression. This is a Python regular expression used to filter the console input. If a match is made something has happened during the boot process that requires a reset. The
target_reset_command
is issued to perform the reset. Typically this field looks for boot loader error messages that indicate the boot process as failed.
target_start_regex
The target start regular expression. This is a Python regular expression to filter the console input to asynchronously detect if a target has reset. If a board crashes running a test or at any point reset this filter detects the restart and ends the test with a suitable result.
target_on_command
- The target on command is a host shell command that is called before the first test. This command powers on a target. Targets should be left powered off when not running tests or the target may request TFTP downloads that are for another target interfering with those test results. We recommend you implement this command as a target off command, a pause, then a target on command.
target_off_command
- The target off command is a host shell command that is called after the last test powering off the target.
target_reset_command
- The target reset command is a host shell command that is called when the target needs to be reset. This command can power cycle the target or toggle a reset signal connected to the target. If you are power cycling a target make sure you have a suitable pause to let the target completely power down.
9.4.3. Configuration Scripts¶
Configuration scripts are provided for each supported RTEMS Tester and RTEMS Run back end and console management. The scripts are in the standard RTEMS Toolkit Configuration Script format. Please refer to the RTEMS Source Builder documentation for the basic scripting syntax and usage.
The RTEMS Tester and RTEMS Run specializes the standard configuration syntax providing a directive for the console and each supported back end. The supported directives are:
%console
%execute
%gdb
%tftp
9.4.3.1. Console¶
The %console
configures the console used to access the target’s console. The console can be a process’s stdout
, a termios tty on Unix and MacOS and Telnet on all hosts. The directive accepts:
stdio
- The standard output stream from the executing processing.
tty <dev> <settings>
The name of the
tty
to open and use. Thetty
device or<dev>
can be a termio device and the<settings>
are standard termios values.The Python termios document provides details of the settings that can be controlled. The settings are a single string where prefix the value with
~
negates the setting. Setting are:B115200
(an example buadrate)BRKINT
IGNBRK
IGNCR
ICANON
ISIG
IEXTEN
ECHO
CLOCAL
CRTSCTS
VMIN=<value>
VTIME=<value
A example in a configuration script is:
%define bsp_tty_dev /dev/ttyUSB2
%define bsp_tty_settings B115200,~BRKINT,IGNBRK,IGNCR,~ICANON,~ISIG,~IEXTEN,~ECHO,CLOCAL,~CRTSCTS,VMIN=1,VTIME=2
A example BSP or User configuration file is:
[bsp-special]
bsp = example-bsp
bsp_tty_dev = /dev/ttyUSB2
bsp_tty_settings = B115200,~BRKINT,IGNBRK,IGNCR,~ICANON,~ISIG,~IEXTEN,~ECHO,CLOCAL,~CRTSCTS,VMIN=1,VTIME=2
The console directive is managed in the %{_rtscripts}/console.cfg
configuration script. If the %{console_stdio}
is defined the console will be stdio
else the console will be the BSP console or %{bsp_tty_dev}
.
Telnet can be combined with the ser2net
daemon to remotely access a target’s physical serial UART interface.
9.4.3.2. Execute¶
The %execute
directive executes a command for each rest. The execute forks the command and arguments supplied to the execute directive and captures the stdout
stream as the console. If the console directive is set to stdout
the sub-processes stdout
stream is used as the console.
The RTEMS Tester will run parallel tests as jobs.
An example is:
%execute %{run_cmd} %{run_opts} %{test_executable} %{test_executable_opts}
9.4.3.3. GDB¶
The %gdb
directive executes GDB in the machine interface mode give the RTEMS Tester and RTEMS Run commands control. The console is taken from GDB if it is stdout
.
The RTEMS Tester will run parallel tests as jobs.
An example is:
%gdb %{gdb_cmd} %{test_executable} %{gdb_script}
9.4.3.4. TFTP¶
The %tftp
directive starts a TFTP session on a specified port sending the test executable to the target over a networking using the TFTP protocol.
The RTEMS Tester will run only one test at a time. There is just one physical board running the test.
An example is:
%tftp %{test_executable} %{tftp_port}
9.5. Consoles¶
The RTEMS Tester uses the target’s console output to determine the state of a test. Console interfaces vary depending on the testing mode, the BSP, and the target hardware.
Consoles for simulator work best if mapped to the simulator’s stdout
interface. The RTEMS Tester can capture and process the stdout
data from a simulator while it is running.
Target hardware console interfaces can vary. The most universal and stable interface target hardware is a UART interface. There are a number of physical interfaces for UART data these days. They are:
- RS232
- TTL
- USB
RS232 is still present on a number of targets. The best solution is to use a RS232 to USB pod and convert the port to USB.
TTL is common on a number of boards where cost is important. A console interface is typically a development tool and removing the extra devices need to convert the signal to RS232 or directly to USB is not needed on production builds of the target. There is a standard header pin out for TTL UART consoles and you can purchase low cost cables with the header and a built in UART to USB converter. The cables come is different voltage levels so make sure you check and use the correct voltage level.
The USB interface on a target is typcially a slave or OTG interface and all you need to a standard USB cable.
We recommend a low cost and low power device to be a terminal server. A Raspberry Pi or similar low cost computer running Linux can be set up quickly and with a powered USB hub and can support a number of USB UART ports. A USB hub with a high power port is recommended that can suppy the Raspberry Pi.
The open source daemon ser2net
is easy to configure to map the USB UART ports to the Telnet protocol. There is no need for security because a typical test environment is part of a lab network that should be partitioned off from an enginnering or corportate network and not directly connected to the internet.
A test set up like this lets you place a terminal server close to your target hardware providing you with the flexibility to select where you run the RTEMS Tester. It could be your desktop or an expensive fast host machine in a server rack. None of this equipment needs to directly interface to the target hardware.
The RTEMS Tester directly supports the telnet protcol as a console and can interface to the ser1net
server. The telnet console will poll the server waiting for the remote port to connect. If the terminal server ser2net
does not have a tty
device it will not listen on the port assigned to that tty
. A USB tty
can come and go depending on the power state of the hardware and the target hardware’s design and this can cause timing issues if the target hardware is power cycled as part of a reset process.
9.6. Simulation¶
Simulation is a important regression and development tool for RTEMS. Developers use simulation to work on core parts of RTEMS as it provides excellent debugging supporting. Simulation run via the RTEMS Tester allows a test to run on each core of your testing host machine lower the time to run all tests.
The RTEMS Tester Simulation figure shows the structure of RTEMS Testing using simulation. The executables are built and the rtems-test
command is run from the top of the build directory. The RTEMS Tester executes the BSP specific simulator for each test capturing the output
9.7. GDB and JTAG¶
GDB with JTAG provides a low level way to runs tests on hardware with limited resources. The RTEMS Tester runs and controls an instance of GDB per test and GDB connects via the GDB remote protocol to a GDB server that interfaces to the JTAG port of a target.
The Figure RTEMS Tester using GDB and JTAG shows the structure of RTEMS Testing using GDB and JTAG. The executables are built and the rtems-test
command is run from the top of the build directory. The RTEMS Tester executes the BSP architecture’s GDB and expects the user to provide a gdb-script
to connect t the JTAG GDB server.
9.8. TFTP and U-Boot¶
TFTP and U-Boot provides a simple way to test RTEMS on a network capable target. The RTEMS Tester starts a TFTP server for each test and the target’s boot monitor, in this case U-Boot request a file, any file, which the TFTP server supplies. U-Boot loads the executable and boots it using a standard U-Boot script.
The Figure RTEMS Tester using TFTP and U-Boot. figure shows the structure and control flow of the RTEMS Tester using TFTP and U-boot. The executables are built and the rtems-test
command is run from the top of the build directory.
This test mode can only support a single test job running at once. You cannot add more test target hardware and run the tests in parallel.
9.8.1. Target Hardware¶
The RTEMS Tester TFTP and U-Boot method of testing requires:
- A target with network interface.
- U-Boot, iPXE or similar boot loader with network driver support for your target hardware and support for the TFTP protocol.
- Network power of IO switch.
- Network DHCP server.
- Console interface cable that matches your target’s console UART interface.
- Telnet terminal server. See Consoles.
The network power or IO switch is a device that can control power or an IO pin over a network connection using a script-able protocol such as Telnet or curl. This device can be used with the target control commands.
9.8.1.1. U-Boot Set Up¶
Obtain a working image of the U-Boot boot loader for your target. We suggest you follow the instructions for you target.
Configure U-Boot to network boot using the TFTP protocol. This is U-Boot script for a Zedboard:
loadaddr=0x02000000
uenvcmd=echo Booting RTEMS Zed from net; set autoload no; dhcp; set serverip 10.10.5.2; tftpboot zed/rtems.img; bootm; reset;
The load address variable loadaddr
is specific to the Zedboard and can be found in the various examples scripts on the internet. The script then sets U-Boot environment variable autoload
to no
causing DHCP to only request a DHCP lease from the DHCP server. The script sets the serverip
to the host that will be running the RTEMS Tester then issues a TFTP request. The file name can be anything because the RTEMS Tester ignores it sending the executable image under test. Finally the script boots the download executable and if that fails the catch all reset
resets the board and starts the boot process over.
Test the target boots and U-Boot runs and obtains a valid DHCP lease. Manually connect the console’s telnet port.
9.8.2. BSP Configuration¶
The BSP’s configuration file must contain the standard fields:
bsp
arch
jobs
- Must be set to1
.tester
- Set to%{_rtscripts}/tftp.cfg
For example the Zedboard’s configuration is:
[xilinx_zynq_zedboard]
bsp = xilinx_zynq_zedboard
arch = arm
jobs = 1
tester = %{_rtscripts}/tftp.cfg
The TFTP configuration supports the following field’s:
bsp_tty_dev
- The target’s tty console. For telnet this is a host and port pair written in the standard networking format, for example
serserver:12345
. test_restarts
- The number of restarts before the test is considered
invalid
. target_reset_regex
- The target reset regular expression. This is a Python regular expression used to filter the console input. If a match is made something has happened during the boot process that requires a reset. The
target_reset_command
is issued to perform the reset. This field is typically looks for boot loader error messages that indicate the boot process as failed. target_start_regex
- The target start regular expression. This also a Python regular expression to filter the console input to detect if a target has reset. If a board crashes running a test or at any point in time and reset this filter detects this as happened and end the test with a suitable result.
target_on_command
- The target on command is a host shell command that is called before the first test. This command powers on a target. Targets should be left powered off when not running tests or the target may request TFTP downloads that are for another target interfering with those test results. We recommend you implement this command as a target off command, a pause, then a target on command.
target_off_command
- The target off command is a host shell command that is called after the last test powering off the target.
target_reset_command
- The target reset command is a host shell command that is called when the target needs to be reset. This command can power cycle the target or toggle a reset signal connected to the target. If you are power cycling a target make sure you have a suitable pause to let the target completely power down.
target_pretest_command
- The target pretest command is a host shell comment that is called before the test is run
The commands in the listed fields can include parameters that are substituted. The parameters are:
@ARCH@
- The BSP architecture
@BSP@
- The BSP’s name
@EXE@
- The executable name.
@FEXE@
- The
- . The
@ARCH
is the
substituted
Some of these field are normally provided by a user’s configuration. To do this use:
requires = bsp_tty_dev, target_on_command, target_off_command, target_reset_command
The requires
value requires the user provide these settings in their configuration file.
The Zedboard’s configuration file is:
[xilinx_zynq_zedboard]
bsp = xilinx_zynq_zedboard
arch = arm
jobs = 1
tester = %{_rtscripts}/tftp.cfg
test_restarts = 3
target_reset_regex = ^No ethernet found.*|^BOOTP broadcast 6.*|^.+complete\.+ TIMEOUT.*
target_start_regex = ^U-Boot SPL .*
requires = target_on_command, target_off_command, target_reset_command, bsp_tty_dev
The target_start_regex
searches for U-Boot’s first console message. This indicate the board can restarted.
The target_reset_regex
checks if no ethernet interface is found. This can happen if U-Boot cannot detect the PHY device. It also checks if too many DHCP requests happen and finally a check is made for any timeouts reported by U-Boot.
An example of a user configuration for the Zedboard is:
[xilinx_zynq_zedboard]
bsp_tty_dev = selserver:12345
target_pretest_command = zynq-mkimg @EXE@
target_exe_filter = /\.exe/.exe.img/
target_on_command = power-ctl toggle-on 1 4
target_off_command = power-ctl off 1
target_reset_command = power-ctl toggle-on 1 3
9.8.3. TFTP Sequences¶
Running a large number of tests on real hardware exposes a range of issues and RTEMS Tester is designed to be tolerant of failures in booting or loading that can happen, for example a hardware design. These sequence diagrams document some of the sequences that can occur when errors happen.
The simplest sequence is running a test. The target is powered on, the test is loaded and executed and a pass or fail is determined:
The target start filter triggers if a start condition is detected. This can happen if the board crashes or resets with no output. If this happens repeatedly the test result is invalid:
The reset filter triggers if an error condition is found such as the bootloader not being able to load the test executable. If the filter triggers the target_reset_command
is run:
If the RTEMS Tester does not detect a test has started it can restart the test by resetting the target. The reset command can toggle an IO pin connected to reset, request a JTAG pod issue a reset or turn the power off and on:
10. Tracing¶
RTEMS Tracing Framework is an on-target software based system which helps track the ongoings inside the operation of applications, third-party packages, and the kernel in real time.
Software based tracing is a complex process which requires components on both the target and the host to work together. However its portability across all architectures and board support packages makes it a useful asset. A key requirement in RTEMS trace process is to take existing code in compiled format (ELF) and instrument it in order to log various events and records in real time. However instrumenting of the code for tracing should happen without rebuilding the code from the source and without annotating the source with trace code.
10.1. Introduction to Tracing¶
Tracing is an important function which has several applications including identification of complex threading, detection of deadlocks, tracing functions along with their argument values, and return values through progression of several function calls and audit the performance of an application according to required specifications.
RTEMS tracing framework is under development and welcomes contribution by users.
RTEMS has the following trace components:
- RTEMS Trace Linker
- RTEMS Capture Engine
- RTEMS Event Recording
- Common Trace Format Integration
RTEMS trace framework can currently function using the following methods. Both of the methods make use of the Trace Linker :
10.1.1. RTEMS Trace Using Trace Buffering¶
This scheme of tracing goes through the flow of events described in a subsequent flowchart:
Step 1: The user creates an application and user configuration file. The configuration file specifies the use of the trace buffer generator and other standard initializations. The user then configures their BSP and invokes the trace linker using a command to link the application executable. The trace linker uses the application files in compiled format (ELF) and the libraries used to build the application for performing this link.
Step 2: The RTEMS Trace Linker reads the user’s configuration file and that results in it reading the standard Trace Buffering Configuration files installed with the RTEMS Trace Linker. The trace linker uses the target compiler and linker to create the trace enabled application executable. It wraps the functions defined in the user’s configuration with code that captures trace records into the statically allocated buffer. The trace wrapper code is compiled with the target compiler and the resulting ELF object file is added to the standard link command line used to link the application and the application is re-linked using the wrapping option of the GNU linker.
Step 3: The trace linker creates an executable which is capable of running on the target hardware or simulator.
Step 4: RTEMS shell provides the “rtrace” command to display and save trace buffers.
10.1.2. RTEMS Trace Using Printk¶
This scheme of tracing goes through the flow of events described in a subsequent flowchart:
Step 1: The user creates an RTEMS application in the normal manner as well as a Trace Linker configuration file. The configuration file specifies using the Printk trace mode and the functions to trace. The user invokes the Trace Linker with the configuration and the normal link command line used to the link the application executable. The application ELF object files and libraries, including the RTEMS libraries are standard and do not need to be built specially.
Step 2: The RTEMS Trace Linker reads the user’s configuration file and that results in it reading the standard Printk Trace Configuration files installed with the RTEMS Trace Linker. The trace linker uses the target compiler and linker to create the trace enabled application executable. It wraps the functions defined in the user’s configuration with code that prints the entry with arguments and exit and return value if any. The trace wrapper code is compiled with the target compiler and the resulting ELF object file is added to the standard link command line used to link the application and the application is relinked using the wrapping option of the GNU linker.
Step 3: The trace linker creates and RTEMS ELF executable that can be run on the target hardware or simulator.
Step 4: The application is run in the hardware directly or using a debugger. The printk() output appears on the target console and the user can save that to a file.
The Tracing Examples section describes generation of traces using Trace Buffering technique for the fileio testsuite available with RTEMS installation.
10.2. Tracing Examples¶
The following example executes RTEMS trace using trace buffering for the fileio sample testcase.
10.2.1. Features¶
Tracing using trace buffering consists of the following sets of features:
- Individual entry and exit records.
- Task details such as CPU, current priority, real priority, task state and interrupt state.
- Nano-second timestamp.
- Interrupt safe buffer management.
- Function argument capture.
- Return value capture.
- Shell command support to report to the console, save a buffer, assess status of tracing, or view buffers between specified index ranges.
10.2.2. Prerequisites¶
- Setup RTEMS for the sparc/erc32 architecture-bsp pair to run the following example.
- Download the fileio configuration file and store it on the top of the installed BSP’s directory.
- Change the value of the keys: rtems-path and prefix according to your rtems installation. The rtems-path is the path to the bsp installation and prefix is the path to the tools used to build rtems. Also set the value of the rtems-bsp key to sparc/erc32.
10.2.3. Demonstration¶
Inside the RTEMS build directory (the directory where the fileio configuration has been stored) run the following commands to generate traces:
BSP is configured with the following command -
../rtems/configure --target=sparc-rtems5 --prefix=/development/rtems/5 \
--enable-networking --enable-tests --enable-rtemsbsp=erc32 --enable-cxx
The next two commands are used to link the fileio executable.The -B option signifies the use of the complete path to the required directory or file. Write the full path instead of the path file: sparc-rtems5/erc32/lib/ in the following commands according to your installation. Also confirm the path of the fileio’s executable and object files in the last line of the command according to your installation.
sparc-rtems5-gcc -Bsparc-rtems5/erc32/lib/ \
-specs bsp_specs -qrtems -mcpu=cypress -O2 -g -ffunction-sections \
-fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration \
-Wstrict-prototypes -Wnested-externs -Wl,--gc-sections -mcpu=cypress \
-o sparc-rtems5/c/erc32/testsuites/samples/fileio.exe sparc-rtems5/c/erc32/\
testsuites/samples/fileio/fileio-init.o
This is the trace linker command to generate and compile the wrapper c file for the application. The link command follows the escape sequence “–”. “-C” option denotes the name of the user configuration file and “-W” specifies the name of the wrapper c file.
rtems-tld -C fileio-trace.ini -W fileio-wrapper -- -Bsparc-rtems5/erc32/lib/ \
-specs bsp_specs -qrtems -mcpu=cypress -O2 -g -ffunction-sections \
-fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration \
-Wstrict-prototypes -Wnested-externs -Wl,--gc-sections -mcpu=cypress \
-o sparc-rtems5/c/erc32/testsuites/samples/fileio.exe sparc-rtems5/c/erc32/\
testsuites/samples/fileio/fileio-init.o
The following command is used to run the application. Hit enter key quickly and type “s” and “root” and “pwd” to run the rtems shell. Use the rtrace status, rtrace trace and rtrace save commands to know the status of the tracing, display the contents of the trace buffer and save the buffer to disk in the form of binary files. Use rtrace -l to list the availalble options for commands with rtrace.
sparc-rtems5-run sparc-rtems5/c/erc32/testsuites/samples/fileio.exe
The output from the above commands will be as follows:
*** BEGIN OF TEST FILE I/O ***
*** TEST VERSION: 5.0.0.de9b7d712bf5da6593386fd4fbca0d5f8b8431d8
*** TEST STATE: USER_INPUT
*** TEST BUILD: RTEMS_NETWORKING RTEMS_POSIX_API
*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB a3a6c34c150a357e57769a26a460c475e188438f, Newlib 3.0.0)
Press any key to start file I/O sample (20s remaining)
Press any key to start file I/O sample (19s remaining)
Press any key to start file I/O sample (18s remaining)
Press any key to start file I/O sample (17s remaining)
Press any key to start file I/O sample (16s remaining)
Press any key to start file I/O sample (15s remaining)
Press any key to start file I/O sample (14s remaining)
=========================
RTEMS FILE I/O Test Menu
=========================
p -> part_table_initialize
f -> mount all disks in fs_table
l -> list file
r -> read file
w -> write file
s -> start shell
Enter your selection ==>s
Creating /etc/passwd and group with four useable accounts:
root/pwd
test/pwd
rtems/NO PASSWORD
chroot/NO PASSWORD
Only the root user has access to all available commands.
=========================
starting shell
=========================
Welcome to rtems-5.0.0 (SPARC/w/FPU/erc32)
COPYRIGHT (c) 1989-2008.
On-Line Applications Research Corporation (OAR).
Login into RTEMS
/dev/foobar login: root
Password:
RTEMS Shell on /dev/foobar. Use 'help' to list commands.
SHLL [/] # rtrace status
RTEMS Trace Bufferring: status
Running: yes
Triggered: yes
Level: 0%
Traces: 25
SHLL [/] # rtrace stop
RTEMS Trace Bufferring: stop
SHLL [/] # rtrace trace
RTEMS Trace Bufferring: trace
Trace buffer: 0x20921d8
Words traced: 1487
Traces: 25
0:00:40.983197010 2081910 0a010002 [ 2/ 2] > malloc((size_t) 00000130)
0:00:40.983333119 136109 0a010002 [ 2/ 2] < malloc => (void*) 0x219bb88
0:00:40.983471669 138550 0a010002 [ 2/ 2] > malloc((size_t) 00000006)
0:00:40.983606557 134888 0a010002 [ 2/ 2] < malloc => (void*) 0x219bcc0
0:00:40.983684682 78125 0a010002 [ 2/ 2] > malloc((size_t) 00000007)
0:00:40.983819569 134887 0a010002 [ 2/ 2] < malloc => (void*) 0x219bcd0
0:00:40.983909901 90332 0a010002 [ 2/ 2] > malloc((size_t) 000003fc)
0:00:40.984046620 136719 0a010002 [ 2/ 2] < malloc => (void*) 0x219bce0
0:00:40.986624137 2577517 0a010003 [200/200] > malloc((size_t) 00000080)
0:00:40.986767569 143432 0a010003 [200/200] < malloc => (void*) 0x219bce0
0:00:40.987531119 763550 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 0000005d)
0:00:40.987603751 72632 0a010003 [200/200] > malloc((size_t) 0000005d)
0:00:40.987744743 140992 0a010003 [200/200] < malloc => (void*) 0x219bce0
0:00:40.987824699 79956 0a010003 [200/200] < calloc => (void*) 0x219bce0
0:00:40.988302604 477905 0a010003 [200/200] > malloc((size_t) 00000080)
0:00:40.988446647 144043 0a010003 [200/200] < malloc => (void*) 0x219bd48
0:00:40.988667595 220948 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000080)
0:00:40.988740837 73242 0a010003 [200/200] > malloc((size_t) 00000080)
0:00:40.988884880 144043 0a010003 [200/200] < malloc => (void*) 0x219bdd0
0:00:40.988964836 79956 0a010003 [200/200] < calloc => (void*) 0x219bdd0
0:00:40.989042961 78125 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000080)
0:00:40.989110100 67139 0a010003 [200/200] > malloc((size_t) 00000080)
0:00:40.989254143 144043 0a010003 [200/200] < malloc => (void*) 0x219be58
0:00:40.989334099 79956 0a010003 [200/200] < calloc => (void*) 0x219be58
0:00:40.990118401 784302 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000061)
0:00:40.990176995 58594 0a010003 [200/200] > malloc((size_t) 00000061)
0:00:40.990309441 132446 0a010003 [200/200] < malloc => (void*) 0x219bd48
0:00:40.990384515 75074 0a010003 [200/200] < calloc => (void*) 0x219bd48
0:00:40.990870355 485840 0a010003 [200/200] > malloc((size_t) 00000080)
0:00:40.991011346 140991 0a010003 [200/200] < malloc => (void*) 0x219bee0
0:00:40.991227411 216065 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000080)
0:00:40.991296380 68969 0a010003 [200/200] > malloc((size_t) 00000080)
0:00:40.991438593 142213 0a010003 [200/200] < malloc => (void*) 0x219bf68
0:00:40.991514276 75683 0a010003 [200/200] < calloc => (void*) 0x219bf68
0:00:40.991589349 75073 0a010003 [200/200] > calloc((size_t) 00000001, (size_t) 00000080)
0:00:40.991653437 64088 0a010003 [200/200] > malloc((size_t) 00000080)
0:00:40.991794428 140991 0a010003 [200/200] < malloc => (void*) 0x219bff0
0:00:40.991871332 76904 0a010003 [200/200] < calloc => (void*) 0x219bff0
0:00:40.992283320 411988 0a010003 [200/200] > malloc((size_t) 00000008)
SHLL [/] # rtrace save fileio-trace.bin
RTEMS Trace Bufferring: trace
Trace File: fileio-trace.bin
Trace buffer: 0x20921d8
Words traced: 1487
Traces: 25
SHLL [/] #
10.3. Capture Engine¶
Capture Engine is a trace tool built inside the RTEMS operating system. Capture Engine is designed to cause the lowest load on the system when operating. Hence it does not effect RTEMS when operating or when disabled. It binds to RTEMS at runtime and does not require RTEMS or your application to be rebuilt in order to use it.
The Capture Engine’s sample testcase for the sparc/erc32 is available in build directory created when building RTEMS in the path file: sparc-rtems5/c/erc32/testsuites/samples. In order to access the capture testcase perform the following set of operations inside the RTEMS build directory.
$ cd /sparc-rtems5/c/erc32/testsuites/samples
$ sparc-rtems5-run ./capture.exe
*** BEGIN OF TEST CAPTURE ENGINE ***
*** TEST VERSION: 5.0.0.de9b7d712bf5da6593386fd4fbca0d5f8b8431d8
*** TEST STATE: USER_INPUT
*** TEST BUILD: RTEMS_NETWORKING RTEMS_POSIX_API
*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB a3a6c34c150a357e57769a26a460c475e188438f, Newlib 3.0.0)
Press any key to start capture engine (20s remaining)
Press any key to start capture engine (19s remaining)
Press any key to start capture engine (18s remaining)
Monitor ready, press enter to login.
1-rtems $
Capture Engine comes with a set of commands to perform various actions.
10.3.1. Capture Engine Commands¶
copen <buffer-size>
: Used to initialize the Capture Engine with the trace buffer size in bytes. By default the Capture Engine is not initialized and not running.cwceil <priority-value>
: Capture Engine filter used to put an upper limit on the event priority to be captured.cwfloor <priority-value>
: Capture Engine filter used to put a lower limit on the event priority to be captured.cwglob <on/off>
: Enable or disable the global watch.cenable
: Enables the Capture Engine. Capture Engine is by default disabled after being opened.cdisable
: Disables the Capture Engine.ctlist
: Lists the watch and trigger configurations.ctrace
: Dumps the recorded traces. By default this command displays 24 trace records. Repeated use of this command will display all the recorded traces.cwadd <task-name>
: Add watch on a particular task.cwtctl <task-name> <on/off>
: Enable or disable watch on a particular task.ctset
: Used to set a trigger. The general form of the command is:
ctset [-?] type [to name/id] [from] [from name/id]
type in the above command refers to the type of trigger needed. The types of triggers that currently exist are:
- switch : a context switch from one task to another task
- create : the executing task creates a task
- start : the executing task starts a task
- restart : the executing task restarts a task
- delete : the executing task deletes a task
- begin : a task is beginning
- exitted : a task is exitting
10.3.2. Example¶
The following is a sample run of the capture testsuite. The test1 command on the Capture Engine Command Line Interface (CLI) makes the RMON task invoke a call to the capture_test_1() command. This function (in the test1.c source code) creates and starts three tasks : CT1a, CT1b and CT1c. These tasks are passed the object id of a semaphore as a task argument. This run through traces the context switches between these tasks. cwceil
and cwfloor
are set to a narrow range of task priorities to avoid creating noise from a large number of context switches between tasks we are not interested in.
*** BEGIN OF TEST CAPTURE ENGINE ***
*** TEST VERSION: 5.0.0.de9b7d712bf5da6593386fd4fbca0d5f8b8431d8
*** TEST STATE: USER_INPUT
*** TEST BUILD: RTEMS_NETWORKING RTEMS_POSIX_API
*** TEST TOOLS: 7.3.0 20180125 (RTEMS 5, RSB a3a6c34c150a357e57769a26a460c475e188438f, Newlib 3.0.0)
Press any key to start capture engine (20s remaining)
Press any key to start capture engine (19s remaining)
Press any key to start capture engine (18s remaining)
Press any key to start capture engine (17s remaining)
Monitor ready, press enter to login.
1-rtems $ copen 50000
capture engine opened.
1-rtems $ cwceil 100
watch ceiling is 100.
1-rtems $ cwfloor 102
watch floor is 102.
1-rtems $ cwglob on
global watch enabled.
1-rtems $ ctset RMON
trigger set.
1-rtems $ cenable
capture engine enabled.
1-rtems $ test1
1-rtems $ cdisable
capture engine disabled.
1-rtems $ ctrace
0 0:18:17.462314124 0a010003 CT1a 102 102 102 4096 TASK_RECORD
0 0:18:17.462398963 0 0a010003 CT1a 102 102 CREATED
0 0:18:17.462647987 249024 0a010003 CT1a 102 102 STARTED
0 0:18:17.462904334 256347 0a010003 CT1a 102 102 SWITCHED_IN
0 0:18:17.463069129 164795 0a010003 CT1a 102 102 BEGIN
0 0:18:17.463335853 266724 0a010003 CT1a 102 102 SWITCHED_OUT
0 0:18:18.461348547 0a010004 CT1b 101 101 101 4096 TASK_RECORD
0 0:18:18.461433997 998098144 0a010004 CT1b 101 101 CREATED
0 0:18:18.461683631 249634 0a010004 CT1b 101 101 STARTED
0 0:18:18.461934485 250854 0a010004 CT1b 101 101 SWITCHED_IN
0 0:18:18.462099891 165406 0a010004 CT1b 101 101 BEGIN
0 0:18:19.460935339 998835448 0a010004 CT1b 101 101 SWITCHED_OUT
0 0:18:19.461431555 0a010005 CT1c 100 100 100 4096 TASK_RECORD
0 0:18:19.461516394 581055 0a010005 CT1c 100 100 CREATED
0 0:18:19.461765418 249024 0a010005 CT1c 100 100 STARTED
0 0:18:19.462019324 253906 0a010005 CT1c 100 100 SWITCHED_IN
0 0:18:19.462184119 164795 0a010005 CT1c 100 100 BEGIN
0 0:18:19.462475257 291138 0a010005 CT1c 100 100 SWITCHED_OUT
0 0:18:19.462551551 76294 0a010004 CT1b 101 101 SWITCHED_IN
0 0:18:19.960935645 498384094 0a010004 CT1b 101 101 SWITCHED_OUT
0 0:18:19.961012549 76904 0a010003 CT1a 102 100 SWITCHED_IN
0 0:18:19.961341528 328979 0a010003 CT1a 102 102 SWITCHED_OUT
1-rtems $ ctrace
0 0:18:19.961418433 0 0a010005 CT1c 100 100 SWITCHED_IN
0 0:18:19.961672339 253906 0a010005 CT1c 100 100 SWITCHED_OUT
0 0:18:19.961749854 77515 0a010004 CT1b 101 101 SWITCHED_IN
0 0:18:20.460967077 499217223 0a010004 CT1b 101 101 SWITCHED_OUT
0 0:18:20.461219763 252686 0a010005 CT1c 100 100 SWITCHED_IN
0 0:18:20.461424231 204468 0a010005 CT1c 100 100 TERMINATED
0 0:18:20.461747107 322876 0a010005 CT1c 100 100 SWITCHED_OUT
0 0:18:20.461824011 76904 0a010004 CT1b 101 101 SWITCHED_IN
0 0:18:20.462015052 191041 0a010004 CT1b 101 101 TERMINATED
0 0:18:20.462336707 321655 0a010004 CT1b 101 101 SWITCHED_OUT
0 0:18:20.462414222 77515 0a010003 CT1a 102 102 SWITCHED_IN
0 0:18:20.462608924 194702 0a010003 CT1a 102 102 TERMINATED
0 0:18:20.462933021 324097 0a010003 CT1a 102 102 SWITCHED_OUT
1-rtems $ ctrace
1-rtems $
10.4. Trace Linker¶
RTEMS trace linker is a post link tool central to the RTEMS trace framework. It is installed as a part of the RTEMS Tool Project. The RTEMS Trace Linker is a post link tool that performs a re-link of your application to produce a trace executable. A trace executable has been instrumented by the RTEMS Trace Linker with additional code that implements software tracing. A key requirement of the trace process in RTEMS is to take existing code in a compiled format (ELF) and instrument it without rebuilding that code from source and without annotating that source with trace code.
10.4.1. Command Line¶
A typical command to invoke the trace linker consists of two parts separated by --
. The first part controls the trace linker and provides the various options it needs and the second part is a standard linker command line you would use to link an RTEMS application. The current command line for trace linker consists of:
$ rtems-tld -h
rtems-trace-ld [options] objects
Options and arguments:
-h : help (also --help)
-V : print linker version number and exit (also --version)
-v : verbose (trace import parts), can supply multiple times
to increase verbosity (also --verbose)
-w : generate warnings (also --warn)
-k : keep temporary files (also --keep)
-c compiler : target compiler is not standard (also --compiler)
-l linker : target linker is not standard (also --linker)
-E prefix : the RTEMS tool prefix (also --exec-prefix)
-f cflags : C compiler flags (also --cflags)
-r path : RTEMS path (also --rtems)
-B bsp : RTEMS arch/bsp (also --rtems-bsp)
-W wrapper : wrapper file name without ext (also --wrapper)
-C ini : user configuration INI file (also --config)
-P path : user configuration INI file search path (also --path)
The trace linker generates code that needs to be compiled and linked to the application executable so it needs to know the target compiler and CFLAGS. There are a couple of ways to do this. The simplest is to provide the path to RTEMS using the -r option and the architecture and BSP name in the standard RTEMS format of arch/bsp. The trace linker will extract the compiler and flags used to build RTEMS and will use them. If you require specific options you can use the -f, -c, -l, and -E options to provide them. If the functions you are tracing use types from your code then add the include path to the CFLAGS.
The trace linker requires you to provide a user configuration file using the -C or --config
option. This is an INI format file detailed in the Configuration section. You can also provide an INI file search path using the -P option.
If you are working with new configuration files and you want to view the files the trace linker generates, add the -k option to keep the temporary files, and -W to specify an explicit wrapper C file name. If you set the dump-on-error
option in the configuration options section you will get a dump of the configuration on an error.
10.4.2. Configuration (INI) files¶
The Trace Linker is controlled using configuration files. Configuration files are categorized into 3 types:
- User Configuration: These are specific to the user application to be traced. This file initializes the values of the trace generator, triggers, enables, and traces.
- Tracer Configuration: These are like a library of common or base trace functions that can be referenced by an application. These files tend to hold the details needed to wrap a specific set of functions. Examples provided with the RTEMS Linker are the RTEMS API and Libc.
- Generator Configuration: This is used to encapsulate a specific method of tracing. RTEMS currently provides generators for trace buffering, printk, and printf.
The configuration files are in the INI file format which is composed of sections. Each section has a section name and set of keys which consist of names and values. A typical key is of the form name=value
. Keys can be used to include other INI files using the include key name. This is shown in the following example where the values indicate rtems and rtld-base configuration files:
include = rtems.ini, rtld-base.ini
The trace linker also uses values in keys to specify other sections. In this example the functions name lists test-trace-funcs and that section contains a headers key that further references a section called test-headers:
functions = test-trace-funcs, rtems-api
[test-trace-funcs]
; Parsed via the 'function-set', not parse as a 'trace'.
headers = test-headers
[test-headers]
header = '#include "test-trace-1.h"'
The format of a configuration file is explained next. Snippets of the file: test-trace.ini have been used for explicit understanding. This file can be found in the rtems-tools directory of the rtems installation.
10.4.2.1. Tracer Section¶
The topmost level section is the tracer
section. It can contains the following keys:
name
: The name of trace being linked.options
: A list of option sections.defines
: A list of sections containing defines or define record.define
: A list of define string that are single or double quoted.enables
: The list of sections containing enabled functions to trace.triggers
: The list of sections containing enabled functions to trigger trace on.traces
: The list of sections containing function lists to trace.functions
: The list of sections containing function details.include
: The list of files to include.
The tracer section of the file:test-trace.ini is shown below with explanatory comments.
;
; RTEMS Trace Linker Test Configuration.
;
; We must provide a top level trace section.
;
[tracer]
;
; Name of the trace.
;
name = RTEMS Trace Linker Test
;
; The BSP.
;
bsp = sparc/sis
;
; Functions to trace.
;
traces = test-trace, test-trace-funcs, rtems-api-task
;
; Specify the options.
;
options = test-options
;
; Define the function sets. These are the function's that can be
; added to the trace lists.
;
functions = test-trace-funcs, rtems-api
;
; Include RTEMS Trace support.
;
include = rtems.ini, rtld-base.ini
10.4.2.2. Options section¶
The options section in the fileio-trace.ini is called the fileio-options. A general options section can contain following sets of keys:
dump-on-error
: Dump the parsed configuration data on error. The value can be true or false.verbose
: Set the verbose level. The value can be true or a number value.prefix
: The prefix for the tools and an install RTEMS if rtems-path is not set.cc
: The compiler used to compile the generated wrapper code. Overrides the BSP configuration value if a BSP is specified.ld
: The linker used to link the application. The default is the cc value as read from the BSP configuration if specified. If your application contains C++ code use this setting to the change the linker to g++.cflags
: Set the CFLAGS used to compiler the wrapper. These flags are pre-pended to the BSP read flags if a BSP is specified. This option is used to provide extra include paths to header files in your application that contain types referenced by functions being traced.rtems-path
: The path to an install RTEMS if not installed under the prefix.rtems-bsp
: The BSP we are building the trace executable for. The is an arch and bsp pair. For example sparc/erc32.
The options section of the file: test-trace.ini uses two of the aforementioned keys as shown below:
;
; Options can be defined here or on the command line.
;
[test-options]
prefix = /development/rtems/5
verbose = true
10.4.2.3. Trace Section¶
A trace section defines how trace wrapper functions are built. To build a trace function that wraps an existing function in an ELF object file or library archive we need to have the function’s signature. A signature is the function’s declaration with any types used. The signature has specific types and we need access to those types which means the wrapper code needs to include header files that define those types. There may also be specific defines needed to access those types. A trace section can contain the following keys:
generator
: The generator defines the type of tracing being used.headers
: List of sections that contain header file’s keys.header
: A header key. Typically the include code.defines
: List of sections that contain defines.define
: A define key. Typically the define code.signatures
: List of function signature sections.trace
: Functions that are instrumented with trace code.
The trace section of the file: test-trace.ini is shown below. A trace section can reference other trace sections of a specific type. This allows a trace sections to build on other trace sections.
; User application trace example.
;
[test-trace]
generator = printf-generator
; Just here for testing.
trace = test_trace_3
[test-trace-funcs]
; Parsed via the 'function-set', not parse as a 'trace'.
headers = test-headers
header = '#include "test-trace-2.h"'
defines = test-defines
define = "#define TEST_TRACE_2 2"
signatures = test-signatures
; Parsed via the 'trace', not parsed as a function-set
trace = test_trace_1, test_trace_2
[test-headers]
header = '#include "test-trace-1.h"'
[test-defines]
define = "#define TEST_TRACE_1 1"
[test-signatures]
test_trace_1 = void, int
test_trace_2 = test_type_2, test_type_1
test_trace_3 = float, float*
10.4.2.4. Function Section¶
Function sections define functions that can be traced. Defining a function so it can be traced does not mean it is traced. The function must be added to a trace list to be traced. Function sections provide any required defines, header files, and the function signatures.
A function signature is the function’s declaration. It is the name of the function, the return value, and the arguments. Tracing using function wrappers requires that we have accurate function signatures and ideally we would like to determine the function signature from the data held in ELF files. ELF files can contain DWARF data, the ELF debugging data format. In time the trace project would like to support libdwarf so the DWARF data can be accessed and used to determine a function’s signature. This work is planned but not scheduled to be done and so in the meantime we explicitly define the function signatures in the configuration files.
A function section can consist of the following keys:
headers
: A list of sections containing headers or header records.header
: A list of include string that are single or double quoted.defines
: A list of sections containing defines or define record.defines
: A list of define string that are single or double quoted.signatures
: A list of section names of function signatures.includes
: A list of files to include.
Function signatures are specified with the function name being the key’s name and the key’s value being the return value and a list of function arguments. You need to provide void if the function uses void. Variable argument list are currently not supported. There is no way to determine statically a variable argument list. The function section in the file: test-trace.ini has been labeled as test-trace-funcs. This can be seen in the file snippet of the previous section.
10.4.2.5. Generators¶
The trace linker’s major role is to wrap functions in the existing executable with trace code. The directions on how to wrap application functions is provided by the generator configuration. The wrapping function uses a GNU linker option called –wrap=symbol. The GNU Ld manual states:
“Use a wrapper function for symbol. Any undefined reference to symbol will be resolved to __wrap_symbol. Any undefined reference to __real_symbol will be resolved to symbol.”
Generator sections specify how to generate trace wrapping code. The trace linker and generator section must match to work. The trace linker expects a some things to be present when wrapping functions. The section’s name specifies the generator and can be listed in a generator key in a tracer or trace section. If the generator is not interested in a specific phase it does not need to define it. Nothing will be generated in regard to this phase. For example code to profile specific functions may only provide the entry-trace and exit-trace code where a nano-second time stamp is taken.
The generate code will create an entry and exit call and the generator code block can be used to allocate buffer space for each with the lock held. The entry call and argument copy is performed with the lock released. The buffer space having been allocated will cause the trace events to be in order. The same goes for the exit call. Space is allocated in separate buffer allocate calls so the blocking calls will have the exit event appear in the correct location in the buffer.
The following keys can be a part of the generator configuration:
headers
: A list of sections containing headers or header records.header
: A list of include string that are single or double quoted.defines
: A list of sections containing defines or define record.define
: A list of define string that are single or double quoted.entry-trace
: The wrapper call made on a function’s entry. Returns bool where true is the function is being traced. This call is made without the lock being held if a lock is defined.arg-trace
: The wrapper call made for each argument to the trace function if the function is being traced. This call is made without the lock being held if a lock is defined.exit-trace
: The wrapper call made after a function’s exit. Returns bool where true is the function is being traced. This call is made without the lock being held if a lock is defined.ret-trace
: The wrapper call made to log the return value if the function is being traced. This call is made without the lock being held if a lock is defined.lock-local
: The wrapper code to declare a local lock variable.lock-acquire
: The wrapper code to acquire the lock.lock-release
: The wrapper code to release the lock.buffer-local
: The wrapper code to declare a buffer index local variable.buffer-alloc
: The wrapper call made with a lock held if defined to allocate buffer space to hold the trace data. A suitable 32bit buffer index is returned. If there is no space an invalid index is returned. The generator must handle any overhead space needed. The generator needs to make sure the space is available before making the alloc all.code-blocks
: A list of code block section names.code
: A code block in <<CODE — CODE (without the single quote).includes
: A list of files to include.
The following macros can be used in wrapper calls:
@FUNC_NAME@
: The trace function name as a quote C string.@FUNC_INDEX@
: The trace function index as a held in the sorted list of trace functions by the trace linker. It can be used to index the names, enables, and triggers data.@FUNC_LABEL@
: The trace function name as a C label that can be referenced. You can take the address of the label.@FUNC_DATA_SIZE@
: The size of the data in bytes.@FUNC_DATA_ENTRY_SIZE@
: The size of the entry data in bytes.@FUNC_DATA_RET_SIZE@
: The size of the return data in bytes.@ARG_NUM@
: The argument number to the trace function.@ARG_TYPE@
: The type of the argument as a C string.@ARG_SIZE@
: The size of the type of the argument in bytes.@ARG_LABEL@
: The argument as a C label that can be referenced.@RET_TYPE@
: The type of the return value as a C string.@RET_SIZE@
: The size of the type of the return value in bytes.@RET_LABEL@
: The return value as a C label that can be referenced.
The buffer-alloc, entry-trace, and exit-trace can be transformed using the following macros:
@FUNC_NAME@
@FUNC_INDEX@
@FUNC_LABEL@
@FUNC_DATA_SZIE@
@FUNC_DATA_ENTRY_SZIE@
@FUNC_DATA_EXIT_SZIE@
The arg-trace can be transformed using the following macros:
@ARG_NUM@
@ARG_TYPE@
@ARG_SIZE@
@ARG_LABEL@
The ret-trace can be transformed using the following macros:
@RET_TYPE@
@RET_SIZE@
@RET_LABEL@
The file: test-trace.ini specifies printf-generator
as its generator. This section can be found in the file: rtld-print.ini in the rtems-tools directory and is shown below:
;
; A printf generator prints to stdout the trace functions.
;
[printf-generator]
headers = printf-generator-headers
entry-trace = "rtld_pg_printf_entry(@FUNC_NAME@, (void*) &@FUNC_LABEL@);"
arg-trace = "rtld_pg_printf_arg(@ARG_NUM@, @ARG_TYPE@, @ARG_SIZE@, (void*) &@ARG_LABEL@);"
exit-trace = "rtld_pg_printf_exit(@FUNC_NAME@, (void*) &@FUNC_LABEL@);"
ret-trace = "rtld_pg_printf_ret(@RET_TYPE@, @RET_SIZE@, (void*) &@RET_LABEL@);"
code = <<<CODE
static inline void rtld_pg_printf_entry(const char* func_name,
void* func_addr)
{
printf (">>> %s (0x%08x)\n", func_name, func_addr);
}
static inline void rtld_pg_printf_arg(int arg_num,
const char* arg_type,
int arg_size,
void* arg)
{
const unsigned char* p = arg;
int i;
printf (" %2d] %s(%d) = ", arg_num, arg_type, arg_size);
for (i = 0; i < arg_size; ++i, ++p) printf ("%02x", (unsigned int) *p);
printf ("\n");
}
static inline void rtld_pg_printf_exit(const char* func_name,
void* func_addr)
{
printf ("<<< %s (0x%08x)\n", func_name, func_addr);
}
static inline void rtld_pg_printf_ret(const char* ret_type,
int ret_size,
void* ret)
{
const unsigned char* p = ret;
int i;
printf (" rt] %s(%d) = ", ret_type, ret_size);
for (i = 0; i < ret_size; ++i, ++p) printf ("%02x", (unsigned int) *