The partitions.csv should be in the same place as the platformio.ini
@sivar2311 I am currently using platform = espressif32@6.12.0. Should I switch to some other platform for e.g. the latest pioarduino? What version are you using? I would like to make my settings as close to you as possible.
That depends on your needs.
Usually I use the latest pioarduino espressif32-platform version.
But when I need Espressif Arduino 2.x (for compatibility reasons) I use the latest official PlatformIO espressif32-platform.
I ran the test with both latest versions without issues.
Ok. And do you also perform Upload Filesystem Image (for data folder) before flashing the code? I see that when I use SPIFFS, I am not getting any error. Only with LittleFS I am unable to work.
First, I just uploaded the sketch to see what would happen. I got an error message saying that the partition could not be mounted. This was to be expected, as there was no valid LittleFS file system in the partition yet.
I then created the file system and uploaded it. After restarting the ESP32, the partition was successfully mounted (as expected).
Yes, its only a name but show in LittleFS.h header file.
bool begin(bool formatOnFail = false, const char *basePath = "/littlefs", uint8_t maxOpenFiles = 10, const char *partitionLabel = "spiffs");
The default label of a littlefs partition is āspiffsā. You should name it that or tell the label name of the begin function.I think that was done for compatibility reasons.
I am having issues using littlefs with esp32s3-n16r8 as well using the Espressif 32 6.12.0 platform, platformio VS Code:
[env:esp32-s3-n16r8]
platform = espressif32
board = esp32-s3-devkitc-1-n16r8v
framework = arduino
monitor_speed = 115200
board_build.partitions = default_16MB.csv
board_build.filesystem = littlefs
upload_protocol = esp-builtin
build_flags =
-D ARDUINO_USB_CDC_ON_BOOT=1
-D ARDUINO_USB_MODE=1
-DBOARD_HAS_PSRAM
-D PIO_FRAMEWORK_ARDUINO_LITTLEFS
And I keep getting this on serial:
--- Terminal on COM5 | 115200 8-N-1
--- Available filters and text transformations: colorize, debug, default, direct, esp32_exception_decoder, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at https://bit.ly/pio-monitor-filters
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x0 (DOWNLOAD(USB/UART0))
waiting for download
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
E (3012) esp_littlefs: ./components/esp_littlefs/src/littlefs/lfs.c:1367:error: Corrupted dir pair at {0x0, 0x1}
This is my partition table printed with esp_partition_get:
--- Partition Table ---
Name | Type | SubType | Offset | Size
---------------------+-------+---------+------------+-----------
nvs | 0x01 | 0x02 | 0x00009000 | 0x00005000
otadata | 0x01 | 0x00 | 0x0000e000 | 0x00002000
app0 | 0x00 | 0x10 | 0x00010000 | 0x00640000
app1 | 0x00 | 0x11 | 0x00650000 | 0x00640000
spiffs | 0x01 | 0x82 | 0x00c90000 | 0x00360000
coredump | 0x01 | 0x03 | 0x00ff0000 | 0x00010000
Same result after uploadfs:
PS I:\Arduino\Projects\Test1\Test1> pio run --target uploadfs
Processing esp32-s3-n16r8 (platform: espressif32; board: esp32-s3-devkitc-1-n16r8v; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32-s3-devkitc-1-n16r8v.html
PLATFORM: Espressif 32 (6.12.0) > Espressif ESP32-S3-DevKitC-1-N16R8V (16 MB QD, 8MB PSRAM)
HARDWARE: ESP32S3 240MHz, 320KB RAM, 16MB Flash
DEBUG: Current (esp-builtin) On-board (esp-builtin) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
- framework-arduinoespressif32 @ 3.20017.241212+sha.dcc1105b
- tool-esptoolpy @ 2.40900.250804 (4.9.0)
- tool-mkfatfs @ 2.0.1
- tool-mklittlefs @ 1.203.210628 (2.3)
- tool-mkspiffs @ 2.230.0 (2.30)
- tool-openocd-esp32 @ 2.1100.20220706 (11.0)
- toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
- toolchain-xtensa-esp32s3 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 33 compatible libraries
Scanning dependencies...
Dependency Graph
|-- FS @ 2.0.0
|-- LittleFS @ 2.0.0
Building in release mode
Building FS image from 'data' directory to .pio\build\esp32-s3-n16r8\littlefs.bin
/hello.txt
Uploading .pio\build\esp32-s3-n16r8\littlefs.bin
Open On-Chip Debugger v0.11.0-esp32-20220706 (2022-07-06-15:48)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
adapter speed: 40000 kHz
Warn : Transport "jtag" was already selected
adapter speed: 5000 kHz
** Programming Started **
** Programming Finished in 43488 ms **
** Verify Started **
** Verify OK **
shutdown command invoked
============================================================================== [SUCCESS] Took 46.74 seconds ==============================================================================
PS I:\Arduino\Projects\Test1\Test1>
Serial:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x4037b31a
pro cpu reset by JTAG
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
E (3014) esp_littlefs: ./components/esp_littlefs/src/littlefs/lfs.c:1367:error: Corrupted dir pair at {0x1, 0x0}
E (3014) esp_littlefs: mount failed, (-84)
E (3017) esp_littlefs: Failed to initialize LittleFS
E (3049) esp_littlefs: Failed to format filesystem
[ 3336][E][LittleFS.cpp:123] format(): Formatting LittleFS failed! Error: -1
[ 3347][E][LittleFS.cpp:98] begin(): Mounting LittleFS failed! Error: -1
NOTE:
My board works fine with Littlefs uploading example from Arduino IDE.
What platform version do you use / which one do you have installed?
This board definition is not included in the official PlatformIO espressif platform.
Where does this come from? (Looks like AI generated)
If you go with PlatformIOās espressif32 platform (6.12.0) use this platformio.ini:
[env:esp32-s3-devkitc-1]
platform = espressif32 @ 6.12.0
board = esp32-s3-devkitc-1
framework = arduino
board_build.arduino.memory_type = qio_opi
board_build.flash_mode = qio
board_build.psram_type = opi
board_upload.flash_size = 16MB
board_upload.maximum_size = 16777216
board_build.partitions = default_16MB.csv
board_build.extra_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
-DBOARD_HAS_PSRAM
If you use pioarduinoās espressif32 platform use this platformio.ini:
[env:esp32-s3-devkitc1-n16r8]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.35/platform-espressif32.zip
board = esp32-s3-devkitc1-n16r8
framework = arduino
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
The use of -DARDUINO_USB_CDC_ON_BOOT=1 is only necessary if you want to use the native built-in usb port instead of the UART usb port.
Try the LittleFS example provided by Espressif:
This one gave me the same result of failing to mount file system and corrupted dir pair.
[env:esp32-s3-devkitc1-n16r8] platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.35/platform-espressif32.zip board = esp32-s3-devkitc1-n16r8 framework = arduino build_flags = -DARDUINO_USB_CDC_ON_BOOT=1
This one seems to just hang after a reset like this:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x0 (DOWNLOAD(USB/UART0))
waiting for download
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x116c
load:0x403c8700,len:0xc2c
load:0x403cb700,len:0x3108
entry 0x403c88b8
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce2820,len:0x116c
load:0x403c8700,len:0xc2c
load:0x403cb700,len:0x3108
entry 0x403c88b8
For both I built the given example ālibraries/LittleFS/examples/LITTLEFS_test/LITTLEFS_test.inoā
I think I found this in some other post, not AI if I recall correctly, but yeah it did not seem to do anything.
There is no Serial output!
You have ARDUINO_USB_CDC_ON_BOOT enabled in your platformio.ini.
This routes all output of Serial.print to the native USB port.
Check your USB connection!
Do you really use the native (USB OTG) port?
Or do you use the UART USB port?
If you use the UART USB port you have to remove -DARDUINO_USB_CDC_ON_BOOT=1!
The output should look like this:
ESP-ROM:esp32s3-20210327
Build:Mar 27 2021
rst:0x1 (POWERON),boot:0x8 (SPI_FAST_FLASH_BOOT)
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fce3808,len:0x4bc
load:0x403c9700,len:0xbd8
load:0x403cc700,len:0x2a0c
entry 0x403c98d0
SPIFFS-like write file to new path and delete it w/folders
[ 125][E][vfs_api.cpp:105] open(): /littlefs/new1/new2/new3/hello3.txt does not exist, no permits for creation
Create missing folders of: /new1/new2/new3/hello3.txt
Writing file to: /new1/new2/new3/hello3.txt
- file written
Listing directory: /
DIR : new1
Listing directory: /new1
DIR : new2
Listing directory: /new1/new2
DIR : new3
Listing directory: /new1/new2/new3
FILE: hello3.txt SIZE: 6
FILE: test.txt SIZE: 0
Deleting file and empty folders on path: /new1/new2/new3/hello3.txt
- file deleted
Removing all empty folders on path: /new1/new2/new3/hello3.txt
Listing directory: /
FILE: test.txt SIZE: 0
Creating Dir: /mydir
Dir created
Writing file: /mydir/hello2.txt
- file written
Listing directory: /
DIR : mydir
Listing directory: /mydir
FILE: hello2.txt SIZE: 6
FILE: test.txt SIZE: 0
Deleting file: /mydir/hello2.txt
- file deleted
Removing Dir: /mydir
Dir removed
Listing directory: /
FILE: test.txt SIZE: 0
Writing file: /hello.txt
- file written
Appending to file: /hello.txt
- message appended
Reading file: /hello.txt
- read from file:
Hello World!
Renaming file /hello.txt to /foo.txt
- file renamed
Reading file: /foo.txt
- read from file:
Hello World!
Deleting file: /foo.txt
- file deleted
Testing file I/O with /test.txt
- writing................................................................
- 1048576 bytes written in 14757 ms
- reading................................................................
- 1048576 bytes read in 355 ms
Deleting file: /test.txt
- file deleted
Test complete
Hi thanks, yes my bad the serial was going to COM8 while I had COM5, the COM8 had the serial messages and little fs test worked properly. Would you be so kind to help me configure this pioarduino file to flash via built in and route serial prints to com5 ch343 so that I can flash / debug while keeping the serial console open?
[env:esp32-s3-devkitc1-n16r8]
platform = https://github.com/pioarduino/platform-espressif32/releases/download/55.03.35/platform-espressif32.zip
board = esp32-s3-devkitc1-n16r8
framework = arduino
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
I tried adding :
debug_tool = esp-builtin
upload_protocol = esp-builtin
debug_init_break = tbreak setup
build_type = debug
but keeps failing:
AVAILABLE: cmsis-dap, esp-bridge, esp-builtin, esp-prog, espota, esptool, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa
CURRENT: upload_protocol = esp-builtin
Uploading .pio\build\esp32-s3-devkitc1-n16r8\firmware.bin
Open On-Chip Debugger v0.12.0-esp32-20250707 (2025-07-06-17:44)
Licensed under GNU GPL v2
For bug reports, read
http://openocd.org/doc/doxygen/bugs.html
debug_level: 1
adapter speed: 5000 kHz
** program_esp input args <0x10000 verify> **
Error: esp_usb_jtag: error finding/claiming JTAG interface on device!
** OpenOCD init failed **
shutdown command invoked
C:/Users/luis7/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg:9: Error:
Traceback (most recent call last):
File "C:/Users/luis7/.platformio/packages/tool-openocd-esp32/share/openocd/scripts/target/esp_common.cfg", line 9, in script
*** [upload] Error 1
=============================================================================== [FAILED] Took 4.33 seconds ===============================================================================
sorry, I am new to the word of esp32 , just started learning how things work.
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=1
Remove this or set it to 0:
build_flags =
-DARDUINO_USB_CDC_ON_BOOT=0
to route the output of the Serial object to the UART port (CH343).
I had faced similar issue in the past. The only thing that helped me was erasing the flash completely before trying to āUpload Filesystem Imageā. One more thing, check whether the partition that you get from esp_partition_get is same like your default_16MB.csv. If not, I would suggest creating a partitions.csv file in the root folder of your project and updating your platform.ini file.