Skip to content

Commit b33ad92

Browse files
JF002Gitea
authored and
Gitea
committed
Merge branch 'develop' of JF/PineTime into master
2 parents 64c1427 + 5541779 commit b33ad92

14 files changed

+529
-301
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.10)
2-
project(pinetime VERSION 0.7.0 LANGUAGES C CXX ASM)
2+
project(pinetime VERSION 0.7.1 LANGUAGES C CXX ASM)
33

44
set(NRF_TARGET "nrf52")
55

README.md

+76-244
Original file line numberDiff line numberDiff line change
@@ -3,255 +3,87 @@
33
44
> We envision the PineTime as a companion for not only your PinePhone but also for your favorite devices — any phone, tablet, or even PC.
55
6-
*https://www.pine64.org/pinetime/*
7-
8-
The goal of this project is to build a firmware designed for the PineTime around FreeRTOS.
9-
It's coded using a mix of C and C++ : the NRF52-SDK and FreeRTOS are written in C, but I prefer to write my own code in C++.
10-
11-
Please **NOTE : for now, this project is in heavy development state**. Feel free to use it, contribute to it or fork it !
12-
13-
This project is based on https://github.com/JF002/nrf52-baseproject.
14-
It's a CMake project that configure everything needed to build applications for the PineTime (https://wiki.pine64.org/index.php/PineTime).
15-
16-
I tested this project (compile only) with the following versions:
17-
18-
* gcc-arm-none-eabi-8-2019-q3-update (from https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
19-
* nRF5_SDK_15.3.0_59ac345 (from https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK)
20-
21-
I've tested this project on the actual PineTime hardware.
22-
23-
## Current state
24-
25-
![Pinetime](./images/v0.3.0.png "Pinetime")
26-
27-
* Project builds and runs on the Pinetime;
28-
* Logs available via JLink RTT;
29-
* SPI (DMA & IRQ based) LCD driver;
30-
* Open source BLE stack : [NimBLE](https://github.com/apache/mynewt-nimble);
31-
* BLE advertising and connection connection;
32-
* BLE CTS client (retrieves the time from the connected device if it implements a CTS server);
33-
* Push button to go to disable screen (and go to low power mode) / enable screen (and wake-up) and UI navigation
34-
* Touch panel support;
35-
* Rich user interface (using [LittleVGL](https://littlevgl.com/)) via display, touchpanel and push button.
36-
* Digital watch face and 4 demo applications (spinning meter, analog gauche, push button and message box);
37-
* Watchdog (automatic reset in case of firmware crash) and reset support (push and hold the button for 7 - 10s);
38-
* BLE Notification support (still Work-In-Progress, [companion app](https://github.com/JF002/gobbledegook) needed);
39-
* Supported by companion app [Amazfish](https://openrepos.net/content/piggz/amazfish) (time synchronization and notifications are integrated).
40-
* **[EXPERIMENTAL]** Firmware update (OTA) via BLE.
41-
6+
*https://www.pine64.org/pinetime/*
7+
8+
The **Pinetime** smartwatch is built around the NRF52832 MCU (512KB Flash, 64KB RAM), a 240*240 LCD display driven by the ST7789 controller, an accelerometer, a heartrate sensor and a vibrator.
9+
10+
The goal of this project is to design an open-source firmware for the Pinetime smartwatch :
11+
12+
- Code written in **modern C++**;
13+
- Build system based on **CMake**;
14+
- Based on **[FreeRTOS 10.0.0](https://freertos.org)** real-time OS.
15+
- Using **[LittleVGL/LVGL 6.1.2](https://lvgl.io/)** as UI library...
16+
- ... and **[NimBLE 1.3.0](https://github.com/apache/mynewt-nimble)** as BLE stack.
17+
18+
##Overview
19+
20+
![Pinetime screens](images/0.7.0/montage.jpg "PinetimeScreens")
21+
22+
As of now, here is the list of achievements of this project:
23+
24+
- Fast and optimized LCD driver
25+
- BLE communication
26+
- Rich user interface via display, touchpanel and push button
27+
- Time synchronisation via BLE
28+
- Notification via BLE
29+
- Multiple 'apps' :
30+
* Clock (displays the date, time, battery level, ble connection status, heart rate and step count)
31+
* Heart rate
32+
* Motion
33+
* System info (displays various info : BLE MAC, build date/time, uptime, version,...)
34+
* Brightess (allows the user to configure the brightness of the display)
35+
- Supported by 2 companion apps (developpments ongoing):
36+
* [Gadgetbridge](https://codeberg.org/Freeyourgadget/Gadgetbridge/src/branch/pinetime-jf) (on Android)
37+
* [Amazfish](https://openrepos.net/content/piggz/amazfish) (on SailfishOS)
38+
- **[Experimental]** OTA (Over-the-air) update via BLE
39+
- **[Experimental]** Bootloader based on [MCUBoot](https://juullabs-oss.github.io/mcuboot/)
40+
4241
## Documentation
43-
44-
* [BLE implementation and API](./doc/ble.md)
45-
* [Bootloader and DFU](./bootloader/README.md)
46-
47-
## Stub using NRF52-DK
48-
![Pinetime stub](./images/pinetimestub1.jpg "PinetimeStub")
49-
50-
See [this page](./doc/PinetimeStubWithNrf52DK.md)
51-
52-
## How to build
53-
54-
* Download and unzip arm-none-eabi and NRF52 SDK
55-
* Clone this repo
56-
* **[JLINK]** Call CMake with the following command line argument
57-
58-
- -DARM_NONE_EABI_TOOLCHAIN_PATH=[Path to the toolchain directory]
59-
- -DNRF5_SDK_PATH=[Path to the SDK directory]
60-
- -DUSE_JLINK=1
61-
- -DNRFJPROG=[Path to NRFJProg executable]
62-
63-
* OR
64-
* **[GDB CLIENT (if you use a BlackMagicProbe, for example)]** Call CMake with the following command line argument
65-
66-
- -DARM_NONE_EABI_TOOLCHAIN_PATH=[Path to the toolchain directory]
67-
- -DNRF5_SDK_PATH=[Path to the SDK directory]
68-
- -DUSE_GDB_CLIENT=1
69-
- -DGDB_CLIENT_BIN_PATH=[Path to arm-none-eabi-gdb executable]
70-
- -DGDB_CLIENT_TARGET_REMOTE=[Target remote connetion string. Ex : /dev/ttyACM0]
71-
72-
* OR
73-
* **[OPENOCD (if you use a STlink v2 clone, for example)]** Call CMake with the following command line argument
74-
75-
- -DARM_NONE_EABI_TOOLCHAIN_PATH=[Path to the toolchain directory]
76-
- -DNRF5_SDK_PATH=[Path to the SDK directory]
77-
- -DUSE_OPENOCD=1
78-
79-
* Optionally, if you want to use a another version then whats on your path
80-
81-
- -DOPENOCD_BIN_PATH=[path to openocd]
82-
83-
84-
JLINK
85-
```
86-
$ mkdir build
87-
$ cd build
88-
$ cmake -DCMAKE_BUILD_TYPE=Debug -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_JLINK=1 -DNRFJPROG=... ../
89-
```
90-
91-
GDB (Back Magic Probe)
92-
```
93-
$ mkdir build
94-
$ cd build
95-
$ cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_GDB_CLIENT=1 -DGDB_CLIENT_BIN_PATH=... -DGDB_CLIENT_TARGET_REMOTE=... ../
96-
```
97-
98-
OpenOCD (STlink v2 clones)
99-
```
100-
$ mkdir build
101-
$ cd build
102-
$ cmake -DARM_NONE_EABI_TOOLCHAIN_PATH=... -DNRF5_SDK_PATH=... -DUSE_OPENOCD=1 -DGDB_CLIENT_BIN_PATH=[optional] ../
103-
```
104-
105-
106-
**Note** : By default, the build configuration *Release* is applied. It means that the code is built with optimisations enabled (-O3). If you wanto to compile in *Debug* mode to ease debugging and step-by-step debugging, specify the CMake variable `CMAKE_BUILD_TYPE` in the CMake command line:
107-
108-
```
109-
-DCMAKE_BUILD_TYPE=Debug
110-
```
42+
### Build, flash and debug
43+
- [Build the project](doc/buildAndProgram.md)
44+
- [Bootloader, OTA and DFU](./bootloader/README.md)
45+
- [Stub using NRF52-DK](./doc/PinetimeStubWithNrf52DK.md)
46+
- Logging with JLink RTT.
47+
- Using files from the releases
11148

112-
113-
* Make
114-
```
115-
$ make -j pinetime-app
116-
```
117-
118-
## How to program
119-
### Using make
120-
121-
* Erase
49+
### API
50+
- [BLE implementation and API](./doc/ble.md)
12251

123-
```
124-
$ make FLASH_ERASE
125-
```
126-
127-
* Flash application
128-
129-
```
130-
$ make FLASH_pinetime-app
131-
```
132-
133-
* For your information : list make targets :
134-
135-
```
136-
$ make help
137-
```
138-
139-
### Using GDB and a Black Magic Probe (BMP)
140-
You can use this procedure if you want to flash the firmware (from a release, for example) without having to build the project locally.
141-
142-
Enter the following command into GDB:
143-
144-
```
145-
target extended-remote /dev/ttyACM0
146-
monitor swdp_scan
147-
attach 1
148-
file ./pinetime-app-full.hex
149-
load
150-
run
151-
```
152-
153-
*Note* : Sometimes, I need to run this procedure 2 times : the first time, the screen stays blank, and the second time, it works. This is something I'll need to debug...
154-
155-
Example:
156-
```
157-
$ /home/jf/nrf52/gcc-arm-none-eabi-8-2019-q3-update/bin/arm-none-eabi-gdb
158-
159-
(gdb) target extended-remote /dev/ttyACM0
160-
Remote debugging using /dev/ttyACM0
161-
(gdb) monitor swdp_scan
162-
Target voltage: ABSENT!
163-
Available Targets:
164-
No. Att Driver
165-
1 Nordic nRF52 M3/M4
166-
2 Nordic nRF52 Access Port
167-
168-
(gdb) attach 1
169-
Attaching to Remote target
170-
warning: No executable has been specified and target does not support
171-
determining executable automatically. Try using the "file" command.
172-
0xfffffffe in ?? ()
173-
(gdb) file ./pinetime-app-full.hex
174-
A program is being debugged already.
175-
Are you sure you want to change the file? (y or n) y
176-
Reading symbols from ./pinetime-app-full.hex...
177-
(No debugging symbols found in ./pinetime-app-full.hex)
178-
(gdb) load
179-
Loading section .sec1, size 0xb00 lma 0x0
180-
Loading section .sec2, size 0xf000 lma 0x1000
181-
Loading section .sec3, size 0x10000 lma 0x10000
182-
Loading section .sec4, size 0x5150 lma 0x20000
183-
Loading section .sec5, size 0xa000 lma 0x26000
184-
Loading section .sec6, size 0x10000 lma 0x30000
185-
Loading section .sec7, size 0xdf08 lma 0x40000
186-
Start address 0x0, load size 314200
187-
Transfer rate: 45 KB/sec, 969 bytes/write.
188-
```
189-
190-
## RTT
191-
192-
RTT is a feature from Segger's JLink devices that allows bidirectionnal communication between the debugger and the target.
193-
This feature can be used to get the logs from the embedded software on the development computer.
194-
195-
* Program the MCU with the code (see above)
196-
* Start JLinkExe
197-
198-
```
199-
$ JLinkExe -device nrf52 -if swd -speed 4000 -autoconnect 1
200-
```
201-
202-
* Start JLinkRTTClient
203-
204-
```
205-
$ JLinkRTTClient
206-
```
207-
208-
## Tools
209-
210-
- https://github.com/eliotstock/memory : display the memory usage (FLASH/RAM) using the .map file from GCC.
52+
### Architecture and technical topics
53+
- [Memory analysis](./doc/MemoryAnalysis.md)
21154

212-
## BLE connection and time synchronization
213-
At runtime, BLE advertising is started. You can then use a smartphone or computer to connect and bond to your Pinetime.
214-
As soon as a device is bonded, Pinetime will look for a **CTS** server (**C**urrent **T**ime **S**ervice) on the connected device.
215-
216-
### Using Android and NRFConnect
217-
Here is how to do it with an Android smartphone running NRFConnect:
218-
219-
* Build and program the firmware on the Pinetime
220-
* Install NRFConnect (https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Connect-for-desktop)
221-
* Start NRFConnect and create a CTS server :
222-
- Tap the hamburger button on the top left and select "Configure GATT server"
223-
- Tap "Add service" on the bottom
224-
- Select server configuration "Current Time Service" and tap OK
225-
* Go back to the main screen and scan for BLE devices. A device called "PineTime" should appear
226-
* Tap the button "Connect" next to the PineTime device. It should connect to the PineTime and switch to a new tab.
227-
* If a CTS server is found, the Pinetime should update its time with the time provided by the server.
228-
229-
### Using Linux and bluetoothctl
230-
* Ensure that your bluetooth controller is enabled and working fine. I've tested this on a x86 Debian computer and on a RaspberryPi 3.
231-
* Run bluetoothctl as root : `sudo bluetoothctl`
232-
* Enter the following commands:
233-
* `scan on` and wait for you Pinetime to be detected. Note the BLE MAC address
234-
* `scan off'
235-
* `trust <MAC ADDRESS>`
236-
* `pair <MAC ADDRESS>`
237-
* Wait for some time, and the connection should be established.
55+
### Using the firmware
56+
- Integration with Gadgetbridge
57+
- Integration with AmazFish
58+
- Integration with NRFConnect
59+
- Firmware update, OTA
23860

239-
**NOTE : ** The commands above establish a BLE connection between your PC, but the time synchronization and notifications won't work because there is not CTS or ANS server running. I'm currently working on an application that'll provide both of these servers.
61+
62+
## TODO - contribute
63+
64+
This project is far from beeing finished, and there are still a lot of things to do for this project to become a firmware usable by the general public.
65+
66+
Here a quick list out of my head of things to do for this project:
67+
68+
- Improve BLE communication stability and reliability
69+
- Improve OTA and MCUBoot bootloader
70+
- Add more functionalities : Alarm, chrono, configuration, activities, heart rate logging, games,...
71+
- Add more BLE functionalities : call notifications, agenda, configuration, data logging,...
72+
- Measure power consumption and improve battery life
73+
- Improve documentation, take better pictures and video than mine
74+
- Improve the UI
75+
- Create companion app for multiple OSes (Linux, Android, IoS) and platforms (desktop, ARM, mobile). Do not forget the other devices from Pine64 like [the Pinephone](https://www.pine64.org/pinephone/) and the [Pinebook Pro](https://www.pine64.org/pinebook-pro/).
76+
- Design a simple CI (preferably selfhosted and easy to reproduce).
77+
78+
Do not hesitate to clone/fork the code, hack it and create pull-requests. I'll do my best to review and merge them :)
79+
80+
## Credits
81+
I’m not working alone on this project. First, many people create PR for this projects. Then, there is the whole #pinetime community : a lot of people all around the world who are hacking, searching, experimenting and programming the Pinetime. We exchange our ideas, experiments and code in the chat rooms and forums.
24082

241-
### Troubleshooting
242-
If the connection cannot be established, or the time synchronization does not work, try the following steps.
83+
Here are some people I would like to highlight:
24384

244-
On Android:
245-
* Disable and re-enable your bluetooth device
246-
* In NRFConnect, in the device tab corresponding to your pinetime, tap on the menu on the top left of the screen and select "Delete bond information".
247-
* Then re-try to bond/connect.
85+
- [Atc1441](https://github.com/atc1441/) : He works on an Arduino based firmware for the Pinetime and many other smartwatches based on similar hardware. He was of great help when I was implementing support for the BMA421 motion sensor and I²C driver.
86+
- [Koen](https://github.com/bosmoment) : He’s working on a firmware based on RiotOS. He integrated similar libs than me : NimBLE, LittleVGL,… His help was invaluable too!
87+
- [Lup Yuen Lee](https://github.com/lupyuen) : He is everywhere : he works on a Rust firmware, buils a MCUBoot based bootloader for the Pinetime, design a Flutter based companion app for smartphones and write a lot of articles about the Pinetime!
24888

249-
On Linux:
250-
* Reset the bluetooth device : `sudo hciconfig hci0 reset`
251-
* Restart the Bluetooth service : `sudo systemctl restart bluetooth.service`
252-
* In bluetootctl:
253-
* `remove <MAC ADDRESS>`
254-
* `trust <MAC ADDRESS>`
255-
* `pair <MAC ADDRESS>`
256-
257-
Note that the current firmware only advertise for the first 3 minutes. If you cannot connect after more than 3 minutes, try resetting the device (push the button and hold it for 7-10 seconds).
89+
*If you feel like you should appear on this list, just get in touch with me or submit a PR :)*

doc/MemoryAnalysis.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,7 @@ add_definitions(-D__STACK_SIZE=8192)
7272
*TODO*
7373

7474
#NimBLE buffers
75-
*TODO*
75+
*TODO*
76+
77+
#Tools
78+
- https://github.com/eliotstock/memory : display the memory usage (FLASH/RAM) using the .map file from GCC.

0 commit comments

Comments
 (0)