1.. zephyr:board:: pinetime_devkit0
2
3Overview
4********
5
6The Pine64 smartwatch, dubbed "PineTime", is a product of a community effort
7for an open source smartwatch in collaboration with wearable RTOS and Linux
8app developers/communities.
9
10Hardware
11********
12
13The PineTime is based on a Nordic NRF52832 chip and features:
14
15- CPU: 64 MHz Cortex-M4 with FPU
16- RAM: 64KB SRAM
17- Flash: 512KB on board flash with additional 4MB SPI NOR XT25F32B
18- Display: 1.3 inches (33mm), 240x240 pixels display with ST7789 driver
19- Touchscreen: CST816S Capacitive Touch
20- Battery: 170-180mAh 3.8V LiPo
21- BMA421 Triaxial Acceleration Sensor
22- HRS3300 PPG Heart Rate Sensor
23- Vibration motor
24
25PineTime schematics
26========================
27
28The `PineTime schematics`_ are available on the pine64 website. Below
29is an overview of the NRF52 port assignment.
30
31+----------------------+---------------------------------+-----------+
32| NRF52 pins           | Function                        | Direction |
33+======================+=================================+===========+
34| P0.00/XL1            | 32.768 kHz –XL1                 |           |
35+----------------------+---------------------------------+-----------+
36| P0.01/XL2            | 32.768 kHz –XL2                 |           |
37+----------------------+---------------------------------+-----------+
38| P0.02/AIN0           | SPI-SCK, LCD_SCK                | OUT       |
39+----------------------+---------------------------------+-----------+
40| P0.03/AIN1           | SPI-MOSI, LCD_SDI               | OUT       |
41+----------------------+---------------------------------+-----------+
42| P0.04/AIN2           | SPI-MISO                        | IN        |
43+----------------------+---------------------------------+-----------+
44| P0.05/AIN3           | SPI-CE# (SPI-NOR)               | OUT       |
45+----------------------+---------------------------------+-----------+
46| P0.06                | BMA421-SDA, HRS3300-SDA, TP-SDA | I/O       |
47+----------------------+---------------------------------+-----------+
48| P0.07                | BMA421-SCL, HRS3300-SCL, TP-SCL | OUT       |
49+----------------------+---------------------------------+-----------+
50| P0.08                | BMA421-INT                      | IN        |
51+----------------------+---------------------------------+-----------+
52| P0.09/NFC1           | LCD_DET                         | OUT       |
53+----------------------+---------------------------------+-----------+
54| P0.10/NFC2           | TP_RESET                        | OUT       |
55+----------------------+---------------------------------+-----------+
56| P0.11                |                                 |           |
57+----------------------+---------------------------------+-----------+
58| P0.12                | CHARGE INDICATION               | IN        |
59+----------------------+---------------------------------+-----------+
60| P0.13                | PUSH BUTTON_IN                  | IN        |
61+----------------------+---------------------------------+-----------+
62| P0.14/TRACEDATA3     | LCD_BACKLIGHT_LOW               | OUT       |
63+----------------------+---------------------------------+-----------+
64| P0.15/TRACEDATA2     | PUSH BUTTON_OUT                 | OUT       |
65+----------------------+---------------------------------+-----------+
66| P0.16/TRACEDATA1     | VIBRATOR OUT                    | OUT       |
67+----------------------+---------------------------------+-----------+
68| P0.17                |                                 |           |
69+----------------------+---------------------------------+-----------+
70| P0.18/TRACEDATA0/SWO | LCD_RS OUT                      |           |
71+----------------------+---------------------------------+-----------+
72| P0.19                | POWER PRESENCE INDICATION       | IN        |
73+----------------------+---------------------------------+-----------+
74| P0.20/TRACECLK       |                                 |           |
75+----------------------+---------------------------------+-----------+
76| P0.21/nRESET         |                                 |           |
77+----------------------+---------------------------------+-----------+
78| P0.22                | LCD_BACKLIGHT_MID               | OUT       |
79+----------------------+---------------------------------+-----------+
80| P0.23                | LCD_BACKLIGHT_HIGH              | OUT       |
81+----------------------+---------------------------------+-----------+
82| P0.24                | 3V3 POWER CONTROL               | OUT       |
83+----------------------+---------------------------------+-----------+
84| P0.25                | LCD_CS                          | OUT       |
85+----------------------+---------------------------------+-----------+
86| P0.26                | LCD_RESET                       | OUT       |
87+----------------------+---------------------------------+-----------+
88| P0.27                | STATUS LED (NOT STAFF)          | OUT       |
89+----------------------+---------------------------------+-----------+
90| P0.28/AIN4           | TP_INT                          | IN        |
91+----------------------+---------------------------------+-----------+
92| P0.29/AIN5           |                                 |           |
93+----------------------+---------------------------------+-----------+
94| P0.30/AIN6           | HRS3300-TEST                    | IN        |
95+----------------------+---------------------------------+-----------+
96| P0.31/AIN7           | BATTERY VOLTAGE (Analog)        | IN        |
97+----------------------+---------------------------------+-----------+
98
99Building
100********
101
102In order to get started with Zephyr on the PineTime, you can use the
103basic button sample:
104
105.. zephyr-app-commands::
106   :zephyr-app: samples/basic/button
107   :board: pinetime_devkit0
108   :goals: build
109
110Programming and Debugging
111*************************
112
113The PineTime Dev Kit comes with the back not glued down to allow it to be
114easily reprogrammed.
115
116The kit does not include a hardware programmer, but existing debuggers
117supporting SWD can be used.
118
119These are the necessary steps for debugging:
120
121- Unlock the device
122- Upload new software
123- Run a debugger
124
125More infos to be found in the `Wiki Reprogramming the PineTime`_ page.
126
127Debugger connection
128===================
129
130The dev kits have exposed SWD pins for flashing and debugging.
131
132Only a few devs have soldered to these pins, most just use friction to make
133contact with the programming cable.
134
135The pinout is:
136
137.. figure:: img/PineTime_SWD_location.jpg
138   :align: center
139   :alt: PineTime SWD location
140
141Unlocking the Flash memory
142==========================
143
144Unlocking the device is a one-time action that is needed to enable to debug
145port and provide full access to the device. This will erase all existing
146software from the internal flash.
147
148**Note: PineTime watches shipped after 20 Sep 2020 do not require unlocking. They are shipped unlocked.**
149
150.. code-block:: console
151
152   $ nrfjprog -f NRF52 --recover
153
154Flashing
155========
156
157Using nrfjprog, flashing the PineTime is done with the command:
158
159.. code-block:: console
160
161   $ nrfjprog -f NRF52 --program firmware.hex --sectorerase
162
163Debugging
164=========
165
166Using Segger Ozone debugger, debugging and flashing is made easy.
167
168Simply load the .elf file containing the final firmware and
169setup the debugger to use SWD over USB for the chip nRF52832_xxAA.
170This setup can be done using the menu Tools/J-Link Settings. or by directly
171typing the following in the debugger console:
172
173.. code-block:: console
174
175   $ Project.SetDevice ("nRF52832_xxAA");
176   $ Project.SetHostIF ("USB", "");
177   $ Project.SetTargetIF ("SWD");
178   $ Project.SetTIFSpeed ("4 MHz");
179   $ File.Open ("path/to/your/build/zephyr/zephyr.elf");
180
181References
182**********
183
184.. target-notes::
185
186.. _Pine64 PineTime presentation:
187   https://www.pine64.org/pinetime
188
189.. _Pine64 PineTime wiki page:
190   https://wiki.pine64.org/index.php/PineTime
191
192.. _Pine64 forum:
193   https://forum.pine64.org
194
195.. _PineTime schematics:
196   http://files.pine64.org/doc/PineTime/PineTime%20Schematic-V1.0a-20191103.pdf
197
198.. _Wiki Reprogramming the PineTime:
199   https://wiki.pine64.org/index.php/Reprogramming_the_PineTime
200