Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f25a7ad

Browse files
committed
feat(nvs_flash): Modify for ESP8266
1 parent f09d861 commit f25a7ad

File tree

16 files changed

+42
-50
lines changed

16 files changed

+42
-50
lines changed

components/esp8266/include/esp_attr.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,10 @@
6868

6969
#define _COUNTER_STRINGIFY(COUNTER) #COUNTER
7070

71+
#ifdef IDF_CI_BUILD
72+
#define IDF_DEPRECATED(REASON) __attribute__((deprecated(REASON)))
73+
#else
74+
#define IDF_DEPRECATED(REASON)
75+
#endif
76+
7177
#endif /* __ESP_ATTR_H__ */

components/esp8266/source/phy_init.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,15 @@ static const char* PHY_NAMESPACE = "phy";
204204
static const char* PHY_CAL_DATA_KEY = "cal_data";
205205
static const char* PHY_RX_GAIN_DC_TABLE_KEY = "dc_table";
206206

207-
static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
207+
static esp_err_t load_cal_data_from_nvs_handle(nvs_handle_t handle,
208208
esp_phy_calibration_data_t* out_cal_data);
209209

210-
static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
210+
static esp_err_t store_cal_data_to_nvs_handle(nvs_handle_t handle,
211211
const esp_phy_calibration_data_t* cal_data);
212212

213213
esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_data)
214214
{
215-
nvs_handle handle;
215+
nvs_handle_t handle;
216216
esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READONLY, &handle);
217217

