Skip to content

Commit

Permalink
rework into a base container for epics-base (#2)
Browse files Browse the repository at this point in the history
* make names, paths and files shorter

* fix TAGS

* fix patch

* update README

* restore patch

* switch to bsp based naming for images

* run targets parallel
  • Loading branch information
gilesknap authored Mar 7, 2024
1 parent 8b17895 commit 9b7ee04
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// For format details, see https://containers.dev/implementors/json_reference/
{
"name": "epics-containers IOC devcontainer",
"image": "ghcr.io/epics-containers/rtems6-powerpc-linux-developer:6.2rc1-ec1b1",
"image": "ghcr.io/epics-containers/rtems6-powerpc-linux-developer:6.2rc1ec2b3",
"remoteEnv": {
// allows X11 apps to run inside the container
"DISPLAY": "${localEnv:DISPLAY}",
Expand Down
7 changes: 3 additions & 4 deletions .devcontainer/postCreateCommand
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,16 @@
################################################################################

if [[ $USER != "root" ]] ; then
# make sure the non-root user can build iocs and (mounted in) support modules
sudo chown -R ${USER}:${USER} /epics/ibek-defs /epics/pvi-defs /epics/support/configure /venv
sudo chown -h ${USER}:${USER} /epics /epics/ioc /epics/support
# make sure the non-root user can interact with the rtems BSP and RSB
sudo chown -R ${USER}:${USER} /rtems*/rsb /rtems*/rtems
fi

################################################################################
# Shell customizations for Generic IOC devcontainers
################################################################################

# pick a theme that does not cause completion corruption in zsh
sed -i $HOME/.zshrc -e 's/ZSH_THEME="devcontainers"/ZSH_THEME="eastwood"/'
sed -i $HOME/.zshrc -e 's/ZSH_THEME="devcontainers"/ZSH_THEME="dst"/'

# allow personalization of all devcontainers in this subdirectory
# by placing a .devcontainer_rc file in the workspace root
Expand Down
35 changes: 12 additions & 23 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,24 @@ on:
pull_request:

jobs:
build-push-images:
build:
# pull requests are a duplicate of a branch push if within the same repo.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.repository
permissions:
contents: read
packages: write
strategy:
fail-fast: true
max-parallel: 1 # take advantage of caching
matrix:
target: [developer, runtime]
architecture: [linux]
include:
- os: ubuntu-latest
platforms: linux/amd64
# add more targets here and add a Dockerfile.${{ matrix.target }} to the repo
target_architecture: [beatnik]

runs-on: ${{ matrix.os }}

runs-on: ubuntu-latest
env:
TAG: ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}-${{ matrix.architecture }}-${{ matrix.target }}:${{ github.ref_name }}
TAG: ghcr.io/${{ github.repository_owner }}/rtems-${{ matrix.target_architecture }}-${{ matrix.target }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
submodules: recursive

- name: Log in to GitHub Docker Registry
uses: docker/login-action@v3
Expand All @@ -43,13 +37,11 @@ jobs:
- name: Build image
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platforms }}
file: Dockerfile.${{ matrix.target_architecture }}
target: ${{ matrix.target }}
build-args: TARGET_ARCHITECTURE=${{ matrix.architecture }}
tags: ${{ env.TAG }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ env.TAG }}:${{ github.ref_name }},${{ env.TAG }}:latest
cache-from: type=gha,scope=${{ matrix.target }}
cache-to: type=gha,mode=max,scope=${{ matrix.target }}
load: true

- name: Test image
Expand All @@ -59,9 +51,6 @@ jobs:
if: ${{ github.event_name == 'push' && github.ref_type == 'tag' }}
uses: docker/build-push-action@v5
with:
context: .
platforms: ${{ matrix.platforms }}
target: ${{ matrix.target }}
build-args: TARGET_ARCHITECTURE=${{ matrix.architecture }}
tags: ${{ env.TAG }}
file: Dockerfile.${{ matrix.target_architecture }}
tags: ${{ env.TAG }}:${{ github.ref_name }},${{ env.TAG }}:latest
push: true
18 changes: 10 additions & 8 deletions Dockerfile → Dockerfile.beatnik
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ ENV RTEMS_MINOR=1-rc2
ENV RTEMS_VERSION=${RTEMS_MAJOR}.${RTEMS_MINOR}
ENV RTEMS_ARCH=powerpc
ENV RTEMS_BSP=beatnik
ENV RTEMS_BASE=/rtems${RTEMS_VERSION}-${RTEMS_BSP}-legacy
ENV RTEMS_PREFIX=${RTEMS_BASE}/rtems/${RTEMS_VERSION}
ENV RTEMS_TOP=/rtems6-${RTEMS_BSP}-legacy
ENV RTEMS_PREFIX=${RTEMS_TOP}/rtems/${RTEMS_VERSION}
ENV PATH=${RTEMS_PREFIX}/bin:${PATH}
ENV LANG=en_GB.UTF-8

FROM environment AS developer

Expand All @@ -34,7 +33,7 @@ RUN python3 -m venv ${VIRTUALENV}
ENV PATH=${VIRTUALENV}/bin:${PATH}

