Open zeroflag opened 6 years ago
I just realized if the flash mode is set to QIO then it works but if it's DIO it doesn't.
How do you set QIO mode? I have several modules with Flash ID C84016 (sdk_spi_flash_get_id() returns 1640C8, but I think this number must be byte swapped to get the correct ID). With these modules, everything works fine. But I am now using other modules with flash ID E04016 (different manufacturer) and flash does not work. I have tried using both sdk_spi_XXX functions, and spiflash_XXX functions without success. Maybe my problem is the same as yours.
How do you set QIO mode?
I use esptool.py with --flash_mode qio parameter. I suspect this makes the device to stay in that mode.
OK, I found out that the way was easier than expected: using the download tool.
I tired first downloading my application with all the modes, and none worked. Then I noticed that the bootloader was run before my application, so flashed the bootloader with QIO mode and... voila! It works :)
Anyway, it is a bit nasty that the flash write functions return success even when they are failing. Maybe this can be improved, so they return failure when erasing/writing fails due to misconfiguration.
I use the combination of _sdk_spi_flash_erasesector + _sdk_spi_flashwrite to write out same data to the flash memory. But after reading it back the result still contain what it was already there previously. In other words it doesn't change the content of the sector.
Here is an example code that tries to update the 100th sector.