Discussion:
[Freetel-codec2] Dumb SM1000 SWD question, where's pin 1?
Stuart Longland
9 years ago
Permalink
Hi all,

It's a rainy day here in Brisbane, just perfect weather to experiment
with the SM1000, maybe get some voice announcement code happening. I
figured I'd get my shiny ST-Link/V2 dongle working so I can single-step
and debug the code.

I'm looking at the board, I see there's a 3-pin header for SWD: CN1.
There's nothing I can see though that marks which of those pins is pin 1
(aka SWCLK). The only hint I have is R19 connects to it; I can see a
trace from R19 going to the pin closest to the SELECT/BACK buttons.

Am I on the right track to assume that's SWCLK and that the other end is
SWDIO?

Regards,
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

------------------------------------------------------------------------------
Steve
9 years ago
Permalink
The one on the bottom goes to R19 and top goes to R20 looks like. I'm
looking at the PNG in the repository.
Bottom also shows a wider bar on the silkscreen. Bottom being with
silkscreen "power" to the left (nearest PTT).
Stuart Longland
9 years ago
Permalink
Post by Steve
The one on the bottom goes to R19 and top goes to R20 looks like. I'm
looking at the PNG in the repository.
Bottom also shows a wider bar on the silkscreen. Bottom being with
silkscreen "power" to the left (nearest PTT).
Well, now I'm confused.

This is the schematic:
Failed to load image: http://www.longlandclan.id.au/~stuartl/freedv/2015/12/12-swd/sm1000-swd.png

This is what I see:
Failed to load image: http://www.longlandclan.id.au/~stuartl/freedv/2015/12/12-swd/sm1000-swd.jpg

The trace looked to be running from R19 to that top pin, I can see the
thicker bar down the bottom end (sort-of visible in that photo), but I'm
not sure if that's accidental or if that's indeed the convention being used.

I'm used to numbers or a little arrow on the silkscreen. That might be
worthwhile on the next run of SM1000s. :-)

Regards,
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

------------------------------------------------------------------------------
Steve
9 years ago
Permalink
looking at that photo, it's the one on the left. R19 trace sneaks between
the right and middle pins and goes down to the left pin.


On Sat, Dec 12, 2015 at 12:29 AM, Stuart Longland <
...
Stuart Longland
9 years ago
Permalink
Post by Steve
looking at that photo, it's the one on the left. R19 trace sneaks
between the right and middle pins and goes down to the left pin.
Ahh, gotcha. Okay, I'll plug 'er in and see what I get.

Hopefully not smoke signals. :-)

Regards,
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

------------------------------------------------------------------------------
Stuart Longland
9 years ago
Permalink
Post by Stuart Longland
Post by Steve
looking at that photo, it's the one on the left. R19 trace sneaks
between the right and middle pins and goes down to the left pin.
Ahh, gotcha. Okay, I'll plug 'er in and see what I get.
Hopefully not smoke signals. :-)
Okay, took a bit of tinkering, but here's the full detail.

You'll need a recent OpenOCD, likely not the one shipped as a binary in
Debian/Ubuntu. I'm doing this on a Gentoo host, and use
dev-embedded/openocd-9999 which pulls source from their git repository.

You'll also need a cable that exposes the SWD pins from the JTAG header.
The three pins you need are:

Pin 7: SWDIO
Pin 8: GND
Pin 9: SWCLK

Failed to load image: http://www.longlandclan.id.au/~stuartl/freedv/2015/12/12-swd/sm1000-stlinkv2-swd.jpg
shows how to connect this cable. I've actually broken out the other
three signals as well. SWDIO is the green wire, SWCLK is the blue wire,
and the white/orange one is the ground.

Also visible but not used is MCU VDD (orange, pin 1), TRACESWO (brown,
pin 13) and nRST (white/green, pin 15).

Open up two terminal sessions. In the first, create a file in your
local working directory called openocd.cfg with the following content
(thanks to Glen English for getting me started with the ST-Link/V2):

source [find interface/stlink-v2.cfg]
source [find target/stm32f4x.cfg]
reset_config none separate

That last line is important, since we don't connect nRST to the target
on the SM1000.
...
Now, set your breakpoints, when you're happy, use `c` to continue execution.
...
You should be able to stop the program anywhere by hitting ^C, inspect
variables, adjust breakpoints, etc. There are also front-ends to gdb if
that's preferred.

Regards,
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

------------------------------------------------------------------------------
glen english
9 years ago
Permalink
Stuart, get it the wrong way around and worst case is it won't work...
Post by Stuart Longland
Post by Steve
looking at that photo, it's the one on the left. R19 trace sneaks
between the right and middle pins and goes down to the left pin.
Ahh, gotcha. Okay, I'll plug 'er in and see what I get.
------------------------------------------------------------------------------
Stuart Longland
9 years ago
Permalink
Post by glen english
Stuart, get it the wrong way around and worst case is it won't work...
Yeah, figured as much. However, would it then be "not working" because
I wired the connections to the SM1000 wrong, or "not working" because I
buggered up my JTAG break-out cable.

There was a good chance of the latter, since I basically cannibalised my
old serial AVR programmer for its pin header sockets.
--
Stuart Longland (aka Redhatter, VK4MSL)

I haven't lost my mind...
...it's backed up on a tape somewhere.

------------------------------------------------------------------------------
David Rowe
9 years ago
Permalink
Hi Stuart,

Nice work documenting that, I haven't used openocd myself so nice to
have an alternative.

I have added a note to the Rev G change log to add silk screen labels to
the CN1 pins.

Cheers,

David
...
------------------------------------------------------------------------------
glen english
9 years ago
Permalink
nice one STuart good tutorial
Post by Steve
looking at that photo, it's the one on th
------------------------------------------------------------------------------
Steve
9 years ago
Permalink
On Sat, Dec 12, 2015 at 12:29 AM, Stuart Longland <
...
Loading...