Skip to content

Commit 6c3d6fb

Browse files
JF002Gitea
authored andcommitted
Merge branch 'develop' of JF/PineTime into master
2 parents db6a701 + 6f9f0e8 commit 6c3d6fb

File tree

136 files changed

+2205
-1374
lines changed

Some content is hidden

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

136 files changed

+2205
-1374
lines changed

.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}

.github/workflows/main.yml

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444

4545
- name: Install Embedded Arm Toolchain arm-none-eabi-gcc
4646
if: steps.cache-toolchain.outputs.cache-hit != 'true' # Install toolchain if not found in cache
47-
uses: fiam/[email protected].2
47+
uses: fiam/[email protected].4
4848
with:
4949
# GNU Embedded Toolchain for Arm release name, in the V-YYYY-qZ format (e.g. "9-2019-q4")
5050
release: 9-2020-q2
@@ -83,10 +83,11 @@ jobs:
8383
if: steps.cache-mcuboot.outputs.cache-hit != 'true' # Install MCUBoot if not found in cache
8484
run: |
8585
cd ${{ runner.temp }}
86-
git clone --branch v1.5.0 https://github.com/JuulLabs-OSS/mcuboot
86+
git clone --branch v1.7.2 https://github.com/mcu-tools/mcuboot
8787
8888
- name: Install imgtool dependencies
89-
run: pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
89+
run: |
90+
pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
9091
9192
- name: Install adafruit-nrfutil
9293
run: |
@@ -99,6 +100,8 @@ jobs:
99100

100101
- name: Checkout source files
101102
uses: actions/checkout@v2
103+
with:
104+
submodules: recursive
102105

103106
- name: Show files
104107
run: set ; pwd ; ls -l
@@ -110,7 +113,7 @@ jobs:
110113
run: |
111114
mkdir -p build
112115
cd build
113-
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 ../
116+
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 -DBUILD_DFU=1 ../
114117
115118
#########################################################################################
116119
# Make and Upload DFU Package
@@ -125,19 +128,10 @@ jobs:
125128
cd build
126129
make pinetime-mcuboot-app
127130
128-
- name: Create firmware image
129-
run: |
130-
# The generated firmware binary looks like "pinetime-mcuboot-app-0.8.2.bin"
131-
ls -l build/src/pinetime-mcuboot-app*.bin
132-
${{ runner.temp }}/mcuboot/scripts/imgtool.py create --align 4 --version 1.0.0 --header-size 32 --slot-size 475136 --pad-header build/src/pinetime-mcuboot-app*.bin build/src/pinetime-mcuboot-app-img.bin
133-
${{ runner.temp }}/mcuboot/scripts/imgtool.py verify build/src/pinetime-mcuboot-app-img.bin
134-
135-
- name: Create DFU package
131+
- name: Unzip DFU package
136132
run: |
137-
~/.local/bin/adafruit-nrfutil dfu genpkg --dev-type 0x0052 --application build/src/pinetime-mcuboot-app-img.bin build/src/pinetime-mcuboot-app-dfu.zip
138-
unzip -v build/src/pinetime-mcuboot-app-dfu.zip
139133
# Unzip the package because Upload Artifact will zip up the files
140-
unzip build/src/pinetime-mcuboot-app-dfu.zip -d build/src/pinetime-mcuboot-app-dfu
134+
unzip build/src/pinetime-mcuboot-app-dfu*.zip -d build/src/pinetime-mcuboot-app-dfu
141135
142136
- name: Upload DFU package
143137
uses: actions/upload-artifact@v2

.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+
}

0 commit comments

Comments
 (0)