In “Eclipse JTAG Debugging the ESP32 with a SEGGER J-Link” I used a SEGGER J-Link to debug an ESP32 device with JTAG. I looked at using one of the FTDI FT2232HL development boards which are supported by OpenOCD. The FT2232HL is dual high-speed USB to UART/FIFO device, and similar FTDI devices are used on many boards as UART to USB converters. With OpenOCD these devices can be turned into inexpensive JTAG debug probes. This article shows how to use a $10 FTDI board as JTAG interface to program and debug the Espressif ESP32.
Bus Pirate prototype “Ultra” version 1c is technically done, but we came up with some hot last minute additions this weekend. We’ll skip this board and send out the updated version 1d with the additional features at the end of the week.
Version 1c changes:
4 layer PCB
1MHz 12 bit SPI ADC connected directly to the FPGA
Vout/Vref is also measured through the analog multiplexer, which is changed to to the bigger 16bit version (74HCT4067). This will probably change to two 74HCT4051s instead because supplies of the 4067 are skimpy! We can have one “divide by two” 4051 for 5volt measurements on the IO pins, and one 3.3volt 4051 tied directly to the ADC for measuring lower voltage analog stuff
Beefier 3.3volt supply
The 1.2volt supply is now monitored by the MCU for self testing
0.5mm flex cable connector for the display board opens up a bit of board space
Additional ADC measurement point before the back-current shut down protection on the power supply. This gives us a way to include it in the self test and detect when it activates
I’ve been working on a little ESP32 expansion board/shield for an LED project I’ve been working on. One of the nice things about the ESP32 is that it has a peripheral known as “LED control” that provides 16 independent channels of PWM for controlling LED brightness, and my project uses that capability. One of my projects is going to require all 16 channels, so I wanted to do a board that would support 16 channels, but I also wanted a version of the board that would only support 8 channels.
The Bus Pirate pinout was supposed to
be intuitive, except for one Arduino-like mistake.
Each protocol uses the same pin for
similar functions, and the pins used are supposed to “walk” up
the row. 1-Wire uses Master Out Slave In (MOSI, pin number 1). I2C
uses MOSI (1) and CLOCK (2). UART uses MOSI (1) and Master In Slave
Out (MISO, 3). SPI uses MOSI (1), CLOCK (2), MISO(3), and Chip Select
It should have been a nice intuitive progression, except for the unfortunate use of a hideous 2x5pin IDC connector. It’s hard to recall why we used this connector. Probably to keep the board small, provide a keyed connector, and likely because it was in our parts box.
The IDC connector was a poor choice. Not only is it ugly, probes end up using crappy ribbon cable that makes it look even worse. The connector was added without regard for the proper pin order, and used something hard to remember – MISO, CS, MOSI, CLK. Once it was loose in the wild we were stuck with that convention, and that’s how Bus Pirates have been produced for over 10 years!
Bus Pirate Ultra uses a 1x10pin connector called TJC8 2.54mm or 2543 by Chinese suppliers. It’s keyed, but also fits common 2.54mm “DuPont” connectors laying around most workshops. The pinout is DIO1 to DIO8, Vout, and Ground. Each protocol mode is in charge of naming the DIO pins, and the labels are displayed on the LCD above the connector.
We also want to give some thought to the color codes used on the pinout display and probe cables. Typically cable manufacturers stock wire in ten colors: red, orange, yellow, green, blue, purple, gray, white, black, and brown.
Goal one is to make the power and
ground pins an intuitive color pair. Black and red, white and black,
maybe even red and green. A color pair that a beginner in electronics
has probably seen somewhere before.
Goal two is to follow the rainbow. Most people are probably familiar with ROY G BIV, the acronym for the order of colors in a rainbow. We want to start with red and progress downwards in a logical order so that pin one is instantly obvious, and the pins can be identified in a tangled messy probe cable without tracing them back to the source. Indigo and violet colored cable isn’t standard and the colors are hard to tell apart, so they’re usually substituted with purple and brown.
Pin 1 (DIO1) is assigned red. DIO2 to
DIO7 are assigned orange, yellow, green, blue, purple and brown. With
three colors remaining (gray, black, white), white and black are the
obvious choice for the power/ground pin pair. Grey is assigned to
Eventually we’ll need to choose good quality wire and some decent probe hooks for the cable. Sigrok, the open source logic analyzer software project, has a good overview of probe hook options. The rest of this week we’ll work on getting the firmware cleaned up and Ultra v1c board routed. As always, you can follow our latest progress in the forum.
App note from OSRAM about IR LEDs and IR detectors used on touchscreen technologies. Link here (PDF)
Touchscreens as a popular user interface are more and more common. Applications span from public information systems to customer self-service terminals. Thus, as a logical step, more and more devices today feature this kind of user interface, e.g. bank automatic teller machines (ATMs), personal digital assistants (PDAs), mobile phones and PC displays. The widespread popularity is actively supported by standard computer based operating systems, such as e.g. Windows® 7.
The rapid development of CMOS imaging sensors and the development of high power infrared (IR) emitters in slim packages have led to a series of new optical touchscreen technologies. Many of them contain proprietary technology and solutions.
Bus Pirate prototype “Ultra” v1b has an IPS LCD to show pinout labels, voltage levels, and other useful info. The background image was done in Photoshop and is stored in the 32Mbit flash chip on the board. Pin labels and voltage readings are drawn on top of the background image with a fixed-width font.
Most LCD fonts represent each pixel with a single bit (on or off). This is an efficient way to store a font, but the results look jagged and unprofessional. To get a better look, we anti aliased an open source font and then extracted two bits per pixel of color data. The results, shown above, use a four color lookup table to represent the background, text color, and two intermediate colors for anti aliased pixels.
Anti aliasing smooths the edges of each letter with a few pixels in intermediate colors. The bottom line of text is not processed at all, angular and circular edges look jagged and stepped. The top four lines of text use various styles of anti aliasing and the edges appear smoother on a small display.
Real-time anti aliasing on the MCU will take too many resources, so we made a pre-anti aliased font. Instead of storing each pixel as a single bit, we use 2bits of data per pixel and a four color lookup table to draw the characters. The resulting font takes twice as much space as a one bit font, but the extra bit (two extra colors) are used for those nice fuzzy edges.
The background image is designed for characters 14 pixels tall. It’s important to choose a fixed-width monospaced font so that each character has even spacing. We used DejaVu Mono, an open source fixed-width font that is used in Linux. At 14 pixels tall the characters are 10 pixels wide. Our characters will be 10×14 at 2 bits per pixel, that’s 35 bytes each.
In Photoshop we used View->New Guide Layout to create a 10×14 pixel grid, then added the typical range of ASCII characters. We skipped a box between each character so that any stray anti aliased pixels that fall outside the box don’t get included in a neighboring character. We tried several types of anti aliasing, and decided “Windows LCD” looks best on our small display.
At this point we have a grid of nicely anti aliased characters, but Photoshop is using dozens of different colored pixels to make those smooth edges. Before we process the character set we need to reduce that to something manageable. The simplest enhancement to a 1 bit font is to add an extra bit. 2 bits per pixel provides a four color pallet: text, background, and two shades of grey for the anti aliased pixels. We converted the characters to a four color pallet in Photoshop with Image->Mode->Indexed color, then assigned a four color custom pallet and saved the result as a 8bit color bitmap.
Bus Terminal has become a dumping ground for our utility scripts. A small addition loads the font image, crops each character, and outputs the font variables as HEX numbers. The font output goes into a font.h file to include in the Bus Pirate firmware.
lcd.c demonstrates how to use the 2 bit font. Our display uses 16 bits per pixel in 565RGB mode. font_lut16RGB contains our pallet of 4 16 bit color codes. We prefer to start with 24 bit color codes because they’re ubiquitous, so we enter our colors into font_lut24 and pre-calculate the 16 bit color values during initialization. Our color pallet includes the background image color, a white shade for the character, and two grey tones for the anti aliased pixels.
To write a character we loop through the 35 bytes of data, pulling out 2 bits at a time. Each two bit set is used to lookup a color code in the lookup table. The color code is sent to the display via SPI. A lot of data has to be moved to write a single character, 280 bytes each for this font.
This is an example of different anti aliasing methods (sharp/crisp/strong/smooth) using 2 bits/pixel. The line on the bottom has no anti aliasing. Without anti aliasing the bottom line is jagged and rough. The other lines add one bit (two indexed colors) for anti aliasing and look remarkably better, even without tweaking.
Taking it further
The 2 bit font looks much better than a 1 bit font. This same technique could be used to extract 3 or more bits of color data per pixel, but that eventually feels like reinventing the PNG.
This is very much a hack in progress. A few tweaks the pallet during conversion to indexed color that will probably make it look much nicer. Some of the characters in the set hang below the outline, so g, q and p are cut off. While Photoshop is good for extensive tweaking, it’s going to take a lot of effort to make font in different sizes.
It seems possible to render each character, anti alias it, and reduce it to indexed color using Qt libraries like QPaint and QPixelmap. The Photoshop side could be automated in Qt to export any system font in any size with minimal hassle.
Yeah. Those pins are beautifully aligned a very precise 0.1” from where they are supposed to be…
Pro tip: Print out your design and put your components on it so that you can check the design.
Meta pro tip: Follow your pro tips.
Anyway, that’s not the only problem; it turns out that the power and LED parts of the connector are right underneath the end of the board, so you can’t use a normal header on them (you could use a right-angle one if you wanted), so I did a new revision of the board with 1.0” rather than 1.1” for the ESP and extended the board so the connectors are out on the end. That’s on the slow ship from China right now.
Bus Pirate prototype “Ultra” v1c will use a 0.5mm flex cable (FFC/FPC) to connect the display board. Of course we could just order the standard parts from Mouser or SZLCSC, but rooting around on Taobao is fun and gives a better idea of the range of stuff out there. Here’s some Chinese vocabulary that helped us order parts.
Cables that are connected 1:1, pin one of one connector is wired to pin 1 of the other connector, are called 反向. Cables that are connected 1:N, pin one of one connector is wired to the highest number pin of the other connector, are called 同向. We ordered the wrong version of the 1.25mm display cable for v1b, but fortunately the crimps can be carefully removed and replaced in reverse order. This won’t be an option with the flex connector.
Most FPC/FFC connectors are available in two types. Metal contacts on the bottom of the connector slot are called 下接. Metal contacts along the top of the connector slot are called 上接.
Orientation is really important because FPC/FFC cables generally only have contacts exposed on one side of each end. FPC/FFC cables are also available in 反向 / 同向 (1:1/1:N), meaning the exposed contacts are on the same side or opposite side of the ends. We’ll post some photos of these cables when they arrive.
In this post I am going to continue with the DIY signal generator based on the AD9833 IC where I have left in the previous part. Earlier, I have talked how I had built my first analog signal generator’s stage – variable gain amplification circuit. Usually, a generator needs to have an ability to change not only the signal’s amplitude, but also its offset. So, today I will walk you through a circuit which adds an offset to the DIY generator’s output signal.
More details on his blog. See part 1 of this series for the analog signal generator’s stage.
The Bus Pirate prototype “Ultra” v1b has a 10 pin 1.25mm connector for a display daughterboard. We wanted a more dynamic way to keep track of the pinout and other handy information like pin states and voltage levels.
There are various reference stickers and labeled probe cables for the Bus Pirate v3 and v4, but a display frees us from strict pinout conventions and makes setup a lot easier for new hackers. More on the display below.
We wanted to use ePaper!
At first we really wanted to use ePaper. A static, easily readable display is reminiscent of the stickers it replaces, and makes reference to its primary purpose as a label. The slow update speeds also dampen expectations of flashy graphics and interaction.
The three color ePaper shown above was a top candidate, but it requires 180 seconds of rest between updates to stay in spec. Slow updates are acceptable, but we need to be able to change the display more frequently than once every three minutes.
While the two color version of this display doesn’t have this limitation, we ultimately decided that the Dots Per Inch is just too low to look really good. ePaper is also quite expensive compared to IPS LCDs with much higher pixel density.
Our attention turned to inexpensive LCDs. These are not the dodgy panels with limited color and ever-changing driver chips you may have used in the past. About $3 buys a 240×320 pixel 2 inch IPS (view from every angle) display supporting 250K colors, with a simple SPI interface and well known driver chip. We bought samples from two manufacturers, a QT020HLCG00 and a HT020SQV003NS.
With a bunch of colors and the ability to constantly update, we can show a lot of useful info. Each pin has a proper name corresponding to the active mode, along with input/output direction indication. Color caps on each pin match the probe cable wires, the terminal interface and the logic analyzer client.
Starting with v1b we can measure voltage on all 8 IO pins, so we’ll show that on the display. We’re particularly excited about this feature because we always end up jugging multimeter probes to verify levels during a rough hack. Now we can just look at the display!
Both LCDs are approximately the same dimensions, but the solderable flex connector is a slightly different length. The LCD daughterboard has extra long pads that fit both displays. The files for the display board are in the git repo.
The image on this LCD is just a static mock-up exported from Photoshop. Next we’ll need to create a font and write actual values to the display. This is will be tricky because LCD fonts typically look jagged and ugly, and we don’t really have enough power to do anti aliasing on the fly. Follow our latest progress in the forum.