Using ESP-IDF bootloader with ESP32-Arduino code for NVS [SOLVED]

__xwtk
Posts: 4
Joined: Mon Feb 21, 2022 5:05 pm

Using ESP-IDF bootloader with ESP32-Arduino code for NVS [SOLVED]

Postby __xwtk » Sun Feb 26, 2023 5:21 pm

Check solution below.

Since ESP32-Arduino core doesn't support flash encryption, I have made a hybrid OTA system which consists of 2 stages:
Stage 1 - ESP-IDF Simple OTA Example with custom partition table + Flash Encryption + NVS Encryption - This program downloads ESP32-Arduino code from the server and flashes it
Stage 2 - ESP32-Arduino code

My current issue is that I am unable to write/read from the NVS partition regardless whether the NVS has been encrypted or not, I even tried disabling the flash encryption in the menuconfig to test.

I am using the Preferences library, all bools regarding .begin and .putXXXX functions return true (putString, putInt, putUInt). However when trying to read the data from the specified namespace, it returns blank.

When I reflash the ESP using Arduino IDE, even with the same partition table as the one used in ESP-IDF Simple OTA Example, everything works flawlessly.

I tried erasing the flash and flashing the ESP-IDF code again, doesn't help, I really need the Flash Encryption, any solutions?

(Using ESP32-S3)

SOLUTION:
I have managed to get everything working, including NVS encryption. You will need to download ESP-IDF v4.4.4 (as Arduino-ESP32 core is based of V4.4.4), then install the Arduino-ESP32 core as an ESP-IDF component by following the documentation (google: Arduino-ESP32 as an ESP-IDF component).

You will need to copy/paste all your libraries to (ESP-IDF project folder) > Components > Arduino > Libraries

Make sure to include all the .cpp files and the directories in CMake file.

Then follow the instructions in the same documentation to use your standard Arduino sketch (with setup() and loop()) in your project.

Take note that you will need to also initialize the functions in your Arduino sketch prior the functions code itself, like this:

Code: Select all

#include <Arduino.h>

void xxx(xxx); (void can be changed too, noting this in case you don't know much about C++)

void xxx(xxx) {
  //Function
}

...
Note that the "xxx" are just placeholders.

Who is online

Users browsing this forum: No registered users and 197 guests