I have been able to reproduce these problems fairly reliably on my ESP-12 boards, but not always on my ESP-01 (which has a nice adapter with a capacitor close to the chip), so I understand when leads on this forum have pointed to issues with power supply. However, I have been able to reproduce the issue on different chips and board configuration, using different machines, so I wanted to investigate what might be happening on the software side, if not to find an error in the software, but maybe to point to something I might be doing wrong. I am including my investigation here.
This has been happening on my boards since I started playing with this (which was around or near after the 1.8.2 release -- I'm a noob). Basically, I could always flash the device successfully, but the file system would end up being corrupt. In some cases I could do an os.listdir(), and it would return empty ("[]"), but in other cases I would get a list of hex characters (usually zeros). In any case, trying to write a file would fail, usually crashing the device.
With 1.8.3, and the addition of the esp.check_fw() command, I can verify that at least the firmware image is correct:
Code: Select all
>>> import esp
>>> esp.check_fw()
size: 558748
md5: f8d6b701f96d5bf51b5f0709b4add1ea
True
Code: Select all
>>> import os
>>> os.listdir()
['\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00', '\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00', '\x00\x00\x00\x00\x00\x00\x00\x00.\x00\x00\x00', '\x00\x00\x00\x00\x00\x00\x00\x00.\x00\]
Code: Select all
>>> import inisetup
>>> inisetup.check_bootsec()
FAT filesystem appears to be corrupted. If you had important data there, you
may want to make a flash snapshot to try to recover it. Otherwise, perform
factory reprogramming of MicroPython firmware (completely erase flash, followed
by firmware programming).
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "inisetup.py", line 21, in check_bootsec
File "inisetup.py", line 32, in fs_corrupted
KeyboardInterrupt:
If I do that manually, however, I see that the first two bytes are 0x00:
Code: Select all
>>> from flashbdev import bdev
>>> buf = bytearray(bdev.SEC_SIZE)
>>> bdev.readblocks(0, buf)
>>> buf
bytearray(b'\x00\x00\x90MSDOS5.0\x00\x10\x01\x01\x00\x01\x00\x02k\x00\xf0\x01\x00?\x00\xff\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x00)\x0f\x00!(NO NAME FAT \x00\x00\x00\x00\x00\x0)
In any event, if I manually proceed with the inisetup.setup function:
Code: Select all
>>> import uos
>>> uos.VfsFat.mkfs(bdev)
>>> vfs = uos.VfsFat(bdev, "")
I will continue to dig into how I ended up with an initial file system that is not all 0xFF, as I think is expected. I am certainly open to the issue still being due to power supply issues, but I am less certain that this is the root cause. I do find it interesting that this occurs with:
* 2 different ESP-12 devices, using a breadboard and CP2102 UART adapter (no caps, though the power supply has some), both USB and wall wart powered.
* An ESP-12 with a resoldered 1MB flash from an ESP-01
* Wemos D1 Mini
and does not happen with:
* ESP-01 on breadboard with ESP-01 breadboard adapter (and capacitor on the adapter)
Any debugging hints appreciated!
[1] https://github.com/micropython/micropyt ... tup.py#L11
[2] https://github.com/micropython/micropyt ... bdev.py#L6