Cannot upload to Wemos board in Arduino IDE

@perigalacticon it’s probably time to try esptool without the IDE. There are 2 versions a Python version and a compiled executable. Let me dig out my notes.

Yes I have the following path: C:\Users\Perigalacticon\Documents\Arduino\sketches\hardware\esp8266com\esp8266

When I installed Arduino IDE, it put the program in the C:\Program Files (x86)\ directory because it is a 32 bit program (C:\Program Files (x86)\Arduino) on a 64 bit machine.

However, I have files in the C:\Users\Perigalacticon\Documents\Arduino\ directory because I think I remember some libraries expect the sketch folder to be in the Documents/Arduino directory. So my sketches are in C:\Users\Perigalacticon\Documents\Arduino\sketches and my libraries are in C:\Program Files (x86)\Arduino\libraries.

I tried duplicating the esp8266com directory to:
C:\Program Files (x86)\Arduino\hardware\esp8266com, I copied it from:
C:\Users\Perigalacticon\Documents\Arduino\sketches\hardware\esp8266com

but no change.

I don’t think it’s a directory issue. The error message is basically a failure to send the file to com port.

The benefit of the standalone esptools is that you don’t have the delay of compiling your code before the upload. So this means you can press the reset button a fraction of a second before doing the flash and this sometimes works for “dead” ESP’s that will not flash in the IDE.

Both versions, exe and Py, have their merits but my current favourite is the exe which I believe you will already have as part of the IDE installation.

Knock up a very basic sketch that simply print’s “\nStarted” to Serial Monitor and then in the IDE select Sketch menu and Export compile Binary. This will put a bin file in the folder for that particular sketch.

esptool command line to follow, meanwhile locate esptool.exe in your system.

Ok now something changed when I copied the esp8266com directory to C:\Program Files (x86)\Arduino\hardware\esp8266com. Now I get this error instead:

java.io.IOException: Cannot run program "C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266/tools/esptool/esptool.exe": CreateProcess error=2, The system cannot find the file specified

Indeed there is no esptool.exe in this directory. And windows search doesn’t find it on my PC, but it often does not find things that do actually exist.

Looks like you are really trashing your IDE installation.

Actually the procedure I quoted in my last post regarding the bin file is for the Python version. For the exe you are going to work with .elf files.

If you compile the basic sketch, but don’t try to upload it it will show in the compiler where your temporary elf files are located.

Let me know when you find esptool.exe and the elf files.

I have the binary now, filename is: “test_wemos.ino.d1_mini.bin”.

The problem is that some library I was using expected the sketches to be in the Documents directory and they wouldn’t work with the installation to the Program Files (x86) directory. I can’t remember what it was but something I was doing would not work if the sketch directory was not exactly in the user / documents / path.

Forget the bin file, find .elf and esptool.exe.

The compiler isn’t showing anything about file locations… the output I get is:

WARNING: Category 'Sensor' in library Adafruit_VL53L0X is not valid. Setting to 'Uncategorized'
WARNING: Category 'Real-time clock' in library DS3231 is not valid. Setting to 'Uncategorized'
Archiving built core (caching) in: C:\Users\PERIGA~1\AppData\Local\Temp\arduino_cache_72267\core\core_esp8266com_esp8266_d1_mini_CpuFrequency_80,UploadSpeed_115200,FlashSize_4M3M_59f27b87b1649ba33697614d4ec8334b.a
Sketch uses 242067 bytes (23%) of program storage space. Maximum is 1044464 bytes.
Global variables use 32828 bytes (40%) of dynamic memory, leaving 49092 bytes for local variables. Maximum is 81920 bytes.

Thats also not the problem… mine is the same way.

C:\Program Files (x86)\Arduino\arduino.exe

Try @Costas’s method.

Yes it is, you have to scroll right over to the right.

This is the GitHub for exe https://github.com/igrr/esptool-ck (but you already have it as part of the IDE) and the Python is at https://github.com/espressif/esptool

I turned on verbose output for compiling, but there’s a lot there do you know what to look for?

Not sure what you mean scrolling to the right, there’s not a filename there. If I go to C:\Users\PERIGA~1\AppData\Local\Temp\arduino_cache_72267\core it’s empty.

For me a typical temporary directory created by 1.8.3 IDE is:

C:\Users\maja\AppData\Local\Temp\arduino_build_572302\

As the name suggests it is temporary and will disappear in time. When you find it copy the elf to the same location as esptool.exe.

Ok I found the elf file in “C:\Users\Perigalacticon\AppData\Local\Temp\arduino_build_439991” but I couldn’t find esptool.exe so I’ll download it.

Ok I have the directory downloaded from github

Forget the directory you should just download the exe by clicking the link below the Windows logo.

When you have the exe put it in a new directory at C:\flash with the elf. Directory name is not important but keep it short and keep the path short.

Sorry I’m not too familiar with using Github. Do you mean where it says Windows and then below there is Build Passing? I click this and a screen of text appears …

With the exe it’s a 2 stage process, unlike Python which is just 1 stage and uses bin files.

rename the elf to app.elf

The following command is for a 4M WeMos and it’s a single line:

esptool -bz 4M -eo app.elf -bo app_00000.bin -bs .text -bs .data -bs .rodata -bc -ec -eo app.elf -es .irom0.text app_40000.bin -ec

This will create the 2 required bin files and the following command line is to upload to the WeMos at 921600 baud on COM4

esptool -cp COM4 -cd nodemcu -cb 921600 -ca 0x00000 -cf app_00000.bin -ca 0x40000 -cf app_40000.bin

Again it is a single line and change COM4 to your com port. If 921600 doesn’t work drop down to 115200 but it’s normally fine at this speed.

Try a few times and if it’s failing press the reset button on the WeMos a fraction of a second before the second command line.

You can also try the Python method. If neither works you probably have faulty WeMos.

Ok I think I found the compiled program under artifacts

Yes sorry, within the text that appears there is a zip link shown as C:\projects\esptool-ck\esptool-0.4.11-5-ga3425f4-win32.zip