November 11, 2016

The Sparkfun ESP32 Thing

I received one of these on November 10, 2016. Features: The LiPo battery connects via a 2mm JST connector (which I now have on order). The battery will charge from USB when USB power is connected.

When plugged in, it seems to run a blink demo out of the box. There is a blue led driven by "pin 5" (and conveniently next to the pin 5 connector). There is also a red power LED next to the USB connector, and a yellow "charge" LED between the red LED and the battery connector. There are also edge pins available to connect the battery if you don't have the 2mm pitch JST connector.

What about an antenna?

The overview drawing indicates that there is some kind of trace antenna, underneath the "sparkfun" silkscreen area. There is no provision for an external antenna.

Get the IDF

The Sparkfun hookup guide only discusses using Arduino for development. That is not what real men use. We want the IDF and cross compiler toolchain. The Hackaday article shines the light on this path.

It is important to clone with the --recursive flag or you don't get the new esptool.py (among other things).

git clone --recursive https://github.com/espressif/esp-idf.git
Cloning into 'esp-idf'...
Checking connectivity... done.
Submodule 'components/bt/lib' (https://github.com/espressif/esp32-bt-lib.git) registered for path 'components/bt/lib'
Submodule 'components/esp32/lib' (https://github.com/espressif/esp32-wifi-lib.git) registered for path 'components/esp32/lib'
Submodule 'components/esptool_py/esptool' (https://github.com/themadinventor/esptool.git) registered for path 'components/esptool_py/esptool'

When you get in the mood to update this stuff, you need a two step process in order to update both the top level and the modules.

git pull
git submodule update --recursive

Get a compiler toolchain

Since I am on a 64 bit linux system, I follow the instructions in docs/linux-setup.rst. You can view these instruction online here (and likely get the most up to date filename). In particular, I fetch the following tarball:
wget https://dl.espressif.com/dl/xtensa-esp32-elf-linux64-1.22.0-59.tar.gz
This is about 33.5M in size.

The question now is, where should this go? I already have my ESP8266 stuff in /opt as /opt/esp-open-sdk/xtensa-lx106-elf. It would make sense to put this right alongside, so I do this:

cd /opt
ln -s esp-open-sdk esp8266
mkdir esp32
cd esp32
tar xzvf /path/xtensa-esp32-elf-linux64-1.22.0-59.tar.gz
mv /path/esp-idf .
After doing this, the compiler paths are analogous as:
/opt/esp32/xtensa-esp32-elf
/opt/esp8266/xtensa-lx106-elf
This is kinda nice.
As the final step:
cd /opt/esp32
git clone https://github.com/espressif/esp-idf-template.git myapp
Now I have all of the esp32 development stuff under /opt/esp32

Fiddle with the demo application

I need some Fedora packages (most of what I need is already installed, but I have not yet needed the following).
dnf install gperf
dnf install ncurses-devel
To use their setup, I need to do this:
export IDF_PATH=/opt/esp32/esp-idf
make menuconfig
This is as far as I have gotten for now.

Figure out the new esptool

This utility was my standby with the ESP8266. There is a significantly revised new version that supports both the ESP8266 and the ESP32. Two important things: Then you can issue commands like this:
./esptool.py -p /dev/ttyUSB1 flash_id
esptool.py v2.0-dev
Connecting...
Detecting chip type... ESP32
Uploading stub...
Running stub...
Stub running...
Manufacturer: ef
Device: 4016
The "stub" business is something new. It is a piece of precompiled code that gets loaded into the ESP32 that adds functionality to the bootloader. Sources are provided (but not required, the precompiled stub code is embedded in the python script).
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org