When using the developer version of PlatformIO or Arduino 2.1.1 to upload a Filesystem image to the ESP32 Nano, an error prevents the process from completing. Furthermore, SPIFFS cannot be initialized, even when using the default SPIFFS_Test example.
ERROR:
Opening DFU capable USB device...
Device ID 2341:0070
Device DFU version 0101
Claiming USB DFU Interface...
Setting Alternate Interface #0 ...
Determining device status...
DFU state(10) = dfuERROR, status(3) = Device is unable to write memory
Clearing status
Determining device status...
DFU state(2) = dfuIDLE, status(0) = No error condition is present
DFU mode device DFU version 0101
Device returned transfer size 4096
Copying data from PC to DFU device
Download [ ] 0% 0 bytes failed!
DFU state(10) = dfuERROR, status(3) = Device is unable to write memory
*** [uploadfs] Error 74
In principle, a spiffs (or littlefs) image is created out of the data folder using mkspiffs (or mklittlefs), and then uploaded to Arduino Nano ESP32 using esptool under bootloader mode.
As to PlatformIO, it seems that the dfu protocol is used by default to upload both sketch and FS image. However, a esptool protocol should be used to upload the FS image.
So, I solved the problem by manually add "upload_protocol = esptool" in the platformio.ini when I'm uploading the FS image.
Note that the Arduino Nano ESP32 should be manually set to bootloader mode (by connecting B1 and Ground with a jumper wire) for the esptool to take effect. The serial port is also different from the one used in dfu protocol, so let it detect the serial port on its own.
After the FS image is successfully uploaded, don't forget to press the reset button on the board to exit from the bootloader mode, and change the line in platformio.ini to "upload_protocol = dfu" for the normal sketch uploading.
The issue with activating the upload_protocol=esptool is that PlatformIO rescans your whole solution once you reset back to the normal sketch upload mechanism (commenting to ;upload_protocol = esptool).
And as a result, it completely recompiles your solution once you build and upload your sketch For me this takes like 5 minutes.
Sorry, no, post #7. I mean, it confused me. I was looking into the IDE looking into your feedback, trying out your recommended solution, and did not find the correct menu option, and I don't understand how the IDE comment of Arduino can help with a PlatformIO related issue ...