Introduction: HackerBox 0049: Debug
Greetings to HackerBox Hackers around the world! For HackerBox 0049, we are experimenting with debugging digital microcontroller systems, configuring the LOLIN32 ESP-32 WiFi Bluetooth platform within the Arduino IDE, applying the FastLED Animation Library with an 8x8 matrix of addressable RGB LEDs, exploring Serial Monitor code debugging techniques, leveraging a FTDI 2232HL module for JTAG debugging of microcontroller systems, and preparing a DIY Logic Analyzer for use in various hardware debug and test scenarios.
This Instructable contains information for getting started with HackerBox 0049, which can be purchased here while supplies last. If you would like to receive a HackerBox like this right in your mailbox each month, please subscribe at HackerBoxes.com and join the revolution!
HackerBoxes is the monthly subscription box service for enthusiasts of electronics and computer technology - Hardware Hackers - The Dreamers of Dreams.
Step 1: Content List for HackerBox 0049
- Wemos LOLIN32 ESP-32 Module
- FTDI 2232HL USB Module
- CY7C68013A Mini Board
- 8x8 Matrix of WS2812B RGB LEDs
- Rainbow Set of Mini Grabber Clips
- Set of Female-Female Dupont Jumpers
- Exclusive HackerBox Thinking Cap
- Going Incognito Sticker
- Skull SIMM Sticker
Some other things that will be helpful:
- Soldering iron, solder, and basic soldering tools
- Computer for running software tools
Most importantly, you will need a sense of adventure, hacker spirit, patience, and curiosity. Building and experimenting with electronics, while very rewarding, can be tricky, challenging, and even frustrating at times. The goal is progress, not perfection. When you persist and enjoy the adventure, a great deal of satisfaction can be derived from this hobby. Take each step slowly, mind the details, and don't be afraid to ask for help.
There is a wealth of information for current and prospective members in the HackerBoxes FAQ. Almost all of the non-technical support emails that we receive are already answered there, so we really appreciate your taking a few minutes to read the FAQ.
Step 2: Wemos LOLIN32 ESP-32 Module
Make the initial tests of the Wemos LOLIN32 ESP-32 Module WiFi Bluetooth platform before soldering the header pins onto the module.
Under tools>board, be sure to select the "WeMos LOLIN32"
Load the example code at Files>Examples>Basics>Blink and program it to the WeMos LOLIN32
The example program should cause the blue LED on the module to blink. Experiment with modifying the delay parameters to make the LED blink with different patterns. This is always a good exercise to build confidence in programming a new microcontroller module.
Once you are comfortable with the module's operation and how to program it, carefully solder the two rows of header pins into place and test loading programs once again.
Step 3: Matrix of 64 RGB LEDs
Install the FastLED Animation Library for the Arduino IDE.
Connect the LED Matrix as shown.
Note that the LED "Data In" is wired to the ESP32 Pin 13 (A14).
When turning on more than a handful of LEDs at a time, especially to full brightness, consider using a higher-current 5V supply instead of the 5V pin on the LOLIN32.
Program the LEDmatrix demo sketch which blinks a random element with a random color for four seconds each.
Step 4: Simple Serial Monitor Debugging for Arduino IDE
One of the simplest and quickest methods for debugging an Arduino sketch is to use the serial monitor to observe output from Serial.print statements during execution of the code.
In the LEDmatrix demo sketch, uncomment the line "//#define DEBUG 1" by removing the two forward slashes.
This will turn on Serial Monitor Debugging in the sketch. Opening the IDE serial monitor to 9600 baud will show the debug output. Review the code to see how these output are generated.
Such serial output statements can be used to flag when execution enters/exits a certain function or area of code. Statements can also be inserted (as shown) to output values used in the program to monitor how they change in different portions of a program or in response to various inputs or other conditions.
Step 5: Advanced Serial Debugging for Arduino IDE
Step 6: JTAG Debugging With the FT2232HL Module
The FT2232H (datasheet and more) is a 5th generation bridge chip between USB 2.0 Hi-Speed (480Mb/s) and UART/FIFO. It has the capability of being configured to a variety of industry standard serial or parallel interfaces. The FT2232H has two multi-protocol synchronous serial engines (MPSSEs) which allow for communication using JTAG, I2C and SPI on two channels simultaneously.
JTAG (Joint Test Action Group) is an industry standard for verifying designs and testing printed circuit boards. Although JTAG's early applications targeted board level testing, JTAG has evolved to be used as the primary means of accessing sub-blocks of integrated circuits, making it an essential mechanism for debugging embedded systems which might not have any other debug-capable communications channel. A "JTAG adapter" uses JTAG as the transport mechanism to access on-chip debug modules inside the target CPU. Those modules let developers debug the software of an embedded system directly at the machine instruction level or in terms of high level language source code.
JTAG Debugging the ESP32 with FT2232 and OpenOCD
In-Circuit Debugging the ESP32 using an FTDI 2232HL based JTAG adapter
OpenOCD the Open On-Chip Debugger
Also check out this cool guide from Adafruit demonstrating how to use an FT232H to connect to I2C and SPI sensors and breakouts from any desktop PC running Windows, Mac OSX, or Linux.
Step 7: DIY Logic Analyzer - CY7C68013A Mini Board
A logic analyzer is an electronic instrument that captures and displays multiple signals from a digital system or digital circuit. Login analyzers can be very useful for debugging digital electronic system.
The sigrok project is a portable, cross-platform, open source signal analysis software suite that supports various device types including logic analyzers, oscilloscopes, etc.
The CY7C68013A Mini Board is a Cypress FX2LP evaluation board. The board can be used as a USB-based, 16-channel logic analyzer with up to a 24MHz sampling rate. Based upon hardware quite similar to the Saleae Logic, the sigrok open-source fx2lafw firmware can support operation as a logic analyzer.
Instructable demonstrating Logic Analyzer Conversion of the Mini Boad
For interfacing logic signals from a target system into the logic analyzer it is helpful to have very small clip leads. A female Dupont jumper with one end removed can be soldered onto a mini-grabber clip. Preparing a set of these can be useful in many hardware debug scenarios requiring a logic analyzer.
Step 8: Exclusive HackerBox Thinking Cap
We hope you are enjoying this month's HackerBox adventure into electronics and computer technology. Reach out and share your success in the comments below or on the HackerBoxes Facebook Group. Also, remember that you can email email@example.com anytime if you have a question or need some help.
What's Next? Join the revolution. Live the HackLife. Get a cool box of hackable gear delivered right to your mailbox each month. Surf over to HackerBoxes.com and sign up for your monthly HackerBox subscription.