Skip to content

Commit df644f5

Browse files
JF002Gitea
authored and
Gitea
committed
Merge branch 'develop' of JF/PineTime into master
2 parents 187ea0f + 12fad74 commit df644f5

File tree

242 files changed

+2308
-10509
lines changed

Some content is hidden

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

242 files changed

+2308
-10509
lines changed

.clang-format

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ AlignConsecutiveDeclarations: false
88
AlignEscapedNewlines: Right
99
AlignOperands: Align
1010
AlignTrailingComments: true
11-
AllowAllArgumentsOnNextLine: true
11+
AllowAllArgumentsOnNextLine: false
1212
AllowAllConstructorInitializersOnNextLine: true
13-
AllowAllParametersOfDeclarationOnNextLine: true
13+
AllowAllParametersOfDeclarationOnNextLine: false
1414
AllowShortBlocksOnASingleLine: Never
1515
AllowShortCaseLabelsOnASingleLine: false
1616
AllowShortFunctionsOnASingleLine: None
@@ -83,6 +83,8 @@ IndentGotoLabels: true
8383
IndentPPDirectives: BeforeHash
8484
IndentWidth: 2
8585
IndentWrappedFunctionNames: false
86+
# Requires Clang >= 15, could also cause incorrect code formatting:
87+
# InsertBraces: true
8688
JavaScriptQuotes: Leave
8789
JavaScriptWrapImports: true
8890
KeepEmptyLinesAtTheStartOfBlocks: true

