From 65423b3c945002b5828f8be3b42e27bc9c83d8b4 Mon Sep 17 00:00:00 2001 From: Niall Cooling Date: Thu, 25 Feb 2021 16:18:08 +0000 Subject: added devcontainer files --- .devcontainer/devcontainer.json | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .devcontainer/devcontainer.json (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 00000000..fb81d289 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,32 @@ +// 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": "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" } + }, + "runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"], + + // Set *default* container specific settings.json values on container create. + "settings": { + "terminal.integrated.shell.linux": "/bin/bash" + }, + + // Add the IDs of extensions you want installed when the container is created. + "extensions": [ + "ms-vscode.cpptools" + ], + + // 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": "gcc -v", + + // 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 -- cgit v1.2.3 From 382db668ed513836a52ff4fdc49b0ee7a08a1527 Mon Sep 17 00:00:00 2001 From: Niall Cooling Date: Thu, 25 Feb 2021 17:49:40 +0000 Subject: macOS and Win10 dockerfile --- .devcontainer/Dockerfile | 5 +++-- .devcontainer/create_build_openocd.sh | 3 +++ .devcontainer/devcontainer.json | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) create mode 100755 .devcontainer/create_build_openocd.sh (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 7e961528..2c223bc1 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -27,14 +27,15 @@ RUN pip3 install adafruit-nrfutil RUN pip3 install setuptools_rust WORKDIR /opt/ -# build.sh knows how to compile +# build.sh knows how to compile but it problimatic on Win10 COPY build.sh . +# create_build_openocd.sh uses cmake to crate to build directory +COPY 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 -# RUN rm gcc-arm-none-eabi-9-2020-q2-update-x86_64-linux.tar.bz2 # 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 diff --git a/.devcontainer/create_build_openocd.sh b/.devcontainer/create_build_openocd.sh new file mode 100755 index 00000000..860ffa1f --- /dev/null +++ b/.devcontainer/create_build_openocd.sh @@ -0,0 +1,3 @@ +#!/bin/bash +rm -rf build/ +cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Debug -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/devcontainer.json b/.devcontainer/devcontainer.json index fb81d289..1740a8e4 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -24,7 +24,7 @@ // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. - // "postCreateCommand": "gcc -v", + // "postCreateCommand": "/opt/create_build_openocd.sh", // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. // "remoteUser": "vscode" -- cgit v1.2.3 From 937d3e19335758ac76607a1d75c8844b49dd3c3e Mon Sep 17 00:00:00 2001 From: Niall Cooling Date: Fri, 26 Feb 2021 08:14:30 +0000 Subject: added dos2unix to docker for Win10 and default to release build --- .devcontainer/Dockerfile | 1 + .devcontainer/create_build_openocd.sh | 2 +- .devcontainer/devcontainer.json | 5 +++-- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2c223bc1..bb7dddba 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -15,6 +15,7 @@ RUN apt-get update -qq \ unzip \ wget \ curl \ + dos2unix \ # aarch64 packages libffi-dev \ libssl-dev \ diff --git a/.devcontainer/create_build_openocd.sh b/.devcontainer/create_build_openocd.sh index 860ffa1f..c5bff5c8 100755 --- a/.devcontainer/create_build_openocd.sh +++ b/.devcontainer/create_build_openocd.sh @@ -1,3 +1,3 @@ #!/bin/bash rm -rf build/ -cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Debug -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 +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/devcontainer.json b/.devcontainer/devcontainer.json index 1740a8e4..90b6eceb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,14 +17,15 @@ // Add the IDs of extensions you want installed when the container is created. "extensions": [ - "ms-vscode.cpptools" + "ms-vscode.cpptools", + "ms-vscode.cmake-tools", ], // 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": "/opt/create_build_openocd.sh", + // "postCreateCommand": "bash /opt/create_build_openocd.sh", // Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root. // "remoteUser": "vscode" -- cgit v1.2.3 From f7643a4d828ec3c60f418b6d9a660097eb44e05e Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Sun, 25 Jul 2021 20:12:34 +0000 Subject: Added cmake variants --- .devcontainer/Dockerfile | 17 +++++++-- .devcontainer/README.md | 60 ++++++++++++++++++++++++++++++++ .devcontainer/build.sh | 0 .devcontainer/create_build_openocd.sh | 0 .devcontainer/devcontainer.json | 1 + .devcontainer/make_build_dir.sh | 2 +- .gitignore | 2 +- .vscode/c_cpp_properties.json | 15 ++++---- .vscode/cmake-variants.json | 62 +++++++++++++++++++++++++++++++++ .vscode/launch.json | 46 +++++++++++++++++++++++++ .vscode/settings.json | 65 ++++------------------------------- .vscode/tasks.json | 44 ++++++++++++++++++++++++ 12 files changed, 245 insertions(+), 69 deletions(-) create mode 100644 .devcontainer/README.md mode change 100755 => 100644 .devcontainer/build.sh mode change 100755 => 100644 .devcontainer/create_build_openocd.sh create mode 100644 .vscode/cmake-variants.json create mode 100644 .vscode/launch.json create mode 100644 .vscode/tasks.json (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 55f30136..4534c7e2 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:latest ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update -qq \ @@ -18,12 +18,20 @@ RUN apt-get update -qq \ dos2unix \ clang-format \ 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 @@ -32,9 +40,10 @@ 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;" @@ -51,4 +60,6 @@ RUN pip3 install -r ./mcuboot/scripts/requirements.txt RUN adduser infinitime -ENV SOURCES_DIR /workspaces/Pinetime +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/README.md b/.devcontainer/README.md new file mode 100644 index 00000000..ff9307b2 --- /dev/null +++ b/.devcontainer/README.md @@ -0,0 +1,60 @@ +# VScode devcontainer +This is a docker-based interactive development environment using VSCode and Docker Devcontainers removing the need to install any tools locally* + + + +## Requirements + +- VScode + - [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension +- Docker +- OpenOCD - For debugging + +## Using + +### Code editing, and building. + +1. Clone InifiniTime and update submodules +2. Launch VSCode +3. Open InifiTime directory, +4. Allow VSCode to open folder with devcontainer. + +After this the environment will be built if you do not currently have a container setup, it will install all the necessary tools and extra VSCode extensions. + +In order to build InfiniTime we need to run the initial submodule init and Cmake commands. + +#### Manually + + You can use the VSCode terminal to run the CMake commands as outlined in the [build instructions](blob/develop/doc/buildAndProgram.md) + +#### Script + +The dev enviroment comes with some scripts to make this easier, They are located in /opt/. + +There are also VSCode tasks provided should you desire to use those. + +The task BuildInit will update submodules and configure for openocd + + + +### Build + +You can use the build.sh script located in /opt/ + +There will also eventually be a Build task. - Not written yet + + + +### Debugging + +Docker on windows does not support passing USB devices to the underlying WSL2 subsystem, To get around this we use openocd in server mode running on the host. + +`openocd -f -f ` + +This will launch openocd in server mode and attach it to the MCU. + +The default launch.json file expects openocd to be listening on port 3333, edit if needed + + +## Current Issues +Currently WSL2 Has some real performance issues with IO on a windows host. Accessing files on the virtualized filesystem is much faster. Using VSCodes "clone in container" feature of the Remote - Containers will get around this. After the container is built you will need to update the submodules and follow the build isntructions like normal \ No newline at end of file diff --git a/.devcontainer/build.sh b/.devcontainer/build.sh old mode 100755 new mode 100644 diff --git a/.devcontainer/create_build_openocd.sh b/.devcontainer/create_build_openocd.sh old mode 100755 new mode 100644 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 90b6eceb..223b651f 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -19,6 +19,7 @@ "extensions": [ "ms-vscode.cpptools", "ms-vscode.cmake-tools", + "marus25.cortex-debug" ], // Use 'forwardPorts' to make a list of ports inside the container available locally. diff --git a/.devcontainer/make_build_dir.sh b/.devcontainer/make_build_dir.sh index 0b86b307..76240037 100644 --- a/.devcontainer/make_build_dir.sh +++ b/.devcontainer/make_build_dir.sh @@ -1,2 +1,2 @@ #!/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 /workspaces/Pinetime +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/.gitignore b/.gitignore index 2f9ac181..6de76a9e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ # CMake cmake-build-* -cmake-* +cmake-*/ CMakeFiles **/CMakeCache.txt cmake_install.cmake diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index b409ec98..f5c74b3a 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -1,15 +1,18 @@ { "configurations": [ { - "name": "Linux", + "name": "nrfCC", "includePath": [ - "${workspaceFolder}/**" + "${workspaceFolder}/**", + "${workspaceFolder}/src/**", + "${workspaceFolder}/src" ], "defines": [], - "compilerPath": "/usr/bin/gcc", - "cStandard": "gnu11", - "cppStandard": "gnu++14", - "intelliSenseMode": "linux-gcc-x64", + "compilerPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc", + "cStandard": "c11", + "cppStandard": "c++14", + "intelliSenseMode": "linux-gcc-arm", + "configurationProvider": "ms-vscode.cmake-tools", "compileCommands": "${workspaceFolder}/build/compile_commands.json" } ], diff --git a/.vscode/cmake-variants.json b/.vscode/cmake-variants.json new file mode 100644 index 00000000..d00e638e --- /dev/null +++ b/.vscode/cmake-variants.json @@ -0,0 +1,62 @@ +{ + "buildType": { + "default": "release", + "choices": { + "debug": { + "short": "Debug", + "long": "Emit debug information without performing optimizations", + "buildType": "Debug" + }, + "release": { + "short": "Release", + "long": "Perform optimizations", + "buildType": "Release" + } + } + }, + "programmer":{ + "default": "OpenOCD", + "choices":{ + "OpenOCD":{ + "short":"OpenOCD", + "long": "Use OpenOCD", + "settings":{ + "USE_OPENOCD":1 + } + }, + "JLink":{ + "short":"JLink", + "long": "Use JLink", + "settings":{ + "USE_JLINK":1 + } + }, + "GDB":{ + "short":"GDB", + "long": "Use GDB", + "settings":{ + "USE_GDB_CLIENT":1 + } + } + } + }, + "DFU": { + "default": "no", + "choices": { + "no": { + "short": "No DFU", + "long": "Do not build DFU", + "settings": { + "BUILD_DFU":0 + } + }, + "yes": { + "short": "Build DFU", + "long": "Build DFU", + "settings": { + "BUILD_DFU":1 + } + } + } + } +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..78fc1180 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,46 @@ + { + "version": "0.1.0", + "configurations": [ + { + "name": "Debug - Openocd docker Remote", + "type":"cortex-debug", + "cortex-debug.armToolchainPath":"${env:COMPILER_DIR}/bin", + "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:COMPILER_DIR}/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" + ] + }, + { + "name": "Debug - Openocd Local", + "type":"cortex-debug", + "cortex-debug.armToolchainPath":"${env:COMPILER_DIR}/bin", + "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:COMPILER_DIR}/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" + ] + } + + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 05b11756..3b686626 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,59 +1,8 @@ { - "files.associations": { - "chrono": "cpp", - "list": "cpp", - "array": "cpp", - "atomic": "cpp", - "bit": "cpp", - "*.tcc": "cpp", - "cctype": "cpp", - "charconv": "cpp", - "clocale": "cpp", - "cmath": "cpp", - "condition_variable": "cpp", - "cstdarg": "cpp", - "cstddef": "cpp", - "cstdint": "cpp", - "cstdio": "cpp", - "cstdlib": "cpp", - "cstring": "cpp", - "ctime": "cpp", - "cwchar": "cpp", - "cwctype": "cpp", - "deque": "cpp", - "unordered_map": "cpp", - "vector": "cpp", - "exception": "cpp", - "algorithm": "cpp", - "functional": "cpp", - "iterator": "cpp", - "memory": "cpp", - "memory_resource": "cpp", - "netfwd": "cpp", - "numeric": "cpp", - "optional": "cpp", - "random": "cpp", - "ratio": "cpp", - "string": "cpp", - "string_view": "cpp", - "system_error": "cpp", - "tuple": "cpp", - "type_traits": "cpp", - "utility": "cpp", - "fstream": "cpp", - "initializer_list": "cpp", - "iosfwd": "cpp", - "iostream": "cpp", - "istream": "cpp", - "limits": "cpp", - "mutex": "cpp", - "new": "cpp", - "ostream": "cpp", - "sstream": "cpp", - "stdexcept": "cpp", - "streambuf": "cpp", - "thread": "cpp", - "cinttypes": "cpp", - "typeinfo": "cpp" - } -} \ No newline at end of file + "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}", + ], + "cmake.generator": "Unix Makefiles" +} diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..17f51f5e --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,44 @@ +{ + "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", + "command": "git submodule update --init", + "options": { + "cwd": "${workspaceFolder}" + }, + "group": { + "kind": "build", + "isDefault": true + }, + "presentation": { + "reveal": "always", + "panel": "shared" + }, + "problemMatcher": [] + }, + { + "label": "BuildInit", + "dependsOn": [ + "update submodules", + "create openocd build" + ], + "problemMatcher": [] + } + ] +} \ No newline at end of file -- cgit v1.2.3 From 44889adda074af2a7a5fe61b19667521755dd24d Mon Sep 17 00:00:00 2001 From: Tim Keller Date: Mon, 9 Aug 2021 00:16:17 +0000 Subject: Setup plugins for Clang-tidy/format --- .devcontainer/Dockerfile | 2 +- .devcontainer/devcontainer.json | 4 +++- .vscode/settings.json | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to '.devcontainer/devcontainer.json') diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 4534c7e2..1dd68f24 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -16,7 +16,7 @@ RUN apt-get update -qq \ wget \ curl \ dos2unix \ - clang-format \ + clang-format-12 \ clang-tidy \ locales \ libncurses5 \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 223b651f..778fe9cb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -19,7 +19,9 @@ "extensions": [ "ms-vscode.cpptools", "ms-vscode.cmake-tools", - "marus25.cortex-debug" + "marus25.cortex-debug", + "notskm.clang-tidy", + "mjohns.clang-format" ], // Use 'forwardPorts' to make a list of ports inside the container available locally. diff --git a/.vscode/settings.json b/.vscode/settings.json index 3b686626..8f0e63f4 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -4,5 +4,6 @@ "-DARM_NONE_EABI_TOOLCHAIN_PATH=${env:ARM_NONE_EABI_TOOLCHAIN_PATH}", "-DNRF5_SDK_PATH=${env:NRF5_SDK_PATH}", ], - "cmake.generator": "Unix Makefiles" + "cmake.generator": "Unix Makefiles", + "clang-tidy.buildPath": "build/compile_commands.json" } -- cgit v1.2.3