<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Guenter</id>
	<title>PINE64 - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.pine64.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Guenter"/>
	<link rel="alternate" type="text/html" href="https://wiki.pine64.org/wiki/Special:Contributions/Guenter"/>
	<updated>2026-05-25T15:59:40Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.37.1</generator>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=Reprogramming_the_PineTime&amp;diff=9806</id>
		<title>Reprogramming the PineTime</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=Reprogramming_the_PineTime&amp;diff=9806"/>
		<updated>2021-04-10T15:38:05Z</updated>

		<summary type="html">&lt;p&gt;Guenter: Typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
&lt;br /&gt;
The PineTime Dev Kit comes with the back not glued down to allow it to be easily reprogrammed, however the kit does not include an hardware programmer/debugger. &lt;br /&gt;
&lt;br /&gt;
'''Before you can use your debugger/programmer, you probably have to [[PineTime devkit wiring|wire up your pinetime]]. Heavily recommended you read this first!'''&lt;br /&gt;
&lt;br /&gt;
There is a bewildering variety of different hardware programmers available but whatever programmer you have there are only a few tasks you will have to learn about:&lt;br /&gt;
&lt;br /&gt;
* Unlocking the device '''Note: PineTime watches shipped after 20 Sep 2020 do not require unlocking. They are shipped unlocked.'''&lt;br /&gt;
* Uploading new software&lt;br /&gt;
* Running a debugger&lt;br /&gt;
&lt;br /&gt;
All of these are described in this article. &lt;br /&gt;
&lt;br /&gt;
Unlocking the device is a one-time action that is needed to enable the debug port and provide full access to the device. Unlocking the device will erase all existing software from the internal flash.&lt;br /&gt;
&lt;br /&gt;
= SWD Pinout =&lt;br /&gt;
 	&lt;br /&gt;
