Skip to content

Commit

Permalink
Merge pull request #226 from nasa/integration-candidate
Browse files Browse the repository at this point in the history
PSP Integration Candidate: 2020-12-08
  • Loading branch information
astrogeco committed Dec 9, 2020
2 parents 8591014 + 3b95ea3 commit 3178920
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 74 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ This is a collection of APIs abstracting platform specific functionality to be l

## Version History

### Development Build: 1.5.0-rc1+dev42

- Updates the Readme for RTEMS and adds `README_RTEMS_5.txt`. The changes include removing references to the CEXP module loader, and describing the development environment setup for RTEMS 5.
- Remove obsolete OS_TaskRegister comment.
- See <https://github.com/nasa/PSP/pull/226>


### Development Build: 1.5.0-rc1+dev36

- Rename `UT_SetForceFail` to `UT_SetDefaultReturnValue` since some functions that retain more than 1 value are not necessarily failing.
Expand Down
2 changes: 1 addition & 1 deletion fsw/mcp750-vxworks/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 36
#define CFE_PSP_IMPL_BUILD_NUMBER 42
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1"

/*
Expand Down
1 change: 0 additions & 1 deletion fsw/mcp750-vxworks/src/cfe_psp_exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ void CFE_PSP_ExceptionHook (TASK_ID task_id, int vector, void* vpEsf )
**
** Notes: The exception environment is local to each task Therefore this must be
** called for each task that that wants to do floating point and catch exceptions
** Currently, this is automatically called from OS_TaskRegister for every task
*/
void CFE_PSP_SetDefaultExceptionEnvironment(void)
{
Expand Down
2 changes: 1 addition & 1 deletion fsw/pc-linux/inc/psp_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
/*
* Development Build Macro Definitions
*/
#define CFE_PSP_IMPL_BUILD_NUMBER 36
#define CFE_PSP_IMPL_BUILD_NUMBER 42
#define CFE_PSP_IMPL_BUILD_BASELINE "v1.5.0-rc1"

/*
Expand Down
1 change: 0 additions & 1 deletion fsw/pc-linux/src/cfe_psp_exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,6 @@ void CFE_PSP_AttachExceptions(void)
**
** Notes: The exception environment is local to each task Therefore this must be
** called for each task that that wants to do floating point and catch exceptions
** Currently, this is automaticall called from OS_TaskRegister for every task
*/

void CFE_PSP_SetDefaultExceptionEnvironment(void)
Expand Down
134 changes: 66 additions & 68 deletions fsw/pc-rtems/README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
ABOUT THE PC-RTEMS CFE PSP
==========================
Note: These instructions are for RTEMS 4.11

The "pc-rtems" PSP layer is intended to be an easy way to prove out the basic functionality
of CFE running on RTEMS without actually requiring a real hardware target with RTEMS support.
Expand All @@ -14,13 +15,8 @@ build system. The RTEMS_BSP_TOP directory must be set to the same location eith
the example toolchain file or via -D options to the CMake build.




I. Setting up and compiling RTEMS BSP

Steps 1 & 5 may require root access. Everything else should be done as regular user.


1) install RTEMS toolchain for i386-rtems4.11 (or relevant target arch) into /opt/rtems-4.11

The RTEMS official docs have instructions for this, which should supercede anything here.
Expand All @@ -29,23 +25,23 @@ Basic use of the the "rtems source builder" tool which works at the time of this
OFFICIAL RTEMS SOURCE BUILDER CLONE URL: git:https://git.rtems.org/rtems-source-builder.git


sudo mkdir -p /opt/rtems-4.11
git clone git:https://git.rtems.org/rtems-source-builder.git
mkdir -p ${HOME}/rtems-4.11
git clone -b 4.11 git:https://git.rtems.org/rtems-source-builder.git
cd rtems-source-builder/rtems
git checkout 4.11.2
../source-builder/sb-set-builder --prefix=/opt/rtems-4.11 4.11/rtems-i386
../source-builder/sb-set-builder --prefix=$HOME/rtems-4.11 4.11/rtems-i386


2) Clone/Bootstrap RTEMS source tree:

