Arduino CLI and Nano ESP32 - Can't Upload

Platform Information

Hardware

Board: Arduino Nano ESP32, Chip: ESP32-S3

Linux OS

PRETTY_NAME = "Ubuntu 24.04 LTS"
NAME        = "Ubuntu"
VERSION_ID  = "24.04"
VERSION     = "24.04 LTS (Noble Numbat)"

Arduino SW Version

>> arduino-cli version
arduino-cli  Version: 0.35.3 Commit: 95cfd654 Date: 2024-02-19T13:24:24Z

Problem

I am having trouble uploading code to an Arduino Nano ESP32 using arduino-cli. At some point I was able to upload code but it stopped working, I don't know what I did to make this not work. Currently, it has a simple blink code loaded on to the board.

When it is working, it will display what I believe is the correct board in the board list. However, I'm unsure of the USB DFU listing (In the past I was getting an error associated with USB DFU, maybe it's related).

>> arduino-cli board list
Port         Protocol Type              Board Name         FQBN                  Core
1-2.3        dfu      USB DFU           Arduino Nano ESP32 esp32:esp32:nano_nora esp32:esp32
/dev/ttyACM1 serial   Serial Port (USB) Arduino Nano ESP32 esp32:esp32:nano_nora esp32:esp32

When I try to upload new code I get this error:

esptool.py v4.5.1
Serial port /dev/ttyACM1
Connecting.............

A serial exception error occurred: Could not configure port: (5, 'Input/output error')
Note: This error originates from pySerial. It is likely not a problem with esptool, but with the hardware connection or drivers.
For troubleshooting steps visit: https://docs.espressif.com/projects/esptool/en/latest/troubleshooting.html
Failed programming: uploading error: exit status 1

After the failed upload, the board listed changes from nano_nora to lolin_c3_mini:

>> arduino-cli board list
Port         Protocol Type              Board Name    FQBN                      Core
/dev/ttyACM1 serial   Serial Port (USB) LOLIN C3 Mini esp32:esp32:lolin_c3_mini esp32:esp32

If I try uploading again (without pressing reset button), I get this error where it can't find the port:

esptool.py v4.5.1
Serial port /dev/ttyACM1

A fatal error occurred: Could not open /dev/ttyACM1, the port doesn't exist
Failed programming: uploading error: exit status 2

The port /dev/ttyACM1 exists in /dev/:

>> ls /dev/ttyA*
/dev/ttyACM1

When I push the reset button on the board, the code begins running again (a blinking light and serial print), and the arduino-cli board lists nano_nora again.

Things I've tried

  1. Changing USB Cable.

  2. Pressing the reset button on the board.

  3. Pressing reset button on board while Connecting... is displayed on console.

  4. Completely un- and re-installing arduino-cli (including removing ~/.arduino15 directory).

  5. Un- and re- installing esp32:esp32 forcing the post_install after run:

    arduino-cli board install esp32:esp32 --run-post-install
    
  6. Updating arduino-cli cores (was already up to date)

    >> arduino-cli core upgrade
    All the cores are already at the latest version
    

My simple program

#include <Arduino.h>
#include <Wire.h>

int out_pin0 = 5;
int out_pin1 = 6;

void setup()
{
    pinMode(out_pin0, OUTPUT);
    pinMode(out_pin1, OUTPUT);
}

void loop()
{
  Serial.println("blink!");
  digitalWrite(out_pin0, 1);
  digitalWrite(out_pin1, 0);
  delay(250);
  digitalWrite(out_pin0, 0);
  digitalWrite(out_pin1, 1);
  delay(250);
}

Hi @rebeccajr. I see there is a problem with a change that was made recently to the configuration of the esp32:esp32:nano_nora:

This forces Arduino CLI to use the esptool tool when uploading to the esp32:esp32:nano_nora board. We typically use the dfu-util programmer when uploading to the Nano ESP32. The esptool tool is only used with this board for certain specific advanced usages and it is necessary to manually put the board into boot mode in order to upload via the esptool tool, which is why the upload is failing for you.

My recommendation is to use the arduino:esp32 boards platform when uploading to the Nano ESP32. You can install it with this command:

arduino-cli core install arduino:esp32

After that, you can use the arduino:esp32:nano_nora FQBN in your arduino-cli command instead of esp32:esp32:nano_nora. You should now find that the upload is successful.


If for some reason you do need to use the esp32:esp32 platform with the Nano ESP32, I can provide instructions for a more complex alternative fix.

1 Like

That worked! Thank you!!

My main project is using libraries DS3231, Adafuit_GFX, Adafruit_LEDBackpack, and Adafruit_AW9523 libraries. Do you think that I will require the esptool for this use case?

You are welcome. I'm glad it is working now.

No, it is not needed.

I have an update to share: The problem you encountered when using the "esp32" boards platform has now been resolved:

So it is now possible to upload to the Nano ESP32 board using Arduino CLI with the esp32:esp32:nano_nora FQBN. The fix was included in today's 2.0.17 release of the esp32:esp32 platform.

We do generally recommend the use of the Arduino maintained arduino:esp32 platform with the Nano ESP32 for the most stable user experience, but the esp32:esp32 platform might be useful for specific advanced use cases that rely on the recent development work that has not yet propagated to a release version of the arduino:esp32 platform.

2 Likes