1 // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 #include "nvs_flash.h" 22 23 /** 24 * @brief Initialize NVS flash storage with custom flash sector layout 25 * 26 * @note This API is intended to be used in unit tests. 27 * 28 * @param partName Partition name of the NVS partition as per partition table 29 * @param baseSector Flash sector (units of 4096 bytes) offset to start NVS 30 * @param sectorCount Length (in flash sectors) of NVS region. 31 NVS partition must be at least 3 sectors long. 32 * @return ESP_OK if flash was successfully initialized 33 */ 34 esp_err_t nvs_flash_init_custom(const char *partName, uint32_t baseSector, uint32_t sectorCount); 35 36 #ifdef CONFIG_NVS_ENCRYPTION 37 /** 38 * @brief Initialize NVS flash storage with custom flash sector layout 39 * 40 * @note This API is intended to be used in unit tests. 41 * 42 * @param partName Partition name of the NVS partition as per partition table 43 * @param baseSector Flash sector (units of 4096 bytes) offset to start NVS 44 * @param sectorCount Length (in flash sectors) of NVS region. 45 NVS partition must be at least 3 sectors long. 46 * @param[in] cfg Security configuration (keys) to be used for NVS encryption/decryption. 47 * If cfg is null, no encryption/decryption is used. 48 * @return ESP_OK if flash was successfully initialized 49 */ 50 esp_err_t nvs_flash_secure_init_custom(const char *partName, uint32_t baseSector, uint32_t sectorCount, nvs_sec_cfg_t* cfg); 51 #endif 52 53 /** 54 * @brief Dump contents of NVS storage to stdout 55 * 56 * This function may be used for debugging purposes to inspect the state 57 * of NVS pages. For each page, list of entries is also dumped. 58 * 59 * @param partName Partition name of the NVS partition as per partition table 60 */ 61 void nvs_dump(const char *partName); 62 63 64 #ifdef __cplusplus 65 } 66 #endif 67