espressif / esp-idf

Espressif IoT Development Framework. Official development framework for Espressif SoCs.
Apache License 2.0
13.38k stars 7.22k forks source link

How to upload nvs partition with wifi credentials (IDFGH-13678) #14554

Open ConDai opened 1 week ago

ConDai commented 1 week ago

Answers checklist.

General issue report

I would like to generate a nvs partition containing wifi credentials and upload it to my ESP32. I am generating the nvs partition from a CSV using the NVS Partition Generator

I want to set the wifi credentials in the CSV in a format compatible with the esp wifi component. The esp wifi saves wifi credentials in NVS by default. If we read the partition after saving a credential I get the following

# Read the NVS parititon on ESP32
esptool.py --port /dev/ttyUSB0 read_flash 0x9000 0x5000 nvs.img

# Read the key values pairs for wifi sta
python3 /home/daigo/src/espressif/esp-idf/components/nvs_flash/nvs_partition_tool/nvs_tool.py nvs.img  -d minimal -f text | grep sta
 nvs.net80211:sta.rrm_e = 0
 nvs.net80211:sta.btm_e = 0
 nvs.net80211:sta.mbo_e = 0
 nvs.net80211:sta.bss_retry = 0
 nvs.net80211:sta.trans_d = 0
 nvs.net80211:sta.sae_h2e = 2
 nvs.net80211:sta.scan_method = 0
 nvs.net80211:sta.minauth = 3
 nvs.net80211:sta.ssid[0] = b'\x05\x00\x00\x00REDACTED_SSID\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 nvs.net80211:sta.pswd[0] = b'REDACTED_PASSWORD\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
 nvs.net80211:sta.apsw[0] = b'\x05\x01'
 nvs.net80211:sta.chan = 6

I want to set the ssid and password using the following format

key,type,encoding,value
net80211 ,namespace,,
std.ssid,data,string,"SSID"
std.pswd,data,string,"PASSWORD"

However, the SSID is stored as a blob type instead of a string type and is prefixed by \x05\x00\x00\x00

Is there a way I can set the wifi credentials in NVS that is compatible with esp_wifi and is human-friendly?

I originally raised the question on the esp32 forum here but didn't get resolved.

ConDai commented 5 days ago

I understand the team is busy. When can I expect an update?