]> granicus.if.org Git - esp-idf/commitdiff
nvs_util: Fix to support write of multiple singlepage big blob data
authorShivani Tipnis <shivani@espressif.com>
Thu, 14 Feb 2019 09:47:57 +0000 (15:17 +0530)
committerShivani Tipnis <shivani@espressif.com>
Tue, 26 Mar 2019 10:41:38 +0000 (16:11 +0530)
Closes https://github.com/espressif/esp-idf/issues/3011

(cherry picked from commit ce4944edf01b2a4c997eafe36b66d71f98f2fe29)
(cherry picked from commit 76e4ea7f68526c9931218f8705dd4e20661b97e4)

components/nvs_flash/nvs_partition_generator/README.rst
components/nvs_flash/nvs_partition_generator/nvs_partition_gen.py
components/nvs_flash/nvs_partition_generator/sample_multipage_blob.csv
components/nvs_flash/nvs_partition_generator/sample_singlepage_blob.csv
components/nvs_flash/nvs_partition_generator/testdata/sample_blob.bin [new file with mode: 0644]
components/nvs_flash/test_nvs_host/test_nvs.cpp

index 46b3b771df22ba104913978f163ee8c064e87ed0..97a83b730835e320a592c33d3ca07514710ac154 100644 (file)
@@ -158,7 +158,7 @@ You can also provide the format version number (in any of the two modes):
 You can run the utility in this format by setting the version parameter to v2, as shown below.
 A sample CSV file is provided with the utility::
 
-    python nvs_partition_gen.py --input sample_multipage_blob.csv --output partition_multipage_blob.bin --size 0x3000 --version v2
+    python nvs_partition_gen.py --input sample_multipage_blob.csv --output partition_multipage_blob.bin --size 0x4000 --version v2
 
 
 **Multipage Blob Support Disabled (v1):**
index 18d805951c2bde25b5d37c38fbbf98a35fe59fc5..47242302e065f69496e55dc13b2164d698ec5b34 100755 (executable)
@@ -379,9 +379,14 @@ class Page(object):
         total_entry_count = data_entry_count + 1 # +1 for the entry header
 
         # Check if page is already full and new page is needed to be created right away
-        if encoding in ["string", "hex2bin", "binary", "base64"]:
-            if (self.entry_num + total_entry_count) >= Page.PAGE_PARAMS["max_entries"]:
-                raise PageFullError()
+        if version == Page.VERSION1:
+            if encoding in ["string", "hex2bin", "binary", "base64"]:
+                if (self.entry_num + total_entry_count) >= Page.PAGE_PARAMS["max_entries"]:
+                    raise PageFullError()
+        else:
+            if encoding == "string":
+                if (self.entry_num + total_entry_count) >= Page.PAGE_PARAMS["max_entries"]:
+                    raise PageFullError()
 
         # Entry header
         entry_struct = bytearray(b'\xff')*32
index 353430a9322b7ad2fa87f3486eb389ad60dd48c5..384ac6919ead0a2bfd12b2d104700a574c4f5734 100644 (file)
@@ -11,4 +11,6 @@ dummyBase64Key,data,base64,MTIzYWJj
 hexFileKey,file,hex2bin,testdata/sample.hex
 base64FileKey,file,base64,testdata/sample.base64
 stringFileKey,file,string,testdata/sample.txt
+blobFileAKey,file,binary,testdata/sample_blob.bin
+blobFileBKey,file,binary,testdata/sample_blob.bin
 binFileKey,file,binary,testdata/sample_multipage_blob.bin
index 1ae3524ce651f139edcd540891e213392ed1fe0c..c99f513cf2595e0c0911d2994f2b8073e6e549f6 100644 (file)
@@ -11,4 +11,6 @@ dummyBase64Key,data,base64,MTIzYWJj
 hexFileKey,file,hex2bin,testdata/sample.hex
 base64FileKey,file,base64,testdata/sample.base64
 stringFileKey,file,string,testdata/sample.txt
+blobFileAKey,file,binary,testdata/sample_blob.bin
+blobFileBKey,file,binary,testdata/sample_blob.bin
 binFileKey,file,binary,testdata/sample_singlepage_blob.bin
diff --git a/components/nvs_flash/nvs_partition_generator/testdata/sample_blob.bin b/components/nvs_flash/nvs_partition_generator/testdata/sample_blob.bin
new file mode 100644 (file)
index 0000000..eac2d31
--- /dev/null
@@ -0,0 +1 @@
+start0000000000000000000000start0123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef00000000000000000123456789abcdef0000000000000000end00000000000000000000000000end
\ No newline at end of file
index 8dce5d0f1aa4b9a8fe393140693eff97b27f9468..8f3819c535a2fa3dd1cf5a76ddf6356b48791267 100644 (file)
@@ -2057,14 +2057,14 @@ TEST_CASE("Recovery from power-off during modification of blob present in old-fo
     TEST_ESP_ERR(p3.findItem(1, ItemType::BLOB, "singlepage"), ESP_ERR_NVS_NOT_FOUND);
 }
 