Note - at the time of this writing 4.11 is the current "stable" branch and
4.11.2 represents the latest point release tag on that branch. The bleeding
edge "development" branch tends to change on a frequent basis.
Note - at the time of this writing 4.11.3 is the latest point release
on the RTEMS 4.11 branch. We are using the rtems git repository 4.11 branch, which
contains the latest point release (or fixes for the point release in progress)
You may wish to download a specific release such as RTEMS 4.11.3.

OFFICIAL RTEMS CLONE URL: git:https://git.rtems.org/rtems.git

$ git clone -b 4.11.2 git:https://git.rtems.org/rtems.git
$ export PATH=/opt/rtems-4.11/bin:$PATH
$ git clone -b 4.11 git:https://git.rtems.org/rtems.git
$ export PATH=$HOME/rtems-4.11/bin:$PATH
$ (cd rtems && ./bootstrap)


Expand All @@ -72,30 +68,7 @@ $ make
$ make install
$ cd ..


4) Install cexp-2.2.x (dynamic module loader library)

This is necessary to get the module loader to compile and work.

Ref page: http:https://www.slac.stanford.edu/~strauman/rtems/cexp/index.html
Tarball: http:https://www.slac.stanford.edu/~strauman/rtems/cexp/cexp-2.2.3.tgz

NOTE: As of 2017-10-26 the code is also now on github, but the git version appears to be
missing files and I was not able to get it to compile.
git clone -b CEXP_Release_2_2_3 https://github.com/till-s/cexpsh.git

$ mkdir b-cexp
$ cd b-cexp
$ ../cexp-CEXP_Release_2_2_3/configure --with-rtems-top=${HOME}/rtems-4.11 --host=i386-rtems4.11 --enable-std-rtems-installdirs
$ make
$ make install
$ cd ..

NOTE: using 2.2.3 against the latest rtems-4.11 produce a compile error regarding dereferencing incomplete types.
This appears to be due to #define XOPEN_SOURCE 500 on cexplock.c. Remove this and it compiled.


5) RTEMS build module for CMake
4) RTEMS build module for CMake

This tells CMake how to build basic binaries for RTEMS - it does not know how to do this
"out of the box" on a stock install.
Expand All @@ -107,18 +80,6 @@ like this if not already present (prior to the "project()" function):
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../psp/cmake/Modules" ${CMAKE_MODULE_PATH})


>>> IMPORTANT: Any code compiled with "-fPIC" will seriously confuse Cexp!! <<<

RTEMS does not (yet?) do native shared modules. This build uses Cexp (installed earlier)
to get around this but this is _NOT_ a shared module in the traditional sense - it actually
is just a simple relocatable object that it loads.

The "CMAKE_C_COMPILE_OPTIONS_PIC" is actually set to _not_ use -fPIC for this reason.





II. Mission setup modifications to use PC-RTEMS PSP

Use a CMake toolchain file to build CFE for RTEMS. This goes under the mission's "_defs" top-level directory.
Expand All @@ -132,27 +93,52 @@ file will be picked up and used by the build system.

====== START OF EXAMPLE TOOLCHAIN FILE: CUT HERE ===========

# This example toolchain file describes the cross compiler to use for
# the target architecture indicated in the configuration file.

# In this sample application, the cross toolchain is configured to
# use a compiler for the RTEMS operating system targeting the "pc686" BSP

# Note that to use this, the "RTEMS" platform module may need to be added
# to the system-wide CMake installation as a default CMake does not yet
# recognize RTEMS as a system name. An example of this is distributed with
# the pc-rtems PSP.

# Basic cross system configuration
set(CMAKE_SYSTEM_NAME RTEMS)
set(CMAKE_SYSTEM_PROCESSOR i386)
set(CMAKE_SYSTEM_VERSION 4.11)
set(RTEMS_TOOLS_PREFIX "/opt/rtems-${CMAKE_SYSTEM_VERSION}")
set(RTEMS_BSP_PREFIX "$ENV{HOME}/rtems-${CMAKE_SYSTEM_VERSION}")
set(RTEMS_BSP pc686)

