make a simple debugging featherwing for the m0

20
Debug Header for the Feather [M0] Created by Michael Sklar https://learn.adafruit.com/make-a-simple-debugging-featherwing-for-the-m0 Last updated on 2021-11-15 06:51:34 PM EST ©Adafruit Industries Page 1 of 20

Upload: others

Post on 22-Jun-2022

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Make a Simple Debugging Featherwing for the M0

Debug Header for the Feather [M0]Created by Michael Sklar

https://learn.adafruit.com/make-a-simple-debugging-featherwing-for-the-m0

Last updated on 2021-11-15 06:51:34 PM EST

©Adafruit Industries Page 1 of 20

Page 2: Make a Simple Debugging Featherwing for the M0

3

4

6

7

9

12

15

16

16

16

17

17

19

Table of Contents

Overview

Parts

Board Design

Board Milling

Solder It Up

Arduino Feather Setup

Install up J-Link and GDB for Debugging

Launching the Debugger

• Get Yourself Connected

• J-LINK GDB Server

• .gdbinit file

• GDB client

Debugging the Feather M0

©Adafruit Industries Page 2 of 20

Page 3: Make a Simple Debugging Featherwing for the M0

Overview

The Feather M0 can be used in debug mode using the SEGGER J-LINK (http://

adafru.it/1369) programmer. It needs just a little extra effort to get set up. On the

bottom side of the feather M0 (this is the Bluefruit LE model) there are exposed pads

for the SWCLK and SWDIO pins which are required for JTAG programming. The

SWCLK and SWDIO are actualy in two places on the bottom (use the green circles

above) and avoid the red crossed out square pads.

These four pins must be connected to the Segger J-Link debugger along with a USB

cord to power the circuit. 

Feather M0 [pin2] (Vcc) J-Link SWD [pin 1] (Vcc)

Feather M0 [pin3] (GND) J-Link SWD [pin 3,5,9] (GND)

©Adafruit Industries Page 3 of 20

Page 4: Make a Simple Debugging Featherwing for the M0

Feather M0 [SWCLK] J-Link SWD [pin 4]

Feather M0 [SWDIO] J-Link SWD [pin 2]

Making a custom featherwing board will be much more convenient than manually

wiring each connection into the J-Link 2x10 header.

 

Parts

©Adafruit Industries Page 4 of 20

Page 5: Make a Simple Debugging Featherwing for the M0

In order to use a Feather M0 for debugging some connections need to be made to

the Segger J-Link JTAG Debugger. The following parts can be used to create a JTAG

FeatherWing:

