How to Update mfg_nvs Partition

[中文]

mfg_nvs Partition

mfg_nvs (manufacturing nvs) partition is defined in esp-at/module_config/{module_name}/at_customize.csv file. This partition stores the following configurations of factory firmware:

When you need to modify the factory parameter configurations, PKI configurations, or GATTS configurations, you can recompile the ESP-AT project to generate a new mfg_nvs.bin file; Alternatively, through at.py Tool modify the firmware to generate a new firmware for your module. This article introduces the former.

Generate mfg_nvs.bin

After the configuration modifications are completed, re-build the project. During the compilation stage, the mfg_nvs.py script is automatically used to generate the build/customized_partitions/mfg_nvs.csv file (which contains the namespace, key, type, and value information for all configurations). Then, the nvs_partition_gen.py script in esp-idf is used to generate the build/customized_partitions/mfg_nvs.bin file (which represents the structure of the NVS library (NVS flash API reference)). Then, you can download the mfg_nvs.bin file to the device.

Download mfg_nvs.bin

You can download the mfg_nvs.bin in one of the following ways.

  • Download the recompiled ESP-AT firmware. See Step 7. Flash onto the Device for more information.

  • Download mfg_nvs.bin only. This way only updates the mfg_nvs area in the device.

    • Windows

      Please download the Windows Flash Download Tool. Refer to the readme.pdf or the documentation in the doc directory for instructions. Download the build/customized_partitions/mfg_nvs.bin file to ESP32. You can use the AT+SYSFLASH? command to query the download address of mfg_nvs.bin.

    • Linux or macOS

      Please use esptool.py.

      You can execute the following command in the ESP-AT root directory to download the mfg_nvs.bin file.

      esptool.py --chip auto --port PORTNAME --baud 921600 --before default_reset --after hard_reset write_flash -z --flash_mode dio --flash_freq 40m --flash_size 4MB ADDRESS mfg_nvs.bin
      

      Replace PORTNAME with your serial port name. Replace ADDRESS with the address for downloading the mfg_nvs.bin file. You can use the AT+SYSFLASH? command to query the download address.

  • MCU sends the AT+SYSFLASH command to update the mfg_nvs partition of ESP32.

    # Erase the mfg_nvs partition
    AT+SYSFLASH=0,"mfg_nvs",0,MFG_NVS_SIZE
    
    # Write the mfg_nvs.bin file
    AT+SYSFLASH=1,"mfg_nvs",0,MFG_NVS_SIZE
    

    Replace MFG_NVS_SIZE with the size of the downloaded mfg_nvs.bin file. Different modules have different partition sizes. You can use the AT+SYSFLASH? command to query the partition size.