Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk_spi_flash_erase_sector + sdk_spi_flash_write doesn't work #538

Open
zeroflag opened this issue Jan 12, 2018 · 4 comments
Open

sdk_spi_flash_erase_sector + sdk_spi_flash_write doesn't work #538

zeroflag opened this issue Jan 12, 2018 · 4 comments

Comments

@zeroflag
Copy link

I use the combination of sdk_spi_flash_erase_sector + sdk_spi_flash_write 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.

char buffer[8] = "test1234";
sdk_spi_flash_erase_sector(100);
sdk_spi_flash_write(100 * 4096, (uint32_t*) &buffer, 8);
char result[8];
sdk_spi_flash_read(100 * 4096, (uint32_t*) &result, 8);
printf("result: %.8s", result);
@zeroflag
Copy link
Author

I just realized if the flash mode is set to QIO then it works but if it's DIO it doesn't.

@doragasu
Copy link

doragasu commented Mar 18, 2018

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.

@zeroflag
Copy link
Author

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.

@doragasu
Copy link

doragasu commented Mar 18, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants