One of the promising suggestions I got in my other thread was to try lowering the flash frequency from 80 MHz to 40 MHz, which I would want to try ASAP, however the devices I want to try that on are on the field for testing - I can only OTA update them.
AFAIK the flash frequency can only be changed locally by setting the proper cmdline parameters to esptool and uploading a new bootloader for that flash speed as well. In fact, I tried recompiling for 40 MHz and OTA updated one device locally and it seems it didn't slow down the tiniest bit, but then again I'm not 100% sure and I want to verify what the flash speed is now. I looked around and I couldn't find functions to query that, hence this thread.
It seems that the flash speed is set in
Code: Select all
esp-idf/components/spi_flash/spi_flash_rom_patch.c
Code: Select all
spi_cache_mode_switch()
Code: Select all
g_rom_spiflash_dummy_len_plus[]
Code: Select all
esp-idf/components/bootloader_support/src/bootloader_init.c
Then I'd also want to lower the SPI flash freq for my devices on the field - it might be doable by quickly changing both registers with the magics for 40 MHz (say we name this function set_spi_flash_freq()). I can OTA upload a new firmware that calls set_spi_flash_freq() in the beginning and my devices will run on 40MHz almost all the time.
Questions
1. Is there any code that already implements something similar the proposed get_spi_flash_freq()/set_spi_flash_freq() funcs described above?
2. Is the approach in set_spi_flash_freq() workable, can you do that with the flash already being actively used?