Git Product home page Git Product logo

pinetime-updater's Introduction

pinetime-updater: Flash firmware to PineTime the friendly wired way with OpenOCD

Requirements

How To Run

# For macOS Only: Install brew according to https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

# For Raspberry Pi Only: Enable SPI port with raspi-config
# Select Interfacing Options → SPI → Yes
sudo raspi-config

# Download the bash and OpenOCD scripts
git clone https://github.com/lupyuen/pinetime-updater

# Run the bash script
cd pinetime-updater
chmod +x run.sh
./run.sh

We should see Done! when the flashing has completed.

(In case of problems, compare with the logs at the end of this doc)

Remove Flash ROM Protection

The above steps will fail when PineTime has Flash ROM Protection enabled.

All PineTime watches shipped before August 2020 will have Flash ROM Protection enabled.

To remove PineTime's Flash ROM Protection (with Raspberry Pi only)...

  1. Power off our Raspberry Pi

  2. Connect our Raspberry Pi with Raspberry Pi OS (32-bit) to PineTime via the SPI port...

    "Connect PineTime to Raspberry Pi"

  3. Power on our Raspberry Pi. Open the Terminal and enter...

    cd pinetime-updater
    ./scripts/flash-unprotect.sh

    We should see...

    Removing flash protection and erasing flash...
    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.
    
  4. Follow the instructions to power off the Raspberry Pi.

  5. After 30 seconds, power it on and enter...

    cd pinetime-updater
    ./scripts/flash-unprotect.sh

    We should see...

    Flash is already unprotected
    
  6. Follow the steps in the previous section to flash our PineTime

Raspberry Pi Troubleshooting

(This section is for Raspberry Pi only)

If we see Clock Speed and nothing else after that…

Info : BCM2835 SPI SWD driver
Info : SWD only mode enabled
Info : clock speed 31200 kHz
Info : SWD DPIDR 0x2ba01477

Then the connection to the SWD Port is probably loose, please check the pins.

If we don't see this DPIDR number, or if we see a different DPIDR number...

SWD DPIDR 0x2ba01477

Then the connection to the SWD Port is most likely loose, please check the pins.

Also enter sudo raspi-config and confirm that the SPI port has been enabled.

If the PineTime battery is completely empty, this may also cause connectivity problems.

How It Works

See run.sh for the flashing steps.

Once 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...

"Download PineTime Firmware"

(Except we won't be downloading the firmware from GitHub Actions. We will have the official link soon.)

For more about PineTime...

"PineTime doesn't run Linux... But that's OK!"

Sample Log for Raspberry Pi

----- 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)
+ wget -q https://github.com/lupyuen/pinetime-rust-mynewt/releases/download/v4.1.7/mynewt_nosemi.elf.bin -O /tmp/mynewt_nosemi.elf.bin
+ '[' '!' -f /tmp/mynewt_nosemi.elf.bin ']'
+ set +x

----- Flashing /tmp/mynewt_nosemi.elf.bin to address 0x0...
+ 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
Open On-Chip Debugger 0.10.0+dev-01130-g9d1b46f5 (2020-08-03-21:20)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
/tmp/mynewt_nosemi.elf.bin
0x0
Info : only one transport option; autoselect 'swd'
force hard breakpoints
Info : BCM2835 SPI SWD driver
Info : SWD only mode enabled
Info : clock speed 31200 kHz
Info : SWD DPIDR 0x2ba01477
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Stopping...
target halted due to debug-request, current mode: Thread 
xPSR: 0x61000000 pc: 0x000001ce msp: 0x2000ffd8

Flashing ROM...
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000
Enabled ARM Semihosting to show debug output
** Programming Started **
Info : nRF52832-QFAA(build code: E1) 512kB Flash, 64kB RAM
Warn : Adding extra erase range, 0x000056d8 .. 0x00005fff
** Programming Finished **
** Verify Started **
** Verified OK **

Restarting...
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000, semihosting
Enabled ARM Semihosting to show debug output

Sample Log for ST-Link

----- 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)
+ wget -q https://github.com/lupyuen/pinetime-rust-mynewt/releases/download/v4.1.7/mynewt_nosemi.elf.bin -O /tmp/mynewt_nosemi.elf.bin
+ '[' '!' -f /tmp/mynewt_nosemi.elf.bin ']'
+ set +x

----- Flashing /tmp/mynewt_nosemi.elf.bin to address 0x0...
+ 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
xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-12:31)
Licensed under GNU GPL v2
For bug reports, read
        http://openocd.org/doc/doxygen/bugs.html
/tmp/mynewt_nosemi.elf.bin
0x0

nRF52 device has a CTRL-AP dedicated to recover the device from AP lock.
A high level adapter (like a ST-Link) you are currently using cannot access
the CTRL-AP so 'nrf52_recover' command will not work.
Do not enable UICR APPROTECT.

force hard breakpoints
Stopping...
target halted due to debug-request, current mode: Thread 
xPSR: 0x41000000 pc: 0x00000da0 msp: 0x2000ffa0

