From b0e6b43bd20eadfc0f5cd05a119c70563830a888 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Sun, 4 Aug 2024 23:35:24 +0200 Subject: [PATCH] CI: Add automated container build 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 --- .dockerignore | 3 + .github/workflows/container-build.yaml | 78 ++++++++++++++++++++++++++ Containerfile | 67 ++++++++++++++++++++++ coordinator/Z-Stack_3.x.0/COMPILE.md | 50 +++++++++++++++++ 4 files changed, 198 insertions(+) create mode 100644 .dockerignore create mode 100644 .github/workflows/container-build.yaml create mode 100644 Containerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c94c2c3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +* +!**/*.patch +!**/znp_*.syscfg diff --git a/.github/workflows/container-build.yaml b/.github/workflows/container-build.yaml new file mode 100644 index 0000000..c4b3250 --- /dev/null +++ b/.github/workflows/container-build.yaml @@ -0,0 +1,78 @@ +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: Free Disk Space (Ubuntu) + uses: jlumbroso/free-disk-space@main + with: + android: true + docker-images: true + dotnet: true + haskell: true + large-packages: true + swap-storage: true + tool-cache: true + + - 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 diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..53dacfa --- /dev/null +++ b/Containerfile @@ -0,0 +1,67 @@ +# SPDX-License-Identifier: MIT +# +# Copyright (C) 2024 Olliver Schinagl + +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/" + +ENV HOME="/build" +ENV CCS_VERSION=${CCS_VERSION}.${CCS_RELEASE} +ENV SLF2_VERSION=${SLF2_VERSION} +ENV SLF2_COMPONENTS=${SLF2_COMPONENTS} +ENV SLF2_SDK="${HOME}/simplelink_cc13xx_cc26xx_sdk" + +RUN apt-get update && apt-get install --yes \ + 'build-essential' \ + 'cmake' \ + 'git' \ + 'libc6-i386' \ + 'libgconf-2-4' \ + 'libncurses5' \ + 'libtinfo5' \ + 'libusb-0.1-4' \ + 'python3' \ + 'unzip' \ + && \ + rm -f -r '/var/cache/apt' && \ + rm -f -r '/var/lib/apt' && \ + echo 'Extracting CCS ...' && \ + tar -xvf "/tmp/ccs_install/CCS${CCS_VERSION:?}_linux-x64.tar.gz" -C '/tmp/ccs_install' && \ + echo 'Installing CCS ...' && \ + "/tmp/ccs_install/CCS${CCS_VERSION}_linux-x64/ccs_setup_${CCS_VERSION}.run" \ + --enable-components "${SLF2_COMPONENTS:?}" \ + --mode unattended \ + --prefix '/opt/ti/' \ + && \ + echo 'Extracting the SDK ...' && \ + unzip "/tmp/ccs_install/simplelink_cc13xx_cc26xx_sdk_${SLF2_VERSION_PATH:?}__linux.zip" \ + -d "${HOME}" \ + && \ + echo 'Wrapping things up' && \ + ln -f -s \ + "${SLF2_SDK}_${SLF2_VERSION_PATH}" \ + "${SLF2_SDK}" \ + && \ + ln -f -s \ + "$(find '/opt/ti/ccs/utils' -type d -iname 'sysconfig_*')" \ + '/opt/ti/ccs/utils/sysconfig' \ + && \ + rm -f -r "${SLF2_SDK}/docs" && \ + rm -f -r "${SLF2_SDK}/examples/nortos" && \ + rm -f -r '/tmp/ccs_install' && \ + echo 'Installation complete' + +ENV PATH="/opt/ti/ccs/eclipse/:/opt/ti/ccs/utils/sysconfig/:${PATH}" diff --git a/coordinator/Z-Stack_3.x.0/COMPILE.md b/coordinator/Z-Stack_3.x.0/COMPILE.md index 13df0c0..8399713 100644 --- a/coordinator/Z-Stack_3.x.0/COMPILE.md +++ b/coordinator/Z-Stack_3.x.0/COMPILE.md @@ -25,3 +25,53 @@ - `znp_LP_CC1352P7_4_tirtos7_ticlang.hex` -> CC1352P7 based boards - `znp_LP_CC2652R7_tirtos7_ticlang.hex` -> CC2652R7 based boards - `znp_LP_CC2652RB_tirtos7_ticlang.hex` -> CC2652RB based boards + +## 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' +``` + +> __Note:__ The URL in the example can be replace with a '.' when the repository has been cloned locally and having `cd`ed into the repository directory. + +> __:Warning:__ The build of the container will download the SDK and CCS. While docker keeps a cached copy on subsequent builds, this download can take a while and is not immediately obvious it is happening. + +1. Enter the container so that the firmware can be built. +```console +$ docker run \ + --interactive \ + --rm \ + --tty \ + --volume './:/src' \ + --volume './workspace:/build/workspace' \ + --workdir '/build/workspace' \ + 'z-stack:dev' \ + '/bin/bash' +``` + +> *TIP:* This document assumes that docker is pulling the container directly from git and an unpatched build environment is setup. Patching of the SDK sources and workspace still is needed. A volume `/src` is mounted in the container where patches are expected to be located. + +> __Note:__ The local directory `./workspace` is volume-mounted into the containers `/build/workspace` directory to be able to keep files from the container, but can be freely removed when done. + +Within the container, we now follow the same steps as above. The GUI is still needed and instructions below explain how this can be achieved. + +### Launching eclipse in the container +To launch eclipse in the container to test/check things out. This does require a X11 compatible host. + ``` +--env DISPLAY="${DISPLAY}" --volume '/tmp/.X11-unix' --network='host' +``` +> __Note:__ The network mapping is required for local X11 forwarding to work due to the `DISPLAY` variable assuming `localhost`. + +Within the container, eclipse does require `libswt-gtk-4-java epiphany-browser` installed (ccs/eclipse does come with chromium, but epiphany is an easy way to fulfill its missing dependencies). + +Almost certainly some additional security mechanisms need to be bypassed, where a quick (and dangerous) hack is to `xhost +` on the host before launching the container. + +Finally start `eclipse -data '/build/workspace'` from within the container and it will then pop up a UI window on the host. + +> __Note:__ Optionally, a VNC in docker solution or X11 forwarding over ssh can also be used, but that is out of scope for here.