# get the RTEMS Source Builder
WORKDIR ${RTEMS_BASE}
WORKDIR ${RTEMS_TOP}
RUN curl https://ftp.rtems.org/pub/rtems/releases/${RTEMS_MAJOR}/rc/${RTEMS_VERSION}/sources/rtems-source-builder-${RTEMS_VERSION}.tar.xz \
| tar -xJ && \
mv rtems-source-builder-${RTEMS_VERSION} rsb
Expand All @@ -50,13 +49,13 @@ RUN ../source-builder/sb-set-builder --prefix=${RTEMS_PREFIX} ${RTEMS_MAJOR}/rte
ranlib $(find ${RTEMS_PREFIX} -name '*.a')

# get the kernel
WORKDIR ${RTEMS_BASE}
WORKDIR ${RTEMS_TOP}
RUN curl https://ftp.rtems.org/pub/rtems/releases/${RTEMS_MAJOR}/rc/${RTEMS_VERSION}/sources/rtems-${RTEMS_VERSION}.tar.xz \
| tar -xJ && \
mv rtems-${RTEMS_VERSION} kernel

# patch the kernel
WORKDIR ${RTEMS_BASE}/kernel
WORKDIR ${RTEMS_TOP}/kernel
COPY VMEConfig.patch .
RUN git apply VMEConfig.patch && \
./waf bspdefaults --rtems-bsps=${RTEMS_ARCH}/${RTEMS_BSP} > config.ini && \
Expand All @@ -67,10 +66,10 @@ RUN git apply VMEConfig.patch && \
RUN ./waf && \
./waf install

RUN git clone git://git.rtems.org/rtems-net-legacy.git ${RTEMS_BASE}/rtems-net-legacy
RUN git clone git://git.rtems.org/rtems-net-legacy.git ${RTEMS_TOP}/rtems-net-legacy

# add in the legacy network stack
WORKDIR ${RTEMS_BASE}/rtems-net-legacy
WORKDIR ${RTEMS_TOP}/rtems-net-legacy
RUN git submodule init && \
git submodule update && \
./waf configure --prefix=${RTEMS_PREFIX} --rtems-bsps=${RTEMS_ARCH}/${RTEMS_BSP} && \
Expand All @@ -91,5 +90,8 @@ RUN rm -r \

from runtime_prep AS runtime

# environment variables for epics-base build
ENV RTEMS_BASE=${RTEMS_PREFIX}

COPY --from=runtime_prep ${RTEMS_PREFIX} ${RTEMS_PREFIX}

39 changes: 16 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
# rtems6-powerpc
RTEMS Board Support Packages
============================

A container that makes the RTEMS powerpc beatnik Board Support Package (BSP).
A container that makes the RTEMS Board Support Packages (BSPs).

This container gets the sources from RTEMS releases, builds the toolchain and then compiles the BSP.

The current configuration is:-
- rtems version: 6.1-rc2
- patches for MVME5500 boards used at DLS
- legacy network stack
The developer target serves as an archive for the source code. The runtime target is a minimal container with the RTEMS BSP only, intended to be used as a base image for epics-base builds (see https://github.com/epics-containers/epics-base)

This container can be run to experiment with building components with the RSP and prebuilt rtems6 toolchain.
Supported BSPs
--------------

See https://docs.rtems.org/branches/master/user/start/index.html
The repo is designed to allow for multiple target architectures. At present the list of BSPs is only 1 long:

To just get the Board Support Package (BSP) with toolchain, you can extract these products into your own container with:
- mvme5500
- rtems version: 6.1-rc2
- patches for MVME5500 boards used at DLS
- legacy network stack
- processor is m4700 with hardware floating point support

```
ENV RTEMS_VERSION=6.1-rc2
ENV RTEMS_TOP=/rtems${RTEMS_VERSION}-beatnik-legacy/rtems/${RTEMS_VERSION}/
ENV RTEMS_BSP_IMAGE=ghcr.io/epics-containers/rtems6-powerpc-linux-developer

COPY --from=${RTEMS_BSP_IMAGE}:${RTEMS_VERSION} ${RTEMS_TOP} ${RTEMS_TOP}
```
Acknowledgements
================

Or you can get the BSP locally with:
```
docker run --rm -v $(pwd):/workdir ghcr.io/epics-containers/rtems6-powerpc-linux-developer:6.1-rc2
# in another terminal
mkdir -p /rtems6-beatnik-legacy/rtems/
docker cp $(docker ps -lq):/rtems6-beatnik-legacy/rtems/6.1-rc2/ /rtems6-beatnik-legacy/rtems/6.1-rc2/
```
This is all possible due to the hard work of the RTEMS community.

IMPORTANT: the BSP contains absolute paths so you must copy it to the same path as inside the container.
See https://docs.rtems.org/branches/master/user/start/index.html
6 changes: 3 additions & 3 deletions local_patch/patch-rsb.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/bin/bash

THIS=$(realpath $(dirname $0))
RSB=${RTEMS_BASE}/rsb
RSB=${RTEMS_TOP}/rsb

set -xe

mkdir -p $RSB/rtems/patches
cp $THIS/gcc.patch $RSB/rtems/patches
cp $THIS/rtems-gcc-13.2-newlib-head.cfg $RSB/rtems/config/tools
cp $THIS/rtems-default-tools.bset $RSB/rtems/config/tools

cp $THIS/rtems-gcc-13.2-newlib-head.cfg $RSB/rtems/config/tools/rtems-gcc-13.2-newlib-head.cfg
1 change: 0 additions & 1 deletion local_patch/rtems-gcc-13.2-newlib-head.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@
%define with_iconv 1

%include %{_configdir}/gcc-13.cfg

0 comments on commit 9b7ee04

Please sign in to comment.