Skip to content

Instantly share code, notes, and snippets.

@pfeerick
Last active January 14, 2021 23:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pfeerick/59bdb78710bb43670d44c0ab5f8a2572 to your computer and use it in GitHub Desktop.
Save pfeerick/59bdb78710bb43670d44c0ab5f8a2572 to your computer and use it in GitHub Desktop.
stlink pinetime swd
#!/bin/bash
OCD_SCRIPTS=/home/pfeerick/repos
openocd -f ${OCD_SCRIPTS}/stlink.cfg -f ${OCD_SCRIPTS}/flash_app.ocd
if {[ info exists filename ]} {
echo "**** Flashing specified firmware : $filename"
} else {
set filename "/home/pfeerick/repos/Pinetime/build/output/image-0.10.0.bin"
# set filename "/home/pfeerick/repos/joaq-pinetime/build/src/pinetime-app-0.9.1.bin"
echo "**** Flashing default firmware : $filename"
}
echo "**** Connecting to device..."
init
echo "**** Flashing new firmware..."
program $filename verify 0x00008000
#program $filename verify 0x00000000
echo "**** Restarting PineTime..."
reset init
echo "**** Done!"
exit
if {[ info exists bootloader ]} {
echo " ==> Flashing custom bootloader: $bootloader"
} else {
set bootloader "/home/pfeerick/repos/Pinetime/build/output/bootloader.bin"
echo " ==> Flashing default bootloader : $bootloader"
}
if {[ info exists firmware ]} {
echo " ==> Flashing custom app firmware: $firmware"
} else {
set firmware "/home/pfeerick/repos/Pinetime/build/output/image-0.10.0.bin"
echo " ==> Flashing default app firmware : $firmware"
}
echo " ==> Connecting to device..."
init
echo " ==> Flashing bootloader..."
program $bootloader verify 0x00000000
echo " ==> Flashing app firmware..."
program $firmware verify 0x00008000
echo " ==> Restarting PineTime..."
reset
echo " ==> Done!"
exit
#!/bin/bash
OCD_SCRIPTS=/home/pfeerick/repos
openocd -f ${OCD_SCRIPTS}/stlink.cfg -f ${OCD_SCRIPTS}/flash_bootloader_app.ocd
Open On-Chip Debugger 0.10.0+dev-01514-ga8edbd020-dirty (2020-11-18-17:44)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
force hard breakpoints
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
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.
==> Flashing default bootloader : /home/pfeerick/repos/Pinetime/build/output/bootloader.bin
==> Flashing default app firmware : /home/pfeerick/repos/Pinetime/build/output/image-0.10.0.bin
==> Connecting to device...
Info : clock speed 1000 kHz
Info : STLINK V2J31S7 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.245563
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : starting gdb server for nrf52.cpu on 3333
Info : Listening on port 3333 for gdb connections
==> Flashing bootloader...
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0xfffffffe msp: 0xfffffffc
** Programming Started **
Info : nRF52832-QFAA(build code: E0) 512kB Flash, 64kB RAM
Warn : Adding extra erase range, 0x00005490 .. 0x00005fff
** Programming Finished **
** Verify Started **
** Verified OK **
==> Flashing app firmware...
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x000000d8 msp: 0x20010000
** Programming Started **
Warn : Adding extra erase range, 0x0004bf84 .. 0x0004bfff
** Programming Finished **
** Verify Started **
** Verified OK **
==> Restarting PineTime...
==> Done!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment