Skip to content

Commit

Permalink
CI: Add automated container build
Browse files Browse the repository at this point in the history
This commit adds a Container which holds the CCS and SDK so they can be
used to build the various firmwares.

The pipeline can be later expanded to also actually build the
firmware(s).

Signed-off-by: Olliver Schinagl <[email protected]>
  • Loading branch information
oliv3r committed Aug 6, 2024
1 parent 579956b commit 5d9cf72
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!**/firmware.patch
67 changes: 67 additions & 0 deletions .github/workflows/container-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Create and publish Container image

on:
push:
branches:
- master
tags:
- 'v*'
pull_request:
branches:
- master

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=edge
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
flavor: |
latest=auto
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: Containerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
load: true
58 changes: 58 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# SPDX-License-Identifier: MIT
#
# Copyright (C) 2024 Olliver Schinagl <[email protected]>

ARG UBUNTU_VERSION="22.04"
ARG TARGET_ARCH="library"

FROM index.docker.io/${TARGET_ARCH}/ubuntu:${UBUNTU_VERSION}

ARG SLF2_COMPONENTS="PF_CC2X"

# Remember to supply/update both version fields.
ARG SLF2_VERSION="7.10.00.98"
ARG SLF2_VERSION_PATH="7_10_00_98"
ADD "https://dr-download.ti.com/software-development/software-development-kit-sdk/MD-BPlR3djvTV/${SLF2_VERSION}/simplelink_cc13xx_cc26xx_sdk_${SLF2_VERSION_PATH}__linux.zip" "/tmp/ccs_install/"

ARG CCS_VERSION="12.3.0"
ARG CCS_RELEASE="00005"
ADD "https://dr-download.ti.com/software-development/ide-configuration-compiler-or-debugger/MD-J1VdearkvK/${CCS_VERSION}/CCS${CCS_VERSION}.${CCS_RELEASE}_linux-x64.tar.gz" "/tmp/ccs_install/"

COPY "coordinator/Z-Stack_3.x.0/firmware.patch" "/build/Z-Stack_3.x.0-coordinator.patch"

ENV CCS_VERSION=${CCS_VERSION}.${CCS_RELEASE}
ENV SLF2_VERSION=${SLF2_VERSION}
ENV SLF2_COMPONENTS=${SLF2_COMPONENTS}
RUN apt-get update && apt-get install --yes \
'git' \
'libncurses5' \
'build-essential' \
'cmake' \
'libc6-i386' \
'libgconf-2-4' \
'libtinfo5' \
'libusb-0.1-4' \
'python3' \
'unzip' \
&& \
rm -f -r '/var/cache/apt' && \
rm -f -r '/var/lib/apt' && \
tar -xvf "/tmp/ccs_install/CCS${CCS_VERSION:?}_linux-x64.tar.gz" -C '/tmp/ccs_install' && \
"/tmp/ccs_install/CCS${CCS_VERSION}_linux-x64/ccs_setup_${CCS_VERSION}.run" \
--enable-components "${SLF2_COMPONENTS:?}" \
--mode unattended \
--prefix '/opt/ti/' \
&& \
unzip "/tmp/ccs_install/simplelink_cc13xx_cc26xx_sdk_${SLF2_VERSION_PATH:?}__linux.zip" \
-d '/build' \
&& \
ln -f -s \
"/build/simplelink_cc13xx_cc26xx_sdk_${SLF2_VERSION_PATH}" \
'/build/simplelink_cc13xx_cc26xx_sdk' && \
rm -f -r '/build/simplelink_cc13xx_cc26xx_sdk/docs' && \
rm -f -r '/build/simplelink_cc13xx_cc26xx_sdk/examples/nortos' && \
rm -f -r '/tmp/ccs_install' && \
echo 'Done'

ENV PATH="/opt/ti/ccs/eclipse/:${PATH}"
ENV HOME="/build/simplelink_cc13xx_cc26xx_sdk/"
39 changes: 39 additions & 0 deletions coordinator/Z-Stack_3.x.0/COMPILE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,42 @@
- `znp_CC1352P_2_LAUNCHXL_tirtos7_ticlang.hex` -> CC1352P-2 and CC2652P
- `znp_LP_CC1352P7_4_tirtos7_ticlang.hex` -> CC1352P7
- `znp_LP_CC2652R7_tirtos7_ticlang.hex` -> CC2652R7

## Docker build environment
This repo includes a Container file, to help with setting up a build environment without the need to download and install things manually. [Docker](https://docker.com) or [Podman](https://podman.io) can be used. The following example uses docker.

1. This step builds the container locally. This step may be skipped if using a [released container](https://github.com/Koenkk/pkgs/container/Z-Stack-firmware) from this repository instead.
```console
$ docker build \
--file 'Containerfile' \
--rm \
--tag 'z-stack:dev' \
"https://github.com/Koenkk/Z-Stack-firmware.git#master"
```

1. Enter the container so that the firmware can be built.
```console
$ docker run \
--interactive \
--rm \
--tty \
--volume '/tmp:/tmp' \
'z-stack:dev' \
'/bin/bash'
```

> __Note:__ The local directory `/tmp` is volume-mounted into the containers `/tmp` directory to be able to extract the firmware from the container.
1. Within the container, import the relevant project into the workspace
`# eclipse -noSplash -data "${HOME}/workspace" -application com.ti.ccstudio.apps.projectImport -ccs.location "${HOME}/examples/rtos/CC1352P_2_LAUNCHXL/zstack/znp/tirtos7/ticlang/znp_CC1352P_2_LAUNCHXL_tirtos7_ticlang.projectspec`

1. Apply the needed workspace patches
`# git apply --ignore-space-change '/build/Z-Stack_3.x.0-coordinator_CC1352P_2_LAUNCHXL.patch'`

1. Compile!
`# eclipse --compile`

1. Copy the firmware from the container to the host
`# cp firmware /tmp/`

> __Note:__ The path used here depends on the location used in the previous step!

0 comments on commit 5d9cf72

Please sign in to comment.