Segger J-Link EDU - JTAG/SWD Debugger (http://adafru.it/1369)

JTAG to SWD Cable Adapter Board (http://adafru.it/2094)

Adafruit Feather M0 (https://adafru.it/u7a) (BLE (http://adafru.it/2995), WiFi (http:

//adafru.it/3010), LoRa (http://adafru.it/3179), Proto (http://adafru.it/2772), Adalog

ger (http://adafru.it/2796), Packet Radio (http://adafru.it/3176), etc.

JST 2-pin cable (https://adafru.it/u7b)

JST-PH 2-Pin SMT Right Angle Connector (http://adafru.it/1769)

Short Feather Male Headers - 12-pin and 16-pin Male Header Set (http://adafru.it

/3002)

2x5 SWD Shrouded JTAG Mini Connector (https://adafru.it/u7c) [Digikey Part#

1175-1629-ND]

You can also use our SWD breakout board:

SWD (2x5 1.27mm) Cable Breakout Board

This adapter board is designed to make it

easier to use ARM dev boards that use

slimmer 2x5 (0.05"/1.27mm pitch) SWD

cables for programming.  It's helpful for

using...

https://www.adafruit.com/product/2743

©Adafruit Industries Page 5 of 20

Page 6: Make a Simple Debugging Featherwing for the M0

Board Design

The above schematic is for the Feather M0 with JTAG connections. It includes two

connectors. The top right is the SWD (2x5) shrouded JTAG connector (https://adafru.it

/u7c). The bottom right connector is Adafruit's JST-PH-2-Pin SMT Right Angle

Connector (http://adafru.it/1769) used to connect the a JST cable to the SWDIO and

SWCLK (circular not square) pads on the bottom side of the Feather M0 boards.

Download the schematic file here (https://adafru.it/u7e).

Featherwing board layout in Eagle format (https://adafru.it/u7f).  You can also access t

he gerber files here (https://adafru.it/u7A) if you are not an Eagle user.

©Adafruit Industries Page 6 of 20

Page 7: Make a Simple Debugging Featherwing for the M0

Board Milling

This is how Otherplan (https://adafru.it/u7B) (the milling software that is free from Oth

ermill (https://adafru.it/u7C)) renders the board. It took about 10 minutes to mill, switch

bits drill and cut out this single sided PCB. I used the following bits:

traces 1/64" end mill

.9mm (36 mil wide drill bit) (http://adafru.it/2120) for the through holes

V30 degree carving bit for cut out

Otherplan can read Eagle BRD files directly or you can import your own gerbers. 

©Adafruit Industries Page 7 of 20

Page 8: Make a Simple Debugging Featherwing for the M0

Blank single sided FR1 PCB mounted up and milled in the Othermill. 

The traces came out just perfect and with the PCB in hand we can go ahead and

solder it up.

©Adafruit Industries Page 8 of 20

Page 9: Make a Simple Debugging Featherwing for the M0

Solder It Up

Place and solder the SWD JTAG connector (2.5 1.27mm). 

Solder the 2-pin JST connector. 

©Adafruit Industries Page 9 of 20

Page 10: Make a Simple Debugging Featherwing for the M0

Solder the short feather male headers (http://adafru.it/3002). Short side up with the

black plastic on the bottom. The only pins that need to be soldered are the ones with

traces running to them (pins 2 and 4). I recommend at least soldering the end pins on

each side to secure the headers.

Mount the JTAG debug featherwing to your Feather M0 module.

©Adafruit Industries Page 10 of 20

Page 11: Make a Simple Debugging Featherwing for the M0

Go ahead and solder the JST pigtail connector to the bottom of your Feather M0

module. If you wish to run the leads through the Feather and FeatherWing mount

holes that might make the wires look a little neater.

JST red lead SWCLK

JST black lead SWDIO

Plug in 2-pin JST connector to JTAG FeatherWing.

©Adafruit Industries Page 11 of 20

Page 12: Make a Simple Debugging Featherwing for the M0

Arduino Feather Setup

Be sure that Arduino --> Preferences --> Additional Boards Manager URLs contains:

https://adafruit.github.io/arduino-board-index/

package_adafruit_index.json

Launch the Arduino app and select Tools --> Board --> Boards Manager. 

©Adafruit Industries Page 12 of 20

Page 13: Make a Simple Debugging Featherwing for the M0

Use the search field and install both the SAMD Board packages. One is from Arduino

and the other is from Adafruit. 

Plug in your Feather M0. Make sure the following is selected under Arduino --> Tools:

Board: "Adafruit Feather M0 (Native USB Port)"

Port: "/dev/cu.usbmodem14211 (Adafruit Feather M0 (Native USB Port)" - or

whatever the port is.

©Adafruit Industries Page 13 of 20

Page 14: Make a Simple Debugging Featherwing for the M0

An ELF binary file is necessary for debugging with JTAG. In order to locate the file we

will enable both of these:

"Show verbose output during:  X compilation  X upload"

The lower window which shows the compile process has the ELF files path and name

highlighted. Not this as it will be necessary when launching gdb. 

©Adafruit Industries Page 14 of 20

Page 15: Make a Simple Debugging Featherwing for the M0

Install up J-Link and GDB for Debugging

Download and install the latest copy of the J-Link GDB server from Segger's site (http

s://adafru.it/u7D). This is available for Windows/OS X/Linux.

On a mac, we run

$ brew install gcc-arm-none-eabi

We want to install an ARM based GDB client. The easiest way to do this on OS/X is to

use BREW (https://adafru.it/u7E). We can search for the latest versions with the above

command then install it.

©Adafruit Industries Page 15 of 20

Page 16: Make a Simple Debugging Featherwing for the M0

Launching the Debugger

Get Yourself Connected

Go ahead and plug in the following. This will be necessary for all debugging sessions.

Micro USB Feather <--> USB Computer

Segger J-Link USB <--> USB Computer

Make sure JST 2-pin connector is plugged in

Make sure J-Link is connected to Adafruit Board and the SWD 2x5 ribbon is

connected to the FeatherWing Header Board we have made.

J-LINK GDB Server

$ sudo /usr/local/bin/JLinkGDBServer \

-device Cortex-M0 -speed auto -if SWD

Launch the  J-Link GDB server from the command line. 

©Adafruit Industries Page 16 of 20

Page 17: Make a Simple Debugging Featherwing for the M0

This is what it looks like when the GDB Server is launched and waiting for a the GDB

client to connect.

.gdbinit file

target remote localhost:2331

monitor device Cortex-M0

monitor speed auto

file /var/folders/_t/fsyrnxxs53v59j1l1xkn9k8r0000gp/T/arduino_build_244528/feather-

m0.ino.elf

load

monitor reset

A .gdbinit file in your home directory ~/.gdbinit will greatly improve your quality of life

when debugging. It gets around the problem of needing to remember the command

sequence, connection ports and file paths to get the debugger going.

GDB client

$ /usr/local/bin/arm-none-eabi-gdb

©Adafruit Industries Page 17 of 20

Page 18: Make a Simple Debugging Featherwing for the M0

The above command will start the gdb client.

and we are off...Now the code is running in full debug mode on our Feather M0 board.

©Adafruit Industries Page 18 of 20

Page 19: Make a Simple Debugging Featherwing for the M0

Debugging the Feather M0

I've found these commands to be the most useful when using gdb:

continue # execute code

^C # stop code get debugger prompt

print # shows value

list <line#> - shows code

next - execute next line of code

break <line#> - stop code ehre

info breakpoints # shows breakpoints

del <breakpoint#> # deletes breakpoints

quit # exits GDB

©Adafruit Industries Page 19 of 20

Page 20: Make a Simple Debugging Featherwing for the M0

(gdb) continue

(gdb) ^C

(gdb) print

(gdb) list

(gdb) next

(gdb) break

(gdb) info breakpoints

(gdb) del

(gdb) quit

©Adafruit Industries Page 20 of 20