Upload Error: exit status 2 | ESP32 (2024 again)

Hello Arduino Maker Community!

I wanted to share something weird that I've been experiencing repeatedly while trying to upload new code to my ESP32 using the Arduino Cloud. In my previous uploads, everything was working perfectly, but now I’m encountering unusual behavior when I upload new code.

I noticed that every time I upload, the Arduino IDE generates two folders in the %temp% directory. Upon closer inspection, I found that the filenames are not being assigned correctly. The Arduino Cloud expects the files to be named without the .ino extension, specifically as .bootloader.bin or .partitions.bin. However, the filenames in my computer's folder are incorrectly assigned with the .ino extension, appearing as follows: ino.bootloader.bin or ino.partitions.bin.

Of course, I know that a logical solution would be to rename the files, but when I do that, it doesn’t affect the new upload. Each time I upload again, it generates another temporary folder with the same incorrect filename extensions.

I would greatly appreciate any help you can provide to resolve this issue. I have looked into other cases for solutions, but I haven’t found anything that works for me. I also tried using a different computer, installing the CP210 drivers and the Arduino Cloud Agent, but the same error persists.

Thank you for your help!



Have you checked github to see if it is a known problem, if not then if you are sure it's a bug report it.

I haven't checked GitHub yet, to be honest, and I'm not completely sure if this is exactly a bug or an error in the matrix. However, I can't deny that something unusual is happening. I’m curious if you have had a similar experience and how you managed to resolve it.

I have not, I haven't used the cloud for over a year maybe more. You do need to consider if this is a bug thousands of users would be affected. It is very rare to be the first to uncover a bug.

Hello again!

In the end, because I really wanted to finish this project soon, I decided to download my project from the Arduino Cloud to my local Arduino IDE. The only problem was that I needed to install all the required libraries for the cloud, and no, it's not just the ArduinoIoTCloud.h; I also had to install the following additional libraries:

  • ArduinoHttpClient.h
  • ArduinoMqttClient.h
  • Arduino_ConnectionHandler.h
  • WatchDog.h

I just want to clarify that I don't use all these libraries in my code, but apparently, they were required to pass the verification.

Once I had every file in the same directory, it compiled correctly. I then proceeded to upload it to my ESP32, and everything works perfectly fine. I really didn't know what the issue was with the Arduino Cloud IDE when I was trying to do the new upload, but thank God I found a quick solution. The program works well and can connect to Arduino Cloud and dashboards without any problems.


I have exactly the same problem w. my ESP32 boad.

The generated file name contains an additional ".ino." e.g.
Error: "esptool write_flash: error: argument : [Errno 2] No such file or directory: 'C:/Users/Anwender/AppData/Local/Temp/extrafiles3253181703/WeatherStation_dec08a.bootloader.bin'
Executing command: exit status 2"
but the generated file is "WeatherStation_dec08a.ino.bootloader.bin'

Any idea how this coud be fixed?
tHO

1 Like

Thanks for reporting this @jhoan_daniel_30 and @thornemann. I confirm the bug and have reported this to the Arduino Cloud developers. I'll let you know if I receive any news from them about a resolution.

Until then, I can suggest using Arduino IDE as a workaround.

Arduino IDE has Arduino Cloud integration, which provides convenient access to the sketches from your Arduino Cloud account.

I'll provide instructions you can follow to set up Arduino IDE and upload your sketch:

  1. Install Arduino IDE by following the instructions here.
  2. Start Arduino IDE.
  3. Install the "esp32" boards platform by following the instructions here.
  4. Connect Arduino IDE to your Arduino Cloud account by following the instructions here
  5. You should now see the list of sketches from your Arduino Cloud account in the "SKETCHBOOK" panel of the IDE window. Click on the sketch you would like to upload to your board.
  6. Click the cloud with downward pointing arrow icon ("Pull Sketch") that appears to the right of the sketch name.
    A "Synchronizing sketchbook, pulling ..." process will start.
  7. Wait for the synchronization process to finish, as indicated by the appearance of a notification at the bottom right corner of the IDE window:

    Done pulling ...

  8. Double click on the sketch name in the "SKETCHBOOK" panel.
    The sketch will open in a new Arduino IDE window.
  9. Select the appropriate board from the IDE's Tools > Board > esp32 menu.
  10. Select the appropriate port from the IDE's Tools > Port menu.
  11. Select Sketch > Upload from the Arduino IDE menus.

The sketch should now upload successfully to the board.


Note that you can use Arduino IDE for development of Arduino Cloud Thing sketches. It is convenient to use the Arduino Cloud web interface for the initial setup of the Thing, but after that you can open the sketch in Arduino IDE for editing and uploading to your board. You will see newly created Thing sketches under the "Cloud Sketchbook" tab of the IDE's "SKETCHBOOK" panel after you click the "Sync" icon at the bottom right corner of the panel.


Please let me know if you have any questions or problems while following those instructions.

3 Likes

Thank you very much! This information is very helpful.

I also found a workaround for this issue. You can upload the sketch directly from a terminal (such as CMD on Windows). Here's how:

  • Copy the command shown in the error message into a terminal window.
  • Correct the filenames in the command (make sure to include the ".ino" extension).
  • Hit Enter, and the sketch will be uploaded directly using esptool.

Although this method is less convenient than uploading from the editor, it works reliably and is a good alternative.

