How to flash an ESP32 on production

Francesco Colasante
4 min readMar 31, 2021

In this tutorial I will show you how to flash an ESP32 without using an ESP32 Development board. Until recently, I had always made my ESP32 prototypes always with development kits and I had no idea how to flash and put ESP32 chips into production. If you find yourself in the same situation as me, I recommend that you read this article.

We will therefore see how to flash an ESP32 soldered on a custom PCB using a bridge or an ESP32 flasher.

If you need to bring an ESP32 based project into production it is important to migrate from a Development Kit to a standalone ESP32.

ESP32 miniaturization

ESP32 DevKit

ESP32 DevKit is very convenient to start making the first experiments and prototypes because it has the integrated micro-USB connector and therefore it is very easy to flash directly and is powered directly from the USB port.
Another very important advantage is that it has I/O connectors and can be connected to sensors and actuators with simple Dupont wires.

ESP32-DevKitC V4

For complete information, my suggestion is to study the technical documentation at the following link. Obviously, you will surely have already flashed an ESP32 DevKit, as it is enough to simply connect with a USB cable to the pc and useesptool.py

ESP32 WROOM

ESP32 WROOM is ideal for soldering directly to a proprietary custom PCB.

Now we go into more electronic and technical issues and my suggestion is to rely on experts who know how to design a PCB.

ESP32 Peripheral schematics

It is important to decide what to integrate into our PCB board, if we want to keep the UART port, if we want to insert a USB-to-UART Bridge and so on.

It depends a lot on the technical needs of the project, however I would like to give 2 technical tips. We will now look at two of the main methodologies for flashing an ESP32 in production

Flash before soldering

If you want to minimize the components on your PCB, avoid inserting a UART connector for flashing, my advice is to use an external flasher.

There are flashing boards practically the same as the ESP32 DevKit that allow you to flash the ESP32 and then release it from the housing.

ESP32-DevKitS-R

You can easily find a flashing board on Mouser. You can then mount the standalone ESP32 on the flasher, flash the firmware, remove it from the base and then solder it on the PCB.

Pro & Cons DevKItS

Flash after soldering

This second methodology allows the ESP32 to be soldered directly on the PCB and then the firmware is flashed.

To do this, you need to extract the pins from the ESP32 and insert a connector to flash the ESP32 externally.

This methodology therefore allows you to obtain the ESP32s directly from the manufacturer of your PCB, avoiding that the ESP32s first pass through your hands for flashing. This way, you can flash once the PCB is ready and assembled

PCB + external UART to USB bridge

With this methodology, you can connect the bridge and debug the ESP32 easily for troubleshooting and firmware update.

Pro & Cons Flash after soldering

However, it exposes the UART port more and could be a security issue.

To overcome this problem, ESP32 allows flash encryption to avoid memory dumps by malicious people. I recommend reading this link for more information on ESP32 flash encryption.

Generally, using the esptool.pytool the flashing procedure is automated and it is not necessary to enter the bootloader through the connection of the RTSand DTRpins. If you have any problems about it or want to understand better about ESP32 boot mode selection, I suggest this guide.

Useful reference:

  • ESP32 datasheet: link
  • ESP32 DevKit tutorial: link
  • ESP32 Boot mode selection: link
  • Manufacturing utility: link

Let me know if you are interested in an article about ESP32 PICO, a System-in-Package (SiP) module.

Other contents

Check out my guide to building IoT systems with Thingsboard (link).

Check out my latest video on ESP32, Google Cloud and Mongoose OS (link)

For more information and other contents, here is my website, feel free to contact me for advice or support. https://www.francescocolasante.it/

--

--

Francesco Colasante

Sapienza University — Engineering in Computer Science