Arduino Commands Cheat Sheet



edit

Arduino Commands Cheat Sheet

In this wiki, you will learn how to use SWD Interface to debug your Arduino boards via the J-Link Debug Programmer. For reference, Wio Terminal is used as the hardware to demonstrate the debugging process.

It’s a super cute MP3 player that is great for Arduino powered projects. The only problem being with the documentation. It is a little spotty and I had to work pretty hard to get around a few issues. So here is a little cheat sheet to help you along: How should I wire up the DFPlayer Mini to my Arduino? Arduino Cheat Sheet This is a poster-sized cheat sheet for Arduino programmers. It draws primarily from the Arduino Language Reference, including most of the common, basic syntax and a variety of the built-in functions. It is based on a cheat sheet by Gavin Smith and an SVG adaptation by Frederic Dufourg.

What is SWD Debugging¶

SWD, also known as Serial Wire Debug is a 2-pin interface (SWDIO/SWCLK) of which it's also an alternative JTAG interface that has the same JTAG protocol. SWD uses an ARM CPU standard bi-directional wire protocol, defined in the ARM Debug programmer.

Hardware Connection¶

Before you start, you will need the following materials:

  1. Wio Terminal (or Other Arduino Boards with SWD Interface)

Wio Terminal SWD Interface¶

For Wio Terminal, the SWD interface pads are on the bottom of the front side of Wio Terminal (Bare PCBA without casing). There are three jumper wires that need to be led out:

  • SWCLK
  • SWDIO
  • GND
Arduino Commands Cheat Sheet

Once the jumper wires are soldered on, we can connect them to the J-Link Debug programmer following the SWD Pin Map:

Connect as followed:

  • SWCLK (Wio Terminal) -> SWCLK (J-Link Debug Programmer Pin 7)
  • SWDIO (Wio Terminal) -> SWDIO (J-Link Debug Programmer Pin 9)
  • GND (Wio Terminal) -> GND (J-Link Debug Programmer Pin 4)

Installing J-Link GDB Server for Debugging¶

To debug with J-Link Debug programmer, you will need to download the J-Link GDB Server. Download and install according to your OS.

Arduino Set-up¶

Before launching J-Link GDB Server, you will also need to open Arduino IDE for later configurations.

1. Obtaining the Arduino Sketch ELF File Path¶

Arduino Cheat Sheet Pdf

In the settings of Arduino IDE, make sure that the Show verbose output during compilation and upload are both ticked.

Under the Arduino sketch you want to debug, click Compile (select Wio Termianl as board), and check the log information to get the path of the .elf file location. Let's take Blink as example:

Copy this path and it will be used later for GDB.

For example, in my case:

2. Obtain the GCC Path¶

Under the same sketch compile log information, you can also find the GCC path used by Arduino of which also can be used for J-Link Debug Programmer later.

For example, in my case:

Getting Started with J-Link GDB Server¶

Connect the J-Link Debug Programmer to the PC and also power Wio Terminal from the USB port. Launch the J-Link GDB Server, select the following settings:

  • Connection to J-Link: USB
  • Target Device: Cortex-M4
  • Target Interface: SWD

Select OK and if everything goes well you should see the following screen:

You should see that the listening port will appear and the J-Link GDB server is up and ready!

Launching a GDB Client¶

Sheet

Now you can launch the GDB Client by using the path we've saved earlier from the GCC path in Arduino. Open Terminal and paste the copied path + /arm-none-eabi-gdb:

For Example: /Users/ansonhe/Library/Arduino15/packages/Seeeduino/tools/arm-none-eabi-gcc/7-2017q4/bin/arm-none-eabi-gdb

Run the following commands under gdb:

  1. target remote localhost:2331
  2. monitor device Cortex-M4
  3. monitor speed auto
  4. file + Arduino Sketch ELF File Path, i.e. file /var/folders/7g/10kskmw90bg08j_g_r7flwq40000gn/T/arduino_build_633418/Blink.ino.elf
  5. load
  6. monitor reset
Arduino commands cheat sheet online

Now you can use GDB to debug your Arduino Sketch!

.gdbinit Method¶

Arduino Commands List

You can also create a .gdbinit file, copy the following and save it in the ~/ location to avoid keep repeating setting process for gbd.

Now if you just launch the GDB client and you can start debugging straight away!

Debugging¶

Some useful commands for GDB:

  • continue/cont
  • Ctrl+C
  • next
  • break
  • info break
  • clear
  • delete
  • list

Resources¶

FAQ¶

Q1. How to take off the enclosure of Wio Terminal?

Arduino Commands Cheat Sheet Free

A1. First, take out the 4 rubber pads of 4 corner, and you will see 2 screws that holds the Wio Terminal enclosure together. Simply unscrew them and you can take it apart.