Hi,
Still working on getting MQX 4.1.1 on a K70 stable enough for for an update to our product. 6 weeks and counting.
My CTO wants me to ask if you guys have heard of unit tests. There cool. Give them a look on wikipedia.
Anyway, here's the bug:
We have found that when a file is exactly a multiple of the cluster size (in our case 4096 bytes) opening with filemode a or a+ fails (fopen returns null).
Looking through the code it seems that MFS_Move_file_pointer returns sets the error_code to MFS_EOF.
It seems that when the data ends exactly at the end of a cluster, MFS_get_cluster_from_fat returns CLUSTER_EOF as the new "current_cluster".
This sets the error_code to MFS_EOF, which doesn't seem unreasonable since we are seeking to the end of the file, however when we get back to _io_mfs_open, it sees this error and fails.
I *think* a simple fix is to check if the error_code is
if( error_code == MFS_EOF ) {
error_code = MFS_NO_ERROR;
}
at line 462 of mfs_init.c (or thereabouts), but I am not an expert on FAT file systems, so I'm looking for confirmation?
Thanks
Chris
P.S.
Easy to replicate, just use the sh_write test app.
Hi Chris,
thank you for confirmation.
Just for make it sure. Did you use fix from your initial topic (edit mfs_init.c) or recommended solution with use r+/w/w+ modes instead of append mode?
Anyway, current MFS in MQX 4.2 was reworked and do not suffer this by this bug.
Have a great day,
RadekS
I can confirm I've been using the edit mfs_init.c solution since January without issue. Now that MQX 4.2 is out and should have the issue resolved I will try that, if I can get past the printf linking issue I've been getting with my code in MQX 4.2.
Thank you for your bug report.
Yes, you are right. It is known issue. Unfortunately, append mode is implemented wrongly.
As workaround, please use r+/w/w+ modes instead of append mode and seeks manually according your needs.
Next MQX release will contain complete redesigned MFS subsystem which will solve this issue.
Have a great day,
RadekS
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------