tHO

2 Likes

Excellent workaround @thornemann. Thanks for sharing your findings!

Thank you very much, Arduino Team! I never thought it was a real bug, but it's amazing that the developers are already aware of it!

2 Likes

A post was split to a new topic: How to remove the Arduino Cloud sync?

2 posts were split to a new topic: Executing command: exit status 2. PLEASE FIX BUG

I tried using the Arduino IDE and still got an error (Exit status:2) I even changed the baud rate and had all the libraries needed for the Arduino cloud. Still i got the error I may be missing something. I also am attempting Thornemann's solution which i am assuming needs python. I'll try it out and see.

Ok I went through with your method thanks so much. But still struggling a little while looking at the ino.bootloader.bin in windows notebook it looked to be corrupted im not sure if it is just more or something else. Here is a snippet of what it looks like:

é/ð@î        ÿÿ    0 ÿ?@  ÿÿÿÿ Pÿ¬       ðõ?                 Assert failed in %s, %s:%d (%s)
 abort() was called at PC 0x%08x
 mosi_len <= 32 /IDF/components/bootloader_support/src/bootloader_flash.c miso_len <= 32 miso_byte_num <= 4 bootloader_flash_read_sfdp bootloader_flash_execute_command_common end1>start1 /IDF/components/bootloader_support/include/bootloader_util.h end2>start2 load_end > load_addr /IDF/components/bootloader_support/src/esp_image_format.c Calculated hash Expected hash bootloader_util_regions_overlap verify_load_addresses handle != NULL /IDF/components/bootloader_support/src/esp32/bootloader_sha.c data_len % 4 == 0 words_hashed % BLOCK_WORDS == 60 / 4 words_hashed % BLOCK_WORDS == 0 €                                                               bootloader_sha256_finish bootloader_sha256_data &_bss_start <= &_bss_end /IDF/components/bootloader_support/src/esp32/bootloader_esp32.c &_data_start <= &_data_end sp < &_bss_start sp < &_data_start bootloader_init buffer != NULL /IDF/components/bootloader_support/src/bootloader_random.c bootloader_fill_random MXIC ISSI WinBond GD XM25QU64A TH ^ÿ?   ÿ˜
@ð
@cÿ? @ Ϙ
@ð
@hÿ?ï @ ÿÈ
@@	pÿ?È ` ÿÈ
@@	sÿ? 8ÿÿ,@\@}ÿ?Í ` ÿÈ
@@	    ÿÿÿÿÿ°

The rest is just random looking collections of symbols

Ok ive noticed something which is the likely cause of this bug im not sure if there was an update to the arduino cloud but the locations changed.

Here was working code on the 7th of December: C:\Users\eperi\AppData\Local\Temp\arduino-language-server2142792907\fullbuild

This is a faulty one now:
C:\Users\eperi\AppData\Local\Temp\extrafiles1354034688

Now sure if this helps in anyway or if there is a way to change it.

I'm going to ask you to provide some additional information that might help us to identify the problem.


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


Please do this:

  1. Perform whatever action that causes this error to occur in Arduino IDE.
  2. There should be an error notification at the bottom right corner of the Arduino IDE window. Click the "COPY ERROR MESSAGES" button on that notification.
  3. Open a forum reply here by clicking the "Reply" button.
  4. 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.
  5. Press the Ctrl+V keyboard shortcut (Command+V for macOS users).
    This will paste the copied output into the code block.
  6. Move the cursor outside of the code block before you add any additional text to your reply.
  7. Click the "Reply" button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here.

Click here for attachment instructions

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the "Reply" button.
  5. Click the "Upload" icon (Upload icon) on the post composer toolbar:

    The "Open" dialog will open.
  6. Select the .txt file you saved from the "Open" dialog.
  7. Click the "Open" button.
    The dialog will close.
  8. Click the "Reply" button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

No, it does not use Python.

It is not corrupted. It is a binary file. It is normal to see gibberish when you open a binary file in a text editor. The binary file contents are intended to be read by a machine, not by a human.

There is no need to open the file in a text editor to perform the workaround described by @thornemann. If you want to use this workaround, I'll be happy to provide detailed instructions you can follow. However, this is a very complex workaround compared to using the user friendly Arduino IDE. So I think that it will be better for us to focus exclusively on getting Arduino IDE working for you.

Ok thank you so much I did not know about the binary file thing. Ok here was the result from the Arduino IDE:

Sketch uses 964085 bytes (73%) of program storage space. Maximum is 1310720 bytes.
Global variables use 48340 bytes (14%) of dynamic memory, leaving 279340 bytes for local variables. Maximum is 327680 bytes.
esptool.py v4.5.1
Serial port COM4

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

Looking at my device manager the ESP32 is connected and I also tried multiple ESP32's.

I did get pretty far with the CMD terminal but in the end I really couldn't get it to work.

[sterretje edit]
fixed the code tags
[/sterretje end]

Good news, everyone! The Arduino Cloud developers have fixed the bug. You should now be able to upload to use Arduino Cloud Editor to upload ESP32 boards without encountering that "No such file or directory" error message.

Please let us know if you still encounter any problems using Arduino Cloud.

I apologize for any inconvenience this bug has caused.

Regards, Per

2 Likes

A post was split to a new topic: Upload to ESP32 board fails: "invalid choice: '{upload.flags}'"