Skip to content

Commit 85c9979

Browse files
committed
Merge branch 'develop' into new_touch_handler
2 parents fe33c75 + df8ea7f commit 85c9979

40 files changed

Lines changed: 836 additions & 400 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.devcontainer/Dockerfile

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
FROM ubuntu:latest
2+
3+
ARG DEBIAN_FRONTEND=noninteractive
4+
RUN apt-get update -qq \
5+
&& apt-get install -y \
6+
# x86_64 / generic packages
7+
bash \
8+
build-essential \
9+
cmake \
10+
git \
11+
make \
12+
python3 \
13+
python3-pip \
14+
tar \
15+
unzip \
16+
wget \
17+
curl \
18+
dos2unix \
19+
clang-format-12 \
20+
clang-tidy \
21+
locales \
22+
libncurses5 \
23+
# aarch64 packages
24+
libffi-dev \
25+
libssl-dev \
26+
python3-dev \
27+
rustc \
28+
&& rm -rf /var/cache/apt/* /var/lib/apt/lists/*;
29+
30+
#SET LOCALE
31+
RUN locale-gen en_US.UTF-8
32+
ENV LANG en_US.UTF-8
33+
ENV LANGUAGE en_US:en
34+
ENV LC_ALL en_US.UTF-8
35+
36+
RUN pip3 install adafruit-nrfutil
37+
# required for McuBoot
38+
RUN pip3 install setuptools_rust
39+
40+
WORKDIR /opt/
41+
# build.sh knows how to compile but it problimatic on Win10
42+
COPY build.sh .
43+
RUN chmod +x build.sh
44+
# create_build_openocd.sh uses cmake to crate to build directory
45+
COPY create_build_openocd.sh .
46+
RUN chmod +x create_build_openocd.sh
47+
# Lets get each in a separate docker layer for better downloads
48+
# GCC
49+
# RUN bash -c "source /opt/build.sh; GetGcc;"
50+
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
51+
# NrfSdk
52+
# RUN bash -c "source /opt/build.sh; GetNrfSdk;"
53+
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
54+
RUN unzip -q /tmp/nRF5_SDK_15.3.0_59ac345 -d /opt
55+
RUN rm /tmp/nRF5_SDK_15.3.0_59ac345
56+
# McuBoot
57+
# RUN bash -c "source /opt/build.sh; GetMcuBoot;"
58+
RUN git clone https://github.com/JuulLabs-OSS/mcuboot.git
59+
RUN pip3 install -r ./mcuboot/scripts/requirements.txt
60+
61+
RUN adduser infinitime
62+
63+
ENV NRF5_SDK_PATH /opt/nRF5_SDK_15.3.0_59ac345
64+
ENV ARM_NONE_EABI_TOOLCHAIN_PATH /opt/gcc-arm-none-eabi-9-2020-q2-update
65+
ENV SOURCES_DIR /workspaces/InfiniTime

.devcontainer/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# VS Code Dev Container
2+
This is a docker-based interactive development environment using VS Code and Docker Dev Containers removing the need to install any tools locally*
3+
4+
5+
6+
## Requirements
7+
8+
- VS Code
9+
- [Remote - Containers](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) extension
10+
- Docker
11+
- OpenOCD - For debugging
12+
13+
## Using
14+
15+
### Code editing, and building.
16+
17+
1. Clone InfiniTime and update submodules
18+
2. Launch VS Code
19+
3. Open InfiniTime directory,
20+
4. Allow VS Code to open folder with devcontainer.
21+
22+
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.
23+
24+
In order to build InfiniTime we need to run the initial submodule init and CMake commands.
25+
26+
#### Manually
27+
28+
You can use the VS Code terminal to run the CMake commands as outlined in the [build instructions](blob/develop/doc/buildAndProgram.md)
29+
30+
#### Script
31+
32+
The dev environment comes with some scripts to make this easier, They are located in /opt/.
33+
34+
There are also VS Code tasks provided should you desire to use those.
35+
36+
The task "update submodules" will update the git submodules
37+
38+
39+
40+
### Build
41+
42+
You can use the build.sh script located in /opt/
43+
44+
CMake is also configured and controls for the CMake plugin are available in VS Code
45+
46+
47+
48+
### Debugging
49+
50+
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.
51+
52+
`openocd -f <yourinterface> -f <nrf52.cfg target file>`
53+
54+
This will launch OpenOCD in server mode and attach it to the MCU.
55+
56+
The default launch.json file expects OpenOCD to be listening on port 3333, edit if needed
57+
58+
59+
## Current Issues
60+
Currently WSL2 Has some real performance issues with IO on a windows host. Accessing files on the virtualized filesystem is much faster. Using VS Codes "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 instructions like normal

.devcontainer/build.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
(return 0 2>/dev/null) && SOURCED="true" || SOURCED="false"
3+
export LC_ALL=C.UTF-8
4+
export LANG=C.UTF-8
5+
set -x
6+
set -e
7+
8+
# Default locations if the var isn't already set
9+
export TOOLS_DIR="${TOOLS_DIR:=/opt}"
10+
export SOURCES_DIR="${SOURCES_DIR:=/sources}"
11+
export BUILD_DIR="${BUILD_DIR:=$SOURCES_DIR/build}"
12+
export OUTPUT_DIR="${OUTPUT_DIR:=$BUILD_DIR/output}"
13+
14+
export BUILD_TYPE=${BUILD_TYPE:=Release}
15+
export GCC_ARM_VER=${GCC_ARM_VER:="gcc-arm-none-eabi-9-2020-q2-update"}
16+
export NRF_SDK_VER=${NRF_SDK_VER:="nRF5_SDK_15.3.0_59ac345"}
17+
18+
MACHINE="$(uname -m)"
19+
[[ "$MACHINE" == "arm64" ]] && MACHINE="aarch64"
20+
21+
main() {
22+
local target="$1"
23+
24+
mkdir -p "$TOOLS_DIR"
25+
26+
[[ ! -d "$TOOLS_DIR/$GCC_ARM_VER" ]] && GetGcc
27+
[[ ! -d "$TOOLS_DIR/$NRF_SDK_VER" ]] && GetNrfSdk
28+
[[ ! -d "$TOOLS_DIR/mcuboot" ]] && GetMcuBoot
29+
30+
mkdir -p "$BUILD_DIR"
31+
32+
CmakeGenerate
33+
CmakeBuild $target
34+
BUILD_RESULT=$?
35+
if [ "$DISABLE_POSTBUILD" != "true" -a "$BUILD_RESULT" == 0 ]; then
36+
source "$BUILD_DIR/post_build.sh"
37+
fi
38+
}
39+
40+
GetGcc() {
41+
GCC_SRC="$GCC_ARM_VER-$MACHINE-linux.tar.bz"
42+
wget -q https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2020q2/$GCC_SRC -O - | tar -xj -C $TOOLS_DIR/
43+
}
44+
45+
GetMcuBoot() {
46+
git clone https://github.com/JuulLabs-OSS/mcuboot.git "$TOOLS_DIR/mcuboot"
47+
pip3 install -r "$TOOLS_DIR/mcuboot/scripts/requirements.txt"
48+
}
49+
50+
GetNrfSdk() {
51+
wget -q "https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/$NRF_SDK_VER.zip" -O /tmp/$NRF_SDK_VER
52+
unzip -q /tmp/$NRF_SDK_VER -d "$TOOLS_DIR/"
53+
rm /tmp/$NRF_SDK_VER
54+
}
55+
56+
CmakeGenerate() {
57+
# We can swap the CD and trailing SOURCES_DIR for -B and -S respectively
58+
# once we go to newer CMake (Ubuntu 18.10 gives us CMake 3.10)
59+
cd "$BUILD_DIR"
60+
61+
cmake -G "Unix Makefiles" \
62+
-DCMAKE_BUILD_TYPE=$BUILD_TYPE \
63+
-DUSE_OPENOCD=1 \
64+
-DARM_NONE_EABI_TOOLCHAIN_PATH="$TOOLS_DIR/$GCC_ARM_VER" \
65+
-DNRF5_SDK_PATH="$TOOLS_DIR/$NRF_SDK_VER" \
66+
"$SOURCES_DIR"
67+
cmake -L -N .
68+
}
69+
70+
CmakeBuild() {
71+
local target="$1"
72+
[[ -n "$target" ]] && target="--target $target"
73+
if cmake --build "$BUILD_DIR" --config $BUILD_TYPE $target -- -j$(nproc)
74+
then return 0; else return 1;
75+
fi
76+
}
77+
78+
[[ $SOURCED == "false" ]] && main "$@" || echo "Sourced!"

.devcontainer/build_app.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
cmake --build /workspaces/Pinetime/build --config Release -- -j6 pinetime-app
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
rm -rf build/
3+
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

.devcontainer/devcontainer.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.154.2/containers/cpp
3+
{
4+
// "name": "Pinetime",
5+
// "image": "feabhas/pinetime-dev"
6+
"build": {
7+
"dockerfile": "Dockerfile",
8+
// Update 'VARIANT' to pick an Debian / Ubuntu OS version: debian-10, debian-9, ubuntu-20.04, ubuntu-18.04
9+
// "args": { "VARIANT": "ubuntu-20.04" }
10+
},
11+
"runArgs": [ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
12+
13+
// Set *default* container specific settings.json values on container create.
14+
"settings": {
15+
"terminal.integrated.shell.linux": "/bin/bash"
16+
},
17+
18+
// Add the IDs of extensions you want installed when the container is created.
19+
"extensions": [
20+
"ms-vscode.cpptools",
21+
"ms-vscode.cmake-tools",
22+
"marus25.cortex-debug",
23+
"notskm.clang-tidy",
24+
"mjohns.clang-format"
25+
],
26+
27+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
28+
// "forwardPorts": [],
29+
30+
// Use 'postCreateCommand' to run commands after the container is created.
31+
// "postCreateCommand": "bash /opt/create_build_openocd.sh",
32+
33+
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
34+
// "remoteUser": "vscode"
35+
"remoteUser": "infinitime"
36+
}

.devcontainer/make_build_dir.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
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}

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
# CMake
66
cmake-build-*
7-
cmake-*
7+
cmake-*/
88
CMakeFiles
99
**/CMakeCache.txt
1010
cmake_install.cmake