See [[PineTime devkit wiring|PineTime devkit wiring]]&lt;br /&gt;
&lt;br /&gt;
= nrfjprog (for Segger JLink) =&lt;br /&gt;
&lt;br /&gt;
The following steps have been tested with the Segger JLink embedded in the [https://www.nordicsemi.com/Software-and-Tools/Development-Kits/nRF52-DK NRF52-DK development board].&lt;br /&gt;
&lt;br /&gt;
=== Hookup ===&lt;br /&gt;
&lt;br /&gt;
Connect the Pinetime SWD pins to the debugger (P20 on NRF52-DK)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Pinetime&lt;br /&gt;
!JLink&lt;br /&gt;
|-&lt;br /&gt;
|GND&lt;br /&gt;
|GND&lt;br /&gt;
|-&lt;br /&gt;
|SWDCLK&lt;br /&gt;
|SWDCLK&lt;br /&gt;
|-&lt;br /&gt;
|SWDIO&lt;br /&gt;
|SWDIO&lt;br /&gt;
|-&lt;br /&gt;
|VCC (3.3V)&lt;br /&gt;
|VTG (target detect)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Unlocking the FLASH ===&lt;br /&gt;
&lt;br /&gt;
Unlocking the device and erase the memory. &lt;br /&gt;
&lt;br /&gt;
'''You need to execute this step only once, to remove the read protection on the memory. Note that it will erase the whole flash memory of the MCU!''' :&lt;br /&gt;
 &lt;br /&gt;
 nrfjprog -f NRF52 --recover&lt;br /&gt;
&lt;br /&gt;
=== Uploading new software ===&lt;br /&gt;
&lt;br /&gt;
1. Program the BLE softdevice (if needed by the firmware). Replace PATH_TO_NRF_SDK by the path where you unzipped the [https://www.nordicsemi.com/Software-and-Tools/Software/nRF5-SDK NRF52 SDK] :&lt;br /&gt;
&lt;br /&gt;
 nrfjprog -f NRF52 --program /PATH_TO_NRF_SDK/components/softdevice/s132/hex/s132_nrf52_6.1.1_softdevice.hex --sectorerase&lt;br /&gt;
&lt;br /&gt;
2. Program the firmware (replace firmware.hex by the actual filename of the firmware):&lt;br /&gt;
&lt;br /&gt;
 nrfjprog -f NRF52 --program firmware.hex --sectorerase&lt;br /&gt;
&lt;br /&gt;
3. Reset and run the new firmware:&lt;br /&gt;
 &lt;br /&gt;
 nrfjprog -f NRF52 --reset&lt;br /&gt;
&lt;br /&gt;
= OpenOCD =&lt;br /&gt;
&lt;br /&gt;
OpenOCD, the Open On-Chip Debugger supports multiple different adapters. You can read more about it here: http://openocd.org/&lt;br /&gt;
&lt;br /&gt;
== Adapters ==&lt;br /&gt;
&lt;br /&gt;
These examples allow you to use telnet to issue futher commands to the devkit. Using them you can connect to ''127.0.0.1'' (''localhost'') port ''4444'' using telnet and invoke OpenOCD commands. GDB should also be available on port ''3333''.&lt;br /&gt;
&lt;br /&gt;
You can simplify your life by creating a configuration file that contains the interface, transport, target and speed configuration. Things like CLion also need one to work properly.&lt;br /&gt;
&lt;br /&gt;
If you aren't using the latest version of OpenOCD, you might need to substitute things in these examples with older syntax (e.g. instead of ''adapter speed'' it's ''adapter_khz'').&lt;br /&gt;
&lt;br /&gt;
=== CMSIS-DAP ===&lt;br /&gt;
&lt;br /&gt;
Issue this command to initialize a connection to the devkit:&lt;br /&gt;
&lt;br /&gt;
 openocd \&lt;br /&gt;
    -c 'source [find interface/cmsis-dap.cfg]' \&lt;br /&gt;
    -c 'transport select swd' \&lt;br /&gt;
    -c 'source [find target/nrf52.cfg]' \&lt;br /&gt;
    -c 'adapter speed 8000' \&lt;br /&gt;
    -c 'init'&lt;br /&gt;
&lt;br /&gt;
=== JLink ===&lt;br /&gt;
&lt;br /&gt;
Start OpenOCD:&lt;br /&gt;
&lt;br /&gt;
 openocd \&lt;br /&gt;
    -c 'source [find interface/jlink.cfg]' \&lt;br /&gt;
    -c 'transport select swd' \&lt;br /&gt;
    -c 'source [find target/nrf52.cfg]' \&lt;br /&gt;
    -c 'adapter speed 8000' \&lt;br /&gt;
    -c 'init'&lt;br /&gt;
&lt;br /&gt;
=== Raspberry Pi ===&lt;br /&gt;
&lt;br /&gt;
 openocd \&lt;br /&gt;
    -c 'source bcm2835spi' \&lt;br /&gt;
    -c 'bcm2835spi_speed 31200' \&lt;br /&gt;
    -c 'source [find target/nrf52.cfg]' \&lt;br /&gt;
    -c 'init'&lt;br /&gt;
&lt;br /&gt;
=== STLink ===&lt;br /&gt;
&lt;br /&gt;
Connect PineTime SWD Pins to ST-Link v2 as follows:&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!PineTime&lt;br /&gt;
!ST-Link&lt;br /&gt;
|-&lt;br /&gt;
|GND&lt;br /&gt;
|GND&lt;br /&gt;
|-&lt;br /&gt;
|SWDCLK&lt;br /&gt;
|SWDCLK&lt;br /&gt;
|-&lt;br /&gt;
|SWDIO&lt;br /&gt;
|SWDIO&lt;br /&gt;
|-&lt;br /&gt;
|VCC (3.3V)&lt;br /&gt;
|3.3V&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[File:pinetime-stlink.jpg|400px]]&lt;br /&gt;
&lt;br /&gt;
Note that only the bottom row of pins on ST-Link are used.&lt;br /&gt;
&lt;br /&gt;
To flash PineTime with ST-Link on Linux and macOS, use [https://github.com/lupyuen/pinetime-updater/blob/master/README.md PineTime Updater]&lt;br /&gt;
&lt;br /&gt;
[[PineTime FAQ|'''ST-Link can't be used to remove nRF52 flash protection''']]&lt;br /&gt;
&lt;br /&gt;
== Unlocking the device ==&lt;br /&gt;
&lt;br /&gt;
If you need to disable access port protection then you can do this using the following commands below.&lt;br /&gt;
&lt;br /&gt;
This can be done in two ways:&lt;br /&gt;
&lt;br /&gt;
Appending this to OpenOCD command line:&lt;br /&gt;
&lt;br /&gt;
  -c 'nrf52.dap apreg 1 0x04' -c 'nrf52.dap apreg 1 0x04 0x01' -c 'nrf52.dap apreg 1 0x04'&lt;br /&gt;
&lt;br /&gt;
Or by using the telnet connection, just type in ''telnet localhost 4444'' and then you can issue commands to OpenOCD:&lt;br /&gt;
&lt;br /&gt;
Note: ''Unlocking the device to remove access port protection will erase the contents of flash.''&lt;br /&gt;
&lt;br /&gt;
  telnet localhost 4444&lt;br /&gt;
    Trying 127.0.0.1...&lt;br /&gt;
    Connected to localhost.&lt;br /&gt;
    Escape character is '^]'.&lt;br /&gt;
    Open On-Chip Debugger&lt;br /&gt;
    &amp;gt; nrf52.dap apreg 1 0x04&lt;br /&gt;
    0x00000000&lt;br /&gt;
    &amp;gt; nrf52.dap apreg 1 0x04 0x01&lt;br /&gt;
    &amp;gt; nrf52.dap apreg 1 0x04&lt;br /&gt;
    0x00000001&lt;br /&gt;
&lt;br /&gt;
(If the ''nrf52.dap'' command cannot be found, try just ''dap'' instead.)&lt;br /&gt;
&lt;br /&gt;
== Uploading new software ==&lt;br /&gt;
&lt;br /&gt;
Just issue this command, replace ''code.hex'' with your own (and cmsis-dap.cfg with an appropriate adapter).&lt;br /&gt;
&lt;br /&gt;
  openocd \&lt;br /&gt;
      -c 'source [find interface/cmsis-dap.cfg]' \&lt;br /&gt;
      -c 'transport select swd' \&lt;br /&gt;
      -c 'source [find target/nrf52.cfg]' \&lt;br /&gt;
      -c 'init' \&lt;br /&gt;
      -c 'nrf5 mass_erase' \&lt;br /&gt;
      -c 'program code.hex verify' \&lt;br /&gt;
      -c 'reset' \&lt;br /&gt;
      -c 'exit'&lt;br /&gt;
&lt;br /&gt;
= Black Magic Probe =&lt;br /&gt;
&lt;br /&gt;
BlackMagic Probe is an JTAG/SWD adapter with open-source firmware, allowing for it to be ported to a multitude of different boards. One of it's defining features is lack of need for intermediate software such as OpenOCD - one would just need to connect to the GDB server running on the chip and proceed with debugging. For more information, refer to [https://github.com/blacksphere/blackmagic/wiki wiki].&lt;br /&gt;
&lt;br /&gt;
=== Native adapters ===&lt;br /&gt;
&lt;br /&gt;
The native adapters are the official Black Magic family of debug adapters, including the original Black Magic Probe and the Black Magic Probe Mini. By buying the official hardware you are supporting the continued development of the Black Magic Probe software.&lt;br /&gt;
&lt;br /&gt;
Providing your native adapter is running up-to-date firmware then it can be used to program your PineTime.&lt;br /&gt;
&lt;br /&gt;
=== STM32 (Blue Pill) ===&lt;br /&gt;
&lt;br /&gt;
It is possible to flash a popular development board based on STM32F103C8T6 microcontroller, known as Blue Pill, to make a BlackMagic Probe device. For example, one may follow instructions in [https://forum.pine64.org/showthread.php?tid=8816&amp;amp;pid=57095#pid57095 forum post] or [https://gist.github.com/darnel/dac1370d057e176386ca4026418abc2b gist] (mac os). Also, it is possible to use SWD pins on the board to flash other devices, instead using arbitrary pins on the board itself. See [https://buger.dread.cz/black-magic-probe-bmp-on-bluepill-stm32f103c8-minimum-system-development-board.html this link] for more detals.&lt;br /&gt;
&lt;br /&gt;
=== Other hardware ===&lt;br /&gt;
&lt;br /&gt;
The Black Magic Probe firmware can be run on a variety of host devices. See [https://github.com/blacksphere/blackmagic/wiki/Debugger-Hardware BMP Debugger Hardware] for more information.&lt;br /&gt;
&lt;br /&gt;
=== Using the BMP to flash the PineTime ===&lt;br /&gt;
&lt;br /&gt;
Refer to the BMP [https://github.com/blacksphere/blackmagic/wiki/Useful-GDB-commands wiki] for the full description of commands.&lt;br /&gt;
Overall, the process on Linux is like following. (/dev/ttyBmpGdb is a symlink created by the udev rule). It's useful to create a gdb script file (or .gdbinit) with following commands:&lt;br /&gt;
&lt;br /&gt;
  target extended-remote /dev/ttyBmpGdb&lt;br /&gt;
  monitor swdp_scan&lt;br /&gt;
  attach 1&lt;br /&gt;
  file %firmware file%&lt;br /&gt;
&lt;br /&gt;
Then one may use '''load''' command to flash the firmware, '''compare-sections''' to verify the upload, or '''monitor erase_mass''' to erase the firmware. &lt;br /&gt;
&lt;br /&gt;
Then, proceed with debugging as normal.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= External links and additional tutorials = &lt;br /&gt;
&lt;br /&gt;
* https://github.com/jlukanc1/pinetime-boot-flasher&lt;br /&gt;
* https://blog.aegrel.ee/absniffer-cmsis-dap-sniffer.html&lt;br /&gt;
* https://blog.dbrgn.ch/2020/5/16/nrf52-unprotect-flash-jlink-openocd/&lt;br /&gt;
* https://medium.com/@ly.lee/openocd-on-raspberry-pi-better-with-swd-on-spi-7dea9caeb590&lt;br /&gt;
* https://medium.com/@ly.lee/build-and-flash-rust-mynewt-firmware-for-pinetime-smart-watch-5e14259c55&lt;br /&gt;
&lt;br /&gt;
[[Category:PineTime]]&lt;/div&gt;</summary>
		<author><name>Guenter</name></author>
	</entry>
	<entry>
		<id>https://wiki.pine64.org/index.php?title=InfiniTime&amp;diff=8191</id>
		<title>InfiniTime</title>
		<link rel="alternate" type="text/html" href="https://wiki.pine64.org/index.php?title=InfiniTime&amp;diff=8191"/>
		<updated>2020-11-05T10:24:08Z</updated>

		<summary type="html">&lt;p&gt;Guenter: Typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== InfiniTime ==&lt;br /&gt;
InfiniTime (also known as JF's project, FreeRTOS firmware or Pinetime-JF) is an open source (GPLv3) firmware written in C++ and based on FreeRTOS, LVGL and NimBLE. This firmware (version 0.7.1) is preloaded at the factory since the new batch of PineTime devkits and sealed PineTimes of end of September 2020.&lt;br /&gt;
&lt;br /&gt;
* Github repo : https://github.com/JF002/Pinetime&lt;br /&gt;
* Official website : https://infinitime.io/&lt;br /&gt;
&lt;br /&gt;
== Read this first! ==&lt;br /&gt;
* PineTime is still considered as a development device. InfiniTime and the bootloader are still in heavy development, and some features might not work as expected.&lt;br /&gt;
* OTA is a critical feature which is still considered as risky on sealed devices. There is no known way to recover a sealed device from a failed OTA upgrade.&lt;br /&gt;
* There is currently no way to upgrade the bootloader on a sealed device.&lt;br /&gt;
* Do not use a sealed PineTime as a development device, there is a lot of chances that you'll brick it.&lt;br /&gt;
&lt;br /&gt;
== Known issues ==&lt;br /&gt;
{{warning|1=Please read this section carefully before upgrading the firmware on your PineTime, especially if you are using a sealed device!}}&lt;br /&gt;
=== Black screen after a reset in sleep mode ===&lt;br /&gt;
==== Description ====&lt;br /&gt;
This issue occurs if you are using the original bootloader (from InfiniTime 0.7.1), upgraded from InfiniTime 0.7.1 to 0.8.2 and the watch resets while the display is OFF : the watch is stuck on a black screen and does not respond to touch, button press or BLE.&lt;br /&gt;
&lt;br /&gt;
The reset can be triggered by the watchdog or manually by long pressing the button.&lt;br /&gt;
&lt;br /&gt;
This issue is caused by InfiniTime 0.8.2 that put the external SPI flash memory to sleep before switching the display off and by the bootloader that cannot wake the memory chip up. The bootloader is stuck in an infinite loop.&lt;br /&gt;
&lt;br /&gt;
More info : https://github.com/lupyuen/pinetime-rust-mynewt/issues/24 and https://github.com/JF002/Pinetime/issues/60&lt;br /&gt;
&lt;br /&gt;
==== Workaround ====&lt;br /&gt;
On a development kit, a simple reset via SWD is needed to unlock the bootloader.&lt;br /&gt;
&lt;br /&gt;
On a sealed device, the only way to work around this issue is to wait for the battery to drain completely before trying again.&lt;br /&gt;
&lt;br /&gt;
This issue can be avoided by ensuring that the display is ON when manually resetting the device (long push on the button).&lt;br /&gt;
&lt;br /&gt;
==== Fixed version ====&lt;br /&gt;
This issues is fixed in [https://github.com/JF002/Pinetime/releases/tag/0.8.3 InfiniTime 0.8.3]&lt;br /&gt;
&lt;br /&gt;
== Releases == &lt;br /&gt;
=== [https://github.com/JF002/Pinetime/releases/tag/0.7.1 Version 0.7.1] ===&lt;br /&gt;
This is the version that ships with PineTime devkits and sealed PineTime as of September 2020.&lt;br /&gt;
* Time synchronization over BLE&lt;br /&gt;
* Display brightness setting&lt;br /&gt;
* Notifications over BLE&lt;br /&gt;
* Integration with AmazFish (SailFishOS) and Gadgetbridge (Android)&lt;br /&gt;
* OTA using NRFConnect&lt;br /&gt;
&lt;br /&gt;
Bootloader : https://github.com/lupyuen/pinetime-rust-mynewt/releases/tag/v4.1.7&lt;br /&gt;
&lt;br /&gt;
=== [https://github.com/JF002/Pinetime/releases/tag/0.8.2 Version 0.8.2] ===&lt;br /&gt;
* Music control app&lt;br /&gt;
* Paint app&lt;br /&gt;
* Manual image validation after OTA&lt;br /&gt;
&lt;br /&gt;
Bootloader : https://github.com/lupyuen/pinetime-rust-mynewt/releases/tag/v5.0.4.&lt;br /&gt;
&lt;br /&gt;
This new version of the bootloader fixes [[#Black_screen_after_a_reset_in_sleep_mode]] and enables the watchdog before launching the firmware.&lt;/div&gt;</summary>
		<author><name>Guenter</name></author>
	</entry>
</feed>