esphome / esp-web-tools

Open source tools to allow working with ESP devices in the browser
https://esphome.github.io/esp-web-tools/
Apache License 2.0
440 stars 119 forks source link

Detect fake flash #254

Open DTTerastar opened 2 years ago

DTTerastar commented 2 years ago

Users often report issues w/ certain devices not working correctly and blame the firmware. Could we when detecting flash try and read towards the end of flash and actually verify that the flash isn't a 2mb chip reporting it's a 4mb chip? It would help immensely on the amount of support. Those cruddy chips often report "success" when writing, but error on reading past 2mb.

balloob commented 2 years ago

How does this show up in the logs? Do we get a write failure or just a timeout when writing above a certain %?

Right now we show a generic error message when installation fails. That could be expand to launch some "diagnostics" mode to analyze the chip or it could redirect to a website to help with further troubleshooting (and it would analyze the chip).

DTTerastar commented 2 years ago

Writes succeed with zero errors. Reads get errors past halfway. My suggestion is right after detecting the flash size do a read from the last byte of flash. Just a console log if it fails is probably a good start just to get some data on this.

TD-er commented 2 years ago

I think these fake units will then "roll over" on the address, so when reading from the "4M-1" address, you're actually reading from the "2M-1" address (or "1M-1") So be careful when drawing conclusions based on whether you can read from some address.

DTTerastar commented 2 years ago

esptool.py read_flash can't read past 2mb. I'm not saying ALL fake flash work this way, but my devkit c3 certainly does.

balloob commented 2 years ago

We definitely should avoid raising any false positives, claiming a device is fake while it's not.

TD-er commented 2 years ago

We definitely should avoid raising any false positives, claiming a device is fake while it's not.

You don't need to call it "fake", more like a warning about some unexpected behavior would do I guess.

DTTerastar commented 2 years ago

Yeah keep it in the console for people that have flashed something 15 times and are currently looking for something :)

Jason2866 commented 2 years ago

The problem are not fake flash chips. There are C3 devkits with 2M. When the are sold as 4MB devices or the user did not noticed that it is a 2MB device...

DTTerastar commented 2 years ago

I can write all the way to 4MB. I can't read past 2MB. That's all I know atm.