# The TOOLS and BSP are allowed to be installed in different locations.
# If the README was followed they will both be installed under $HOME
# By default it is assumed the BSP is installed to the same directory as the tools
SET(RTEMS_TOOLS_PREFIX "$ENV{HOME}/rtems-${CMAKE_SYSTEM_VERSION}" CACHE PATH
"RTEMS tools install directory")
SET(RTEMS_BSP_PREFIX "${RTEMS_TOOLS_PREFIX}" CACHE PATH
"RTEMS BSP install directory")

# The BSP that will be used for this build
set(RTEMS_BSP "pc686")

# specify the cross compiler - adjust accord to compiler installation
# This uses the compiler-wrapper toolchain that buildroot produces
set(TARGET_PREFIX "${CMAKE_SYSTEM_PROCESSOR}-rtems${CMAKE_SYSTEM_VERSION}-")
set(CPUTUNEFLAGS "-march=i686 -mtune=i686")

SET(CMAKE_C_COMPILER "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}gcc")
SET(CMAKE_CXX_COMPILER "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}g++")
SET(CMAKE_LINKER "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}ld")
SET(CMAKE_ASM_COMPILER "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}as")
SET(CMAKE_STRIP "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}strip")
SET(CMAKE_NM "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}nm")
SET(CMAKE_AR "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}ar")
SET(CMAKE_OBJDUMP "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}objdump")
SET(CMAKE_OBJCOPY "${RTEMS_TOOLS_PREFIX}/bin/${TARGET_PREFIX}objcopy")
SET(SDKHOSTBINDIR "${RTEMS_TOOLS_PREFIX}/bin")
set(TARGETPREFIX "${CMAKE_SYSTEM_PROCESSOR}-rtems${CMAKE_SYSTEM_VERSION}-")
set(RTEMS_BSP_C_FLAGS "-march=i686 -mtune=i686 -fno-common")
set(RTEMS_BSP_CXX_FLAGS ${RTEMS_BSP_C_FLAGS})

SET(CMAKE_C_COMPILER "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}gcc")
SET(CMAKE_CXX_COMPILER "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}g++")
SET(CMAKE_LINKER "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}ld")
SET(CMAKE_ASM_COMPILER "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}as")
SET(CMAKE_STRIP "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}strip")
SET(CMAKE_NM "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}nm")
SET(CMAKE_AR "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}ar")
SET(CMAKE_OBJDUMP "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}objdump")
SET(CMAKE_OBJCOPY "${RTEMS_TOOLS_PREFIX}/bin/${TARGETPREFIX}objcopy")

# Exception handling is very iffy. These two options disable eh_frame creation.
set(CMAKE_C_COMPILE_OPTIONS_PIC -fno-exceptions -fno-asynchronous-unwind-tables)

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
Expand All @@ -167,9 +153,21 @@ SET(CMAKE_PREFIX_PATH /)
# abstraction layers are built when using this toolchain
SET(CFE_SYSTEM_PSPNAME pc-rtems)
SET(OSAL_SYSTEM_BSPTYPE pc-rtems)
SET(OSAL_SYSTEM_OSTYPE rtems-ng)


SET(OSAL_SYSTEM_OSTYPE rtems)

# Info regarding the RELOCADDR:
#+--------------------------------------------------------------------------+
#| Set the value of RELOCADDR to the address where you want your image to
#| load. If you'll be using GRUB to load the images it will have to be >=
#| 0x100000 (1024K). If you are using NetBoot to load the images it can be
#| >= 0x10000 (64K) AND <= 0x97C00 (607K) OR >= 0x100000 (1024K). The memory
#| top is of course another limit. Make sure there is enough space before the
#| upper memory limits for the image and the memory allocated by it to fit.
#| Make sure the value you choose is aligned to 4 bytes.
#+--------------------------------------------------------------------------+
set(RTEMS_RELOCADDR 0x00100000)

====== END OF EXAMPLE TOOLCHAIN FILE: CUT HERE ===========

2) Get RTEMS GRUB boot image

Expand Down
Loading

0 comments on commit 3178920

Please sign in to comment.