I am using an ESP32-WROOM-32U module with 16MB flash. I have been able to make a 12MG partition on the flash called fs_ext but I have been unable to mount a file system on it. The goal is to have a 12MB file system that survives OTA reflashes and reboots, so user data is preserved.
The partition was made with entries in mos.yml. Here is the partition table:
[Apr 13 23:04:26.809] e[0;32mI (65) boot: ## Label Usage Type ST Offset Length Flagse[0m
[Apr 13 23:04:26.809] e[0;32mI (73) boot: 0 nvs WiFi data 01 02 00009000 00004000 00000000e[0m
[Apr 13 23:04:26.809] e[0;32mI (82) boot: 1 otadata OTA data 01 00 0000d000 00002000 00000000e[0m
[Apr 13 23:04:26.820] e[0;32mI (90) boot: 2 app_0 OTA app 00 10 00010000 00180000 00000000e[0m
[Apr 13 23:04:26.825] e[0;32mI (98) boot: 3 fs_0 FS 01 82 00190000 00040000 00000000e[0m
[Apr 13 23:04:26.836] e[0;32mI (106) boot: 4 app_1 OTA app 00 11 001d0000 00180000 00000000e[0m
[Apr 13 23:04:26.842] e[0;32mI (115) boot: 5 fs_1 FS 01 82 00350000 00040000 00000000e[0m
[Apr 13 23:04:26.853] e[0;32mI (123) boot: 6 fs_ext FS 01 82 00390000 00c00000 00000000e[0m
[Apr 13 23:04:26.859] e[0;32mI (131) boot: End of partition tablee[0m
Here are the entries I made in mos.yml to try and create the file system:
config_schema:
- ["fstab.fs_ext.dev", "data"]
- ["fstab.fs_ext.type", "LFS"]
- ["fstab.fs_ext.opts", '{"bs": 4096}']
- ["fstab.fs_ext.path", "/data"]
- ["fstab.fs_ext.create", true]
Here is the code I usd to test it:
// Use POSIX and C standard library functions to work with files.
// First create a file.
LOG(LL_INFO, ("%s", "Opening file"));
FILE* f = fopen("/data/hello.txt", "w");
if (f == NULL)
{
LOG(LL_INFO, ("%s","Failed to open file for writing"));
return;
}
fprintf(f, "Hello World!\n");
fclose(f);
LOG(LL_INFO, ("%s","File written"));
The code just fails to open the file. If someone could let me know what I messed up I would appreciate it, thanks…