ESP32-C3 + LittleFs + USB serial/jtag issues

pataga
Posts: 73
Joined: Sat Aug 12, 2017 5:53 am

ESP32-C3 + LittleFs + USB serial/jtag issues

Postby pataga » Wed Aug 10, 2022 9:52 am

Hardware : ESP32-C3 AI thinker C3FN4 module with 4MB flash, using onboard USB serial/JTAG for flash and debug
Software development environment : VSC + PlatformIO + arduino framework

If I use older releases for the arduino framework e.g. 2.0.2 I get build errors for USB Serial, so 2.0.2 or earlier is not a solution.
If I user newer releases e.g. 2.0.3 I can build and flash successfully.
But with board_build.flash_mode = qio, I get boot loops.
With board_build.flash_mode = dio, I get a LittleFS mount error.

Based on this supposedly resolved issue, we need to specify flash_mode as qio
https://github.com/espressif/arduino-esp32/issues/6579
I tried specifying framework v2.0.3 in platformio.ini and this results in bootloops.

Based on this
viewtopic.php?p=85621 using qio results in bootloops so we need to specify dio
If I specify dio, the code boots but I get LittleFS mount errors.


platformio.ini

Code: Select all

[env:esp32c3]
platform = https://github.com/tasmota/platform-espressif32/releases/download/v.2.0.3/platform-espressif32-v.2.0.3.zip
platform_packages =  framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3
framework = arduino
board = esp32-c3-devkitm-1
board_build.partitions = partitions.csv
board_build.flash_mode = qio
board_build.f_cpu = 80000000L
build_flags =
	-DARDUINO_USB_MODE=1
	-DARDUINO_USB_CDC_ON_BOOT

upload_speed = 460800
monitor_speed = 115200
upload_port = /dev/ttyACM1
monitor_port = /dev/ttyACM1
build_type = debug
monitor_filters = esp32_exception_decoder
extra_scripts = ./littlefsbuilder.py	
partitions.csv

Code: Select all

# Name,  Type, SubType, Offset,   Size,  Flags
# App partition x 2 : 1966080 bytes
ota_0,     app, ota_0,   0x10000,  0x1E0000,
ota_1,     app, ota_1,          ,  0x1E0000,
otadata,  data, ota,            ,  0x2000,
nvs,      data, nvs,            ,  0x6000,
# SPIFFS partition : 163840 bytes
spiffs,     data, spiffs,         ,  0x28000,

I also tried this example partitions file from the link above (apparently working for them with qio and 2.0.3), no difference

Code: Select all

# Name,   Type, SubType, Offset,  Size, Flags
nvs,      data, nvs,     0x9000,  0x5000,
otadata,  data, ota,     0xe000,  0x2000,
app0,     app,  ota_0,   0x10000, 0x1D0000,
app1,     app,  ota_1,   0x1E0000, 0x1D0000,
spiffs,   data, spiffs,  0x3B0000, 0x50000,
I would appreciate any pointers on a working platformio.ini for an AI Thinker C3FN4 module that will resolve the boot loops and
LittleFS mounting errors while still supporting USB CDC on boot.

Thanks !

pataga
Posts: 73
Joined: Sat Aug 12, 2017 5:53 am

Re: ESP32-C3 + LittleFs + USB serial/jtag issues

Postby pataga » Wed Aug 10, 2022 1:00 pm

As per https://community.platformio.org/t/no-s ... in/29067/3

I also tried

Code: Select all

platform = espressif32
platform_packages =
	framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git#2.0.3
With qio I get a couple of reboots and then a hang, with dio and dout I get a clean boot but LittleFS mount error

Code: Select all

Attempting to boot anyway...
entry 0x403ce000
./components/esp_littlefs/src/littlefs/lfs.c:1071:error: Corrupted dir pair at {0x0, 0x1}
E (6338) esp_littlefs: mount failed,  (-84)
E (6338) esp_littlefs: Failed to initialize LittleFS
[  6126][E][LittleFS.cpp:94] begin(): Mounting LittleFS failed! Error: -1
Error mounting LittleFS, restarting...

pataga
Posts: 73
Joined: Sat Aug 12, 2017 5:53 am

Re: ESP32-C3 + LittleFs + USB serial/jtag issues

Postby pataga » Sun Aug 14, 2022 5:03 am

Accidentally found a platform and packages specification that works :-)

Now LittleFS, Preferences and USB CDC on boot are working ...
Keeping my fingers crossed.

Code: Select all

[env:esp32c3]
platform = https://github.com/platformio/platform-espressif32.git
platform_packages = 
	framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32

framework = arduino
board = esp32-c3-devkitm-1
board_build.flash_mode = qio
board_build.partitions = partitions.csv
board_build.filesystem = littlefs
board_build.f_cpu = 80000000L

build_flags =
	-DARDUINO_USB_MODE=1
	-DARDUINO_USB_CDC_ON_BOOT

upload_speed = 115200
monitor_speed = 115200
build_type = debug
monitor_filters = esp32_exception_decoder

upload_port = /dev/ttyACM1
monitor_port = /dev/ttyACM1

Grohlfer
Posts: 2
Joined: Wed Dec 13, 2023 7:51 pm

Re: ESP32-C3 + LittleFs + USB serial/jtag issues

Postby Grohlfer » Wed Dec 13, 2023 7:54 pm

Hi @pataga!
Could you please share the solution?
Thanks! :D

Who is online

Users browsing this forum: Bing [Bot] and 39 guests