-static void check_nvs_part_gen_args(char const *part_name, char const *filename, bool is_encr, nvs_sec_cfg_t* xts_cfg)
+static void check_nvs_part_gen_args(char const *part_name, int size, char const *filename, bool is_encr, nvs_sec_cfg_t* xts_cfg)
 {
     nvs_handle handle;
    
     if (is_encr)
-        TEST_ESP_OK(nvs_flash_secure_init_custom(part_name, 0, 3, xts_cfg));
+        TEST_ESP_OK(nvs_flash_secure_init_custom(part_name, 0, size, xts_cfg));
     else
-        TEST_ESP_OK( nvs_flash_init_custom(part_name, 0, 3) );
+        TEST_ESP_OK( nvs_flash_init_custom(part_name, 0, size) );
     
     TEST_ESP_OK( nvs_open_from_partition(part_name, "dummyNamespace", NVS_READONLY, &handle));
     uint8_t u8v;
@@ -2148,7 +2148,7 @@ TEST_CASE("check and read data from partition generated via partition generation
     
     TEST_ESP_OK(nvs_flash_deinit());
     
-    check_nvs_part_gen_args("test", "../nvs_partition_generator/testdata/sample_singlepage_blob.bin", false, NULL);
+    check_nvs_part_gen_args("test", 3, "../nvs_partition_generator/testdata/sample_singlepage_blob.bin", false, NULL);
 }
 
 
@@ -2163,7 +2163,7 @@ TEST_CASE("check and read data from partition generated via partition generation
                 "--output",
                 "../nvs_partition_generator/partition_multipage_blob.bin", 
                 "--size",
-                "0x3000",
+                "0x4000",
                 "--version",
                 "v2",NULL));
     } else {
@@ -2175,7 +2175,7 @@ TEST_CASE("check and read data from partition generated via partition generation
 
     SpiFlashEmulator emu("../nvs_partition_generator/partition_multipage_blob.bin");
     
-    check_nvs_part_gen_args("test", "../nvs_partition_generator/testdata/sample_multipage_blob.bin",false,NULL);
+    check_nvs_part_gen_args("test", 4, "../nvs_partition_generator/testdata/sample_multipage_blob.bin",false,NULL);
 
 }
 
@@ -2329,7 +2329,7 @@ TEST_CASE("test nvs apis for nvs partition generator utility with encryption ena
                 "--output",
                 "../nvs_partition_generator/partition_encrypted.bin",
                 "--size",
-                "0x3000",
+                "0x4000",
                 "--encrypt",
                 "True",
                 "--keyfile",
@@ -2349,7 +2349,7 @@ TEST_CASE("test nvs apis for nvs partition generator utility with encryption ena
         cfg.tky[count] = 0x22;
     }
 
-    check_nvs_part_gen_args(NVS_DEFAULT_PART_NAME, "../nvs_partition_generator/testdata/sample_multipage_blob.bin", true, &cfg);
+    check_nvs_part_gen_args(NVS_DEFAULT_PART_NAME, 4, "../nvs_partition_generator/testdata/sample_multipage_blob.bin", true, &cfg);
     
 }
 
@@ -2366,7 +2366,7 @@ TEST_CASE("test nvs apis for nvs partition generator utility with encryption ena
                     "--output",
                     "../nvs_partition_generator/partition_encrypted_using_keygen.bin",
                     "--size",
-                    "0x3000",
+                    "0x4000",
                     "--encrypt",
                     "True",
                     "--keygen",
@@ -2396,7 +2396,7 @@ TEST_CASE("test nvs apis for nvs partition generator utility with encryption ena
         cfg.tky[count] = buffer[count+32] & 255;
     }
 
-    check_nvs_part_gen_args(NVS_DEFAULT_PART_NAME, "../nvs_partition_generator/testdata/sample_multipage_blob.bin", true, &cfg);
+    check_nvs_part_gen_args(NVS_DEFAULT_PART_NAME, 4, "../nvs_partition_generator/testdata/sample_multipage_blob.bin", true, &cfg);
 
 
 }
@@ -2413,7 +2413,7 @@ TEST_CASE("test nvs apis for nvs partition generator utility with encryption ena
                 "--output",
                 "../nvs_partition_generator/partition_encrypted_using_keyfile.bin",
                 "--size",
-                "0x3000",
+                "0x4000",
                 "--encrypt",
                 "True",
                 "--keyfile",
@@ -2443,7 +2443,7 @@ TEST_CASE("test nvs apis for nvs partition generator utility with encryption ena
         cfg.tky[count] = buffer[count+32] & 255;
     }
 
-    check_nvs_part_gen_args(NVS_DEFAULT_PART_NAME, "../nvs_partition_generator/testdata/sample_multipage_blob.bin", true, &cfg);
+    check_nvs_part_gen_args(NVS_DEFAULT_PART_NAME, 4, "../nvs_partition_generator/testdata/sample_multipage_blob.bin", true, &cfg);
 
     childpid = fork();
     if (childpid == 0) {