I can' t find the exact scope of the make erase_flash command in the documentation. From tests is looks like it erases all of the flash?
The application had two custom OTA partitions, uses NVS to store data and SPIFFS storage.
Unfortunately it erases the NVS partition I use to store data. Is there a way around?
make erase_flash affects OTA and NVS patitions
-
- Posts: 27
- Joined: Sun Jan 01, 2017 9:21 pm
make erase_flash affects OTA and NVS patitions
Jan Jansen
Amsterdam
The Netherlands
Amsterdam
The Netherlands
-
- Posts: 9764
- Joined: Thu Nov 26, 2015 4:08 am
Re: make erase_flash affects OTA and NVS patitions
It indeed nukes the entire flash, OTA, NVS and all.
-
- Posts: 27
- Joined: Sun Jan 01, 2017 9:21 pm
Re: make erase_flash affects OTA and NVS patitions
Is there a convenient way to only erase both ota partitions. E.g. an "erase_flash_ota" "coupled" to all ota partitions only.
I thought about flashing an empty image in ota_0, store this empty image also on the web server. Load the target image in ota_0. Let ota_0 load the empty image in ota_1 etc. But is is very inconvenient. Or maybe I have to attach an SD card.
I thought about flashing an empty image in ota_0, store this empty image also on the web server. Load the target image in ota_0. Let ota_0 load the empty image in ota_1 etc. But is is very inconvenient. Or maybe I have to attach an SD card.
Jan Jansen
Amsterdam
The Netherlands
Amsterdam
The Netherlands
Re: make erase_flash affects OTA and NVS patitions
My thinking that erase_flash is like a "factory reset" and goes through all the bytes of flash memory and zeros them. I'm not seeing the value of using "erase flash" for a purpose other than the reset. In an application, flash memory can be written to at known locations ... so in principle, there is nothing to stop your app writing arbitrary data to any location under the auspices of your own logic. The esptool erase_flash is a convenience (opinion).
Can you elaborate on the need of your application to erase data other than NVS?
Can you elaborate on the need of your application to erase data other than NVS?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: make erase_flash affects OTA and NVS patitions
esptool has erase_region
I suppose erase_partition could be useful to add to makefile where it would read partition table and erase named partition's region
I suppose erase_partition could be useful to add to makefile where it would read partition table and erase named partition's region
Last edited by WiFive on Sun Jul 16, 2017 7:28 pm, edited 1 time in total.
-
- Posts: 27
- Joined: Sun Jan 01, 2017 9:21 pm
Re: make erase_flash affects OTA and NVS patitions
Thks for your reply Kolban,
The erase_flash is for development only. In case you change partition sizes it's possible that some data remains. I used it initially to erase the flash when a runtime error in a program occurred. (If I remember correctly I could not flash to ota_0 at that point.)
There is also (sometimes) a strange behavior with "make copyfs" . When you define the SPIFFS base_addr in menuconfig the result in sdkconfig is what you expect. But copyfs complains that the base_addr has an incorrect format " 0x0x2A8000" . So I had to remove the 0x in sdkconfig and afterwards it' s okay. See below. I use eclipse for the development and keep a terminal window open.
# My SPIFFS configuration in sdkconfig
#
CONFIG_SPIFFS_BASE_ADDR=2A8000
CONFIG_SPIFFS_SIZE=1048576
CONFIG_SPIFFS_LOG_BLOCK_SIZE=8192
CONFIG_SPIFFS_LOG_PAGE_SIZE=256
The erase_flash is for development only. In case you change partition sizes it's possible that some data remains. I used it initially to erase the flash when a runtime error in a program occurred. (If I remember correctly I could not flash to ota_0 at that point.)
There is also (sometimes) a strange behavior with "make copyfs" . When you define the SPIFFS base_addr in menuconfig the result in sdkconfig is what you expect. But copyfs complains that the base_addr has an incorrect format " 0x0x2A8000" . So I had to remove the 0x in sdkconfig and afterwards it' s okay. See below. I use eclipse for the development and keep a terminal window open.
# My SPIFFS configuration in sdkconfig
#
CONFIG_SPIFFS_BASE_ADDR=2A8000
CONFIG_SPIFFS_SIZE=1048576
CONFIG_SPIFFS_LOG_BLOCK_SIZE=8192
CONFIG_SPIFFS_LOG_PAGE_SIZE=256
Jan Jansen
Amsterdam
The Netherlands
Amsterdam
The Netherlands
-
- Posts: 27
- Joined: Sun Jan 01, 2017 9:21 pm
Re: make erase_flash affects OTA and NVS patitions
thks for the hint:
This information is in:
https://esp-idf.readthedocs.io/en/v1.0/ ... #functions
Code: Select all
esp_err_t spi_flash_erase_range(size_t start_address, size_t size)
https://esp-idf.readthedocs.io/en/v1.0/ ... #functions
Jan Jansen
Amsterdam
The Netherlands
Amsterdam
The Netherlands
Who is online
Users browsing this forum: No registered users and 158 guests