使用NVS Partition Generator Utility nvs读取不到key值
Posted: Fri Apr 19, 2019 7:32 am
https://docs.espressif.com/projects/esp ... n_gen.html
我这边是按照上面的流程进行操作
要生成的test.csv
转.bin指令
分区表也进行了修改
读取的函数
但是得到的日志出来是
if the requested key doesn't exist,key值不存在,请问下我是哪一步出现问题呢?
我这边是按照上面的流程进行操作
要生成的test.csv
- key,type,encoding,value
- namespace_name,namespace,,
- key1,data,u8,1
- python ~/esp/esp-idf/components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py --input test.csv --output test.bin --size 0x6000
- # Espressif ESP32 Partition Table
- #
- # Note: if you change the phy_init or app partition offset
- # make sure to change the offset in Kconfig.projbuild
- #
- # Name, Type, SubType, Offset, Size, Flags
- nvs, data, nvs, 0x9000, 0x6000,
- phy_init, data, phy, 0xf000, 0x1000,
- factory, app, factory, 0x10000, 1200000,
- #define TEST_STORAGE_NAMESPACE "namespace_name" //nvs测试名字空间
- uint8_t test_data = 0;
- /******************************
- * 函数名称:get_nvs_csv_data
- * 作 者:Kyle
- * 日 期:20190419
- * 描 述:测试nvs
- * 输入参数:无
- * 返 回 值:无
- ******************************/
- esp_err_t get_nvs_csv_data(void)
- {
- esp_err_t ret = ESP_FAIL;
- esp_err_t err = ESP_FAIL;
- nvs_handle read_nvs_handle;
- size_t required_size = 1;
- ESP_LOGI(SPP_TAG, "required_size:%d\n",required_size);
- // Open
- ESP_ERROR_CHECK(nvs_open(TEST_STORAGE_NAMESPACE, NVS_READWRITE, &read_nvs_handle));
- // Read
- err = nvs_get_blob(read_nvs_handle, "key1", &test_data, &required_size);
- ESP_LOGI(SPP_TAG, "[ test data ]:%d\n",test_data);
- if(err == ESP_OK)
- {
- ESP_LOGI(SPP_TAG, "[ test data ]:%d\n",test_data);
- ret = ESP_OK;
- }
- else if(err == ESP_ERR_NVS_NOT_FOUND)
- {
- ESP_LOGI(SPP_TAG,"ESP_ERR_NVS_NOT_FOUND\n");
- }
- // Commit
- ESP_ERROR_CHECK(nvs_commit(read_nvs_handle));
- // Close
- nvs_close(read_nvs_handle);
- return ret;
- }
- I (264) SPP_ACCEPTOR_DEMO: required_size:1
- I (274) SPP_ACCEPTOR_DEMO: [ test data ]:0
- I (274) SPP_ACCEPTOR_DEMO: ESP_ERR_NVS_NOT_FOUND