Skip to content

Commit 1bb7342

Browse files
committed
Backport Github Actions files from master branch.
1 parent 3e612e7 commit 1bb7342

2 files changed

Lines changed: 171 additions & 202 deletions

File tree

.github/workflows/c-cpp.yml

Lines changed: 0 additions & 202 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
# GitHub Actions Workflow to build FreeRTOS Firmware for PineTime Smart Watch
2+
# See https://lupyuen.github.io/pinetime-rust-mynewt/articles/cloud
3+
# Based on https://github.com/JF002/Pinetime/blob/master/doc/buildAndProgram.md
4+
# and https://github.com/JF002/Pinetime/blob/master/bootloader/README.md
5+
6+
# Name of this Workflow
7+
name: Build PineTime Firmware
8+
9+
# When to run this Workflow...
10+
on:
11+
12+
# Run this Workflow when files are updated (Pushed) in the "master" Branch
13+
push:
14+
branches: [ master ]
15+
16+
# Also run this Workflow when a Pull Request is created or updated in the "master" Branch
17+
pull_request:
18+
branches: [ master ]
19+
20+
# Steps to run for the Workflow
21+
jobs:
22+
build:
23+
24+
# Run these steps on Ubuntu
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
29+
#########################################################################################
30+
# Download and Cache Dependencies
31+
32+
- name: Install cmake
33+
uses: lukka/get-cmake@v3.18.0
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.2
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.5.0 https://github.com/JuulLabs-OSS/mcuboot
87+
88+
- name: Install imgtool dependencies
89+
run: pip3 install --user -r ${{ runner.temp }}/mcuboot/scripts/requirements.txt
90+
91+
- name: Install adafruit-nrfutil
92+
run: |
93+
pip3 install --user wheel
94+
pip3 install --user setuptools
95+
pip3 install --user adafruit-nrfutil
96+
97+
#########################################################################################
98+
# Checkout
99+
100+
- name: Checkout source files
101+
uses: actions/checkout@v2
102+
103+
- name: Show files
104+
run: set ; pwd ; ls -l
105+
106+
#########################################################################################
107+
# CMake
108+
109+
- name: CMake
110+
run: |
111+
mkdir -p build
112+
cd build
113+
cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=${{ runner.temp }}/arm-none-eabi -DNRF5_SDK_PATH=${{ runner.temp }}/nrf5_sdk -DUSE_OPENOCD=1 ../
114+
115+
#########################################################################################
116+
# Make and Upload DFU Package
117+
# pinetime-mcuboot-app.img must be flashed at address 0x8000 in the internal flash memory with OpenOCD:
118+
# program image.bin 0x8000
119+
120+
# For Debugging Builds: Remove "make" option "-j" for clearer output. Add "--trace" to see details.
121+
# For Faster Builds: Add "make" option "-j"
122+
123+
- name: Make pinetime-mcuboot-app
124+
run: |
125+
cd build
126+
make pinetime-mcuboot-app
127+
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
136+
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
139+
# 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
141+
142+
- name: Upload DFU package
143+
uses: actions/upload-artifact@v2
144+
with:
145+
name: pinetime-mcuboot-app-dfu.zip
146+
path: build/src/pinetime-mcuboot-app-dfu/*
147+
148+
#########################################################################################
149+
# Make and Upload Standalone Firmware
150+
151+
- name: Make pinetime-app
152+
run: |
153+
cd build
154+
make pinetime-app
155+
156+
- name: Upload standalone firmware
157+
uses: actions/upload-artifact@v2
158+
with:
159+
name: pinetime-app.out
160+
path: build/src/pinetime-app*.out
161+
162+
#########################################################################################
163+
# Finish
164+
165+
- name: Find output
166+
run: |
167+
find . -name "pinetime-app.*" -ls
168+
find . -name "pinetime-mcuboot-app.*" -ls
169+
170+
# Embedded Arm Toolchain and nRF5 SDK will only be cached if the build succeeds.
171+
# So make sure that the first build always succeeds, e.g. comment out the "Make" step.

0 commit comments

Comments
 (0)