Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

West manifest usage and ZSWatch rev 3 support #79

Merged
merged 11 commits into from
Oct 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
57 changes: 23 additions & 34 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,33 @@
name: Build firmware
on: push
name: Build

env:
ZEPHYR_VERSION: 3.4.0
on:
push:
pull_request:

jobs:
NRF:
runs-on: ubuntu-20.04
build:
runs-on: ubuntu-22.04
container: ghcr.io/zephyrproject-rtos/ci:v0.26.2
env:
CMAKE_PREFIX_PATH: /opt/toolchains
strategy:
matrix:
ncs_version: [2.4]
board: [zswatch_nrf5340_cpuapp@1,zswatch_nrf5340_cpuapp@2]
built_type: [debug, release]
board: [zswatch_nrf5340_cpuapp@1, zswatch_nrf5340_cpuapp@3, native_posix]
steps:
- name: Clone repository
uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v3
with:
path: project
path: ZSWatch
submodules: recursive
- name: Build ZSWatch Binaries
working-directory: project

- name: Initialize
working-directory: ZSWatch
run: |
docker run -v $PWD:/workdir/project nordicplayground/nrfconnect-sdk:v${{ matrix.ncs_version }}-branch \
west build --board ${{ matrix.board }} /workdir/project/app
west init -l app
west update -o=--depth=1 -n

Posix:
name: Posix build
runs-on: ubuntu-20.04
container:
image: ghcr.io/bcdevices/zephyr:v3.4.0-0
options: --user root
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Install deps
run: |
dpkg --add-architecture i386
apt-get -y update
apt-get install --no-install-recommends -y libsdl2-dev:i386
- name: build
run: |
cd /usr/src/zephyr-3.4.0
west build --board native_posix $GITHUB_WORKSPACE/app
- name: Build firmware
working-directory: ZSWatch
run: |
west build app -p -b ${{ matrix.board }} -- -DOVERLAY_CONFIG=boards/${{ matrix.built_type }}.conf
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ build*
*.vsix

*.bin

