Don’t Tempt the Demo Gods

Including a live technical demonstration as part of a presentation is a lot like walking a tightrope without a net. Which isn’t to say that we don’t do it — we just keep our fingers crossed and bring our lucky horseshoe. The demo gods have smote [Quinn] a mighty blow, in front of a class at Stanford, no less.


[Quinn]’s scratch-built computer, Veronica, failed to boot in front of a hall of eager students. When the pressure was off, in the comfort of her own lab, [Quinn] got to debugging. You should read her blog post if you’re at all interested in retrocomputing or troubleshooting of low-level hardware bugs. But if you just can’t spare the five minutes for a pleasant read, here’s a spoiler: watch out for flaky card-edge connectors. All’s well that ends well, with a game of pong.

We’ve been following Veronica from her very first clock cycles, so we’re happy to see her back on her feet again. Good job, [Quinn]!

Squash Your ESP-8266 Bugs with ESP-gdbstub

We hope we’re not insulting you by suggesting this, but it’s possible that even the best among us may be faced with bugs in our embedded code from time to time. And while we’re great fans of printf debugging over the serial port, and its high-speed equivalent — flipping a GPIO pin — there’s a time when your bug is so deep that having a real debugger is the best way to dig it out.

[slaff] has been doing some great work documenting C/C++ programming on the ESP-8266, mostly using Eclipse and some of the Arduino libraries. In the fourth part of his series of posts, he walks through using a couple debugger options for the ESP. What makes this all work is the ESP-gdbstub code from Espressif themselves. gdbstub looks great — it works both with the standard SDK as well as with FreeRTOS, so you can debug your ESP-8266 code whether it’s in an OS or on the bare metal. And all this just using the standard serial connection that’s used for programming.

Now, this still may not help with timing-related bugs. ESP-gdbstub uses the serial port, after all. But having the ability to set breakpoints and interactively inspect what’s going on in the chip’s memory is priceless, and doing so with no extra hardware connections is brilliant.

Continue reading “Squash Your ESP-8266 Bugs with ESP-gdbstub”

uController Code Profiler Debugs Your Microcontroller

When working on digital circuits that operate at high frequencies it helps to have some special tools on hand. Things like oscilloscopes and logic analyzers are priceless when something isn’t working right. Another great tool would be this hardware-based profiler that [Mike] came up with while he was working on another project.

The profiler connects to USB and shows up as a serial port. Normally [Mike] used a set of LEDs to get information about how his microcontrollers work, but for this project that wasn’t enough. The uController Code Profiler can provide the main loop running time, time functions and sections of code, keep track of variables, and a few other tasks as well, all with nanosecond resolution.

The source code isn’t provided but a hex file is available, along with a schematic and an include file, if you want to try this one out on your next project. Like this homemade logic analyzer, this could be a powerful tool in your microcontroller arsenal. Simply include the file with various pieces of your code to get it up and running!

Execution Tracing on Cortex-M3 Microcontrollers

The higher-power ARM micros have a bunch of debugging tools for program and data tracing, as you would expect. This feature – CoreSight Trace Macrocells – is also found in the lowly ARM Cortex M3 microcontroller. The Cortex M3 is finding its way into a lot of projects, and [Petteri] wondered why these debugging tools weren’t seen often enough. Was it a question of a lack of tools, or a lack of documentation? It doesn’t really matter now, as he figured out how to do it with a cheap logic analyzer and some decoders for the trace signals.

There are two trace blocks in most of the Cortex M3 chips: the ITM and ETM. The Instrumentation Trace Macrocell is the higher level of the two, tracing watchpoints, and interrupts. The Embedded Trace Macrocell shows every single instruction executed in the CPU.  Both of these can be read with a cheap FX2-based logic analyzer that can be found through the usual outlets for about $10. The problem then becomes software, for which [Petteri] wrote a few decoders.

To demonstrate the debugging capability, [Petteri] tracked down a bug in his CNC controller of choice, the Smoothieboard. Every once in a great while, the machine would miss a step. With the help of the trace tool and by underclocking the micro, [Petteri] found the bug in the form of a rounding error of the extruder. Now that he knows what the bug is, he can figure out a way to fix it. He hasn’t figured that out yet. Still, knowing what to fix is invaluable and something that couldn’t be found with the normal set of tools.

