make erase_flash affects OTA and NVS patitions

JanJansen47
Posts: 27
Joined: Sun Jan 01, 2017 9:21 pm

make erase_flash affects OTA and NVS patitions

Postby JanJansen47 » Sun Jul 16, 2017 10:02 am

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?
Jan Jansen
Amsterdam
The Netherlands

ESP_Sprite
Posts: 9766
Joined: Thu Nov 26, 2015 4:08 am

Re: make erase_flash affects OTA and NVS patitions

Postby ESP_Sprite » Sun Jul 16, 2017 11:31 am

It indeed nukes the entire flash, OTA, NVS and all.

JanJansen47
Posts: 27
Joined: Sun Jan 01, 2017 9:21 pm

Re: make erase_flash affects OTA and NVS patitions

Postby JanJansen47 » Sun Jul 16, 2017 1:03 pm

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.
Jan Jansen
Amsterdam
The Netherlands

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: make erase_flash affects OTA and NVS patitions

Postby kolban » Sun Jul 16, 2017 1:23 pm

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?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

WiFive
Posts: 3529
Joined: Tue Dec 01, 2015 7:35 am

Re: make erase_flash affects OTA and NVS patitions

Postby WiFive » Sun Jul 16, 2017 7:27 pm

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
Last edited by WiFive on Sun Jul 16, 2017 7:28 pm, edited 1 time in total.

JanJansen47
Posts: 27
Joined: Sun Jan 01, 2017 9:21 pm

Re: make erase_flash affects OTA and NVS patitions

Postby JanJansen47 » Sun Jul 16, 2017 7:28 pm

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
Jan Jansen
Amsterdam
The Netherlands

JanJansen47
Posts: 27
Joined: Sun Jan 01, 2017 9:21 pm

Re: make erase_flash affects OTA and NVS patitions

Postby JanJansen47 » Sun Jul 16, 2017 7:35 pm

thks for the hint:

Code: Select all

esp_err_t spi_flash_erase_range(size_t start_address, size_t size)
This information is in:

https://esp-idf.readthedocs.io/en/v1.0/ ... #functions
Jan Jansen
Amsterdam
The Netherlands

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 69 guests