HackerBox 0049: Debug

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.

Install the Arduino IDE and the ESP-32 support package

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

The SerialDebug Library allows you to leverage more advanced debugging in the Arduino IDE.

This Random Nerds Tutorial demonstrates how to use the SerialDebug Library in your projects.

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 support@hackerboxes.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.

6 People Made This Project!

Recommendations

  • Space Contest

    Space Contest
  • Lamps and Lighting Contest

    Lamps and Lighting Contest
  • Organization Contest

    Organization Contest

25 Comments

0
peace4eva04
peace4eva04

1 year ago

How do you connect the female to female wire from the 8x8 Matrix LED and the ESP32?

0
mitchellhayes95
mitchellhayes95

Reply 1 year ago

super late response, but I just stripped one end of the female to female and soldered it on.

0
RichW36
RichW36

Question 1 year ago on Step 3

So I am trying to get the sketch to work that was provided. It will not compile properly. I count 12 compile errors. I removed and reinstalled FastLed and still run into the same errors. This is the error that shows at the bottom . no matching function for call to 'CFastLED::addLeds(CRGB [64], int)'

0
MikeM551
MikeM551

Answer 1 year ago

RichW36
connect the 8x8 Matrix of WS2812B RGB LEDs

Replace the line

FastLED.addLeds(leds, NUM_LEDS);

in the Arduino code with

FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);

change the delay from 4000 to 10 for an interesting effect!

The FastLED.h library is well commented.

Mike M

0
RichW36
RichW36

Reply 1 year ago

Thanks for the reply. I did get this working. And I have got it working with a few different librayies.

0
asmagill121
asmagill121

Reply 1 year ago

Running some of the other examples in the FastLED library, I found that my board conforms to the GRB color ordering, not RGB, so if you're getting unexpected colors, try that.

0
TimGTech
TimGTech

Reply 1 year ago

Assuming everyone received the exact same matrix board, it is also compatible with Adafruit's NeoPixel library. You can load it and use the StrandTest example. Set Data_Pin to A14 and Num_Pixels = 64 and should work just fine. For that matter, any of the examples should work.

0
MikeM551
MikeM551

Reply 1 year ago

On their original code try the following code change. Should be various green brightness.
...
int red = random(0); //256
int green = random(50); //256
int blue = random(0); //256
int rgb = (green << 16) + (red << 8) + (blue);
leds[i] = rgb;
...
works with red and blue as well.
Don't forget the FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS); vice FastLED.addLeds(leds, NUM_LEDS); fix.

something else to try after.

My last five lines of code look like this:

FastLED.show();
// delay(4000);
delay(10);
// leds[i] = 0;
// FastLED.show();


Looks kind of cool actually.

0
asmagill121
asmagill121

Reply 1 year ago

I should have been more explicit — all I had to do was change was the addLeds line to `FastLED.addLeds<WS2812B, DATA_PIN, GRB>` to get the expected output for this code *and* all of the library examples.

0
asmagill121
asmagill121

Reply 1 year ago

though looking closer at your code I see you’re also dropping the randomness of the blue and red to almost nothing... so your changes to the `=random(...)` lines are still needed for a green blinky tile, but the `int rgb = ` line can probably remain as given in the original code with my change to the `addLeds` line.

0
MikeM551
MikeM551

Reply 1 year ago

Ah you do have a different panel. I did modify the fastLED line to GRB, the result is now red. ( nothing else was changed). RGB gives me green as intended. ( red and blue channels off) I left "int rgb = " alone. I thought we all had WS2812B LEDs.

0
bob4343
bob4343

Answer 1 year ago

Change the following line:
FastLED.addLeds(leds, NUM_LEDS);
to:
FastLED.addLeds< WS2812B, DATA_PIN, RGB >(leds, NUM_LEDS);
The code was missing the template parameters. To find the error, I searched all the files for "fastled.addleds" using a text editor, and found the lines 40-59 in RGBCalibrate.ino to be good examples. I used the Github repository for fastLED.

Good hacking!
0
corigami79
corigami79

Reply 1 year ago

I had the same issue, @bob4343 you do have a typo in your fix... should be <WS2812B, ...> this threw me for a loop for a few minutes before I figured it out.

Thanks for digging through the source for the fix though!

0
bob4343
bob4343

Reply 1 year ago

Thanks! I fixed the typo, Instructables really doesn't like the > or < symbols in comments as it deletes them when copy/pasted.

0
petronivs
petronivs

Question 1 year ago on Step 2

I'm having trouble getting the Arduino IDE to connect to the ESP-32 board. I get the below error. According to the linked troubleshooting, this is a known issue and I can get around it by holding down the 'boot' button, but this board has no 'boot' button, and holding down the reset button doesn't seem to work. Thoughts?
Arduino: 1.8.10 (Windows 10), Board: "WEMOS LOLIN32, 80MHz, Default, 240MHz (WiFi/BT), 921600"
Sketch uses 213233 bytes (16%) of program storage space. Maximum is 1310720 bytes.
Global variables use 15380 bytes (4%) of dynamic memory, leaving 312300 bytes for local variables. Maximum is 327680 bytes.
esptool.py v2.6
Serial port COM10
Connecting........_____....._____....._____....._____....._____....._____.....____An error occurred while uploading the sketch
_
A fatal error occurred: Failed to connect to ESP32: Timed out waiting for packet header

0
seaprimate
seaprimate

Answer 1 year ago

Maybe a driver issue if its persistent across boards? Windows 10 seems to love the generic libusbk for usb devices. If all else fails, sometimes that fixes it. Though if you can see it in the ports, then it's probably not that.

Also, I didn't use the "WEMOS LOLIN32" one, I used "ESP32 Dev Module"
upload 921600
cpu 240mhz
flash 80mhz
flash mode QIO
Flash size 4MB(32Mb)
Debug none
PSRAM disabled
Programmer AVRISP MKII

Worked for me.



0
TimGTech
TimGTech

Reply 1 year ago

Just as a side note - you can also select the ESP32 Wrover board. It is almost the same board.

0
edub3605
edub3605

Answer 1 year ago

I am having the same problem. I have tried to change all of the upload speeds and have had no luck. I am also on Window10 with the same version and settings that you have. Also the blue light on my board is flashing really fast as soon as its hooked up. All of my other boards work fine.

0
edub3605
edub3605

Reply 1 year ago

Ok I figured it out. I didn't have the 210x driver. I did that and the held the reset key for a second while it was connecting and it worked.

0
petronivs
petronivs

Reply 1 year ago

How did you get the 210x driver?