nvs_test_api.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. #pragma once
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #include "nvs_flash.h"
  19. /**
  20. * @brief Initialize NVS flash storage with custom flash sector layout
  21. *
  22. * @note This API is intended to be used in unit tests.
  23. *
  24. * @param partName Partition name of the NVS partition as per partition table
  25. * @param baseSector Flash sector (units of 4096 bytes) offset to start NVS
  26. * @param sectorCount Length (in flash sectors) of NVS region.
  27. NVS partition must be at least 3 sectors long.
  28. * @return ESP_OK if flash was successfully initialized
  29. */
  30. esp_err_t nvs_flash_init_custom(const char *partName, uint32_t baseSector, uint32_t sectorCount);
  31. #ifdef CONFIG_NVS_ENCRYPTION
  32. /**
  33. * @brief Initialize NVS flash storage with custom flash sector layout
  34. *
  35. * @note This API is intended to be used in unit tests.
  36. *
  37. * @param partName Partition name of the NVS partition as per partition table
  38. * @param baseSector Flash sector (units of 4096 bytes) offset to start NVS
  39. * @param sectorCount Length (in flash sectors) of NVS region.
  40. NVS partition must be at least 3 sectors long.
  41. * @param[in] cfg Security configuration (keys) to be used for NVS encryption/decryption.
  42. * If cfg is null, no encryption/decryption is used.
  43. * @return ESP_OK if flash was successfully initialized
  44. */
  45. esp_err_t nvs_flash_secure_init_custom(const char *partName, uint32_t baseSector, uint32_t sectorCount, nvs_sec_cfg_t* cfg);
  46. #endif
  47. /**
  48. * @brief Dump contents of NVS storage to stdout
  49. *
  50. * This function may be used for debugging purposes to inspect the state
  51. * of NVS pages. For each page, list of entries is also dumped.
  52. *
  53. * @param partName Partition name of the NVS partition as per partition table
  54. */
  55. void nvs_dump(const char *partName);
  56. #ifdef __cplusplus
  57. }
  58. #endif