# Zephyr workspace
/.west
/bootloader
/modules
/tools
/zephyr
__pycache__
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,9 @@
[submodule "app/src/applications/2048/2048_lib"]
path = app/src/applications/2048/2048_lib
url = https://github.com/100askTeam/lv_lib_100ask.git
[submodule "hardware/ZSWatch-HW"]
path = hardware/ZSWatch-HW
url = [email protected]:jakkra/ZSWatch-HW.git
[submodule "hardware/ZSWatch-Dock"]
path = hardware/ZSWatch-Dock
url = [email protected]:jakkra/ZSWatch-Dock.git
12 changes: 7 additions & 5 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"nrf-connect.boardRoots": [
"${workspaceFolder}/app"
],
"nrf-connect.applications": [
"${workspaceFolder}/app"
"${workspaceFolder}/app",
"${workspaceFolder}\\app"
],
"nrf-connect.boardRoots": [
"${workspaceFolder}/app",
"${workspaceFolder}\\app"
],
}
}
70 changes: 41 additions & 29 deletions GETTING_STARTED.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,65 +30,61 @@ Download and install the tools needed for flashing.
- [SEGGER J-Link](https://www.segger.com/downloads/jlink/#J-LinkSoftwareAndDocumentationPack)
- [nRF Commond line tools](https://www.nordicsemi.com/Products/Development-tools/nrf-command-line-tools/download)

Two options, either set up toolchain and everything by following [Zephyr Getting Started Guide](https://docs.zephyrproject.org/3.2.0/develop/getting_started/index.html) or you can use the in my opinion easier approch by using the [Nordic Toolchain manager](https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/getting_started/assistant.html).
Everything works with both Zephyr and with nRF Connect (Nordic Semi. Zephyr fork). If you are new to Zephyr I suggest installing using Nordic Toolchain manager together with the nRF Connect VSCode plugin as I think that is a bit easier.

*Tested with both*
- Zephyr 3.4.0
- nRF Connect SDK 2.4.0
Set up toolchain and everything by following [Zephyr Getting Started Guide](https://docs.zephyrproject.org/latest/develop/getting_started/index.html).
At this point it's not possible to use nRF Connect SDK as features and fixes not yet released in NCS are needed to build ZSWatch SW.

## Cloning source code
Make sure you have enough space and clone the source code:
```
git clone https://github.com/jakkra/ZSWatch.git
git submodule update --init --recursive
west init -l app/
west update
```

## Building and Flashing

There to approach to deal with Zephyr based projects:
There are two approaches to deal with Zephyr based projects:
- [Using the nRF Connect extension for VSCode](#using-the-nrf-connect-extension-for-vscode)
- [Using the command line](#using-the-command-line)

### Using the nRF Connect extension for VSCode
To be able to build, flash and debug via VSCode please install [nRF Connect for VS Code Extension Pack](https://marketplace.visualstudio.com/items?itemName=nordic-semiconductor.nrf-connect-extension-pack).
[Here](https://nrfconnect.github.io/vscode-nrf-connect/get_started/build_app_ncs.html) you can also find a manual on how to deal with the nRF Connect extension.
Follow the steps below to open and build the ZSWatch application:
- Press "Open an existing application" under the "WELCOME" field of nRF Connect extension.
- Select the `app` folder in the ZSWatch project root folder.
- Create new build configuration by clicking on "No build configuration" field in "APPLICATIONS" window.
- Choose `zswatch_nrf5340_cpuapp` as the board and nRF Connect SDK 2.4.0.
- Set revision to 1 or 2 depending on what version of ZSWatch is used. If your watch is built before Aug. 1 2023 it's revision 1. Revision 2 adds external flash.
- Press "Add fragment" under the "Kconfig fragments" field, here choose either debug (for developing) or release (for daily use).
- Press "Build configuration" button.

### Compiling
Due to a bug in nRF Connect VSCode plugin at the moment it's necessary to do the first build using the command line. Afterwards everything can be done withing VSCode in the nRF Connect Plugin.

### Using the command line
The second option is to use a command line to build and flash Zephyr applications. [Here](https://nrfconnect.github.io/vscode-nrf-connect/get_started/build_app_ncs.html) you can find some more information.
- Set revision zswatch_nrf5340_cpuapp@\<revision\> to 1 or 3 depending on what version of ZSWatch is used. If your watch is built before Aug. 1 2023 it's revision 1, otherwise revision 3.
- Replace release.conf with debug.conf if the build is for development.

Example of building for ZSWatch board:
```
west build --board zswatch_nrf5340_cpuapp@1 -- -DOVERLAY_CONFIG="boards/{debug/release}.conf"
west build --board zswatch_nrf5340_cpuapp@3 -- -DOVERLAY_CONFIG="boards/release.conf"
west flash
```

__NOTE (Zephyr only)__
### Using the nRF Connect extension for VSCode
To be able to build, flash and debug via VSCode please install [nRF Connect for VS Code Extension Pack](https://marketplace.visualstudio.com/items?itemName=nordic-semiconductor.nrf-connect-extension-pack).
[Here](https://nrfconnect.github.io/vscode-nrf-connect/get_started/build_app_ncs.html) you can also find a manual on how to deal with the nRF Connect extension.
Follow the steps below to open and build the ZSWatch application:
- Make sure you compiled once using command line steps above.
- Open the `app` folder in VSCode (important it's the `app` folder) the the nRF Connect plugin will automatically see the app and you should see the build, debug etc. buttons. If not press "Add Folder as Application and pick the app` folder.

__NOTE__
<br>
Since the nrf5340 is a dual core microcontroller where the second core is designed to serve the BLE stack, the second image needs to be flashed for BLE operation.
If you are building with Zephyr you need in addition manually compile and flash the `zephyr/samples/bluetooth/hci_rpmsg` sample and flash that to the NET core. With nRF Connect this is done automatically thanks to the `child_image/hci_rpmsg.conf`. For convenience I have also uploaded a pre-compiled [hex image for NET CPU](app/child_image/GENERATED_CP_NETWORK_merged_domains.hex) if you don't want to recompile it yourself. Flash it using following:
Since the nRF5340 is a dual core microcontroller where the second core is designed to serve the Bluetooth Controller, the second image needs to be flashed for BLE operation.
If you are building with Zephyr you need in addition manually compile and flash the `zephyr/samples/bluetooth/hci_rpmsg` sample and flash that to the NET core. For convenience I have also uploaded a pre-compiled [hex image for NET CPU](app/child_image/GENERATED_CP_NETWORK_merged_domains.hex) if you don't want to recompile it yourself. Flash it using following:
<br>
`nrfjprog -f NRF53 --coprocessor CP_NETWORK --program app/child_image/GENERATED_CP_NETWORK_merged_domains.hex --chiperase`

To build the NET core image:
To build the NET core image yourself:
Command line:
- Navigate to `zephyr/samples/bluetooth/hci_rpmsg`
- Build using `west build --board zswatch_nrf5340_cpunet@1 -- -DBOARD_ROOT=<ZSWatch absolute path>/app -DOVERLAY_CONFIG=nrf5340_cpunet_df-bt_ll_sw_split.conf`
- Build using `west build --board zswatch_nrf5340_cpunet@3 -- -DBOARD_ROOT=<ZSWatch absolute path>/app -DOVERLAY_CONFIG=nrf5340_cpunet_df-bt_ll_sw_split.conf`
- `west flash`
- This only needs to be done once, unless you do a full erase or recover of the nRF5340, which you typically don't do.

VScode:
- Add `zephyr/samples/bluetooth/hci_rpmsg` as an application.
- Select `zswatch_nrf5340_cpunet` as board (VSCode should pick this one up automatically if you added the ZSWatch application earlier).
- Set revision to 1 or 2 depending on what version of ZSWatch is used. If your watch is built before Aug. 1 2023 it's revision 1. Revision 2 adds external flash.
- Set revision depending on what version of ZSWatch is used.
- Press `Add Fragment` under the "Kconfig fragments" field and select the `nrf5340_cpunet_df-bt_ll_sw_split.conf`
- Done, press `Build Configuration`.

Expand Down Expand Up @@ -128,7 +124,23 @@ sudo ./build/zephyr/zephyr.exe --bt-dev=hci<hci index>
```

__Tips:__
1. If you want to be able to debug: `sudo gdb -ex=r --args build/zephyr/zephyr.exe --bt-dev=hci<hci index>`
1. If you want to be able to debug: `sudo gdb -ex=r --args build/zephyr/zephyr.exe --bt-dev=hci<hci index>` or add below in your `.vscode/launch.json`
```
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Native Posix",
"type": "gdb",
"request": "launch",
"target": "${workspaceFolder}/build/zephyr/zephyr.exe",
"cwd": "${workspaceRoot}",
"valuesFormatting": "parseText",
"arguments": "--bt-dev=hci0" // Fill in hciX
}
]
}
```
2. If you want to scale up the SDL window (4x) apply the patch in `app/zephyr_patches/sdl_upscale.patch`

https://github.com/jakkra/ZSWatch/assets/4318648/3b3e4831-a217-45a9-8b90-7b48cea7647e
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
[![License](https://img.shields.io/badge/License-GPL%203.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![discord](https://img.shields.io/badge/chat-discord-blue?logo=discord&logoColor=white)](https://discord.gg/8XfNBmDfbY)

<img src=".github/in_use.jpg"/>
<img src=".github/images/in_use.jpg"/>
<sub>
ZSWatch v2
</sub>
Expand All @@ -16,16 +16,16 @@
Smartwatch built from scratch, both hardware and software. Built on the [Zephyr™ Project](https://www.zephyrproject.org/) RTOS, hence the name **ZSWatch** - *Zephyr Smartwatch*.
<br/>

<kbd><img title="Overview" src=".github/many_in_row.jpg"/></kbd><br/>
<kbd><img title="Overview" src=".github/images/many_in_row.jpg"/></kbd><br/>

<kbd><img title="Overview" src=".github/v2_overview.jpg"/></kbd><br/>
<kbd><img title="Overview" src=".github/images/v2_overview.jpg"/></kbd><br/>

**Synced remote control over BLE**

[https://user-images.githubusercontent.com/64562059/234390129-321d4f35-cb4b-45e8-89d9-20ae292f34fc.mp4](https://github.com/jakkra/ZSWatch/assets/4318648/8d0f40c2-d519-4db1-8634-b43caa502cbe)

<p align="center" >
<a href="https://www.youtube.com/watch?v=MmCzV0jV9hs"><img width="55%" src=".github/presentation.png" ></a>
<a href="https://www.youtube.com/watch?v=MmCzV0jV9hs"><img width="55%" src=".github/images/presentation.png" ></a>
</p>
<p align="center">Watch my presentation at Zephyr Developer Summit 2023</p>

Expand Down Expand Up @@ -74,7 +74,7 @@ This will allow me If you want to get notified when I'm "releasing" it, then sim
PCB done, casing to be designed. Idea is that watch will sit on top.
Built in debugger. Will be an option without debugger also (requires licence).
<p float="left">
<img src=".github/dock.jpg" width="65%"/>
<img src=".github/images/dock.jpg" width="65%"/>
</p>

## Enclosure/Casing
Expand Down Expand Up @@ -123,7 +123,7 @@ To select watchface background see below config in prj.conf:
`CONFIG_WATCHFACE_BACKGROUND_NONE=n`<br>

<p float="center">
<img src=".github/watchfaces.png" width="99%"/>
<img src=".github/images/watchfaces.png" width="99%"/>
</p>

## Android phone communication
Expand All @@ -138,19 +138,19 @@ Fortunately there is a great Android app called [GadgetBridge](https://codeberg.
A 4 layer board which measures 38mm in diameter designed in KiCad.

<p float="left">
<img src=".github/pcb_features.png" width="90%" object-fit="cover"/>
<img src=".github/images/pcb_features.png" width="90%" object-fit="cover"/>
</p>
<p float="left">
<img src=".github/v2_render_wip_back.png" width="49%" object-fit="cover"/>
<img src=".github/layer1_and_4_v2.PNG" width="41%" object-fit="cover"/>
<img src=".github/images/v2_render_wip_back.png" width="49%" object-fit="cover"/>
<img src=".github/images/layer1_and_4_v2.PNG" width="41%" object-fit="cover"/>
</p>

## ZSWatch v1 in action (Note old, not updated for latest HW and SW).
|*Music control*|*Accelerometer for step count and tap detection*|
|---|---|
| <img src=".github/music.gif" object-fit="cover" /> | <img src=".github/accel.gif" object-fit="cover" /> |
| <img src=".github/images/music.gif" object-fit="cover" /> | <img src=".github/images/accel.gif" object-fit="cover" /> |
|*Notifications from phone (Gmail here)*|*Settings*|
| <img src=".github/notifications.gif" object-fit="cover" /> | <img src=".github/settings.gif" object-fit="cover"/> |
| <img src=".github/images/notifications.gif" object-fit="cover" /> | <img src=".github/images/settings.gif" object-fit="cover"/> |


https://github.com/jakkra/ZSWatch/assets/4318648/8d8ec724-8145-4a30-b241-e69a8c2853bf
Expand Down
30 changes: 0 additions & 30 deletions ZSWatch-dock/.gitignore

This file was deleted.

Loading