218218
if (err == ESP_ERR_NVS_NOT_INITIALIZED) {
@@ -230,7 +230,7 @@ esp_err_t esp_phy_load_cal_data_from_nvs(esp_phy_calibration_data_t* out_cal_dat
230230

231231
esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_data)
232232
{
233-
nvs_handle handle;
233+
nvs_handle_t handle;
234234
esp_err_t err = nvs_open(PHY_NAMESPACE, NVS_READWRITE, &handle);
235235

236236
if (err != ESP_OK) {
@@ -243,7 +243,7 @@ esp_err_t esp_phy_store_cal_data_to_nvs(const esp_phy_calibration_data_t* cal_da
243243
}
244244
}
245245

246-
static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
246+
static esp_err_t load_cal_data_from_nvs_handle(nvs_handle_t handle,
247247
esp_phy_calibration_data_t* out_cal_data)
248248
{
249249
esp_err_t err;
@@ -278,7 +278,7 @@ static esp_err_t load_cal_data_from_nvs_handle(nvs_handle handle,
278278
return ESP_OK;
279279
}
280280

281-
static esp_err_t store_cal_data_to_nvs_handle(nvs_handle handle,
281+
static esp_err_t store_cal_data_to_nvs_handle(nvs_handle_t handle,
282282
const esp_phy_calibration_data_t* cal_data)
283283
{
284284
esp_err_t err;

components/esp8266/source/system_api.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ static const char *BACKUP_MAC_DATA_KEY = "backup_mac_data";
136136
static esp_err_t load_backup_mac_data(uint8_t *mac)
137137
{
138138
esp_err_t err;
139-
nvs_handle handle;
139+
nvs_handle_t handle;
140140
uint32_t efuse[4];
141141
uint8_t efuse_crc = 0;
142142
uint8_t calc_crc = 0;
@@ -221,7 +221,7 @@ static esp_err_t load_backup_mac_data(uint8_t *mac)
221221
static esp_err_t store_backup_mac_data()
222222
{
223223
esp_err_t err;
224-
nvs_handle handle;
224+
nvs_handle_t handle;
225225
uint32_t efuse[4];
226226
efuse[0] = REG_READ(EFUSE_DATA0_REG);
227227
efuse[1] = REG_READ(EFUSE_DATA1_REG);

components/lwip/port/esp8266/netif/dhcp_state.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ static const char *interface_key[] = {"IF_STA", "IF_AP", "IF_ETH", "IF_TEST"};
3131
_Static_assert(sizeof(interface_key) / sizeof(char*) == TCPIP_ADAPTER_IF_MAX,
3232
"Number interface keys differs from number of interfaces");
3333

34-
typedef nvs_handle nvs_handle_t;
3534
bool dhcp_ip_addr_restore(void *netif)
3635
{
3736
nvs_handle_t nvs;

components/nvs_flash/Kconfig

Lines changed: 0 additions & 12 deletions
This file was deleted.

components/nvs_flash/host_test/fixtures/test_fixtures.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class PartitionMock : public nvs::Partition {
5252

5353
esp_err_t read_raw(size_t src_offset, void* dst, size_t size) override
5454
{
55-
return esp_partition_read_raw(&partition, src_offset, dst, size);
55+
return esp_partition_read(&partition, src_offset, dst, size);
5656
}
5757

5858
esp_err_t read(size_t src_offset, void* dst, size_t size) override
@@ -62,7 +62,7 @@ class PartitionMock : public nvs::Partition {
6262

6363
esp_err_t write_raw(size_t dst_offset, const void* src, size_t size) override
6464
{
65-
return esp_partition_write_raw(&partition, dst_offset, src, size);
65+
return esp_partition_write(&partition, dst_offset, src, size);
6666
}
6767

6868
esp_err_t write(size_t dst_offset, const void* src, size_t size) override

components/nvs_flash/mock/int/crc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static const unsigned int crc32_le_table[256] = {
5252

5353

5454

55-
extern "C" uint32_t esp_rom_crc32_le(unsigned int crc, unsigned char const * buf,unsigned int len)
55+
extern "C" uint32_t crc32_le(unsigned int crc, unsigned char const * buf,unsigned int len)
5656
{
5757
unsigned int i;
5858
crc = ~crc;

components/nvs_flash/mock/int/crc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extern "C" {
2424
* Mock function to replace ESP ROM function used in IDF with a Linux implementation.
2525
* Note: the name MUST have the prefix esp_rom_* since tools/ci/check_rom_apis.sh checks and complains otherwise.
2626
*/
27-
uint32_t esp_rom_crc32_le(uint32_t crc, const uint8_t* buf, size_t len);
27+
uint32_t crc32_le(uint32_t crc, const uint8_t* buf, size_t len);
2828

2929
#ifdef __cplusplus
3030
}

components/nvs_flash/src/nvs_api.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "crc.h"
2828
#define ESP_LOGD(...)
2929
#else // LINUX_TARGET
30-
#include <esp32/rom/crc.h>
30+
#include <esp_crc.h>
3131

3232
// Uncomment this line to force output from this module
3333
// #define LOG_LOCAL_LEVEL ESP_LOG_DEBUG
@@ -586,13 +586,13 @@ extern "C" esp_err_t nvs_flash_generate_keys(const esp_partition_t* partition, n
586586
* But the read is decrypted through flash encryption engine. This allows unique NVS encryption configuration,
587587
* as flash encryption key is randomly generated per device.
588588
*/
589-
err = esp_partition_write_raw(partition, 0, cfg->eky, NVS_KEY_SIZE);
589+
err = esp_partition_write(partition, 0, cfg->eky, NVS_KEY_SIZE);
590590
if(err != ESP_OK) {
591591
return err;
592592
}
593593

594594
/* Write without encryption, see note above */
595-
err = esp_partition_write_raw(partition, NVS_KEY_SIZE, cfg->tky, NVS_KEY_SIZE);
595+
err = esp_partition_write(partition, NVS_KEY_SIZE, cfg->tky, NVS_KEY_SIZE);
596596
if(err != ESP_OK) {
597597
return err;
598598
}
@@ -638,17 +638,17 @@ extern "C" esp_err_t nvs_flash_read_security_cfg(const esp_partition_t* partitio
638638
return true;
639639
};
640640

641-
auto err = esp_partition_read_raw(partition, 0, eky_raw, NVS_KEY_SIZE);
641+
auto err = esp_partition_read(partition, 0, eky_raw, NVS_KEY_SIZE);
642642
if(err != ESP_OK) {
643643
return err;
644644
}
645645

646-
err = esp_partition_read_raw(partition, NVS_KEY_SIZE, tky_raw, NVS_KEY_SIZE);
646+
err = esp_partition_read(partition, NVS_KEY_SIZE, tky_raw, NVS_KEY_SIZE);
647647
if(err != ESP_OK) {
648648
return err;
649649
}
650650

651-
err = esp_partition_read_raw(partition, 2 * NVS_KEY_SIZE, &crc_raw, 4);
651+
err = esp_partition_read(partition, 2 * NVS_KEY_SIZE, &crc_raw, 4);
652652
if(err != ESP_OK) {
653653
return err;
654654
}

components/nvs_flash/src/nvs_page.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#if defined(LINUX_TARGET)
1616
#include "crc.h"
1717
#else
18-
#include <esp_rom_crc.h>
18+
#include <esp_crc.h>
1919
#endif
2020
#include <cstdio>
2121
#include <cstring>
@@ -27,7 +27,7 @@ Page::Page() : mPartition(nullptr) { }
2727

2828
uint32_t Page::Header::calculateCrc32()
2929
{
30-
return esp_rom_crc32_le(0xffffffff,
30+
return crc32_le(0xffffffff,
3131
reinterpret_cast<uint8_t*>(this) + offsetof(Header, mSeqNumber),
3232
offsetof(Header, mCrc32) - offsetof(Header, mSeqNumber));
3333
}

0 commit comments

Comments
 (0)