{"id":20316093,"url":"https://github.com/lupyuen/pinetime-updater","last_synced_at":"2025-04-11T17:40:27.751Z","repository":{"id":43813407,"uuid":"283401783","full_name":"lupyuen/pinetime-updater","owner":"lupyuen","description":"Flash firmware to PineTime the friendly wired way with OpenOCD","archived":false,"fork":false,"pushed_at":"2022-10-07T11:47:28.000Z","size":142,"stargazers_count":65,"open_issues_count":1,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T13:39:42.872Z","etag":null,"topics":["linux","macos","openocd","pinetime","raspberrypi"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lupyuen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["lupyuen"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":["paypal.me/lupyuen"]}},"created_at":"2020-07-29T04:55:01.000Z","updated_at":"2024-08-02T09:23:01.000Z","dependencies_parsed_at":"2023-01-19T14:17:10.411Z","dependency_job_id":null,"html_url":"https://github.com/lupyuen/pinetime-updater","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fpinetime-updater","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fpinetime-updater/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fpinetime-updater/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lupyuen%2Fpinetime-updater/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lupyuen","download_url":"https://codeload.github.com/lupyuen/pinetime-updater/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248451334,"owners_count":21105851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["linux","macos","openocd","pinetime","raspberrypi"],"created_at":"2024-11-14T18:24:17.523Z","updated_at":"2025-04-11T17:40:27.726Z","avatar_url":"https://github.com/lupyuen.png","language":"Shell","funding_links":["https://github.com/sponsors/lupyuen","paypal.me/lupyuen"],"categories":[],"sub_categories":[],"readme":"# pinetime-updater: Flash firmware to PineTime the friendly wired way with OpenOCD\n\n![](pinetime-updater.png)\n\n-   Program the bootloader logo to your PineTime\n\n-   Flash the [__Latest Bootloader (MCUBoot)__](https://lupyuen.github.io/pinetime-rust-mynewt/articles/mcuboot) and [__Firmware (InfiniTime based on FreeRTOS)__](https://github.com/JF002/Pinetime) to [__PineTime Smart Watch__](https://lupyuen.github.io/pinetime-rust-mynewt/articles/pinetime) the wired way\n\n-   After the firmware has been flashed to PineTime via the SWD port, we may update the firmware wirelessly (over Bluetooth LE) with the [__nRF Connect__](https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Connect-for-mobile) mobile app\n\n-   Installs [__xPack OpenOCD__](https://xpack.github.io/openocd/install/) automatically\n\n-   Builds [__`openocd-spi`__](https://github.com/lupyuen/openocd-spi) on Raspberry Pi\n\n-   Also works for flashing any device with an SWD port (like STM32 Blue Pill)\n\n## Requirements\n\n-   Linux or macOS, connected to PineTime with [ST-Link v2 Compatible](https://www.aliexpress.com/wholesale?catId=0\u0026initiative_id=SB_20180924134644\u0026SearchText=st-link+v2\u0026switch_new_app=y)\n\n    |PineTime|ST-Link|\n    |:--|:--|\n    |GND|GND\n    |SWDCLK|SWDCLK\n    |SWDIO|SWDIO\n    |VCC (3.3V)|3.3V\n\n    ![SWD Connection to ST-Link v2 Compatible](https://lupyuen.github.io/images/pinetime-stlink.jpg)\n    \n    [SWD Pinout on PineTime](https://wiki.pine64.org/index.php?title=Reprogramming_the_PineTime#SWD_Pinout)\n\n    [Video of PineTime Updater with ST-Link on macOS](https://youtu.be/2p4EZqevVJQ)\n\n-   Or Raspberry Pi with Raspberry Pi OS (32-bit), connected to PineTime via the SPI port...\n\n    [\"Connect PineTime to Raspberry Pi\"](https://github.com/lupyuen/visual-embedded-rust/blob/master/README.md#connect-pinetime-to-raspberry-pi)\n\n    [Video of PineTime Updater on Raspberry Pi](https://youtu.be/PZ5NW8q8Zok)\n\n## How To Run\n\n```bash\n# For macOS Only: Install brew according to https://brew.sh/\n/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)\"\n\n# For Raspberry Pi Only: Enable SPI port with raspi-config\n# Select Interfacing Options → SPI → Yes\nsudo raspi-config\n\n# Download the bash and OpenOCD scripts\ngit clone https://github.com/lupyuen/pinetime-updater\n\n# Run the bash script\ncd pinetime-updater\nchmod +x run.sh\n./run.sh\n\n```\n\nWe should see `Done!` when the flashing has completed.\n\n(In case of problems, compare with the logs at the end of this doc)\n\n## Remove Flash ROM Protection\n\nThe above steps will fail when PineTime has Flash ROM Protection enabled. \n\nAll PineTime watches shipped before August 2020 will have Flash ROM Protection enabled.\n\nTo remove PineTime's Flash ROM Protection (with Raspberry Pi only)...\n\n1. Power off our Raspberry Pi\n\n1. Connect our Raspberry Pi with Raspberry Pi OS (32-bit) to PineTime via the SPI port...\n\n    [\"Connect PineTime to Raspberry Pi\"](https://github.com/lupyuen/visual-embedded-rust/blob/master/README.md#connect-pinetime-to-raspberry-pi)\n\n1. Power on our Raspberry Pi. Open the Terminal and enter...\n\n    ```bash\n    cd pinetime-updater\n    ./scripts/flash-unprotect.sh\n    ```\n\n    We should see...\n\n    ```\n    Removing flash protection and erasing flash...\n    Shut down and power off your Raspberry Pi. Wait 30 seconds then power on your Raspberry Pi. Run flash-unprotect.sh to check flash protection.\n    ```\n\n1.  Follow the instructions to power off the Raspberry Pi.\n\n1.  After 30 seconds, power it on and enter...\n\n    ```bash\n    cd pinetime-updater\n    ./scripts/flash-unprotect.sh\n    ```\n\n    We should see...\n\n    ```\n    Flash is already unprotected\n    ```\n    \n1.  Follow the steps in the previous section to flash our PineTime\n\n## Raspberry Pi Troubleshooting\n\n(This section is for Raspberry Pi only)\n\nIf we see `Clock Speed` and nothing else after that…\n\n```\nInfo : BCM2835 SPI SWD driver\nInfo : SWD only mode enabled\nInfo : clock speed 31200 kHz\nInfo : SWD DPIDR 0x2ba01477\n```\n\nThen the connection to the SWD Port is probably loose, please check the pins.\n\nIf we don't see this `DPIDR` number, or if we see a different `DPIDR` number...\n\n```\nSWD DPIDR 0x2ba01477\n```\n\nThen the connection to the SWD Port is most likely loose, please check the pins.\n\nAlso enter `sudo raspi-config` and confirm that the SPI port has been enabled.\n\nIf the PineTime battery is completely empty, this may also cause connectivity problems.\n\n## How It Works\n\nSee [`run.sh`](run.sh) for the flashing steps.\n\nOnce the latest MCUBoot Bootloader and InfiniTime Firmware have been flashed to PineTime, we will be able to update the firmware wirelessly with the nRF Connect mobile app like this...\n\n[\"Download PineTime Firmware\"](https://lupyuen.github.io/pinetime-rust-mynewt/articles/cloud#download-and-test-our-pinetime-firmware)\n\n(Except we won't be downloading the firmware from GitHub Actions. We will have the official link soon.)\n\nFor more about PineTime...\n\n[\"PineTime doesn't run Linux... But that's OK!\"](https://lupyuen.github.io/pinetime-rust-mynewt/articles/pinetime)\n\n## Sample Log for Raspberry Pi\n\n```\n----- Downloading https://github.com/lupyuen/pinetime-rust-mynewt/releases/download/v4.1.7/mynewt_nosemi.elf.bin to /tmp/mynewt_nosemi.elf.bin... (If it stops here, URL is invalid)\n+ wget -q https://github.com/lupyuen/pinetime-rust-mynewt/releases/download/v4.1.7/mynewt_nosemi.elf.bin -O /tmp/mynewt_nosemi.elf.bin\n+ '[' '!' -f /tmp/mynewt_nosemi.elf.bin ']'\n+ set +x\n\n----- Flashing /tmp/mynewt_nosemi.elf.bin to address 0x0...\n+ openocd-spi/bin/openocd -c ' set filename \"/tmp/mynewt_nosemi.elf.bin\" ' -c ' set address  \"0x0\" ' -f scripts/swd-pi.ocd -f scripts/flash-program.ocd\nOpen On-Chip Debugger 0.10.0+dev-01130-g9d1b46f5 (2020-08-03-21:20)\nLicensed under GNU GPL v2\nFor bug reports, read\n        http://openocd.org/doc/doxygen/bugs.html\n/tmp/mynewt_nosemi.elf.bin\n0x0\nInfo : only one transport option; autoselect 'swd'\nforce hard breakpoints\nInfo : BCM2835 SPI SWD driver\nInfo : SWD only mode enabled\nInfo : clock speed 31200 kHz\nInfo : SWD DPIDR 0x2ba01477\nInfo : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints\nInfo : Listening on port 3333 for gdb connections\nStopping...\ntarget halted due to debug-request, current mode: Thread \nxPSR: 0x61000000 pc: 0x000001ce msp: 0x2000ffd8\n\nFlashing ROM...\ntarget halted due to debug-request, current mode: Thread \nxPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000\nEnabled ARM Semihosting to show debug output\n** Programming Started **\nInfo : nRF52832-QFAA(build code: E1) 512kB Flash, 64kB RAM\nWarn : Adding extra erase range, 0x000056d8 .. 0x00005fff\n** Programming Finished **\n** Verify Started **\n** Verified OK **\n\nRestarting...\ntarget halted due to debug-request, current mode: Thread \nxPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000, semihosting\nEnabled ARM Semihosting to show debug output\n```\n\n## Sample Log for ST-Link\n\n```\n----- Downloading https://github.com/lupyuen/pinetime-rust-mynewt/releases/download/v4.1.7/mynewt_nosemi.elf.bin to /tmp/mynewt_nosemi.elf.bin... (If it stops here, URL is invalid)\n+ wget -q https://github.com/lupyuen/pinetime-rust-mynewt/releases/download/v4.1.7/mynewt_nosemi.elf.bin -O /tmp/mynewt_nosemi.elf.bin\n+ '[' '!' -f /tmp/mynewt_nosemi.elf.bin ']'\n+ set +x\n\n----- Flashing /tmp/mynewt_nosemi.elf.bin to address 0x0...\n+ xpack-openocd/bin/openocd -c ' set filename \"/tmp/mynewt_nosemi.elf.bin\" ' -c ' set address  \"0x0\" ' -f scripts/swd-stlink.ocd -f scripts/flash-program.ocd\nxPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-12:31)\nLicensed under GNU GPL v2\nFor bug reports, read\n        http://openocd.org/doc/doxygen/bugs.html\n/tmp/mynewt_nosemi.elf.bin\n0x0\n\nnRF52 device has a CTRL-AP dedicated to recover the device from AP lock.\nA high level adapter (like a ST-Link) you are currently using cannot access\nthe CTRL-AP so 'nrf52_recover' command will not work.\nDo not enable UICR APPROTECT.\n\nforce hard breakpoints\nStopping...\ntarget halted due to debug-request, current mode: Thread \nxPSR: 0x41000000 pc: 0x00000da0 msp: 0x2000ffa0\n\nFlashing ROM...\ntarget halted due to debug-request, current mode: Thread \nxPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000\nEnabled ARM Semihosting to show debug output\n** Programming Started **\n** Programming Finished **\n** Verify Started **\n** Verified OK **\n\nRestarting...\ntarget halted due to debug-request, current mode: Thread \nxPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000, semihosting\nEnabled ARM Semihosting to show debug output\n\n**** Done!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flupyuen%2Fpinetime-updater","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flupyuen%2Fpinetime-updater","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flupyuen%2Fpinetime-updater/lists"}