Hi,
I have an ESP code built in VS Code and uploaded to ESP32 via Platformio. The software should be updatable by my users via a webpage, using Webserial.
Generally this works fine, I just write all the .bin files from the .pio folder to the appropriate places on the ESP flash. The only file that doesn’t work is the SPIFFS.bin, likely because it’s compressed before upload.
Unfortunately I have not been able to compress the file myself in the correct way. Is there any way to do it? Or to just make platformio write the compressed file to disc instead of directly to the ESP32?
No, the file is already the built filtesystem (output of mkspiffs
or mklittlefs
or mkfatfs
). Uploading it to the correct address as-is should work. Do you correctly use the same target address as pio run -t uploadfs -v
(PlatformIO core CLI) does?
Yes, I use the same address, but it’s clearly the uncompressed file. It’s as large as what Platformio says it has before compression, not what it has after upload.
During upload Platformio says “compressing”.
If I manually compress SPIFFS.bin with gzip, I get nearly the identical size as when Platformio compresses it, but a couple dozen bytes larger.
I’m pretty sure that’s esptool.py doing a transport compression to the bootloader, but in the end, the contents of the original file contents will be written.
Can you show the full log of the regular filesystem upload?
This is the output:
Uploading stub…
Running stub…
Stub running…
Changing baud rate to 921600
Changed.
Configuring flash size…
Flash will be erased from 0x00290000 to 0x003effff…
Compressed 1441792 bytes to 52104…
Writing at 0x00290000… (25 %)
Writing at 0x002996fb… (50 %)
Writing at 0x002a39a2… (75 %)
Writing at 0x002be0fc… (100 %)
Wrote 1441792 bytes (52104 compressed) at 0x00290000 in 8.4 seconds (effective 1375.6 kbit/s)…
Hash of data verified.
Since the file has so many zeroes of 0xff at the end for unused flash content, it sure pays off for esptool.py to do this compression on the transport way. But again, the exact same data ends up in the flash.
How do you invoke esptool.py to write the spiffs.bin to 0x00290000
? Or, via the webserial?
I dont invoke esptool.py. Webserial has a built in function for writing to flash. There I use a manifest.json to specify which file goes to which starting address.
As stated, this works perfectly for the firmaware, bootloader, partitions etc. Only the SPIFFS.bin doesn’t work.
Or at least the ESP cannot read the SPIFFS correctly when written via Webserial
“builds”: [
{
“chipFamily”: “ESP32”,
“parts”: [
{
“path”: “bootloader.bin”,
“offset”: 4096
},
{
“path”: “partitions.bin”,
“offset”: 32768
},
{
“path”: “firmware.bin”,
“offset”: 65536
},
{
“path”: “spiffs.bin”,
“offset”: 2703360
}
]
}
]
}
Ah, I see that for some reason the hex conversion was wrong. With the current address I actually get an error… so it seems writing spiffs.bin somehow is different than writing the other .bin files…