From 6b0a6debc63d85e951cda1f49f507d6ef1f478a9 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Wed, 28 Apr 2021 20:06:25 +0100 Subject: [PATCH] Add Mbed os docker image (#6352) * Update base docker file to include CMake 3.19.3 * Add docker image to build with Mbed OS. * Update chip-build-vscode image to import Mbed OS requirements. Three things are imported in the docker image: - GCC - Mbed OS - OpenOCD --- .../images/chip-build-mbed-os/Dockerfile | 68 +++++++++++++++++++ .../docker/images/chip-build-mbed-os/build.sh | 1 + .../docker/images/chip-build-mbed-os/run.sh | 1 + .../docker/images/chip-build-mbed-os/version | 1 + .../images/chip-build-vscode/Dockerfile | 7 ++ .../docker/images/chip-build/Dockerfile | 10 ++- integrations/docker/images/chip-build/version | 2 +- 7 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 integrations/docker/images/chip-build-mbed-os/Dockerfile create mode 120000 integrations/docker/images/chip-build-mbed-os/build.sh create mode 120000 integrations/docker/images/chip-build-mbed-os/run.sh create mode 120000 integrations/docker/images/chip-build-mbed-os/version diff --git a/integrations/docker/images/chip-build-mbed-os/Dockerfile b/integrations/docker/images/chip-build-mbed-os/Dockerfile new file mode 100644 index 00000000000000..e98d8d9f7c0965 --- /dev/null +++ b/integrations/docker/images/chip-build-mbed-os/Dockerfile @@ -0,0 +1,68 @@ +ARG VERSION=latest +FROM connectedhomeip/chip-build:${VERSION} + +# ------------------------------------------------------------------------------ +# Install system tools via apt +RUN set -x \ + && apt-get update \ + && DEBIAN_FRONTEND=noninteractive apt-get install -fy \ + python3-setuptools \ + python3-usb \ + software-properties-common \ + build-essential \ + astyle \ + mercurial \ + && rm -rf /var/lib/apt/lists \ + && : # last line + +# ------------------------------------------------------------------------------ +# Install Mbed-OS sources +RUN set -x \ + && (mkdir -p /opt/mbed-os \ + && cd /opt/mbed-os \ + && wget --progress=dot:giga https://github.com/ARMmbed/mbed-os/archive/mbed-os-6.7.0.tar.gz \ + && tar --strip-components=1 -xzf mbed-os-6.7.0.tar.gz \ + && rm mbed-os-6.7.0.tar.gz) \ + && : # last line + +# ------------------------------------------------------------------------------ +# Install Python modules +RUN set -x \ + && pip3 install --no-cache-dir -U mbed-cli mbed-tools \ + && pip3 install --no-cache-dir -r /opt/mbed-os/requirements.txt \ + && : # last line + +# ------------------------------------------------------------------------------ +# Install ARM Toolchain (gcc-arm-none-eabi-9-2019-q4) +RUN set -x \ + && (mkdir -p /opt/mbed-os-toolchain \ + && cd /opt/mbed-os-toolchain \ + && wget --progress=dot:giga https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/RC2.1/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 \ + && tar -xjf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 \ + && rm gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 \ + && : ) # last line + +# ------------------------------------------------------------------------------ +# Configure mbed build system +RUN set -x \ + && mbed config -G GCC_ARM_PATH /opt/mbed-os-toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/ \ + && mbed toolchain -G -s GCC_ARM \ + && : # last line + +# ------------------------------------------------------------------------------ +# Install openocd +RUN set -x \ + && (mkdir -p /opt/openocd \ + && cd /opt/openocd \ + && wget --progress=dot:giga https://github.com/cypresssemiconductorco/openocd/releases/download/release-v4.2.0/openocd-4.2.0.1430-linux.tar.gz \ + && tar --strip-components=1 -xzf openocd-4.2.0.1430-linux.tar.gz \ + && rm openocd-4.2.0.1430-linux.tar.gz) \ + && : # last line + +# ------------------------------------------------------------------------------ +# Configure environment variables +ENV MBED_GCC_ARM_PATH=/opt/mbed-os-toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/ +ENV MBED_OS_PATH=/opt/mbed-os/ +ENV OPENOCD_PATH=/opt/openocd/ + +ENV PATH="${PATH}:${MBED_GCC_ARM_PATH}:${OPENOCD_PATH}/bin" diff --git a/integrations/docker/images/chip-build-mbed-os/build.sh b/integrations/docker/images/chip-build-mbed-os/build.sh new file mode 120000 index 00000000000000..fcb4d4ee75d531 --- /dev/null +++ b/integrations/docker/images/chip-build-mbed-os/build.sh @@ -0,0 +1 @@ +../../build.sh \ No newline at end of file diff --git a/integrations/docker/images/chip-build-mbed-os/run.sh b/integrations/docker/images/chip-build-mbed-os/run.sh new file mode 120000 index 00000000000000..ccbd3501b330d9 --- /dev/null +++ b/integrations/docker/images/chip-build-mbed-os/run.sh @@ -0,0 +1 @@ +../../run.sh \ No newline at end of file diff --git a/integrations/docker/images/chip-build-mbed-os/version b/integrations/docker/images/chip-build-mbed-os/version new file mode 120000 index 00000000000000..a4280acd348e7f --- /dev/null +++ b/integrations/docker/images/chip-build-mbed-os/version @@ -0,0 +1 @@ +../chip-build/version \ No newline at end of file diff --git a/integrations/docker/images/chip-build-vscode/Dockerfile b/integrations/docker/images/chip-build-vscode/Dockerfile index 6a49604b0a079a..286c9009532eb4 100644 --- a/integrations/docker/images/chip-build-vscode/Dockerfile +++ b/integrations/docker/images/chip-build-vscode/Dockerfile @@ -3,6 +3,7 @@ FROM connectedhomeip/chip-build-nrf-platform:${VERSION} AS nrf FROM connectedhomeip/chip-build-efr32:${VERSION} AS efr32 FROM connectedhomeip/chip-build-android:${VERSION} AS android FROM connectedhomeip/chip-build-esp32-qemu:${VERSION} as esp32 +FROM connectedhomeip/chip-build-mbed-os:${VERSION} AS mbedos FROM connectedhomeip/chip-build:${VERSION} COPY --from=esp32 /opt/espressif/esp-idf /opt/espressif/esp-idf COPY --from=esp32 /opt/espressif/tools /opt/espressif/tools @@ -12,6 +13,9 @@ COPY --from=nrf /opt/NordicSemiconductor/nrfconnect /opt/NordicSemiconductor/nrf COPY --from=nrf /opt/ARM-software/gcc-arm-none-eabi-9-2019-q4-major /opt/ARM-software/gcc-arm-none-eabi-9-2019-q4-major COPY --from=android /opt/android/sdk /opt/android/sdk COPY --from=android /opt/android/android-ndk-r21b /opt/android/android-ndk-r21b +COPY --from=mbedos /opt/mbed-os /opt/mbed-os +COPY --from=mbedos /opt/mbed-os-toolchain/ /opt/mbed-os-toolchain/ +COPY --from=mbedos /opt/openocd/ /opt/openocd/ ENV IDF_PATH=/opt/espressif/esp-idf/ ENV IDF_TOOLS_PATH=/opt/espressif/tools ENV QEMU_ESP32_DIR=/opt/espressif/qemu @@ -24,4 +28,7 @@ ENV ARM_GCC_INSTALL_ROOT=/opt/ARM-software/gcc-arm-none-eabi-9-2019-q4-major/bin ENV EFR32_BOARD=BRD4161A ENV ANDROID_HOME=/opt/android/sdk ENV ANDROID_NDK_HOME=/opt/android/android-ndk-r21b +ENV MBED_GCC_ARM_PATH=/opt/mbed-os-toolchain/gcc-arm-none-eabi-9-2019-q4-major/bin/ +ENV MBED_OS_PATH=/opt/mbed-os/ +ENV OPENOCD_PATH=/opt/openocd/ ENV PW_ENVIRONMENT_ROOT=/home/vscode/pigweed/env diff --git a/integrations/docker/images/chip-build/Dockerfile b/integrations/docker/images/chip-build/Dockerfile index 97582014a724ab..56913b71ad862e 100644 --- a/integrations/docker/images/chip-build/Dockerfile +++ b/integrations/docker/images/chip-build/Dockerfile @@ -14,7 +14,6 @@ RUN set -x \ clang \ clang-format \ clang-tidy \ - cmake \ curl \ flex \ g++ \ @@ -65,6 +64,15 @@ RUN set -x \ && rm -rf /var/lib/apt/lists/ \ && : # last line +# Cmake (Mbed OS requires >=3.19.0-rc3 version which is not available in Ubuntu 20.04 repository) +RUN set -x \ + && (cd /tmp \ + && wget --progress=dot:giga https://github.com/Kitware/CMake/releases/download/v3.19.3/cmake-3.19.3-Linux-x86_64.sh \ + && sh cmake-3.19.3-Linux-x86_64.sh --exclude-subdir --prefix=/usr/local \ + && rm -rf cmake-3.19.3-Linux-x86_64.sh) \ + && exec bash \ + && : # last line + # Python 2 and PIP RUN set -x \ && apt-get update \ diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index a7475fbf5f0c9e..c5d16566fb13d6 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.4.23 +0.4.24