Why is my OTA attempt failing and how to fix it

I have a couple of Wemos D1 Mini running WLED the precombiled WLED_0.10.0_ESP8266_1M_ota.bin from Github. Now I wanted to try out a usermod, so I installed platformIO for VS Code and compiled Wled myself with the usermod. That is working fine.
Now I wanted to try it so I started an OTA update going to config -> security & updates -> manual OTA update and selected the esp01_1m_ota .bin file that I created. Unfortunately the update fails with

Failed updating firmware!
Please check your file and retry!

Why is this happening? Can I see any logs somewhere to find out why?

Reason is Wemos D1 mini is using 4M memory and correct bin file will be https://github.com/Aircoookie/WLED/releases/download/v0.10.0/WLED_0.10.0_ESP8266.bin
You using file designed to work with esp-01 module1 with is 1M of memory

Actually when I first flashed the mini (via cable) I tried that version. I was able to flash it but it was unable to safe any settings. So I switches to the 1M version. Maybe I have fake versions of the D1 mini…
Now via OTA I am also unable to flash your version: same error. Is there anything else I can try or do I have to flash via cable again?

First you have to reflash board with correct version. When you connect your board to computer can you use https://www.espressif.com/en/support/download/other-tools flash download tool to figure out memory size? If size is 4mb then reflash your board with full featured firmware. If it’s only 1M than you need this for OTA https://github.com/Aircoookie/WLED/releases/download/v0.10.0/WLED_0.10.0_ESP8266_1M_ota.bin

I did download the tool and connected the ESP via cable. If I read the output correctly it has 4MB of RAM.
I tried flashing the standard ESP8266 version from the github repo as well as my self compiled version but in both cases I got “WLED ERROR 2” popups whenever I tried to safe any setting.
Then I flashed my self compile version of the 1M_ota and that seems to work without a problem. I did not try OTA afterwards though. Very strange

For now I am using the 1M version of the software and flashed directly via cable. Maybe I have a bad/old batch of Wemos D1 minis.

D1 Mini’s have 4 MB of RAM. Flashing / using the wrong firmware is going to cause problems either right away, or when you want to update it.

I recommend using a single D1 Mini for troubleshooting the process to get them all working correctly.

Steps to follow:
Erase the D1 Mini using a reputable erasing tool that is know to work with your O/S and D1 Mini’s. I see a couple of them recommended from various online souces. Maybe PyFlasher works in your environment.
Once you get a successful erase, flash the D1 Mini 4MB specific firmware.
Verify everything works.
If it does not, try a different erasing tool.
Once you get a successful D1 Mini on your own wifi, follow the same steps for the remaining D1 Minis.
Remember to give them useful host names (descriptions) so you can tell them apart later. The default of WLED_[part of the MAC address] is not useful unless you can read the mac address on the esp8266.

when you using erase tool in log window you can read MAC address, also when you flashing.

Thank you @huggy-d1! This sounds like it could solve my problems. It will take me some time as I am quite busy right now but I will try PyFlasher to erase the flash.