Skip to content

Instantly share code, notes, and snippets.

@fizzyade
Last active January 14, 2022 02:48
Show Gist options
  • Save fizzyade/6a48e0435440bb184ef3329092fb7835 to your computer and use it in GitHub Desktop.
Save fizzyade/6a48e0435440bb184ef3329092fb7835 to your computer and use it in GitHub Desktop.

The Problem

If you've found your way here, it's probably because you've got a shiny new Firebeetle ESP32-E and discovered (at the time of writing this gist) that it doesn't work under Big Sur, this is thanks to the CH340 USB->SERIAL bridge not having any drivers for Big Sur.

The reason for this is that Apple has deprecated kernel extensions in Big Sur, and therefore the existing driver for the CH340 does not work and needs to be re-written to support Big Sur. A fairly lengthy gap has existed since Big Sur and now with no hint of drivers on the horizon, so you probably are going to have to use an alternative solution.

My Solution

Use JTAG. If you have the JTAG pins free on the firebeetle, then with the aid of a JTAG adaptor you can use that to flash the device, and then, with the help of a different USB->SERIAL bridge (FTDI is a good bet, or silicon labs) you can tap the TX line (TTL 3.3 levels) on the firebeetle to the RX line on your serial adaptor.

Now you can flash the device over JTAG, and can see the data that the ESP32 transmits on your alternative serial port.

The following script is my "compile, flash, run" script, you will need to adapt it by changing the serial port name and the serial port to match your configuration.

#!env /bin/bash

idf.py build

if [ $? -ne 0 ]; then
        tput setaf 1; echo -e "\r\nBUILD FAILED.\r\n"
        exit 1
fi

openocd -f interface/jlink.cfg -f board/esp-wroom-32.cfg -c "program_esp build/hugh.bin 0x10000;reset;exit"

if [ $? -ne 0 ];then
        tput setaf 1; echo -e "\r\nFLASH FAILED.\r\n"
        exit 1
fi

idf.py monitor -p /dev/tty.usbserial-A123456

In addition to this, I also have a "reset" script that omits the flashing stage and just attaches to the ESP32 and performs a JTAG reset and then attaches to the UART we have tapped into.

#!/usr/bin/env bash

openocd -f interface/jlink.cfg -f board/esp-wroom-32.cfg -c "init;reset;exit"
idf.py monitor -p /dev/tty.usbserial-A123456

Advantages

Now that you have the ESP32 connected over JTAG, you now have the ability to debug code using GDB, this is something that is extremely useful and provides a much easier way debugging complex code as you can step through your program line-by-line (or indeed, instruction-by-instruction) and see the contents of variables, memory or registers in real-time.

Issues

I've not spent very much time on this from the initial "getting it working", it's working for my needs. If your application puts the ESP32 in sleep mode then the JTAG interface will also be asleep and you cannot attach to it until the processor wakes up, it should be possible to send a command to reset the device via the JTAG interface, but I am not familiar with openocd and I'm not sure of how to acheive this, and, well, the documentation for openocd is atrocious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment