-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SPIFFS可以成功挂载文件系统,POSSIX / C均可以打开文件,但是读文件失败,返SPIFFS_ERR_INDEX_REF_LU [-10016] (GIT8266O-328) #766
Comments
问题已解决:
|
spiffsgen.py生成的spiffs.bin文件系统镜像和SDK配置的spiffs格式不一致,使用mkspiffs工具将spiffs文件系统镜像的格式与SDK配成一致,问题解决。 |
Hi @EaonL,
Is there a wrong setting? Could you please post the relevant settings of your sdkconfig? |
This is my config: ./mkspiffs --version grep SPIFFS sdkconfig Which version of the SDK are you using? |
Dear @EaonL,
Thank you for our config. I can see no relevant differences.
sdk version v3.2-261-g7ab9602e-dirty I have no idea what is wrong :-( |
This question is annoying,but it will definitely be resolved in the end. Beside, the mkffs tool is generated with your system's gcc compiler,check the version of your system's gcc compiler. xtensa-lx106-elf-gcc is a cross-link provided by Espressif, if your system's gcc version is not consistent with the gcc version of the compiled xtensa-lx106-elf-gcc cross toolchain, it may also cause the file to be unreadable: root@ubuntu:~# gcc --version root@ubuntu:~# xtensa-lx106-elf-gcc --version See, the gcc version of my system is the same as the gcc version that generated xtensa-lx106-elf-gcc, they are both Version-5.2.0. At last, I provide you a file system image 《spiffs_img.bin》, you can burn this file system image and read the file 《eaon.txt》 to see if it can be read successfully: root@ubuntu:/root/spiffs_img# pwd root@ubuntu:/root/spiffs_img# ls root@ubuntu:/root/spiffs_img# cat eaon.txt root@ubuntu:/root/spiffs_img# cd .. root@ubuntu:/root# ./tools/mkspiffs/mkspiffs -c spiffs_img/ -b 4096 -p 256 -s 0x70000 spiffs_img.bin root@ubuntu:/root# stat spiffs_img.bin As you can see, the size of spiffs_img.bin was defined as 0x70000, which means you need to set the partition of spiffs to 448K. root@ubuntu:/root# cd $IDF_PATH/examples/storage/spiffs/ root@ubuntu:/root/esp/ESP8266_RTOS_SDK/examples/storage/spiffs# cat partitions_example.csv python /root/tools/esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x90000 spiffs_img.bin modify main/spiffs_example_main.c to read /spiffs_img/eaon.txt: make flash && make monitor Then, hope u can see, good luck: You should unzip the 《spiffs_img.zip》, and then you get 《spiffs_img.bin》. |
I'm using Windows 10 with the msys32 enviroment provided by EspressIF.
I use the gcc versions provided by EpressIF within the msys32 enviroment:
You are right, there is a mismatch!
Your file is working :-)
So neither spiffsgen.py nor mkspiffs produce a valid image on my windows system. Perhaps this is really caused by the different gcc versions. To depend on specific compiler versions seems a bit difficult. Perhaps it is possible to remove this dependency by adding esp8266 support to spiffsgen.py? |
Maybe you should use your system's gcc to compile the toolchain yourself, rather than using the toolchain binary package compiled by Espressif. I don’t know how spiffsgen.py implements file system mirroring, and I don’t trust it. Here is the doc how to build the toolchain yourself: |
Hi @EaonL, I had problems setting up a different toolchain on windows. So I tried to investigate the problem with spiffsgen.py and found a problem with the alignment of the page indices. spiffsgen.py seems not to do any alignment here. According to spiffs_nucleus.h SPIFFS_ALIGNED_OBJECT_INDEX_TABLES is not an integer value, but a binary flag:
As a test I added the following code to spiffsgen.py at line 220 and got a valid image :-)
Of course, this should made a command line option for spiffsgen.py and enabled from Makefile.projbuild. Someone with more knowledge than I might provide a complete patch. Thank you very much your help to find a solution! |
不知道为什么,我的环境中没有spiffsgen.py这个文件 |
export SPIFFS_ALIGNED_OBJECT_INDEX_TABLES=4 |
环境描述:
ESP8266 + 4M Bytes SPI FLASH 【W25Q32】+ SDK release/v3.2
分区定义:
nvs, data, nvs, 0x9000, 0x6000,
phy_init, data, phy, 0xf000, 0x1000,
factory, app, factory, 0x10000, 512K,
storage, data, spiffs, , 448K,
操作步骤:
mkdir spiffs_root
vim hello.txt 【随便写了一串字符串在文件里】
python ./tools/spiffsgen.py 0x70000 spiffs_root/ spiffs.bin
python ./tools/esptool.py --chip esp8266 --port /dev/ttyUSB0 --baud 115200 write_flash -z 0x90000 spiffs.bin
#define SPIFFS_CHECK_RES(res)
do {
if ((res) < SPIFFS_OK)
{
printf("Err!! file: %s, func: %s, line: %d, ErrNo: %d\n\n", FILE, func, LINE, res);
return (res);
}
} while (0);
7.1 挂载spiffs;
7.2 POSSIX 或 C 编写open("/spiffs/hello.txt",...),read(fd, ...);
D (701) SPIFFS: read: load objix page 0001:0000 for data spix:0000
D (711) SPIFFS: read: offset:0 rd:20 data spix:0000 is data_pix:ff00 addr:00ff0005
Err!! file: /root/esp/ESP8266_RTOS_SDK/components/spiffs/spiffs/src/spiffs_nucleus.c, func: spiffs_object_read, line: 2036, ErrNo: -10016
D (741) SPIFFS: SPIFFS_clearerr
Note:
spiffs的问题库上找到一条类似的问题描述: pellepl/spiffs#160
他的环境是MSP430 + IAR,由于地址对齐问题引发,他使能cache可以read;然而我在ESP8266上各种折腾也不能成功读出文件,我有尝试使用esptools.py工具读Flash,读出来的内容和写进去的内容一致。
The text was updated successfully, but these errors were encountered: