How to get started ? Share you development setup!
#10
TLDR: dont buy a STlink clone if you dont know what to do with it.

so i bought a STlink v2 clone, and i though since it spoke SWD it would "just work" TM, that is not the case. if i had read up on the topic i would probably bought a jlink (supported by nrf CommandLineTools and their suite) or a STM32 bluepill (flash it with black magic probe).
Since the STlink firmware only knows about how stm32 chips work it does not know how to unlock and send other specific commands to a nRF52 chip.
and the pinetime development kit comes with a locked firmware since the hardware design was borrowed from an existing product.

But if you already have a stlink programmer and a raspberry pi (similar boards should work aswell but might need extra steps), you can use that to get started.

starting out i  on the raspberry pi installed openocd

Code:
cd ~
sudo apt-get update
sudo apt-get install git autoconf libtool make pkg-config libusb-1.0-0 libusb-1.0-0-dev
git clone http://openocd.zylin.com/openocd
cd openocd
./bootstrap
./configure --enable-sysfsgpio --enable-bcm2835gpio
make
sudo make install

after that is done, i spent some time figuring out how openocd worked, once i actually started reading and thinking about what openocd responed, and some helpful users in the pinetime chat, i eventually found that i should connect the pinetime to the rpi with
  • pinnumber, rpi name - pinetime
  • 1, 3v3 - 3,3V VCC
  • 3, GND - GND
  • 22, BCM 25 - SWDIO
  • 23, BCM 11 - SWDCLK
i also put a piece of electrical tape on the antenna to keep it from shorting out.

then i command below on the raspberry pi to read if it was lock
Code:
sudo openocd -f interface/raspberrypi2-native.cfg -c "transport select swd" -f target/nrf52.cfg -d2 -c "init" -c "nrf52.dap apreg 1 0x0c"
and i got a 0x0000000 back and then i ran to unlock and then read it again to verify
Code:
sudo openocd -f interface/raspberrypi2-native.cfg -c "transport select swd" -f target/nrf52.cfg -d2 -c "init" -c "nrf52.dap apreg 1 0x04 0x01"
sudo openocd -f interface/raspberrypi2-native.cfg -c "transport select swd" -f target/nrf52.cfg -d2 -c "init" -c "nrf52.dap apreg 1 0x0c"
and then disconnected the pinetimes cables and reconnected them, and ran
Code:
sudo openocd -f interface/raspberrypi2-native.cfg -c "transport select swd" -f target/nrf52.cfg -d2 -c "init" -c "nrf52.dap apreg 1 0x0c"

to see that the unlock is persistent over reboots, i had to do this 3 times before it actually persisted. now the raspberry pi part is over and i could start development with the stlink and my laptop instead.

on my laptop with openocd  0.10.0+dev-00954-gded679902 (2019-10-31-15:43)
i ran openocd and it repsoned with

Code:
$ sudo openocd -f interface/stlink.cfg -f target/nrf52.cfg -c "init" -c "reset"

Open On-Chip Debugger 0.10.0+dev-00954-gded679902 (2019-10-31-15:43)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "hla_swd". To override use 'transport select <transport>'.
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
Info : clock speed 1000 kHz
Info : STLINK V2J17S4 (API v2) VID:PID 0483:3748
Info : Target voltage: 3.224851
Info : nrf52.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : Listening on port 3333 for gdb connections
Info : Listening on port 6666 for tcl connections
Info : Listening on port 4444 for telnet connections

and from there i can connect to telnet or GDB and do development, i have not gotten that far yet

.jpg   photo5904619845272580584.jpg (Size: 140.45 KB / Downloads: 810)
.jpg   photo5904619845272580580.jpg (Size: 143.19 KB / Downloads: 655)
.jpg   photo5904619845272580582.jpg (Size: 114.35 KB / Downloads: 680)


Messages In This Thread
RE: How to get started ? Share you development setup! - by luben93 - 11-02-2019, 06:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Looking to sink my teeth in to development, but need a bit of direction. wilsonjholmes 5 4,471 03-03-2022, 10:02 AM
Last Post: danimations

Forum Jump:


Users browsing this thread: 1 Guest(s)