Turn your BeagleBoneBlack in to a 14-channel, 100Msps Logic Analyzer

The BeagleBoneBlack is a SoC of choice for many hackers – and quite rightly so – given its powerful features. [abhishek] is majoring in E&E from IIT-Kharagpur, India and in 2014 applied for a project at via the Google Summer of Code project (GSoC). His project, BeagleLogic aims to realize a logic analyzer using the Programmable Real-Time units on board the AM335X SoC family that powers the BeagleBone and the BeagleBone Black.

The project helps create bindings of the PRU with sigrok, and also provides a web-based front-end so that the logic analyzer can be accessed in much the same way as one would use the Cloud9 IDE on the BeagleBone/BeagleBone Black to create a new application with BoneScript.

Besides it’s obvious use as a debugging tool, the logic analyzer can also be a learning tool that can be used to understand digital signals. BeagleLogic turns the BeagleBone Black into a 14-channel, 100Msps Logic Analyzer. Once loaded, it presents itself as a character device node /dev/beaglelogic. In stand-alone mode, it can do binary captures without any special client software. And when used in conjunction with the sigrok library, BeagleLogic supports software triggers and decoding for over 30 different digital protocols.

The analyzer can sample signals from 10Hz upto 100MHz, in 8 or 16 bits and up to a maximum of 14 channels. Sample depth depends on free RAM, and upto 320MB can be reserved for BeagleLogic. There’s also a web interface, which, once installed on the BeagleBone, can be accessed from port 4000 and can be used for low-volume captures (up to 3K samples).

[abhishek] recently added the BeagleLogic Cape which can be used to debug logic circuits up to 5V safely. Source files for BeagleLogic as well as the Cape are available via his github repos. [abhishek] blogged about his project on his website where there’s a lot more information and links to be found. Catch a video of BeagleLogic after the break.

Continue reading “Turn your BeagleBoneBlack in to a 14-channel, 100Msps Logic Analyzer”

Scripting Debug Sessions: Python for GDB Remote Serial Protocol

Are you tired of hammering out the same commands over and over again in GDB? If not, we highly encourage you take more advantage of The GNU Project Debugger, which is a fantastic way to poke around inside your microcontrollers while they’re running a program.

Back to the matter at hand. [Stef] put together a Python program that leverages GDB’s Remote Serial Protocol. He calls it pyrsp and the talk he recently gave about it can be seen below.

The core feature is the ability to add a callback in your C code that triggers the Python script. Think of this a little bit like a print statement, except you have so much more power since it’s Python and GDB doing the “printing”. Anything that can be done at a breakpoint in GDB can now be executed automatically. So if you need to check a group of registers at every loop execution for hundreds of loops your wrists are going to thank you. Better yet, you can use Python to do the sanity checks automatically, continuing when the data is good and alerting you when it’s not. Neat!

Continue reading “Scripting Debug Sessions: Python for GDB Remote Serial Protocol”

Proper Debugging for Energia Sketches

Moving a sketch from Energia to Code Composer Studio

Energia is a tool that brings the Arduino and Wiring framework to Texas Instruments’ MSP430 microcontrollers and the MSP430 Launchpad development board. This allows for easy development in an Arduino-like environment while targeting a different microcontroller family.

One problem with Energia and Arduino is the difficulty of debugging. Usually, we’re stuck putting a Serial.println(); and watching the serial port to trace what our program is doing. Other options include blinking LEDs, or using external displays.

Code Composer Studio, TI’s official development tool, allows for line-by-line debugging of applications. You can set breakpoints, watch the value of variables, and step through an application one instruction at a time.

The good news is that the latest version of Code Composer Studio supports importing Energia sketches. Once imported, you can step through the code and easily debug your application. This is a huge help to people developing more complex software using Energia, such as libraries.

TI gives us an overview of the new feature in a video after the break.

[Thanks to Adrian for the tip!]

Continue reading “Proper Debugging for Energia Sketches”