igrr / mkspiffs

Tool to build and unpack SPIFFS images
MIT License
186 stars 91 forks source link

SPIFFS image created does not work in esp32 #85

Open dejavu1987 opened 8 months ago

dejavu1987 commented 8 months ago

I was able to create an image from a directory using

mkspiffs -c data -s 1966080 spiffs.bin

When I upload the image with esptools, It uploads fine. But the device fails to read from flash.

esptool.py --chip esp32 --port /dev/tty.usbserial-210 --baud 460800 write_flash 0x210000 spiffs.bin

When I try read_flash using

esptool.py --chip esp32 --port /dev/tty.usbserial-210 --baud 460800 read_flash 0x210000 0x1E0000 readspiffs.bin

It throws following error (This may not be relevant as I have a jumper wires going from external programmer to esp32 module, it could very well be the noise as suggested)

A fatal error occurred: Invalid head of packet (0x16): Possible serial noise or corruption.

Comparison to a build from platform.io

When I build the image using platform.io the binary looks almost identical with same size and when I list files using mkspiffs -l I see same list of files and same file sizes listed. I have tried building clean and uploading to wiped flash multiple times with both and the image built with mkspiffs consistantly fail to work, and built with PIO works fine. I know PIO is using mkspiffs in the background too so I just dont understand why this is not working.

When I mkspiffs -i it shows some difference between two images

mkspiffs -i broken.bin (built with mkspiffs)

era_cnt_max: 316
last_errno:  0
blocks:      480
free_blocks: 4
page_alloc:  4704
page_delet:  2436
used:        1180704 of 1799921
total: 1799921
used: 1180704

mkspiffs -i ok.bin (built with platformio)

era_cnt_max: 702
last_errno: 0
blocks: 480
free_blocks: 3
page_alloc: 5459
page_delet: 1682
used: 1370209 of 1799921
total: 1799921
used: 1370209

Additional info

platform = espressif32 board = esp32dev framework = arduino board_build.partitions = no_ota.csv

MacOS Ventura 13.6 M1 ARM64

Built mkspiffs from latest master f2482965703b9b4031a5d4797bfd7458016bf3d2