igrr / mkspiffs

Tool to build and unpack SPIFFS images
MIT License
193 stars 92 forks source link

ESP8266 can successfully mount spiffs and open the files that spiffs updates, but the read file fails, possix read() returns -1 #70

Closed EaonL closed 4 years ago

EaonL commented 4 years ago

git clone https://github.com/igrr/mkspiffs.git cd mkspiffs git submodule update --init make dist BUILD_CONFIG_NAME="-esp-idf" CPPFLAGS="-DSPIFFS_OBJ_META_LEN=4" ./mkspiffs/mkspiffs -c spiffs_py/spiffs_root/ -b 4096 -p 256 -s 0x200000 spiffs.bin

uodate the file system use esptools.py: python esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x90000 spiffs.bin

and then,uart print: example: Initializing SPIFFS example: Partition size: total: 1920401, used: 2761 example: Reading file SPIFFS: Failed to update mtime (-10021) example: Open the file success, fd: [3] example: Read from ret: [Bug: I read 20 bytes of file, and read() return: -1] example: Read from file: [Bug:Here I want to print some text of file,but read_buffer is NULL...] example: SPIFFS unmounted

EaonL commented 4 years ago

The root cause of this problem should be the inconsistency of the SPIFFS_ALIGNED_OBJECT_INDEX_TABLES configured by the mkffs tool and the SDK configuration. The SDK configures SPIFFS_ALIGNED_OBJECT_INDEX_TABLES to 4.

make dist CPPFLAGS=“-DSPIFFS_OBJ_META_LEN=4 -DSPIFFS_ALIGNED_OBJECT_INDEX_TABLES=4" BUILD_CONFIG_NAME=”-esp-8266”

enjoy...