How to get started ? Share you development setup!
#1
Star 
Hello,

Like many of you, I've received my dev kit yesterday, and I'm looking forward to run some code on the PineTime.
For now, I'm creating my dev environment with the nrfSDK52 and CMake, just the basic thing (if you're interested : https://github.com/JF002/nrf52-baseproject)

But hey, I'm more a software guy, and I do not want to break the device while trying to connect the SWD pins on the board.

Could you share some photos or videos of your debugging setup so that people like me can see how more experienced people are working?

Thanks!
  Reply
#2
Hi!

Cool idea.


As i'm from the espressif sphere, i had to install everything. I did not tested any of the hardware communication yet, but this is for another night.

I'm a GNU/Linux guy, so i'm using a Debian stretch machine.

Software

I followed this guide to install the tools:
https://gustavovelascoh.wordpress.com/20...-on-linux/

Which was quite nice and everything was working fine so far. I was able to compile one of the nordic SDK examples, i guess this is a good sign.

Hardware

Now begins the hardware setup part. As i said, i did not made any test yet, but i did my standard little setup, hoping my cheap STLink will work as attended. 

The devkit is tiny and "watch-sized". So first, i drilled a small hole on the back of the devkit (pictures will soon be added) to pass some 0.3mm enamel wires, which i soldered on the programming pins. On the other side of the 4 wires, i soldered a handy connector, ready to be abused.
Obviously, you have to keep track on which wire goes where.

A tiny piece of tape should keep the wires from being pulled and tugged to hard.

This kind of enamel wire can be sourced from motors, or transformers.

I guess i will attach the connector somewhere neat. I'll keep sharing what's happening here.
  Reply
#3
Stickied. Good thread.
You can find me on IRC, Discord and Twitter


  Reply
#4
You cant recover a protected nrf52 with stlink.

"Regarding the protection bit, one thing to be aware of is that the ST-LINK V2 (and its various clones) are what OpenOCD calls a "high-level adapter." What does that mean?
The ST-LINK V2 is basically an ST Micro ARM chip running some special firmware which is designed specifically for programming/debugging ARM chips that support the Serial Wire Debug (SWD) interface and protocol. (SWD is a variant of JTAG that uses fewer pins.) The firmware accepts commands from a host computer via USB and then issues the corresponding SWD transactions to the device under test.
By contrast, you have things like the Olimex ARM-OCD-USB-H debugger which is considered a low-level adapter. This device contains an FTDI serial chip, which is basically a dumb device whose pins can be twiddled via host software. It doesn't know anything about SWD or JTAG protocols: the intelligence for that is all in the host software (in this case OpenOCD) and the software twiddles the pins to produce the correct signal patterns that correspond to the SWD transaction protocol.
The ST-LINK V2 is considered a high-level adapter because it accepts high-level commands from the host, and its functionality is limited by whatever the firmware developers decided to implement in it. The Olimex is a low-level debugger because you can basically do anything with it: it can support SWD, JTAG or custom protocols."

from: https://devzone.nordicsemi.com/f/nordic-...229#167229
  Reply
#5
Hi!

I made some pictures of the hardware setup on my side. As i said on my first reply, i used some enamel wires to connect the devKit to a cheap STLink clone. Sorry for the poor quality, just assume i'm using a phone from 2010 (no, it's just uber rotten)

[Image: IMG_20191025_134504.jpg]
[Image: IMG_20191025_134211.jpg]

[Image: IMG_20191025_135408.jpg]

[Image: IMG_20191025_135505.jpg]
I'm mad, and i have a plan.
  Reply
#6
Wow, nice @larzuk!

I think it's a good idea to solder wires to the programming pins so that you don't have to put your finger and hands on the PCB each time you want to program and debug the device !

Can you tell me how did you move the battery? Is it just glued on the PCB or is there something (screw?) that should be removed beforehand?

In the mean time, I received my nrf52-dk. It think I'll use the embedded jlink to program my PineTime!
  Reply
#7
(10-26-2019, 03:13 AM)JF002 Wrote: Can you tell me how did you move the battery? Is it just glued on the PCB or is there something (screw?) that should be removed beforehand?

Battery is just glued and can be lifted, just pull gently.

Mine actually came away too easily: the heartbeat sensor flex came away with it too Smile but that wasn't a problem, because you can locate the flex connector, gently lift the black part at the back, insert the flex into the front white part, press the black part back and all is good.
  Reply
#8
(10-26-2019, 04:08 AM)aaribaud Wrote:
(10-26-2019, 03:13 AM)JF002 Wrote: Can you tell me how did you move the battery? Is it just glued on the PCB or is there something (screw?) that should be removed beforehand?

Battery is just glued and can be lifted, just pull gently.

Mine actually came away too easily: the heartbeat sensor flex came away with it too Smile but that wasn't a problem, because you can locate the flex connector, gently lift the black part at the back, insert the flex into the front white part, press the black part back and all is good.

I seriously recommend taping down the battery when you have put the debug cable in. The battery wires are super-thin and come off easily.
  Reply
#9
Overview:
[Image: IMG_20191028_145617.jpg]

Detail of the SWD pins:
[Image: IMG_20191028_145536.jpg]

The connection is:

J-Link EDU Mini -> 10-wire cable -> SWD breakout board -> DuPont wires -> 4-wire SWD cable (that came with the PineTime) -> PineTime.
The PineTime leans slightly on the debug wire, which helps in making a better connection.


Also, I have bent the antenna slightly to not be that close to the debug wires, to avoid shorts.

I'm using this setup with TinyGo, you can see some more information at https://github.com/tinygo-org/tinygo-sit...inetime.md (will be included at https://tinygo.org/microcontrollers/ with the next release).
  Reply
#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: 40)
.jpg   photo5904619845272580580.jpg (Size: 143.19 KB / Downloads: 32)
.jpg   photo5904619845272580582.jpg (Size: 114.35 KB / Downloads: 30)
  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)