What is “hardware debugging”?
“Debugging” means getting rid of “bugs” - program errors. The main idea of debugging is that by using a program called a “debugger” you can stop the running of the program and look closely at what is happening in the code. It makes finding errors a lot easier.
Hardware debugging with physical devices such as Pokitto means that a “hardware debugger” is connected to Pokitto. This hardware debugger, such as Segger J-Link (of which you can get a very cheap and legal version here) connects with a 10-pin cable to the “SWD” connector on Pokitto. Hardware debugging is not difficult, but it is also not easy to explain to someone with little or no experience of programming. Therefore, if this feels difficult to understand, do not worry. Learn to program easier things first and then come back to this. We will be helping users who are interested in hardware debugging here on the Pokitto forums.
Stuff you need for hardware debugging
1. Hardware debugger. I recommend the Segger J-Link, just because the software support is so great. At 19,95$ from Adafruit, there is no good reason to use anything else.You can easily manage with the EDU version of J-Link as it has no real limitations - the only limitation is that EDU is not intended for commercial use.
2. 10-pin SWD cable, 1.27mm (0.05") pin pitch, 2 rows by 5 pins IDC cable. cable sold by Adafruit
3. 10-pin SWD header connector. Can be of boxed (plastic collar around header) or plain type (no plastic collar around pins). Note that the “notch” in the collar has to be the same direction as the “notch” indicated by the graphics on the Pokitto PCB! (SWD header sold by Adafruit)
4. Hardware-debugging capable IDE, such as EmBitz Hardware debugging requires, that the development environment supports hardware debugging. Therefore, you can not do hardware debugging with the mbed online IDE. I recommend you use EmBitz at first and then move on to more sophisticated tools.
Segger J-Link EDU Mini sold by Adafruit at just under 20$!
Location of SWD connector pads on bottom side of Pokitto. Note the “gap” on the outline drawn on the PCB - it shows you which way around the cable is inserted for SWD debugging
10-pin “SWD cable” also sold by Adafruit (you can easily find on Ebay also)
10-pin “SWD connector” sold by Adafruit. Very common, easy to find elsewhere also
Preparations for Hardware debugging
1. Solder the 10-Pin connector on the Pokitto PCB Soldering the 10 pin header on the PCB is actually quite easy. Just put the connector on the pads (check that the notch is in the right direction). Gently warm up each leg and pad with the tip of the solder iron and bring some solder to the joint. A thin solder wire makes this easier. You can use a bit of tape on the other side to keep the header in place while you do the first solders on the other side. In any case - it’s easy.
2. Get the LPC11U6X.svd file for your project The extension “.svd” stands for System View Description file. A SVD file describes the internal structure of the microcontroller / processor to the Debugger program. It describes the registers and ports, their names and what kind of values they can hold.
LPC11U6x.svd (831.2 KB)
3. Put the correct settings into the Debug settings of your project To find the debugging settings go to **Debug->Interfaces". First put the SVD file you downloaded to the “Device file” box.
Debug settings are under “Debug->Interfaces”
The LPC11U6X.svd SVD file goes into the box shown.
4. Put correct GDB server settings for the Debug interface GDB Server is the program that actually does the communication between your computer (=GDB client program run by the EmBitz IDE) and the LPC11U68 chip. GDB Server is the “translator” that talks to the chip. It opens up a localhost port at 2331. The GDB client connects to that port. The GDB server then physically controls the LPC11U68 chip of Pokitto through the J-Link adapter (or other HW adapter that you are using).
Important! to set the target device, select Device family as NXP. Then click **Settings >>" button. In the pop-up window, select “LPC11U37” as target (this is because LPC11U68 is so new, its not on the list!) LPC11U37 and LPC11U68 are so closely related, the settings are the same. Finally, you can rename the target to “LPC11U68” just by typing in the box.
Correct J-Link GDB Server settings for debugging. J-Link directory may be different, depending on how new your J-Link software version is
First select “LPC11U37” as target…
…and then you can rename it LPC11U68. It will work, don’t worry!
Hardware debugging setup is DONE!
This article will get a followup in the form of a hardware debugging tutorial at a later time!