From 121b33be296883406b9306d1be536e4b914eecf2 Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Wed, 29 Dec 2021 19:37:58 +0800 Subject: [PATCH] add nvs initialize --- .../controller_hci_uart_esp32c3/main/uhci_uart_demo.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/uhci_uart_demo.c b/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/uhci_uart_demo.c index 79baa1f166..77306f0e48 100644 --- a/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/uhci_uart_demo.c +++ b/examples/bluetooth/hci/controller_hci_uart_esp32c3/main/uhci_uart_demo.c @@ -13,6 +13,7 @@ #include "soc/lldesc.h" #include "esp_private/gdma.h" #include "hal/uhci_ll.h" +#include "nvs_flash.h" #include "esp_bt.h" #include "esp_log.h" @@ -255,6 +256,14 @@ void app_main(void) { esp_err_t ret; + /* Initialize NVS — it is used to store PHY calibration data */ + ret = nvs_flash_init(); + if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { + ESP_ERROR_CHECK(nvs_flash_erase()); + ret = nvs_flash_init(); + } + ESP_ERROR_CHECK( ret ); + uhci_uart_install(); esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();