OpenOCD (Open On-Chip Debugger) is the open-source tool that we use to flash and debug PineTime.
OpenOCD runs on our Raspberry Pi and connects via GPIO Pins to the SWD (Serial Wire Debug) port of PineTime to perform flashing and debugging.
Because SWD is a serial protocol, OpenOCD needs to have very precise timing in order to control PineTime correctly. (More about SWD)
OpenOCD on Raspberry Pi uses the Broadcom GPIO driver to achieve precise timing. We can see this in the OpenOCD configuration file for Raspberry Pi: swd-pi.ocd
Other single-board computers like ROCK64 and Nvidia Jetson Nano don't run on the Broadcom microcontroller. So this OpenOCD configuration won't work.
OpenOCD works reliably on Raspberry Pi when there are no background tasks running, because OpenOCD uses timing-sensitive Bit-Banging to send data over the GPIO Pins. I recommend booting Raspberry Pi in Console mode and connecting to Pi via ssh to perform flashing...
ssh pi@raspberrypi.local
Disconnect the HDMI cable from the Pi while flashing, because updating the display requires computing power too.
Is it possible to implement the SWD protocol with Raspberry Pi's reliable Bidirectional SPI interface, instead of unreliable Bit-Banging GPIO?
Work in progress...
https://github.com/lupyuen/pi-swd-spi
https://docs.google.com/spreadsheets/d/12oXe1MTTEZVIbdmFXsOgOXVFHCQnYVvIw6fRpIQZybg/edit#gid=0
https://twitter.com/MisterTechBlog/status/1216290917130199040?s=20