Merge branch 'refactor/nvs_header_cleanup' into 'master'

Cleanup of NVS copyright notices, header pragma once and NVS related constants

See merge request espressif/esp-idf!42353
This commit is contained in:
Radek Tandler
2025-10-02 15:08:45 +02:00
29 changed files with 90 additions and 189 deletions
@@ -29,7 +29,7 @@ public:
esp_partition.erase_size = ESP_PARTITION_EMULATED_SECTOR_SIZE;
esp_partition.type = ESP_PARTITION_TYPE_DATA;
esp_partition.subtype = ESP_PARTITION_SUBTYPE_DATA_NVS;
strncpy(esp_partition.label, partition_name, PART_NAME_MAX_SIZE);
strncpy(esp_partition.label, partition_name, NVS_PART_NAME_MAX_SIZE);
p_part = new (std::nothrow) nvs::NVSPartition(&esp_partition);
REQUIRE(p_part != nullptr);
}
@@ -186,7 +186,7 @@ public:
esp_partition2.erase_size = ESP_PARTITION_EMULATED_SECTOR_SIZE;
esp_partition2.type = ESP_PARTITION_TYPE_DATA;
esp_partition2.subtype = ESP_PARTITION_SUBTYPE_DATA_NVS;
strncpy(esp_partition2.label, partition_name2, PART_NAME_MAX_SIZE);
strncpy(esp_partition2.label, partition_name2, NVS_PART_NAME_MAX_SIZE);
p_part2 = new (std::nothrow) nvs::NVSPartition(&esp_partition2);
REQUIRE(p_part2 != nullptr);
}
+2 -5
View File
@@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef ESP_NVS_H
#define ESP_NVS_H
#pragma once
#include <stdint.h>
#include <stddef.h>
@@ -802,5 +801,3 @@ void nvs_release_iterator(nvs_iterator_t iterator);
#ifdef __cplusplus
} // extern "C"
#endif
#endif //ESP_NVS_H
+1 -5
View File
@@ -3,8 +3,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef nvs_flash_h
#define nvs_flash_h
#pragma once
#ifdef __cplusplus
extern "C" {
@@ -325,6 +324,3 @@ esp_err_t nvs_flash_read_security_cfg_v2(nvs_sec_scheme_t *scheme_cfg, nvs_sec_c
#ifdef __cplusplus
}
#endif
#endif /* nvs_flash_h */
+6 -4
View File
@@ -1,5 +1,9 @@
#ifndef NVS_HANDLE_HPP_
#define NVS_HANDLE_HPP_
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <string>
#include <memory>
@@ -307,5 +311,3 @@ esp_err_t NVSHandle::get_item(const char *key, T &value) {
}
} // nvs
#endif // NVS_HANDLE_HPP_
@@ -1,12 +1,9 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef NVS_CONSTANTS_H
#define NVS_CONSTANTS_H
#include "spi_flash_mmap.h" // for SPI_FLASH_SEC_SIZE
#pragma once
// constants for the NVS to be used in the regular as well as bootloader implementations
@@ -18,7 +15,7 @@
#define NVS_CONST_ESB_WRITTEN 0x1
#define NVS_CONST_ESB_ERASED 0x2
#define NVS_CONST_PAGE_SIZE SPI_FLASH_SEC_SIZE
#define NVS_CONST_PAGE_SIZE 4096 // Page size is by design assumed to be 4096 bytes
#define NVS_CONST_ENTRY_SIZE 32
#define NVS_CONST_ENTRY_COUNT 126
@@ -32,6 +29,8 @@
#define NVS_CONST_NVS_VERSION 0xfe // Decrement to upgrade
#define NVS_ENCRYPT_BLOCK_SIZE 16 // Size of the encryption block in bytes
// Page States
// All bits set, default state after flash erase. Page has not been initialized yet.
#define NVS_CONST_PAGE_STATE_UNINITIALIZED 0xffffffff
@@ -64,5 +63,3 @@
#define NVS_CONST_PAGE_HEADER_OFFSET 0
#define NVS_CONST_PAGE_ENTRY_TABLE_OFFSET (NVS_CONST_PAGE_HEADER_OFFSET + 32)
#define NVS_CONST_PAGE_ENTRY_DATA_OFFSET (NVS_CONST_PAGE_ENTRY_TABLE_OFFSET + 32)
#endif
@@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef NVS_INTERNAL_H
#define NVS_INTERNAL_H
#pragma once
#if CONFIG_NVS_ASSERT_ERROR_CHECK
#define NVS_ASSERT_OR_RETURN(condition, retcode) assert(condition);
@@ -14,5 +13,3 @@
return retcode; \
}
#endif // CONFIG_NVS_ASSERT_ERROR_CHECK
#endif // NVS_INTERNAL_H
@@ -1,11 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef compressed_enum_table_h
#define compressed_enum_table_h
#pragma once
#include <cstdint>
#include <cassert>
@@ -71,5 +69,3 @@ protected:
static const uint32_t VALUE_MASK = (1 << Nbits) - 1;
uint32_t mData[WORD_COUNT];
};
#endif /* compressed_enum_table_h */
+2 -6
View File
@@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef intrusive_list_h
#define intrusive_list_h
#pragma once
#include <cassert>
#include <unordered_map>
@@ -251,6 +250,3 @@ protected:
T* mLast = nullptr;
size_t mSize = 0;
};
#endif /* intrusive_list_h */
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -1,22 +1,12 @@
// Copyright 2019 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifndef NVS_ENCRYPTED_PARTITION_HPP_
#define NVS_ENCRYPTED_PARTITION_HPP_
#include "mbedtls/aes.h"
#include "nvs_flash.h"
#include "mbedtls/aes.h" // For mbedtls_aes_xts_context
#include "nvs_flash.h" // For nvs_sec_cfg_t
#include "nvs_partition.hpp"
namespace nvs {
@@ -39,5 +29,3 @@ protected:
};
} // nvs
#endif // NVS_ENCRYPTED_PARTITION_HPP_
@@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef NVS_HANDLE_LOCKED_HPP_
#define NVS_HANDLE_LOCKED_HPP_
#pragma once
#include "nvs_handle_simple.hpp"
@@ -61,5 +60,3 @@ private:
};
} // namespace nvs
#endif // NVS_HANDLE_LOCKED_HPP_
@@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef NVS_HANDLE_SIMPLE_HPP_
#define NVS_HANDLE_SIMPLE_HPP_
#pragma once
#include "intrusive_list.h"
#include "nvs_storage.hpp"
@@ -104,5 +103,3 @@ private:
};
} // nvs
#endif // NVS_HANDLE_SIMPLE_HPP_
@@ -1,17 +1,8 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "nvs_item_hash_list.hpp"
namespace nvs
@@ -1,11 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef nvs_item_hash_list_h
#define nvs_item_hash_list_h
#pragma once
#include "nvs.h"
#include "nvs_types.hpp"
@@ -62,6 +60,3 @@ protected:
}; // class HashList
} // namespace nvs
#endif /* nvs_item_hash_list_h */
@@ -3,14 +3,13 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <cstdlib>
#if !ESP_TEE_BUILD
#include "esp_heap_caps.h"
#endif
#pragma once
/**
* @brief Type that is only usable with new (std::nothrow) to avoid exceptions.
*
+1 -3
View File
@@ -9,14 +9,12 @@
#include <cstdio>
#include <cstring>
#include "nvs_internal.h"
#include "esp_partition.h"
#include "nvs_memory_management.hpp"
namespace nvs {
Page::Page() : mPartition(nullptr) { }
const uint32_t nvs::Page::SEC_SIZE = 4096;
uint32_t Page::Header::calculateCrc32()
{
return esp_rom_crc32_le(0xffffffff,
+3 -14
View File
@@ -1,23 +1,15 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef nvs_page_hpp
#define nvs_page_hpp
#pragma once
#include "nvs.h"
#include "nvs_types.hpp"
#include <cstdint>
#include <type_traits>
#include <cstring>
#include <algorithm>
#include "compressed_enum_table.hpp"
#include "intrusive_list.h"
#include "nvs_item_hash_list.hpp"
#include "nvs_memory_management.hpp"
#include "partition.hpp"
#include "nvs_constants.h"
namespace nvs
{
@@ -34,7 +26,7 @@ public:
static const uint32_t ESB_WRITTEN = NVS_CONST_ESB_WRITTEN;
static const uint32_t ESB_ERASED = NVS_CONST_ESB_ERASED;
static const uint32_t SEC_SIZE;
static const uint32_t SEC_SIZE = NVS_CONST_PAGE_SIZE;
static const size_t ENTRY_SIZE = NVS_CONST_ENTRY_SIZE;
static const size_t ENTRY_COUNT = NVS_CONST_ENTRY_COUNT;
@@ -239,6 +231,3 @@ protected:
}; // class Page
} // namespace nvs
#endif /* nvs_page_hpp */
+6 -19
View File
@@ -1,18 +1,9 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef nvs_pagemanager_hpp
#define nvs_pagemanager_hpp
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <memory>
#include <list>
@@ -74,8 +65,4 @@ protected:
uint32_t mSeqNumber;
}; // class PageManager
} // namespace nvs
#endif /* nvs_pagemanager_hpp */
+1 -1
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
+2 -5
View File
@@ -1,11 +1,10 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifndef ESP_PARTITION_HPP_
#define ESP_PARTITION_HPP_
#include "esp_partition.h"
#include "intrusive_list.h"
@@ -109,5 +108,3 @@ protected:
};
} // nvs
#endif // ESP_PARTITION_HPP_
@@ -1,6 +1,11 @@
#include "esp_partition.h"
#include "nvs_partition_lookup.hpp"
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "nvs_partition_lookup.hpp" // For partition_lookup namespace
#include "esp_partition.h" // For esp_partition_t
#ifndef LINUX_TARGET
#include "nvs_encrypted_partition.hpp"
#endif // ! LINUX_TARGET
@@ -1,9 +1,13 @@
#include "esp_err.h"
#include "nvs_partition.hpp"
#include "nvs_flash.h"
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifndef NVS_PARTITION_LOOKUP_HPP_
#define NVS_PARTITION_LOOKUP_HPP_
#include "esp_err.h"
#include "nvs_partition.hpp" // For nvs::Partition
#include "nvs_flash.h" // For nvs_sec_cfg_t
namespace nvs {
@@ -16,5 +20,3 @@ esp_err_t lookup_nvs_encrypted_partition(const char* label, nvs_sec_cfg_t* cfg,
} // partition_lookup
} // nvs
#endif // NVS_PARTITION_LOOKUP_HPP_
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef NVS_PARTITION_MANAGER_HPP_
#define NVS_PARTITION_MANAGER_HPP_
#pragma once
#include "nvs_handle_simple.hpp"
#include "nvs_storage.hpp"
@@ -49,5 +48,3 @@ protected:
};
} // nvs
#endif // NVS_PARTITION_MANAGER_HPP_
+2 -5
View File
@@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef nvs_storage_hpp
#define nvs_storage_hpp
#pragma once
#include <memory>
#include <cstdlib>
@@ -175,5 +174,3 @@ struct nvs_opaque_iterator_t
intrusive_list<nvs::Page>::iterator page;
nvs_entry_info_t entry_info;
};
#endif /* nvs_storage_hpp */
+5 -14
View File
@@ -1,17 +1,8 @@
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef __cplusplus
+6 -5
View File
@@ -1,10 +1,9 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef nvs_types_h
#define nvs_types_h
#pragma once
#include <cstdint>
#include <cstring>
@@ -14,6 +13,7 @@
#include "nvs_handle.hpp"
#include "compressed_enum_table.hpp"
#include "string.h"
#include "nvs_constants.h"
namespace nvs
{
@@ -116,6 +116,7 @@ public:
bool checkHeaderConsistency(const uint8_t entryIndex) const;
};
} // namespace nvs
// Safeguard for Item size
static_assert(sizeof(Item) == NVS_CONST_ENTRY_SIZE, "Item size must be 32 bytes");
#endif /* nvs_types_h */
} // namespace nvs
+2 -6
View File
@@ -1,11 +1,9 @@
/*
* SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef PARTITION_HPP_
#define PARTITION_HPP_
#pragma once
#include "esp_err.h"
@@ -52,5 +50,3 @@ public:
};
} // nvs
#endif // PARTITION_HPP_
-7
View File
@@ -479,13 +479,6 @@ components/mbedtls/port/include/sha1_alt.h
components/mbedtls/port/include/sha256_alt.h
components/mbedtls/port/include/sha512_alt.h
components/mbedtls/port/sha/parallel_engine/sha.c
components/nvs_flash/include/nvs_handle.hpp
components/nvs_flash/src/nvs_encrypted_partition.hpp
components/nvs_flash/src/nvs_item_hash_list.cpp
components/nvs_flash/src/nvs_pagemanager.hpp
components/nvs_flash/src/nvs_partition_lookup.cpp
components/nvs_flash/src/nvs_partition_lookup.hpp
components/nvs_flash/src/nvs_test_api.h
components/protocomm/include/transports/protocomm_console.h
components/protocomm/include/transports/protocomm_httpd.h
components/riscv/include/riscv/csr.h