.vscode/c_cpp_properties.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"configurations": [
3+
{
4+
"name": "nrfCC",
5+
"includePath": [
6+
"${workspaceFolder}/**",
7+
"${workspaceFolder}/src/**",
8+
"${workspaceFolder}/src"
9+
],
10+
"defines": [],
11+
"compilerPath": "${env:ARM_NONE_EABI_TOOLCHAIN_PATH}/bin/arm-none-eabi-gcc",
12+
"cStandard": "c11",
13+
"cppStandard": "c++14",
14+
"intelliSenseMode": "linux-gcc-arm",
15+
"configurationProvider": "ms-vscode.cpp-tools",
16+
"compileCommands": "${workspaceFolder}/build/compile_commands.json"
17+
}
18+
],
19+
"version": 4
20+
}

.vscode/cmake-variants.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"buildType": {
3+
"default": "release",
4+
"choices": {
5+
"debug": {
6+
"short": "Debug",
7+
"long": "Emit debug information without performing optimizations",
8+
"buildType": "Debug"
9+
},
10+
"release": {
11+
"short": "Release",
12+
"long": "Perform optimizations",
13+
"buildType": "Release"
14+
}
15+
}
16+
},
17+
"programmer":{
18+
"default": "OpenOCD",
19+
"choices":{
20+
"OpenOCD":{
21+
"short":"OpenOCD",
22+
"long": "Use OpenOCD",
23+
"settings":{
24+
"USE_OPENOCD":1
25+
}
26+
},
27+
"JLink":{
28+
"short":"JLink",
29+
"long": "Use JLink",
30+
"settings":{
31+
"USE_JLINK":1
32+
}
33+
},
34+
"GDB":{
35+
"short":"GDB",
36+
"long": "Use GDB",
37+
"settings":{
38+
"USE_GDB_CLIENT":1
39+
}
40+
}
41+
}
42+
},
43+
"DFU": {
44+
"default": "no",
45+
"choices": {
46+
"no": {
47+
"short": "No DFU",
48+
"long": "Do not build DFU",
49+
"settings": {
50+
"BUILD_DFU":"0"
51+
}
52+
},
53+
"yes": {
54+
"short": "Build DFU",
55+
"long": "Build DFU",
56+
"settings": {
57+
"BUILD_DFU":"1"
58+
}
59+
}
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)