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