Flashing ROM...
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000
Enabled ARM Semihosting to show debug output
** Programming Started **
** Programming Finished **
** Verify Started **
** Verified OK **

Restarting...
target halted due to debug-request, current mode: Thread 
xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000, semihosting
Enabled ARM Semihosting to show debug output

**** Done!

pinetime-updater's People

Contributors

bakeromso avatar bmsleight avatar caspermeijn avatar dmlls avatar lupyuen avatar psstoyanov avatar technologyclassroom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

pinetime-updater's Issues

Bootloader logo

This is a great project. Flashing the bootloader and InifiniTime is really easy, but I miss the bootloader logo flasher.
After using the updater I get a garbage screen when booting the PineTime. I assume this is because of the missing bootloader logo.

Updates to bootloader and firmware

Here are links to the latest bootloader and firmware:

Bootloader: https://github.com/JF002/pinetime-mcuboot-bootloader/releases/download/1.0.0/bootloader.bin

Application Firmware: https://github.com/JF002/InfiniTime/releases/download/1.0.0-RC4/pinetime-mcuboot-app-image-1.0.0.bin

I could make a pull request if you would like.

A more permanent solution over hardcoded values would be to check for the most recent stable release and set that for the url value. This would be easier for Infinitime than it would be for the bootloader.

Hacktoberfest

I am going to contribute, as I stated on Twitter, regardless, but could you please tag this as Hacktoberfest friendly so I can use my pull requests toward Hacktoberfest?
hackstuff

ERROR:

I'm just got my pine time about a week ago and an st link v2 and have been trying to reprogram the pinetime. Here is the read from the terminal. Im running manjaro btw

----- 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)

----- Flashing /tmp/mynewt_nosemi.elf.bin to address 0x0...

  • 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
    xPack OpenOCD, x86_64 Open On-Chip Debugger 0.10.0+dev-00378-ge5be992df (2020-06-26-09:27)
    Licensed under GNU GPL v2
    For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
    /tmp/mynewt_nosemi.elf.bin
    0x0

nRF52 device has a CTRL-AP dedicated to recover the device from AP lock.
A high level adapter (like a ST-Link) you are currently using cannot access
the CTRL-AP so 'nrf52_recover' command will not work.
Do not enable UICR APPROTECT.

force hard breakpoints
Error: target voltage may be too low for reliable debugging
Error: init mode failed (unable to connect to the target)

Targets for URL or File Upload

Hi, I'm trying to flash a customized InfiniTime to my PineTime dev kit watch. I was able to flash the latest firmware (option 2), but when I try to download from URL/file the watch is perpetually loading the starting screen. I tried to use the InfiniTime github repository, but had the same error. I am thinking I am typing the wrong path, but am not sure what the right path should be. Would you know where I'm going wrong?

Steps to replicate:

  1. Choose "Download from URL"

Screen Shot 2022-10-21 at 2 18 15 PM

  1. Enter the InfiniTime github repository URL:
    https://github.com/InfiniTimeOrg/InfiniTime

Screen Shot 2022-10-21 at 2 22 31 PM

Comile errors as all all warnings being treated as errors

PR to follow
with fresh raspbian install on Raspberry PI 1

libtool: compile: gcc -DHAVE_CONFIG_H -I. -I./src -I./src -I./src/helper -DPKGDATADIR=\"/usr/local/share/openocd\" -DBINDIR=\"/usr/local/bin\" -I./jimtcl -I./jimtcl -Wall -Wstrict-prototypes -Wformat-security -Wshadow -Wextra -Wno-unused-parameter -Wbad-function-cast -Wcast-align -Wredundant-decls -Werror -g -O2 -MT src/flash/nor/jtagspi.lo -MD -MP -MF src/flash/nor/.deps/jtagspi.Tpo -c src/flash/nor/jtagspi.c -o src/flash/nor/jtagspi.o In file included from ./src/flash/common.h:21, from src/flash/nor/core.h:25, from src/flash/nor/imp.h:22, from src/flash/nor/jtagspi.c:22: src/flash/nor/jtagspi.c: In function ‘jtagspi_write_enable’: ./src/helper/log.h:133:2: error: ‘status’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 133 | log_printf_lf(LOG_LVL_ERROR, __FILE__, __LINE__, __func__, expr) | ^~~~~~~~~~~~~ src/flash/nor/jtagspi.c:262:11: note: ‘status’ was declared here 262 | uint32_t status; | ^~~~~~ src/flash/nor/jtagspi.c: In function ‘jtagspi_wait’: src/flash/nor/jtagspi.c:249:15: error: ‘status’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 249 | if ((status & SPIFLASH_BSY_BIT) == 0) { | ~~~~~~~~^~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors

What's wrong now?

I can't figure out what's wrong now at this step. I don't see "done" and what I do get doesn't completely match your logs.

20200927_010334
20200927_010348
20200927_010359
20200927_010423
20200927_153756

fails after info:clock speed

it outputs nothing after info:clock speed , the cables are connected
2023-03-16-191804

did i do something wrong (edit it still ran infinitime until i tried to flash something on it ).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.