Intro

If you’d like to broaden your software development skills, it’s pretty easy to get a bit “closer to the metal”. There are several system on a chip or single board microcontrollers suitable for hobby projects. One of the popular options is Espressif’s ESP32, A SOC microcontroller with integrated WIFI and Bluetooth.

They’re pretty cheap, starting at $5, you can get them from Adafruit, eBay or your local electronics shop (are they still a thing?).

Setup

Before you get to use it for something useful, you’ve got to instruct it what to do. That is, to write the software and then flash it (copy it on the device).

There are several guides on how to set up your development environment. I’ve used a mash up of instructions from Hackaday and Espressif’s how to get started.

It doesn’t really matter which one of the instructions you pick, you’ll end up performing the following steps:

  • Setup the toolchain - the software that’s going to compile your executable
  • Copy esp-inf - the framework used to develop said executable
  • Setup paths - the toolchain needs to know about esp-inf
  • Install driver - because you’ll need a driver to connect to the device, using a basic USB cable. Installing this driver will create a new device /dev/cu.SLAB_USBtoUART, that’s going to be used to transfer the data to the device.
  • Test the connection - connect the device using the USB cable, and then run the following macOS command: screen -r /dev/cu.SLAB_USBtoUART 115200.

Running your own software

Start by copying the hello world example provided by esp-ifd. After copying of any of the examples, change directory to that folder and run make flash. That should build the project and copy it to the device. To monitor the running program, run make monitor.

This will get you started. The next steps are to change one of the examples and make it your own.

Resetting the state

While bulding your own software, you may create your first infinit loop. E.g. your software starts, prints the “hello world” message and the reboots. In this system, there are so few steps, that the “hellow world” message will run a couple of times per second, keeping the CPU busy, leaving no time for other operations, like replacing the new software. Rebooting the device will not work, since the first thing that happens after reboot is starting your programs.

Being a development board, is pretty easy to get out of this infinte loop. You can do that by erasing the flash

esptool.py --port /dev/cu.SLAB_USBtoUART --baud 115200 --after soft_reset erase_flash

Or by replacing the current program with a new one

make flash

However you won’t be able to install them if the device is busy rebooting.

To get it ouf of this state, you need to get it into the boot mode. To do that, just press one of the buttons (the left one?) and run one of commands from above.

To be continued.