What is 2-2 dfu Arduino IDE 2.1.1 ?

Just getting started with Arduino, so sorry if this is a dumb question. I've got an Arduino Nano ESP32 connected to PC running IDE 2.1.1.
Sometimes it will load the program via Com6. Other times it will only load through 2-2dfu, in which case I need to switch to COM6 to open the serial monitor.
My question: What is 2-2dfu ? I can't get any meaningful answers on Google.
(PS. I note that Gary Sims of "Ask Gary" youTube channel had similar experience)

Hi @dabbo

You should be able to upload with either port selected. Are you able to consistently reproduce this problem? If so, please the full verbose output from an upload attempt.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. Select File > Preferences... from the Arduino IDE menus.
    The "Preferences" dialog will open.
  2. Uncheck the box next to Show verbose output during: compilation in the "Preferences" dialog.
  3. Check the box next to Show verbose output during: ☐ upload.
  4. Click the OK button.
  5. Attempt an upload, as you did before.
  6. Wait for the upload to fail.
  7. You will see a "Upload error: ..." notification at the bottom right corner of the Arduino IDE window. Click the COPY ERROR MESSAGES button on that notification.
  8. Open a forum reply here by clicking the Reply button.
  9. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code tags icon on toolbar
  10. Press Ctrl+V.
    This will paste the error output from the upload into the code block.
  11. Move the cursor outside of the code tags before you add any additional text to your reply.
  12. Click the Reply button to post the output.

Although serial ports are by far the most common, Arduino IDE supports the use of any arbitrary communication channel ("port") for communication between the host computer and the Arduino board.

The classic Arduino boards like the UNO, Mega, and classic Nano have a dedicated USB chip that acts as a "bridge" between the primary microcontroller and the virtual serial port on the connected computer. With those boards, you know you will always have the ability to communicate via a serial port no matter what is happening on the primary microcontroller.

Unlike those classic AVR microcontrollers of the UNO, etc., modern microcontrollers most often have a native USB capability. This means there is no need for a "bridge" chip on the board because the primary microcontroller can communicate directly with the connected computer. This is usually done by the creation of a USB CDC serial port. But the creation of that port requires some code to run in the background of your sketch program. This can be problematic because sometimes that CDC code is disabled or broken by the sketch code, which causes the Arduino board to no longer produce a serial port on the computer.

Communication between the board and port is possible at a more fundamental level of the USB stack. Arduino implemented a new type of port with a protocol name "DFU" (DFU is the acronym for "Device Firmware Upgrade"). This type of port can be used for communication with boards that do not produce a USB CDC serial port. The address of a DFU protocol port has this format like "2-2" instead of the format like "COM6" of the serial protocol.

The average Arduino sketch program on the Nano ESP32 does have that USB CDC serial port code running in the background, which produces the COM6 serial port you see listed in the IDE. In addition, the Nano ESP32 produces a "DFU" port. This is the reason you usually see two ports listed in Arduino IDE when the Nano ESP32 is connected to your computer. As you noticed, you must select the serial port in order to do serial communication with the Arduino IDE Serial Monitor or Serial Plotter. However, you should be able to upload to the board using either port selection (the upload tool always uses DFU communication so the port selection is completely irrelevant for uploading).

1 Like

Good morning,

This is what I am getting this morning:

This is what I am getting this morning:

  1. I wrote a very simple C program, edSquares.ino
  2. From the drop-down menu I selected “Arduino Nano ESP32 Com6”
  3. I pressed upload button
  4. Upload successful
  5. Without me touching anything, the drop-down menu now reads “Arduino Nano ESP32 2-2”
  6. I changed back to “Arduino Nano ESP32 Com6”
  7. I tried to open Serial Monitor
  8. I got the message: “Port Monitor Error: command ‘open’ failed. Serial port busy. Could not connect to Com6 serial port”

My setup is a new Samsung PC laptop running Windows 11 connected via USB C cable to Arduino Nano ESP32 board.

Here is my sketch edSquares.ino:


int j = 1;

void setup() {
  Serial.begin(115200);
}

void loop() {
  for( j=1 ; j<30 ; j++){
    Serial.print(j);
    Serial.print(" ");
    Serial.println(j*j);
  }
}

Please note that after disconnecting and reconnecting the Arduino Nano ESP32, and closing and restarting the IDE, the Serial Monitor is working fine and the program is running well

I'm sorry to hear that. We are aware of the problem in general of Arduino IDE unexpectedly changing the port selection and work is already in progress to fix this:

Unfortunately I don't have an immediate solution for you. I'm glad you already have found the workaround for the problem. If you find that to be too inconvenient, you can use Arduino IDE 1.x (which doesn't have this port switching bug) until the fix is made in Arduino IDE 2.x. The Arduino IDE 1.x download links are listed here:

https://www.arduino.cc/en/software#legacy-ide-18x

You can have Arduino IDE 1.x and 2.x both installed at the same time on your computer without any problems so you don't need to uninstall Arduino IDE 2.x before installing Arduino IDE 1.x.

A note about your information-gathering instructions:

There is no verbose output option in the File > Preferences dialog. I'm using Arduino IDE 2.1.1 on Windows 11. It is necessary to open the "Palette" with ctrl-shift-P, find the Preferences: Open Settings (UI) option and then check the boxes as you described.

Of course this wasn't really about a failure to upload but about use of the Serial monitor. I see that from your link that you are already working on this, which is great. I'll be trying the nightly builds.

In Arduino 1.8.19 things are a little better, but I still have to close and re-open the serial monitor after each compile and upload. That does not happen with the Arduino Mega.

If I don't close the serial monitor and I'm using the Nano ESP32 on 1.8.19 I get this at the end of the download:

Download [=========================] 100% 286656 bytes
Download done.
DFU state(7) = dfuMANIFEST, status(0) = No error condition is present
DFU state(2) = dfuIDLE, status(0) = No error condition is present
Done!
processing.app.SerialException: Error opening serial port 'COM4'.
at processing.app.Serial.(Serial.java:152)
at processing.app.Serial.(Serial.java:82)
at processing.app.SerialMonitor$2.(SerialMonitor.java:132)
at processing.app.SerialMonitor.open(SerialMonitor.java:132)
at processing.app.AbstractMonitor.resume(AbstractMonitor.java:132)
at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2126)
at processing.app.Editor.access$1300(Editor.java:116)
at processing.app.Editor$UploadHandler.run(Editor.java:2095)
at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - COM4; Method name - openPort(); Exception type - Port not found.
at jssc.SerialPort.openPort(SerialPort.java:167)
at processing.app.Serial.(Serial.java:141)
... 8 more
Error opening serial port 'COM4'.

I hope that your efforts will succeed soon and I'll be back on a 2.x version soon. Thanks for working on it.

That is very unexpected. It should definitely be there:

Please note that the fix will only be in the nightly builds once the pull request I linked to in my previous reply has been merged.

A beta tester build will be available before that time though. I'll try to remember to circle back here with instructions once the work is in a condition where it is ready for testing in case you might be interested in trying it out.

That is unfortunate. I can also reproduce this error when using Arduino IDE 1.8.19.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.