2026-04-16 8:31 AM - last edited on 2026-04-16 9:06 AM by Andrew Neil
Hi everyone,
I am working on a custom PCB designed , but I’ve run into a hardware design constraint and would appreciate some architectural advice on the best way forward.
The Setup:
Main MCU: STM32L476 (Programming via STM32CubeIDE / HAL)
Coprocessor/WiFi: ESP32-WROOM (Intended to handle AWS IoT connections)
The Constraint: The PCB designer connected the STM32 and ESP32 exclusively via an I2C bus. There are no physical UART traces connecting the two chips.
The Original Goal: The initial plan was to use the STM32 to write firmware directly to the ESP32 over UART, or to use a UART software bridge, and then use UART for passing sensor data to the ESP32 for AWS publishing.
The Dilemma: Because the ESP32 ROM bootloader requires UART0 (TX0/RX0) for flashing, I realize a software bridge from the STM32 over I2C to flash the ESP32 is physically impossible.
My Questions for the Community:
The Initial Flash: Aside from tack-soldering temporary wires to the ESP32's TX0/RX0 pins to perform the initial flash, is there any advanced or obscure method to flash an ESP32 via an STM32 strictly over an I2C bus?
The Software Architecture: Assuming I tack-solder the board to flash a custom program onto the ESP32, what is the most robust architecture for runtime communication? Should I configure the STM32 as an I2C Master and the ESP32 as an I2C Slave to pass the sensor data, or is there a better paradigm for this specific Master-Coprocessor relationship using the HAL libraries?
Any advice on handling this missing-UART scenario would be hugely appreciated. Thank you!
2026-04-16 8:37 AM
If the ESP32 requires that you use UART to flash it, you will have to use UART to flash the ESP32. To use UART, you will need a UART connection between the two. This is very basic logic. There is no magic solution to avoid this.
2026-04-16 8:46 AM - edited 2026-04-16 8:59 AM
Hello,
@MaddyGitBase wrote:
is there any advanced or obscure method to flash an ESP32 via an STM32 strictly over an I2C bus?
That's more linked to ESP32 than to STM32 question.
You need to ask that question in their forums.
@MaddyGitBase wrote:
The Software Architecture: Assuming I tack-solder the board to flash a custom program onto the ESP32, what is the most robust architecture for runtime communication? Should I configure the STM32 as an I2C Master and the ESP32 as an I2C Slave to pass the sensor data
If ESP32 is receiving the data acquired by STM32 on which the sensor is connected, need to configure it as I2C slave.
Otherwise, what's your problem with using UART? and UART0 of ESP32? So use UART0 to pass the sensor's data and to flash ESP32 as well.
2026-04-16 9:04 AM - edited 2026-04-16 9:08 AM
@MaddyGitBase wrote:Any advice on handling this missing-UART scenario would be hugely appreciated. Thank you!
As the others have said, if the ESP32 requires a UART, then a UART you must use - there's no way to change that by anything you can do outside the ESP32.
It's not clear what connection you do have between the 2 microcontrollers?
If you're going to hack the PCB to provide a UART connection, then you might as well use that for all communication between the 2 microcontrollers.
PS:
Do you really need 2 microcontrollers?
Could the ESP32 not handle everything itself?