Creating a Custom Partition for ESP-AT

drowsell
Posts: 3
Joined: Fri Nov 17, 2023 10:28 pm

Creating a Custom Partition for ESP-AT

Postby drowsell » Fri Nov 17, 2023 10:35 pm

Hello I am flashing my ESP-C3-WROOM-02 with the following command:

[Codebox]python -m esptool -p COM7 -b 921600 --before default_reset --after hard_reset --chip esp32c3 write_flash --flash_mode dio --flash_size 4MB 0x8000 partition_table/partition-table.bin 0xd000 ota_data_initial.bin 0xf000 phy_multiple_init_data.bin 0x0 bootloader/bootloader.bin 0x60000 esp-at.bin 0x1e000 at_customize.bin 0x1F000 customized_partitions/ble_data.bin 0x3a000 customized_partitions/mqtt_key.bin 0x27000 customized_partitions/server_key.bin 0x3c000 customized_partitions/mqtt_ca.bin 0x2d000 customized_partitions/client_key.bin 0x2b000 customized_partitions/client_cert.bin 0x31000 customized_partitions/factory_param.bin 0x2f000 customized_partitions/client_ca.bin 0x38000 customized_partitions/mqtt_cert.bin 0x29000 customized_partitions/server_ca.bin 0x25000 customized_partitions/server_cert.bin[/Codebox]

I would like to create some additional custom partitions to hold user data. I am wondering how I would go about creating a partition space? I am not sure of the steps to creating a user_space.bin that I could add here. Additionally, how much space could I realistically use for this user data section?

Lastly, to write to this space via an AT command would I use AT+SYSFLASH?

Thanks for any help!

drowsell
Posts: 3
Joined: Fri Nov 17, 2023 10:28 pm

Re: Creating a Custom Partition for ESP-AT

Postby drowsell » Mon Nov 20, 2023 9:39 pm

Today I continued to work on this. I used the ESP-IDF to change my partition to look like the following:

partitions.csv
[Codebox]# Name, Type, SubType, Offset, Size
phy_init, data, phy, 0xd000, 0x1000
nvs, data, nvs, 0xe000, 0xE000
at_customize, 0x40, 0, 0x1E000, 0x262000
factory, app, factory, 0x280000, 0x180000[/Codebox]

at_customize.csv
[Codebox]# Name, Type, SubType, Offset, Size
mfg_nvs, data, nvs, 0x1f000, 124K
fatfs, data, fat, 0x47000, 100K
storage, data, spiffs, 0x60000, 0x220000[/Codebox]

I am trying to access raw text data from the storage partition via AT commands.

I am using the following commands, but I am receiving ERROR:

"AT+SYSFLASH=?"
"AT+SYSFLASH=0,"storage"
"AT+SYSFLASH=1,"storage",0x60000,10<0xaa>"
"AT+SYSFLASH=2,"storage",0x60000,10"

Can anyone tell me what could be wrong? I could use some insight.

All the best!


esp-at
Posts: 200
Joined: Mon May 09, 2022 3:00 am

Re: Creating a Custom Partition for ESP-AT

Postby esp-at » Tue Dec 05, 2023 1:13 pm

Hello drowsell,
If you would like to save some data to flash, you could use AT+SYSMFG command to make it: https://docs.espressif.com/projects/esp ... cmd-sysmfg

For example, you want to save "hello world", you can send AT+SYSMFG=2,"factory_param","mykey",7,11 command and enter "hello world", the data will be stored into mfg_nvs partition (the partition size is depends on your at_customize.csv).
Once it was stored, you can query this data by command: AT+SYSMFG=1,"factory_param","mykey"

If you just want to save some temporary data in RAM space, you also can consider use AT+USERRAM command:
https://docs.espressif.com/projects/esp ... md-userram

~

drowsell
Posts: 3
Joined: Fri Nov 17, 2023 10:28 pm

Re: Creating a Custom Partition for ESP-AT

Postby drowsell » Fri Dec 15, 2023 8:29 pm

esp-at wrote:
Tue Dec 05, 2023 1:13 pm
Hello drowsell,
If you would like to save some data to flash, you could use AT+SYSMFG command to make it: https://docs.espressif.com/projects/esp ... cmd-sysmfg

For example, you want to save "hello world", you can send AT+SYSMFG=2,"factory_param","mykey",7,11 command and enter "hello world", the data will be stored into mfg_nvs partition (the partition size is depends on your at_customize.csv).
Once it was stored, you can query this data by command: AT+SYSMFG=1,"factory_param","mykey"

If you just want to save some temporary data in RAM space, you also can consider use AT+USERRAM command:
https://docs.espressif.com/projects/esp ... md-userram

~
Hi,

We decided that FatFS would work best for our needs, but I am having trouble with expanding its size through the IDF. My partitions are as follow:

at_customize:

# Name, Type, SubType, Offset, Size
mfg_nvs, data, nvs, 0x1f000, 124K
fatfs, data, fat, 0x47000, 0x239000

partitions_at:

# Name, Type, SubType, Offset, Size
phy_init, data, phy, 0xd000, 0x1000
nvs, data, nvs, 0xe000, 0xE000
at_customize, 0x40, 0, 0x1E000, 0x262000
factory, app, factory, 0x280000, 0x180000

Here are the steps I am taking with the IDF:

python build.py menuconfig

Navigate to “AT Customized Partitions > AT Customized Partition Table (enable AT customized partition table) > Enable”

Navigate to “AT Customized Partitions > (module_config/module_esp32c3_default/at_customize.csv) AT Customized partition file”

Change the file location to match where you saved the file in your directory

Navigate to “AT Customized Partitions > (0x1e000) offset of AT customized partition table”

Make sure the offset matches the offset of your at_customize that is found in you main partition file.

Navigate to “Partition Table > Partition Table (Custom partition table CSV) > Custom partition table CSV”

Navigate to “Partition Table > (module_config/module_esp32c3_default/partitions_at.csv) Custom partition CSV file” and change the file path to you new partition file.

Configs:

Added:

Component config>AT>AT FS command support

AT Customized Partition>AT Customized Partition Table

Compiler options>Optimization Level>Optimize for size -Os

Removed:

Compiler options>Optimization Level>Debug -Og

Component config>AT>AT OTA command support

Component config>ESP HTTPS OTA>Allow HTTP for OTA

python build.py build


When I build I get the following error message:

fatfs size error

This prevents the fatfs.bin from being created. I tried to get around this by manually generating the binary with the following command:
[Codebox]
C:\Espressif\python_env\idf5.1_py3.11_env\Scripts\python.exe C:/Projects/esp-at\esp-idf\components\fatfs\wl_fatfsgen.py C:/Projects/esp-at\components\fs_image --partition_size 0x239000 --output_file C:/Projects/esp-at/build/customized_partitions\fatfs.bin --sector_size 4096 --long_name_support --sectors_per_cluster 1 --fat_type 0 [/Codebox]

However this has not worked. The build will compile, but FS commands are not working.

Is there any step that I am missing? I was able to to get the default image working with FatFS, but I cannot expand the size of the FatFS to larger than 100K.

Any help is appreciated!

esp-at
Posts: 200
Joined: Mon May 09, 2022 3:00 am

Re: Creating a Custom Partition for ESP-AT

Postby esp-at » Tue Jan 16, 2024 3:02 am

could you please try to change `--sector_size 4096` to `--sector_size 512`, and test again.

And if the issue still exists, i would like to look into it if you can push your reproduce code to GitHub.

Who is online

Users browsing this forum: No registered users and 68 guests