From d3709cc143ba661d18f85fa84641b38db883f80b Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Tue, 14 Feb 2023 11:41:49 +0000 Subject: [PATCH 01/23] Only use one Dockerfile and build.sh script for both docker and devcontainer --- .devcontainer/devcontainer.json | 23 ++++++++++++----------- .vscode/c_cpp_properties.json | 2 +- .vscode/cmake-kits.json | 10 ++++++++++ .vscode/settings.json | 7 ++++--- docker/Dockerfile | 18 +++++++++++++++++- 5 files changed, 44 insertions(+), 16 deletions(-) create mode 100644 .vscode/cmake-kits.json diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 1bb315f7ef..9bca6ddfbd 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -4,19 +4,23 @@ // "name": "Pinetime", // "image": "feabhas/pinetime-dev" "build": { - "dockerfile": "Dockerfile", + "dockerfile": "../docker/Dockerfile", // Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04 - // "args": { "VARIANT": "ubuntu-20.04" } + "args": { + "devcontainer": "true" + } }, - "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], - + "runArgs": [ + "--cap-add=SYS_PTRACE", + "--security-opt", + "seccomp=unconfined" + ], // Set *default* container specific settings.json values on container create. - "settings": { + "settings": { "terminal.integrated.shell.linux": "/bin/bash", "editor.formatOnSave": true, "clang-format.executable": "clang-format-12" }, - // Add the IDs of extensions you want installed when the container is created. "extensions": [ "ms-vscode.cpptools", @@ -25,14 +29,11 @@ "notskm.clang-tidy", "mjohns.clang-format" ], - // Use 'forwardPorts' to make a list of ports inside the container available locally. // "forwardPorts": [], - // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "bash /opt/create_build_openocd.sh", - + "postCreateCommand": "", // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. // "remoteUser": "vscode" "remoteUser": "infinitime" -} +} \ No newline at end of file diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 392f4151e4..8c754c1e11 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -8,7 +8,7 @@ "${workspaceFolder}/src" ], "defines": [], - "compilerPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc", + "compilerPath": "/usr/bin/gcc", "cStandard": "c11", "cppStandard": "c++20", "intelliSenseMode": "linux-gcc-arm", diff --git a/.vscode/cmake-kits.json b/.vscode/cmake-kits.json new file mode 100644 index 0000000000..c13d387e67 --- /dev/null +++ b/.vscode/cmake-kits.json @@ -0,0 +1,10 @@ +[ + { + "name": "InfiniTime Compiler", + "environmentSetupScript": "${workspaceFolder}/docker/build.sh", + "compilers": { + "CC": "/usr/bin/gcc", + "CXX": "/usr/bin/g++" + } + } +] \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index f1cc3a8176..8445e8fb0f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,8 +1,9 @@ { "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", "cmake.configureArgs": [ - "-DARM_NONE_EABI_TOOLCHAIN_PATH=${env:ARM_NONE_EABI_TOOLCHAIN_PATH}", - "-DNRF5_SDK_PATH=${env:NRF5_SDK_PATH}", + // FIXME: This is a duplicate of /docker/build.sh. This could lead to some weird behaviour if build.sh is changed but this is not! No clue if this can be avoided though + "-DARM_NONE_EABI_TOOLCHAIN_PATH=${env:TOOLS_DIR}/${env:GCC_ARM_PATH}", + "-DNRF5_SDK_PATH=${env:TOOLS_DIR}/${env:NRF_SDK_VER}", ], "cmake.generator": "Unix Makefiles", "clang-tidy.buildPath": "build/compile_commands.json", @@ -56,4 +57,4 @@ "cinttypes": "cpp", "typeinfo": "cpp" } -} +} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 22bf7bd7dd..db3af008e0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -37,6 +37,15 @@ RUN apt-get update -qq \ libpangocairo-1.0-0 \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; +# Add the necessary apt-gets for devcontainer if this is a devcontainer FIXME: This currently does not work +RUN if [[ "$devcontainer" == "true" ]] ; then \ + apt-get update -qq \ + && apt-get install -y \ + clang-format-12 \ + clang-tidy; fi + +# TODO: Do I need to set the locales for the devcontainer? + # Git needed for PROJECT_GIT_COMMIT_HASH variable setting RUN pip3 install adafruit-nrfutil @@ -55,5 +64,12 @@ RUN bash -c "source /opt/build.sh; GetNrfSdk;" # McuBoot RUN bash -c "source /opt/build.sh; GetMcuBoot;" +# FIXME: Currently the conditional statement doesnt seem to work properly?!? +RUN adduser infinitime + +# If we are a devcontainer add the infinitime user +RUN if [[ "$devcontainer" == "true" ]] ; then \ + adduser infinitime; fi + ENV SOURCES_DIR /sources -CMD ["/opt/build.sh"] +CMD ["/opt/build.sh"] \ No newline at end of file From 6a46d7b09d00abf5c7ce3e31898c57ee70374c3f Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Tue, 14 Feb 2023 11:42:19 +0000 Subject: [PATCH 02/23] Remove all now unneccessary tasks and scripts --- .devcontainer/Dockerfile | 66 -------------------- .devcontainer/build.sh | 87 --------------------------- .devcontainer/build_app.sh | 2 - .devcontainer/create_build_openocd.sh | 3 - .devcontainer/make_build_dir.sh | 2 - .vscode/tasks.json | 14 ----- 6 files changed, 174 deletions(-) delete mode 100644 .devcontainer/Dockerfile delete mode 100644 .devcontainer/build.sh delete mode 100644 .devcontainer/build_app.sh delete mode 100644 .devcontainer/create_build_openocd.sh delete mode 100644 .devcontainer/make_build_dir.sh diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index e4ad5c4fa8..0000000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,66 +0,0 @@ -FROM ubuntu:latest - -ARG DEBIAN_FRONTEND=noninteractive -RUN apt-get update -qq \ - && apt-get install -y \ -# x86_64 / generic packages - bash \ - build-essential \ - cmake \ - git \ - make \ - python3 \ - python3-pip \ - python3-pil \ - tar \ - unzip \ - wget \ - curl \ - dos2unix \ - clang-format-12 \ - clang-tidy \ - locales \ - libncurses5 \ -# aarch64 packages - libffi-dev \ - libssl-dev \ - python3-dev \ - rustc \ - && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; - -#SET LOCALE -RUN locale-gen en_US.UTF-8 -ENV LANG en_US.UTF-8 -ENV LANGUAGE en_US:en -ENV LC_ALL en_US.UTF-8 - -RUN pip3 install adafruit-nrfutil -# required for McuBoot -RUN pip3 install setuptools_rust - -WORKDIR /opt/ -# build.sh knows how to compile but it problimatic on Win10 -COPY build.sh . -RUN chmod +x build.sh -# create_build_openocd.sh uses cmake to crate to build directory -COPY create_build_openocd.sh . -RUN chmod +x create_build_openocd.sh -# Lets get each in a separate docker layer for better downloads -# GCC -# RUN bash -c "source /opt/build.sh; GetGcc;" -RUN wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2 -O - | tar -xj -C /opt -# NrfSdk -# RUN bash -c "source /opt/build.sh; GetNrfSdk;" -RUN wget -q "https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip" -O /tmp/nRF5_SDK_15.3.0_59ac345 -RUN unzip -q /tmp/nRF5_SDK_15.3.0_59ac345 -d /opt -RUN rm /tmp/nRF5_SDK_15.3.0_59ac345 -# McuBoot -# RUN bash -c "source /opt/build.sh; GetMcuBoot;" -RUN git clone https://github.com/mcu-tools/mcuboot.git -RUN pip3 install -r ./mcuboot/scripts/requirements.txt - -RUN adduser infinitime - -ENV NRF5_SDK_PATH /opt/nRF5_SDK_15.3.0_59ac345 -ENV ARM_NONE_EABI_TOOLCHAIN_PATH /opt/gcc-arm-none-eabi-9-2020-q2-update -ENV SOURCES_DIR /workspaces/InfiniTime diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh deleted file mode 100644 index b4f080dd92..0000000000 --- a/.devcontainer/build.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash -(return 0 2>/dev/null) && SOURCED="true" || SOURCED="false" -export LC_ALL=C.UTF-8 -export LANG=C.UTF-8 -set -x -set -e - -# Default locations if the var isn't already set -export TOOLS_DIR="${TOOLS_DIR:=/opt}" -export SOURCES_DIR="${SOURCES_DIR:=/sources}" -export BUILD_DIR="${BUILD_DIR:=$SOURCES_DIR/build}" -export OUTPUT_DIR="${OUTPUT_DIR:=$BUILD_DIR/output}" - -export BUILD_TYPE=${BUILD_TYPE:=Release} -export GCC_ARM_VER=${GCC_ARM_VER:="gcc-arm-none-eabi-9-2020-q2-update"} -export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"} - -MACHINE="$(uname -m)" -[[ "$MACHINE" == "arm64" ]] && MACHINE="aarch64" - -main() { - local target="$1" - - mkdir -p "$TOOLS_DIR" - - [[ ! -d "$TOOLS_DIR/$GCC_ARM_VER" ]] && GetGcc - [[ ! -d "$TOOLS_DIR/$NRF_SDK_VER" ]] && GetNrfSdk - [[ ! -d "$TOOLS_DIR/mcuboot" ]] && GetMcuBoot - - mkdir -p "$BUILD_DIR" - - CmakeGenerate - CmakeBuild $target - BUILD_RESULT=$? - if [ "$DISABLE_POSTBUILD" != "true" -a "$BUILD_RESULT" == 0 ]; then - source "$BUILD_DIR/post_build.sh" - fi - # assuming post_build.sh will never fail on a successful build - return $BUILD_RESULT -} - -GetGcc() { - GCC_SRC="$GCC_ARM_VER-$MACHINE-linux.tar.bz" - wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/$GCC_SRC -O - | tar -xj -C $TOOLS_DIR/ -} - -GetMcuBoot() { - git clone https://github.com/mcu-tools/mcuboot.git "$TOOLS_DIR/mcuboot" - pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt" -} - -GetNrfSdk() { - wget -q "https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/$NRF_SDK_VER.zip" -O /tmp/$NRF_SDK_VER - unzip -q /tmp/$NRF_SDK_VER -d "$TOOLS_DIR/" - rm /tmp/$NRF_SDK_VER -} - -CmakeGenerate() { - # We can swap the CD and trailing SOURCES_DIR for -B and -S respectively - # once we go to newer CMake (Ubuntu 18.10 gives us CMake 3.10) - cd "$BUILD_DIR" - - cmake -G "Unix Makefiles" \ - -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ - -DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_VER" \ - -DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \ - "$SOURCES_DIR" - cmake -L -N . -} - -CmakeBuild() { - local target="$1" - [[ -n "$target" ]] && target="--target $target" - if cmake --build "$BUILD_DIR" --config $BUILD_TYPE $target -- -j$(nproc) - then return 0; else return 1; - fi -} - -if [[ $SOURCED == "false" ]]; then - # It is important to return exit code of main - # To be future-proof, this is handled explicitely - main "$@" - BUILD_RESULT=$? - exit $BUILD_RESULT -else - echo "Sourced!" -fi diff --git a/.devcontainer/build_app.sh b/.devcontainer/build_app.sh deleted file mode 100644 index 0f578cc642..0000000000 --- a/.devcontainer/build_app.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -cmake --build /workspaces/Pinetime/build --config Release -- -j6 pinetime-app \ No newline at end of file diff --git a/.devcontainer/create_build_openocd.sh b/.devcontainer/create_build_openocd.sh deleted file mode 100644 index c5bff5c89b..0000000000 --- a/.devcontainer/create_build_openocd.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -rm -rf build/ -cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release -DUSE_OPENOCD=1 -DARM_NONE_EABI_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-9-2020-q2-update -DNRF5_SDK_PATH=/opt/nRF5_SDK_15.3.0_59ac345 -S . -Bbuild \ No newline at end of file diff --git a/.devcontainer/make_build_dir.sh b/.devcontainer/make_build_dir.sh deleted file mode 100644 index 76240037c2..0000000000 --- a/.devcontainer/make_build_dir.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release -DUSE_OPENOCD=1 -DARM_NONE_EABI_TOOLCHAIN_PATH=/opt/gcc-arm-none-eabi-9-2020-q2-update -DNRF5_SDK_PATH=/opt/nRF5_SDK_15.3.0_59ac345 ${SOURCES_DIR} diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 17f51f5efd..02b5f75fe6 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,20 +1,6 @@ { "version": "2.0.0", "tasks": [ - { - "label": "create openocd build", - "type": "shell", - "command": "/opt/create_build_openocd.sh", - "group": { - "kind": "build", - "isDefault": true - }, - "presentation": { - "reveal": "always", - "panel": "shared" - }, - "problemMatcher": [] - }, { "label": "update submodules", "type": "shell", From 82fd87d5435678e14ed9b7b5ef365dcebe73d84b Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Tue, 14 Feb 2023 12:43:33 +0000 Subject: [PATCH 03/23] Update to clang-format-14 --- .devcontainer/devcontainer.json | 3 ++- docker/Dockerfile | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9bca6ddfbd..b72eec5895 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -19,7 +19,8 @@ "settings": { "terminal.integrated.shell.linux": "/bin/bash", "editor.formatOnSave": true, - "clang-format.executable": "clang-format-12" + // FIXME: This and the Dockerfile might get out of sync + "clang-format.executable": "clang-format-14" }, // Add the IDs of extensions you want installed when the container is created. "extensions": [ diff --git a/docker/Dockerfile b/docker/Dockerfile index db3af008e0..799470b71f 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -41,7 +41,7 @@ RUN apt-get update -qq \ RUN if [[ "$devcontainer" == "true" ]] ; then \ apt-get update -qq \ && apt-get install -y \ - clang-format-12 \ + clang-format-14 \ clang-tidy; fi # TODO: Do I need to set the locales for the devcontainer? From b828a1a5cb0b510ef31027ef3d2461112a04f0cb Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Tue, 14 Feb 2023 12:44:33 +0000 Subject: [PATCH 04/23] Move devcontainer.json into root folder --- .devcontainer/devcontainer.json => .devcontainer.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .devcontainer/devcontainer.json => .devcontainer.json (100%) diff --git a/.devcontainer/devcontainer.json b/.devcontainer.json similarity index 100% rename from .devcontainer/devcontainer.json rename to .devcontainer.json From a242eff020ae320150909f403d5c7f176fd87755 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Tue, 14 Feb 2023 12:50:01 +0000 Subject: [PATCH 05/23] Fix: .devcontainer.json pointing at wrong Dockerfile location --- .devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer.json b/.devcontainer.json index b72eec5895..a1dc53229c 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -4,7 +4,7 @@ // "name": "Pinetime", // "image": "feabhas/pinetime-dev" "build": { - "dockerfile": "../docker/Dockerfile", + "dockerfile": "docker/Dockerfile", // Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04 "args": { "devcontainer": "true" From ec9ede2cc38f20fcee94d6e1edee54df687c4fd9 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Tue, 14 Feb 2023 14:02:23 +0000 Subject: [PATCH 06/23] Fix conditional statements in Dockerfile --- .devcontainer.json | 2 +- docker/Dockerfile | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index a1dc53229c..a42bea4167 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -7,7 +7,7 @@ "dockerfile": "docker/Dockerfile", // Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04 "args": { - "devcontainer": "true" + "DEVCONTAINER": "true" } }, "runArgs": [ diff --git a/docker/Dockerfile b/docker/Dockerfile index 799470b71f..6bf567d005 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,5 +1,6 @@ FROM ubuntu:22.04 +ARG DEVCONTAINER ARG DEBIAN_FRONTEND=noninteractive ARG NODE_MAJOR=20 RUN apt-get update -qq \ @@ -37,8 +38,8 @@ RUN apt-get update -qq \ libpangocairo-1.0-0 \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; -# Add the necessary apt-gets for devcontainer if this is a devcontainer FIXME: This currently does not work -RUN if [[ "$devcontainer" == "true" ]] ; then \ +# Add the necessary apt-gets for devcontainer if this is a devcontainer +RUN if [ -n "$DEVCONTAINER" ] ; then \ apt-get update -qq \ && apt-get install -y \ clang-format-14 \ @@ -64,12 +65,8 @@ RUN bash -c "source /opt/build.sh; GetNrfSdk;" # McuBoot RUN bash -c "source /opt/build.sh; GetMcuBoot;" -# FIXME: Currently the conditional statement doesnt seem to work properly?!? -RUN adduser infinitime - # If we are a devcontainer add the infinitime user -RUN if [[ "$devcontainer" == "true" ]] ; then \ - adduser infinitime; fi +RUN if [ -n "$DEVCONTAINER" ] ; then adduser infinitime ; fi ENV SOURCES_DIR /sources -CMD ["/opt/build.sh"] \ No newline at end of file +CMD ["/opt/build.sh"] From 890793c70b4bffc48e5f98d953d50401e9bdd957 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Tue, 14 Feb 2023 14:05:02 +0000 Subject: [PATCH 07/23] Move .devcontainer/README into doc/usingDevcontainers --- doc/buildWithVScode.md | 2 +- .devcontainer/README.md => doc/usingDevcontainers.md | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename .devcontainer/README.md => doc/usingDevcontainers.md (100%) diff --git a/doc/buildWithVScode.md b/doc/buildWithVScode.md index 9d0a5bdfea..5f8724828a 100644 --- a/doc/buildWithVScode.md +++ b/doc/buildWithVScode.md @@ -32,7 +32,7 @@ The .devcontainer folder contains the configuration and scripts for using a Dock Using the [Remote-Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension is recommended. It will handle configuring the Docker virtual machine and setting everything up. -More documentation is available in the [readme in .devcontainer](../.devcontainer/README.md) +More documentation is available in the [readme in .devcontainer](usingDevcontainers.md) ### DevContainer on Ubuntu diff --git a/.devcontainer/README.md b/doc/usingDevcontainers.md similarity index 100% rename from .devcontainer/README.md rename to doc/usingDevcontainers.md From 7ab317772d037ab38de40e597ef94e35a8a8e153 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Thu, 16 Feb 2023 17:09:04 +0000 Subject: [PATCH 08/23] Remove obsolete VSCode Task --- .vscode/tasks.json | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 02b5f75fe6..06a08bfceb 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -17,14 +17,6 @@ "panel": "shared" }, "problemMatcher": [] - }, - { - "label": "BuildInit", - "dependsOn": [ - "update submodules", - "create openocd build" - ], - "problemMatcher": [] } ] } \ No newline at end of file From 4a7b0c540f6ea7b89269b4d3e50814b28eaa4da2 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Fri, 17 Feb 2023 08:53:15 +0000 Subject: [PATCH 09/23] Change standard compiler path to the correct compiler --- .vscode/cmake-kits.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.vscode/cmake-kits.json b/.vscode/cmake-kits.json index c13d387e67..13b4147a91 100644 --- a/.vscode/cmake-kits.json +++ b/.vscode/cmake-kits.json @@ -3,8 +3,7 @@ "name": "InfiniTime Compiler", "environmentSetupScript": "${workspaceFolder}/docker/build.sh", "compilers": { - "CC": "/usr/bin/gcc", - "CXX": "/usr/bin/g++" + "CC": "${env:TOOLS_DIR}/${env:GCC_ARM_PATH}" } } ] \ No newline at end of file From 71ad9a0e1c80e7aeed925216cf545a68465af80e Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Mon, 20 Feb 2023 16:38:52 +0000 Subject: [PATCH 10/23] Use the correct compiler for building and for IntelliSense --- .vscode/c_cpp_properties.json | 7 ++++++- .vscode/cmake-kits.json | 5 +---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 8c754c1e11..fe1cf0f680 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,4 +1,9 @@ { + "env": { + // TODO: This is a duplication of the configuration set in /docker/build.sh! + "TOOLS_DIR": "/opt", + "GCC_ARM_PATH": "gcc-arm-none-eabi-10.3-2021.10" + }, "configurations": [ { "name": "nrfCC", @@ -8,7 +13,7 @@ "${workspaceFolder}/src" ], "defines": [], - "compilerPath": "/usr/bin/gcc", + "compilerPath": "${TOOLS_DIR}/${GCC_ARM_PATH}/bin/arm-none-eabi-gcc", "cStandard": "c11", "cppStandard": "c++20", "intelliSenseMode": "linux-gcc-arm", diff --git a/.vscode/cmake-kits.json b/.vscode/cmake-kits.json index 13b4147a91..11b2dd2efd 100644 --- a/.vscode/cmake-kits.json +++ b/.vscode/cmake-kits.json @@ -1,9 +1,6 @@ [ { "name": "InfiniTime Compiler", - "environmentSetupScript": "${workspaceFolder}/docker/build.sh", - "compilers": { - "CC": "${env:TOOLS_DIR}/${env:GCC_ARM_PATH}" - } + "environmentSetupScript": "${workspaceFolder}/docker/build.sh" } ] \ No newline at end of file From ac3902991de4117fea36b48e904c6ea26cad9172 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Mon, 20 Feb 2023 17:59:14 +0000 Subject: [PATCH 11/23] Set GDB Path for debugging --- .vscode/launch.json | 33 ++++++++++----------------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index a50270d25b..0785092ccc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,45 +1,33 @@ - { +{ "version": "0.1.0", "configurations": [ { "name": "Debug - Openocd docker Remote", - "type":"cortex-debug", - "cortex-debug.armToolchainPath":"${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin", + "type": "cortex-debug", "cwd": "${workspaceRoot}", "executable": "${command:cmake.launchTargetPath}", "request": "launch", "servertype": "external", - // This may need to be arm-none-eabi-gdb depending on your system - "gdbPath" : "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gdb", + // FIXME: This is hardcoded. I have no idea how to use the values set in build.sh here + "gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb", // Connect to an already running OpenOCD instance "gdbTarget": "host.docker.internal:3333", "svdFile": "${workspaceRoot}/nrf52.svd", - "runToMain": true, - // Work around for stopping at main on restart - "postRestartCommands": [ - "break main", - "continue" - ] + "runToEntryPoint": "main" }, { "name": "Debug - Openocd Local", - "type":"cortex-debug", - "cortex-debug.armToolchainPath":"${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin", + "type": "cortex-debug", "cwd": "${workspaceRoot}", "executable": "${command:cmake.launchTargetPath}", "request": "launch", "servertype": "openocd", - // This may need to be arm-none-eabi-gdb depending on your system - "gdbPath" : "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gdb", + // FIXME: This is hardcoded. I have no idea how to use the values set in build.sh here + "gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb", // Connect to an already running OpenOCD instance "gdbTarget": "localhost:3333", "svdFile": "${workspaceRoot}/nrf52.svd", - "runToMain": true, - // Work around for stopping at main on restart - "postRestartCommands": [ - "break main", - "continue" - ] + "runToEntryPoint": "main" }, { "cwd": "${workspaceRoot}", @@ -59,6 +47,5 @@ "target/nrf52.cfg" ], } - ] -} +} \ No newline at end of file From 3a58fde7b0d549087707dea4973da2120a9d67da Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Mon, 20 Feb 2023 17:59:36 +0000 Subject: [PATCH 12/23] Hide broken buttons from CMake Extension --- .vscode/settings.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 8445e8fb0f..3b737f5f33 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,10 +1,20 @@ { "C_Cpp.default.configurationProvider": "ms-vscode.cmake-tools", "cmake.configureArgs": [ - // FIXME: This is a duplicate of /docker/build.sh. This could lead to some weird behaviour if build.sh is changed but this is not! No clue if this can be avoided though "-DARM_NONE_EABI_TOOLCHAIN_PATH=${env:TOOLS_DIR}/${env:GCC_ARM_PATH}", "-DNRF5_SDK_PATH=${env:TOOLS_DIR}/${env:NRF_SDK_VER}", ], + "cmake.statusbar.advanced": { + "launch": { + "visibility": "hidden" + }, + "launchTarget": { + "visibility": "hidden" + }, + "debug": { + "visibility": "hidden" + } + }, "cmake.generator": "Unix Makefiles", "clang-tidy.buildPath": "build/compile_commands.json", "files.associations": { From e8477c7826ed7cacb72c1ee7af5cf2582102d64a Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Thu, 16 Mar 2023 11:00:02 +0000 Subject: [PATCH 13/23] Refactor .devcontainer --- .devcontainer.json | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index a42bea4167..21d82ffd03 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -1,11 +1,8 @@ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at: // https://github.com/microsoft/vscode-dev-containers/tree/v0.154.2/containers/cpp { - // "name": "Pinetime", - // "image": "feabhas/pinetime-dev" "build": { "dockerfile": "docker/Dockerfile", - // Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04 "args": { "DEVCONTAINER": "true" } @@ -15,26 +12,31 @@ "--security-opt", "seccomp=unconfined" ], - // Set *default* container specific settings.json values on container create. - "settings": { - "terminal.integrated.shell.linux": "/bin/bash", - "editor.formatOnSave": true, - // FIXME: This and the Dockerfile might get out of sync - "clang-format.executable": "clang-format-14" + "customizations": { + "vscode": { + "settings": { + // Set *default* container specific settings.json values on container create. + "terminal.integrated.profiles.linux": { + "bash": { + "path": "/bin/bash" + } + }, + "terminal.integrated.defaultProfile.linux": "bash", + "editor.formatOnSave": true, + // FIXME: This and the Dockerfile might get out of sync + "clang-format.executable": "clang-format-14" + }, + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.cpptools", + "ms-vscode.cmake-tools", + "marus25.cortex-debug", + "notskm.clang-tidy", + "mjohns.clang-format" + ] + } }, - // Add the IDs of extensions you want installed when the container is created. - "extensions": [ - "ms-vscode.cpptools", - "ms-vscode.cmake-tools", - "marus25.cortex-debug", - "notskm.clang-tidy", - "mjohns.clang-format" - ], - // Use 'forwardPorts' to make a list of ports inside the container available locally. - // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "", - // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. - // "remoteUser": "vscode" "remoteUser": "infinitime" } \ No newline at end of file From a56501520883f7342451bcfd9e4f15a7da58f5a7 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Thu, 16 Mar 2023 11:07:34 +0000 Subject: [PATCH 14/23] Remove unneccessary runArgs --- .devcontainer.json | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index 21d82ffd03..abeffa0f7f 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -7,11 +7,6 @@ "DEVCONTAINER": "true" } }, - "runArgs": [ - "--cap-add=SYS_PTRACE", - "--security-opt", - "seccomp=unconfined" - ], "customizations": { "vscode": { "settings": { From 7d6bff9a72a955e29ddc984191d465768e697242 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Thu, 16 Mar 2023 11:20:03 +0000 Subject: [PATCH 15/23] Remove unneccessary postBuildCommand --- .devcontainer.json | 2 -- 1 file changed, 2 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index abeffa0f7f..eca50eeea1 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -31,7 +31,5 @@ ] } }, - // Use 'postCreateCommand' to run commands after the container is created. - "postCreateCommand": "", "remoteUser": "infinitime" } \ No newline at end of file From 1dc1609e2abba4517c14e0d805dd3a9fb8bfb544 Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Thu, 16 Mar 2023 11:32:57 +0000 Subject: [PATCH 16/23] Add devcontainer dependencies to all docker images --- docker/Dockerfile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 6bf567d005..d762f34066 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -38,12 +38,11 @@ RUN apt-get update -qq \ libpangocairo-1.0-0 \ && rm -rf /var/cache/apt/* /var/lib/apt/lists/*; -# Add the necessary apt-gets for devcontainer if this is a devcontainer -RUN if [ -n "$DEVCONTAINER" ] ; then \ - apt-get update -qq \ - && apt-get install -y \ - clang-format-14 \ - clang-tidy; fi +# Add the necessary apt-gets for the devcontainer +RUN apt-get update -qq \ + && apt-get install -y \ + clang-format-14 \ + clang-tidy # TODO: Do I need to set the locales for the devcontainer? @@ -65,8 +64,8 @@ RUN bash -c "source /opt/build.sh; GetNrfSdk;" # McuBoot RUN bash -c "source /opt/build.sh; GetMcuBoot;" -# If we are a devcontainer add the infinitime user -RUN if [ -n "$DEVCONTAINER" ] ; then adduser infinitime ; fi +# Add the infinitime user for connecting devcontainer +RUN adduser infinitime ENV SOURCES_DIR /sources CMD ["/opt/build.sh"] From 2826a253096cd16e3acc0692b8de4381a3b4257e Mon Sep 17 00:00:00 2001 From: Tim Aschhoff Date: Mon, 20 Mar 2023 09:02:14 +0000 Subject: [PATCH 17/23] Clean outdated comment --- docker/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index d762f34066..5c6fa5e9d0 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -44,8 +44,6 @@ RUN apt-get update -qq \ clang-format-14 \ clang-tidy -# TODO: Do I need to set the locales for the devcontainer? - # Git needed for PROJECT_GIT_COMMIT_HASH variable setting RUN pip3 install adafruit-nrfutil From 9b2c1b69c08827d19577cb9fc15b07d0d997869a Mon Sep 17 00:00:00 2001 From: BloodStainedCrow Date: Tue, 28 Nov 2023 23:54:23 +0000 Subject: [PATCH 18/23] Add Devcontainer Debug launch config --- .vscode/launch.json | 24 ++++++++++++++++++------ .vscode/settings.json | 2 +- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0785092ccc..30499864cb 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,8 +8,7 @@ "executable": "${command:cmake.launchTargetPath}", "request": "launch", "servertype": "external", - // FIXME: This is hardcoded. I have no idea how to use the values set in build.sh here - "gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb", + "gdbPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gdb", // Connect to an already running OpenOCD instance "gdbTarget": "host.docker.internal:3333", "svdFile": "${workspaceRoot}/nrf52.svd", @@ -22,8 +21,7 @@ "executable": "${command:cmake.launchTargetPath}", "request": "launch", "servertype": "openocd", - // FIXME: This is hardcoded. I have no idea how to use the values set in build.sh here - "gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb", + "gdbPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gdb", // Connect to an already running OpenOCD instance "gdbTarget": "localhost:3333", "svdFile": "${workspaceRoot}/nrf52.svd", @@ -46,6 +44,20 @@ "interface/stlink.cfg", "target/nrf52.cfg" ], - } + }, + { + "name": "Debug - Openocd Devcontainer", + "type": "cortex-debug", + "cwd": "${workspaceRoot}", + "executable": "${command:cmake.launchTargetPath}", + "request": "launch", + "servertype": "external", + // FIXME: This is hardcoded. I have no idea how to use the values set in build.sh here + "gdbPath": "/opt/gcc-arm-none-eabi-10.3-2021.10/bin/arm-none-eabi-gdb", + // Connect to an already running OpenOCD instance + "gdbTarget": "host.docker.internal:3333", + "svdFile": "${workspaceRoot}/nrf52.svd", + "runToEntryPoint": "main" + }, ] -} \ No newline at end of file +} diff --git a/.vscode/settings.json b/.vscode/settings.json index 3b737f5f33..a7b04eea3c 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -67,4 +67,4 @@ "cinttypes": "cpp", "typeinfo": "cpp" } -} \ No newline at end of file +} From de77ef89a0aa20fcb5d2ef1eff973e10eb4a6361 Mon Sep 17 00:00:00 2001 From: BloodStainedCrow Date: Wed, 29 Nov 2023 00:12:52 +0000 Subject: [PATCH 19/23] Add an additional c_cpp_properties config as a fallback for devcontainer --- .vscode/c_cpp_properties.json | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index fe1cf0f680..48021bc4a1 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -13,6 +13,21 @@ "${workspaceFolder}/src" ], "defines": [], + "compilerPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc", + "cStandard": "c11", + "cppStandard": "c++14", + "intelliSenseMode": "linux-gcc-arm", + "configurationProvider": "ms-vscode.cpp-tools", + "compileCommands": "${workspaceFolder}/build/compile_commands.json" + }, + { + "name": "nrfCC Devcontainer", + "includePath": [ + "${workspaceFolder}/**", + "${workspaceFolder}/src/**", + "${workspaceFolder}/src" + ], + "defines": [], "compilerPath": "${TOOLS_DIR}/${GCC_ARM_PATH}/bin/arm-none-eabi-gcc", "cStandard": "c11", "cppStandard": "c++20", @@ -22,4 +37,4 @@ } ], "version": 4 -} \ No newline at end of file +} From 077af794780b48bc07716cab2721faef8db5a845 Mon Sep 17 00:00:00 2001 From: BloodStainedCrow Date: Wed, 29 Nov 2023 00:24:29 +0000 Subject: [PATCH 20/23] Remove obsolete Docker Argument --- .devcontainer.json | 5 +---- .vscode/c_cpp_properties.json | 2 +- docker/Dockerfile | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index eca50eeea1..95a27dac74 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -2,10 +2,7 @@ // https://github.com/microsoft/vscode-dev-containers/tree/v0.154.2/containers/cpp { "build": { - "dockerfile": "docker/Dockerfile", - "args": { - "DEVCONTAINER": "true" - } + "dockerfile": "docker/Dockerfile" }, "customizations": { "vscode": { diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 48021bc4a1..4db949d5c9 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -37,4 +37,4 @@ } ], "version": 4 -} +} \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index 5c6fa5e9d0..a75d457815 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,6 +1,5 @@ FROM ubuntu:22.04 -ARG DEVCONTAINER ARG DEBIAN_FRONTEND=noninteractive ARG NODE_MAJOR=20 RUN apt-get update -qq \ From 0a0a4c31befceb758920e3aee6fba6f7c9747303 Mon Sep 17 00:00:00 2001 From: BloodStainedCrow Date: Wed, 29 Nov 2023 00:35:29 +0000 Subject: [PATCH 21/23] Re-Add stopping on main after restart --- .vscode/launch.json | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 30499864cb..7d3f17a11c 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -12,7 +12,12 @@ // Connect to an already running OpenOCD instance "gdbTarget": "host.docker.internal:3333", "svdFile": "${workspaceRoot}/nrf52.svd", - "runToEntryPoint": "main" + "runToEntryPoint": "main", + // Work around for stopping at main on restart + "postRestartCommands": [ + "break main", + "continue" + ] }, { "name": "Debug - Openocd Local", @@ -25,7 +30,12 @@ // Connect to an already running OpenOCD instance "gdbTarget": "localhost:3333", "svdFile": "${workspaceRoot}/nrf52.svd", - "runToEntryPoint": "main" + "runToEntryPoint": "main", + // Work around for stopping at main on restart + "postRestartCommands": [ + "break main", + "continue" + ] }, { "cwd": "${workspaceRoot}", @@ -37,6 +47,11 @@ "showDevDebugOutput": false, "servertype": "openocd", "runToMain": true, + // Work around for stopping at main on restart + "postRestartCommands": [ + "break main", + "continue" + ], // Only use armToolchainPath if your arm-none-eabi-gdb is not in your path (some GCC packages does not contain arm-none-eabi-gdb) "armToolchainPath": "${workspaceRoot}/../gcc-arm-none-eabi-10.3-2021.10/bin", "svdFile": "${workspaceRoot}/nrf52.svd", @@ -57,7 +72,12 @@ // Connect to an already running OpenOCD instance "gdbTarget": "host.docker.internal:3333", "svdFile": "${workspaceRoot}/nrf52.svd", - "runToEntryPoint": "main" + "runToEntryPoint": "main", + // Work around for stopping at main on restart + "postRestartCommands": [ + "break main", + "continue" + ] }, ] } From f0e39846f6ec299e9620e94f5586be9a092d2beb Mon Sep 17 00:00:00 2001 From: BloodStainedCrow Date: Thu, 21 Mar 2024 14:21:05 +0100 Subject: [PATCH 22/23] Fix wrong C/Cpp versions --- .vscode/c_cpp_properties.json | 6 +++--- .vscode/cmake-kits.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 4db949d5c9..c5f88a827b 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -15,7 +15,7 @@ "defines": [], "compilerPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc", "cStandard": "c11", - "cppStandard": "c++14", + "cppStandard": "c++20", "intelliSenseMode": "linux-gcc-arm", "configurationProvider": "ms-vscode.cpp-tools", "compileCommands": "${workspaceFolder}/build/compile_commands.json" @@ -29,7 +29,7 @@ ], "defines": [], "compilerPath": "${TOOLS_DIR}/${GCC_ARM_PATH}/bin/arm-none-eabi-gcc", - "cStandard": "c11", + "cStandard": "c99", "cppStandard": "c++20", "intelliSenseMode": "linux-gcc-arm", "configurationProvider": "ms-vscode.cpp-tools", @@ -37,4 +37,4 @@ } ], "version": 4 -} \ No newline at end of file +} diff --git a/.vscode/cmake-kits.json b/.vscode/cmake-kits.json index 11b2dd2efd..95bb600b33 100644 --- a/.vscode/cmake-kits.json +++ b/.vscode/cmake-kits.json @@ -3,4 +3,4 @@ "name": "InfiniTime Compiler", "environmentSetupScript": "${workspaceFolder}/docker/build.sh" } -] \ No newline at end of file +] From c326cd9ccd373fc13b1cf30453ecf432f5580b8a Mon Sep 17 00:00:00 2001 From: BloodStainedCrow Date: Fri, 22 Mar 2024 13:50:33 +0000 Subject: [PATCH 23/23] Fix silent fail of gdb, add libncurses5 --- docker/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index a75d457815..bb5d5f65be 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -41,7 +41,8 @@ RUN apt-get update -qq \ RUN apt-get update -qq \ && apt-get install -y \ clang-format-14 \ - clang-tidy + clang-tidy \ + libncurses5 # Git needed for PROJECT_GIT_COMMIT_HASH variable setting