ESP32, NVS 이해하기
결론적으로 얘기하면 50% 정도만 이해하였다고 판단합니다.
0. 참고 사이트
- http://www.lucadentella.it/en/2017/06/03/esp32-19-nvs/
- https://github.com/lucadentella/esp32-tutorial/blob/master/13_nvs/
- https://esp-idf.readthedocs.io/en/latest/api-guides/partition-tables.html#
- https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/storage/nvs_flash.html#
- https://github.com/espressif/esp-idf/tree/020ade652d9b6b0b87b0bebe176a150cc4407749/components/nvs_flash
sglee@sglee-virtual-machine:~/esp/project/nvs_rw_value$ make partition_table
Partition table binary generated. Contents:
*******************************************************************************
# Espressif ESP32 Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,
*******************************************************************************
Partition flashing command:
python /home/sglee/esp/esp-idf/components/esptool_py/esptool/esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 115200 --before default_reset --after hard_reset write_flash 0x8000 /home/sglee/esp/project/nvs_rw_value/build/partitions_singleapp.bin
로그를 분석하면
- offset 36KB : nvs,data,nvs,0x9000,24K,
- offset 60KB : phy_init,data,phy,0xf000,4K,
- offset 64KB: factory,app,factory,0x10000,1M,
sglee@sglee-virtual-machine:~/esp/project/nvs_rw_value$ make print_flash_cmd
--flash_mode dio --flash_freq 40m --flash_size detect 0x1000 bootloader/bootloader.bin 0x10000 nvs-rw-value.bin 0x8000 partitions_singleapp.bin
로그를 분석하면
- offset 4KB : 0x1000 bootloader/bootloader.bin
- offset 32KB : 0x8000 partitions_singleapp.bin
- offset 64KB : 0x10000 nvs-rw-value.bin
위 2개 로그를 토대로 4MB Flash Size를 쓴다면
4MB-----------------------
할당되지 않은 영역
1.64MB-----------------------
App 영역, 1MB, The bootloader will run this app by default
64KB (factory)-----------------------
phy 영역, 4KB, PHY init data
60KB (phy_init)-----------------------
nvs 영역, 24KB, NVS library partition
36KB (nvs)-----------------------
파티션 테이블, 가변적, 기본적인 partitions_singleapp.bin 크기는 3KB
32KB (partition_table)-----------------------
부트로더, ???KB
4KB (bootloader)-----------------------
???
0KB-----------------------
사용자가 사용할 수 있는 NVS 크기에 대해
홈페이지에서 설명하기를
String values
are currently limited to 4000 bytes. This includes the null terminator.
Blob values are limited to 508000 bytes or (97.6% of the partition size -
4000) bytes whichever is lower.
환산해 보면
3.9KB string
496KB blob
그리고 참고한 홈페이지 중에서 아래와 같이 언급하는데
그렇다면 NVS 파티션 24KB 영역 안에 사용자가 데이터가 들어가는 것으로 보여집니다.
storage1 = 4kb string
storage2 = 4kb string
...
If you use the default partition table (“Single factory app, no OTA”), you may notice that it contains a partition of type data and subtype nvs: The default size for that partition is 24Kbyte. Thanks to the NVS library, you can store custom data into that partition. Information is organized in key/value pairs; a label (= key) with a maximum length of 15 characters is assigned to each value:
|
'ESP32' 카테고리의 다른 글
ESP32, NVS, nvs_rw_blob (0) | 2018.08.23 |
---|---|
ESP32, NVS, nvs_rw_value (0) | 2018.08.23 |
ESP32, TIMER, esp_timer (0) | 2018.08.22 |
ESP32, GPIO, gpio_intr (0) | 2018.08.22 |
ESP32, Bluetooth, ble_spp_server, ble_spp_client (0) | 2018.08.21 |