joltwallet / esp_littlefs

LittleFS port for ESP-IDF
MIT License
259 stars 97 forks source link

Flash format failed on ESP32S3 #128

Closed Maldus512 closed 1 year ago

Maldus512 commented 1 year ago

Hello, I need help debugging an issue that arose on a new ESP32S3 board I started working on. esp_littlefs fails to format its flash partition with the following error (output taken from the repository example):

Demo LittleFs implementation by esp_littlefs!
   https://github.com/joltwallet/esp_littlefs
This is esp32s3 chip with 2 CPU cores, WiFi/BLE, silicon revision 1, 2MB external flash
Free heap: 389312
Now we are starting the LittleFs Demo ...
I (293) demo_esp_littlefs: Initializing LittleFS
E (293) esp_littlefs: /home/maldus/Source/Github/esp_littlefs/src/littlefs/lfs.c:1224:error: Corrupted dir pair at {0x0, 0x1}

W (303) esp_littlefs: mount failed,  (-84). formatting...
W (353) esp_littlefs: /home/maldus/Source/Github/esp_littlefs/src/littlefs/lfs.c:1887:warn: Superblock 0x0 has become unwritable

E (353) esp_littlefs: Failed to format filesystem
E (353) esp_littlefs: format failed
E (363) esp_littlefs: Failed to initialize LittleFS
E (363) demo_esp_littlefs: Failed to mount or format filesystem

On a different ESP32S3 it works. The only relevant difference seems to be the flash type and size:

# Configuration of the board that doesn't work
esptool.py v4.5.1
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP32-S3
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 68:b6:b3:3c:c8:18
Uploading stub...
Running stub...
Stub running...
Manufacturer: c2
Device: 8039
Detected flash size: 32MB
Flash type set in eFuse: octal (8 data lines)

# Configuration of the board that works
esptool.py v4.5.1
Serial port /dev/ttyACM0
Connecting...
Detecting chip type... ESP32-S3
Chip is ESP32-S3 (revision v0.1)
Features: WiFi, BLE
Crystal is 40MHz
MAC: 70:04:1d:ad:8f:b8
Uploading stub...
Running stub...
Stub running...
Manufacturer: ef
Device: 4018
Detected flash size: 16MB
Flash type set in eFuse: quad (4 data lines)
Hard resetting via RTS pin...

This result occurs when working with the branch release/v5.0 of ESP-IDF. By chance I also tried the release/v5.1 version, which works in both cases.

Now, I could be satisfied with working with 5.1, but if possible I'd like to get to the root of the issue. Any help?

BrianPugh commented 1 year ago

hm, very odd. Since changing esp-idf versions impacts it, it's probably an upstream issue, but I'm curious as well as to what the issue could be. I'll try looking around a bit, but please let me know what you discover!

Maldus512 commented 1 year ago

I agree the core of the issue is to be searched upstream. I created this post while I experiment to find out more.

Maldus512 commented 1 year ago

As it turns out ESP-IDF v5.0 does not detect octal flash automatically (while 5.1 does). After toggling CONFIG_ESPTOOLPY_OCT_FLASH everything works as expected.