.github/workflows/format.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Code formatting
2+
3+
on:
4+
pull_request:
5+
branches: [ master, develop ]
6+
paths:
7+
- '**.cpp'
8+
- '**.h'
9+
- '!src/libs/**'
10+
- '!src/FreeRTOS/**'
11+
12+
jobs:
13+
test-format:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 1000
19+
20+
- name: Configure git
21+
run: |
22+
git fetch origin "$GITHUB_BASE_REF":"$GITHUB_BASE_REF" --depth=1000
23+
24+
- name: Install clang-format
25+
run: |
26+
sudo apt-get update
27+
sudo apt-get -y install clang-format-12
28+
29+
- name: Check formatting
30+
run: tests/test-format.sh
31+
32+
- name: Upload patches
33+
uses: actions/upload-artifact@v3
34+
if: failure()
35+
with:
36+
name: Patches
37+
path: ./*.patch

.github/workflows/lv_sim.yml

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
# GitHub Actions Workflow to build Simulator for PineTime Smart Watch LVGL Interface
22

3-
# Name of this Workflow
43
name: Build PineTime LVGL Simulator
54

6-
# When to run this Workflow...
75
on:
8-
9-
# Run on all branches
106
push:
11-
branches: []
12-
13-
# Also run this Workflow when a Pull Request is created or updated in the "master" and "develop" Branch
7+
branches: [ master, develop ]
148
pull_request:
159
branches: [ master, develop ]
1610

17-
# Steps to run for the Workflow
1811
jobs:
1912
build:
20-
21-
# Run these steps on Ubuntu
2213
runs-on: ubuntu-latest
2314

2415
steps:
@@ -34,6 +25,10 @@ jobs:
3425
sudo apt-get update
3526
sudo apt-get -y install libsdl2-dev
3627
28+
- name: Install lv_font_conv
29+
run:
30+
npm i -g lv_font_conv@1.5.2
31+
3732
#########################################################################################
3833
# Checkout
3934

@@ -60,15 +55,12 @@ jobs:
6055
#########################################################################################
6156
# Build and Upload simulator
6257

63-
# For Debugging Builds: Remove "make" option "-j" for clearer output. Add "--trace" to see details.
64-
# For Faster Builds: Add "make" option "-j"
65-
6658
- name: Build simulator executable
6759
run: |
6860
cmake --build build_lv_sim
6961
7062
- name: Upload simulator executable
71-
uses: actions/upload-artifact@v2
63+
uses: actions/upload-artifact@v3
7264
with:
73-
name: infinisim
65+
name: infinisim-${{ github.head_ref }}
7466
path: build_lv_sim/infinisim

.github/workflows/main.yml

+23-146
Original file line numberDiff line numberDiff line change
@@ -3,168 +3,45 @@
33
# Based on https://github.com/JF002/InfiniTime/blob/master/doc/buildAndProgram.md
44
# and https://github.com/JF002/InfiniTime/blob/master/bootloader/README.md
55

6-
# Name of this Workflow
76
name: Build PineTime Firmware
87

9-
# When to run this Workflow...
108
on:
11-
12-
# Run this Workflow when files are updated (Pushed) in the "master" and "develop" Branch
139
push:
1410
branches: [ master, develop ]
15-
16-
# Also run this Workflow when a Pull Request is created or updated in the "master" and "develop" Branch
1711
pull_request:
1812
branches: [ master, develop ]
1913

20-
# Steps to run for the Workflow
2114
jobs:
2215
build:
23-
24-
# Run these steps on Ubuntu
2516
runs-on: ubuntu-latest
26-
17+
container:
18+
image: infinitime/infinitime-build
2719
steps:
28-
29-
#########################################################################################
30-
# Download and Cache Dependencies
31-
32-
- name: Install cmake
33-
uses: lukka/get-cmake@v3.18.3
34-
35-
- name: Check cache for Embedded Arm Toolchain arm-none-eabi-gcc
36-
id: cache-toolchain
37-
uses: actions/cache@v2
38-
env:
39-
cache-name: cache-toolchain-9-2020-q2
40-
with:
41-
path: ${{ runner.temp }}/arm-none-eabi
42-
key: ${{ runner.os }}-build-${{ env.cache-name }}
43-
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
44-
45-
- name: Install Embedded Arm Toolchain arm-none-eabi-gcc
46-
if: steps.cache-toolchain.outputs.cache-hit != 'true' # Install toolchain if not found in cache
47-
uses: fiam/arm-none-eabi-gcc@v1.0.4
48-
with:
49-
# GNU Embedded Toolchain for Arm release name, in the V-YYYY-qZ format (e.g. "9-2019-q4")
50-
release: 9-2020-q2
51-
# Directory to unpack GCC to. Defaults to a temporary directory.
52-
directory: ${{ runner.temp }}/arm-none-eabi
53-
54-
- name: Check cache for nRF5 SDK
55-
id: cache-nrf5sdk
56-
uses: actions/cache@v2
57-
env:
58-
cache-name: cache-nrf5sdk
59-
with:
60-
path: ${{ runner.temp }}/nrf5_sdk
61-
key: ${{ runner.os }}-build-${{ env.cache-name }}
62-
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
63-
64-
- name: Install nRF5 SDK
65-
if: steps.cache-nrf5sdk.outputs.cache-hit != 'true' # Install SDK if not found in cache
66-
run: |
67-
cd ${{ runner.temp }}
68-
curl https://developer.nordicsemi.com/nRF5_SDK/nRF5_SDK_v15.x.x/nRF5_SDK_15.3.0_59ac345.zip -o nrf5_sdk.zip
69-
unzip nrf5_sdk.zip
70-
mv nRF5_SDK_15.3.0_59ac345 nrf5_sdk
71-
72-
- name: Check cache for MCUBoot
73-
id: cache-mcuboot
74-
uses: actions/cache@v2
75-
env:
76-
cache-name: cache-mcuboot
77-
with:
78-
path: ${{ runner.temp }}/mcuboot
79-
key: ${{ runner.os }}-build-${{ env.cache-name }}
80-
restore-keys: ${{ runner.os }}-build-${{ env.cache-name }}
81-
82-
- name: Install MCUBoot
83-
if: steps.cache-mcuboot.outputs.cache-hit != 'true' # Install MCUBoot if not found in cache
84-
run: |
85-
cd ${{ runner.temp }}
86-
git clone --branch v1.7.2 https://github.com/mcu-tools/mcuboot
87-
88-
- name: Install imgtool dependencies
89-
run: |
90-
pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
91-
92-
- name: Install adafruit-nrfutil
93-
run: |
94-
pip3 install --user wheel
95-
pip3 install --user setuptools
96-
pip3 install --user adafruit-nrfutil
97-
98-
#########################################################################################
99-
# Checkout
100-
20+
# This workaround fixes the error "unsafe repository (REPO is owned by someone else)".
21+
# See https://github.com/actions/checkout/issues/760 and https://github.com/actions/checkout/issues/766
22+
# The fix in "actions/checkout@v2" was not sufficient as the build process also uses git (to get the current
23+
# commit hash, for example).
24+
- name: Workaround permission issues
25+
run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
10126
- name: Checkout source files
10227
uses: actions/checkout@v2
10328
with:
10429
submodules: recursive
105-
106-
- name: Show files
107-
run: set ; pwd ; ls -l
108-
109-
#########################################################################################
110-
# CMake
111-
112-
- name: CMake
113-
run: |
114-
mkdir -p build
115-
cd build
116-
cmake -G Ninja -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 -DBUILD_DFU=1 ../
117-
118-
#########################################################################################
119-
# Make and Upload DFU Package
120-
# pinetime-mcuboot-app.img must be flashed at address 0x8000 in the internal flash memory with OpenOCD:
121-
# program image.bin 0x8000
122-
123-
# For Debugging Builds: Remove "make" option "-j" for clearer output. Add "--trace" to see details.
124-
# For Faster Builds: Add "make" option "-j"
125-
126-
- name: Make pinetime-mcuboot-app
127-
run: |
128-
cmake --build build --target pinetime-mcuboot-app
129-
30+
- name: Build
31+
shell: bash
32+
env:
33+
SOURCES_DIR: .
34+
run: /opt/build.sh all
35+
# Unzip the package because Upload Artifact will zip up the files
13036
- name: Unzip DFU package
131-
run: |
132-
# Unzip the package because Upload Artifact will zip up the files
133-
unzip build/src/pinetime-mcuboot-app-dfu*.zip -d build/src/pinetime-mcuboot-app-dfu
134-
135-
- name: Upload DFU package
136-
uses: actions/upload-artifact@v2
37+
run: unzip ./build/output/pinetime-mcuboot-app-dfu-*.zip -d ./build/output/pinetime-mcuboot-app-dfu
38+
- name: Upload DFU artifacts
39+
uses: actions/upload-artifact@v3
13740
with:
138-
name: pinetime-mcuboot-app-dfu
139-
path: build/src/pinetime-mcuboot-app-dfu/*
140-
141-
#########################################################################################
142-
# Make and Upload Standalone Firmware
143-
144-
- name: Make pinetime-app
145-
run: |
146-
cmake --build build --target pinetime-app
147-
148-
- name: Upload standalone firmware
149-
uses: actions/upload-artifact@v2
41+
name: InfiniTime DFU ${{ github.head_ref }}
42+
path: ./build/output/pinetime-mcuboot-app-dfu/*
43+
- name: Upload MCUBoot image artifacts
44+
uses: actions/upload-artifact@v3
15045
with:
151-
name: pinetime-app.out
152-
path: build/src/pinetime-app*.out
153-
154-
#########################################################################################
155-
# Make but don't Upload the Recovery Firmware to be sure it builds correctly
156-
157-
- name: Make pinetime-recovery
158-
run: |
159-
cmake --build build --target pinetime-recovery
160-
161-
#########################################################################################
162-
# Finish
163-
164-
- name: Find output
165-
run: |
166-
find . -name "pinetime-app.*" -ls
167-
find . -name "pinetime-mcuboot-app.*" -ls
168-
169-
# Embedded Arm Toolchain and nRF5 SDK will only be cached if the build succeeds.
170-
# So make sure that the first build always succeeds, e.g. comment out the "Make" step.
46+
name: InfiniTime MCUBoot image ${{ github.head_ref }}
47+
path: ./build/output/pinetime-mcuboot-app-image-*.bin

.vscode/launch.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"servertype": "openocd",
5353
"runToMain": true,
5454
// Only use armToolchainPath if your arm-none-eabi-gdb is not in your path (some GCC packages does not contain arm-none-eabi-gdb)
55-
"armToolchainPath": "${workspaceRoot}/../gcc-arm-none-eabi-9-2020-q2-update/bin",
55+
"armToolchainPath": "${workspaceRoot}/../gcc-arm-11.2-2022.02-x86_64-arm-none-eabi/bin",
5656
"svdFile": "${workspaceRoot}/nrf52.svd",
5757
"configFiles": [
5858
"interface/stlink.cfg",

CMakeLists.txt

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
cmake_minimum_required(VERSION 3.10)
2+
3+
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose Debug or Release")
4+
25
project(pinetime VERSION 1.9.0 LANGUAGES C CXX ASM)
36

47
set(CMAKE_C_STANDARD 99)
@@ -51,13 +54,8 @@ if(BUILD_DFU)
5154
set(BUILD_DFU true)
5255
endif()
5356

54-
option(WATCH_COLMI_P8 "Build for the Colmi P8" OFF)
55-
set(TARGET_DEVICE "PineTime")
56-
57-
if(WATCH_COLMI_P8)
58-
set(TARGET_DEVICE "Colmi P8")
59-
add_definitions(-DWATCH_P8)
60-
endif()
57+
set(TARGET_DEVICE "PINETIME" CACHE STRING "Target device")
58+
set_property(CACHE TARGET_DEVICE PROPERTY STRINGS PINETIME MOY-TFK5 MOY-TIN5 MOY-TON5 MOY-UNK)
6159

6260
set(PROJECT_GIT_COMMIT_HASH "")
6361

@@ -66,12 +64,14 @@ execute_process(COMMAND git rev-parse --short HEAD
6664
OUTPUT_VARIABLE PROJECT_GIT_COMMIT_HASH
6765
RESULT_VARIABLE PROJECT_GIT_COMMIT_HASH_SUCCESS)
6866

69-
string(STRIP ${PROJECT_GIT_COMMIT_HASH} PROJECT_GIT_COMMIT_HASH)
67+
string(STRIP "${PROJECT_GIT_COMMIT_HASH}" PROJECT_GIT_COMMIT_HASH)
7068

7169
message("PROJECT_GIT_COMMIT_HASH_SUCCESS? " ${PROJECT_GIT_COMMIT_HASH_SUCCESS})
7270

71+
message("")
7372
message("BUILD CONFIGURATION")
7473
message("-------------------")
74+
message(" * Mode : " ${CMAKE_BUILD_TYPE})
7575
message(" * Version : " ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH})
7676
message(" * Toolchain : " ${ARM_NONE_EABI_TOOLCHAIN_PATH})
7777
message(" * GitRef(S) : " ${PROJECT_GIT_COMMIT_HASH})

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Fast open-source firmware for the [PineTime smartwatch](https://www.pine64.org/p
1515
- [Gadgetbridge](https://gadgetbridge.org/) (Android)
1616
- [AmazFish](https://openrepos.net/content/piggz/amazfish/) (SailfishOS)
1717
- [Siglo](https://github.com/alexr4535/siglo) (Linux)
18-
- [InfiniLink](https://github.com/xan-m/InfiniLink) **[Experimental]** (iOS)
18+
- [InfiniLink](https://github.com/InfiniTimeOrg/InfiniLink) **[Experimental]** **[Unmaintained, looking for developers/maintainers]** (iOS)
1919
- [ITD](https://gitea.arsenm.dev/Arsen6331/itd) (Linux)
2020

2121
## Development

bootloader/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ Integrating a BLE stack for the OTA functionality would have used to much memory
99

1010
When it is run, this bootloader looks in the SPI flash memory if a new firmware is available. It there is one, it *swaps* the current firmware with the new one (the new one is copied in the main flash memory, and the current one is copied in the SPI flash memory) and run the new one. If the new one fails to run properly, the bootloader is able to revert to the old one and mark the new one as not working.
1111

12-
As this bootloader does not provide any OTA capability, it is not able to actually download a new version of the application. Providing OTA functionality is thus the responsability of the application firmware.
12+
As this bootloader does not provide any OTA capability, it is not able to actually download a new version of the application. Providing OTA functionality is thus the responsibility of the application firmware.
1313

1414
# About MCUBoot
1515
MCUBoot is run at boot time. In normal operation, it just jumps to the reset handler of the application firmware to run it. Once the application firmware is running, MCUBoot does not run at all.
1616

1717
![MCUBoot boot sequence diagram](../doc/bootloader/boot.png "MCUBoot boot sequence diagram")
1818

19-
But MCUBoot does much more than that : it can upgrade the firmware that is currently running by a new one, and it is also able to revert to the previous version of the firmware in case the new one does not run propertly.
19+
But MCUBoot does much more than that : it can upgrade the firmware that is currently running by a new one, and it is also able to revert to the previous version of the firmware in case the new one does not run properly.
2020

2121
To do this, it uses 2 memory 'slots' :
2222
- **The primary slot** : it contains the current firmware, the one that will be executed by MCUBoot
@@ -40,7 +40,7 @@ This chapter describes degraded cases that are handled by our bootloader and tho
4040
Case | Current bootloader | Solution
4141
-----|--------------------|----------------------------------------------
4242
Data got corrupted during file transfer | [OK] Application firmware does a CRC check before applying the update, and does not proceed if it fails. | N/A
43-
New firmware does not run at all (bad file) (1) | [NOK] MCU executes unknown instructions and will most likely end up in an infinite loop or freeze in an error handler. The bootloader does not run, it can do nothing, the MCU is stucked until next reset | [OK] The bootloader starts the watchdog just before running the new firmware. This way, the watchdog will reset the MCU after ~7s because the firmware does not refresh it. Bootloader reverts to the previous version of the firmware during the reset.
43+
New firmware does not run at all (bad file) (1) | [NOK] MCU executes unknown instructions and will most likely end up in an infinite loop or freeze in an error handler. The bootloader does not run, it can do nothing, the MCU is stuck until next reset | [OK] The bootloader starts the watchdog just before running the new firmware. This way, the watchdog will reset the MCU after ~7s because the firmware does not refresh it. Bootloader reverts to the previous version of the firmware during the reset.
4444
New firmware runs, does not set the valid bit and does not refresh the watchdog | [NOK] The new firmware runs until the next reset. The bootloader will be able to revert to the previous firmware only during the next reset. If the new firmware does not run properly and does not reset, the bootloader can do nothing until the next reset | [OK] The bootloader starts the watchdog just before running the new firmware. This way, the watchdog will reset the MCU after ~7s because the firmware does not refresh it. Bootloader reverts to the previous version of the firmware during the reset.
4545
New firmware does not run properly, does not set the valid bit but refreshes the watchdog | [NOK] The bootloader will be able to revert to the previous firmware only during the next reset. If the new firmware does not run properly and does not reset, the bootloader can do nothing until the next reset | [~] Wait for the battery to drain. The CPU will reset the next time the device is charged and will be able to rollback to the previous version.
4646
New firmware does not run properly but sets the valid bit and refreshes the watchdog | [NOK] The bootloader won't revert to the previous version because the valid flag is set | [~] Wait for the battery to drain. The CPU will reset the next time the device is charged. Then, the bootloader must provide a way for the user to force the rollback to the previous version

bootloader/ota-dfu-python/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__

0 commit comments

Comments
 (0)