ESP32, wear_levelling
In Performance mode by erase sector
operation data will be stored to the RAM, sector will be erased and then data will be stored
back to the flash.
If by this operation power off situation will occur, the complete 4096 bytes
will be lost.
To prevent this the Safety mode was implemented.
In safety mode the data will be first
stored to the flash and after sector will be erased, will be stored back.
If power off situation will
occur, after power on, the data will be recovered.
By default defined the sector size 512 bytes and Performance mode.
간략하게 얘기하면
기본 방식은 파티션에 어떤 데이터를 저장할 때
파티션의 해당 sector를 erase하고 다시 write합니다.
문제는 sector erase 후 power off 가 발생하면 데이터 손실이 발생한다는 것입니다.
그래서 나온 방법이
B sector (?)에 data write를 하고
A sector를 erase한 다음
B sector의 data를 A sector에 write하는 방식으로 보여집니다.
만일에 B sector에 data write 이후
power off가 발생한다면
다음 부팅에서 데이터가 복구된다는 것입니다.
여기서 복구란 아마도.... B sector의 data를 A sector로 write하지 않을까 생각합니다.
0. 참고 사이트
- esp-idf\examples\storage\wear_levelling
- https://github.com/espressif/esp-idf/tree/master/examples/storage/wear_levelling
- https://esp-idf.readthedocs.io/en/latest/api-reference/storage/wear-levelling.html
1. 모듈
2. 보드 연결
3. 소스 설명
Custom partition table CSV > partitions_example.csv
cat partitions_example.csv
4. 소스
5. 결과 확인
'ESP32' 카테고리의 다른 글
ESP32, pwm, ledc (0) | 2018.08.23 |
---|---|
ESP32, adc (0) | 2018.08.23 |
ESP32, spiffs (0) | 2018.08.23 |
ESP32, NVS, nvs_rw_blob (0) | 2018.08.23 |
ESP32, NVS, nvs_rw_value (0) | 2018.08.23 |