Page 2 of 2
Re: STM32F107-FATFS demo lands in unhandled exception
Posted: Sat Aug 11, 2012 8:38 am
by Giovanni
Hi,
Thanks for finding, could you edit your post and embed the patch in "code" tags?
Giovanni
Re: STM32F107-FATFS demo lands in unhandled exception
Posted: Wed Aug 15, 2012 4:16 am
by hazelnusse
The version of demos/ARMCM4-STM32F407-LWIP-FATFS-USB/main.c that is in the SVN and git repos has:
not
And your patch suggests changing it to:
Originally this was tagged as a toolchain problem, so I'm a bit confused about this part of the patch. I agree that the other part of the patch which initializes the FILINFO fno struct makes sense but I am confused about this part.
Anybody know what is going on here?
Luke
Re: STM32F107-FATFS demo lands in unhandled exception
Posted: Wed Aug 15, 2012 4:37 am
by hazelnusse
I just tested the STM32F107-FATFS demo with both toolchains [0], [1], with only the following patch:
Code: Select all
diff --git a/demos/ARMCM3-STM32F107-FATFS/main.c b/demos/ARMCM3-STM32F107-FATFS/main.c
index fd49241..8724c2d 100644
--- a/demos/ARMCM3-STM32F107-FATFS/main.c
+++ b/demos/ARMCM3-STM32F107-FATFS/main.c
@@ -135,6 +135,10 @@ static FRESULT scan_files(BaseSequentialStream *chp, char *path) {
int i;
char *fn;
+#if _USE_LFN
+ fno.lfname = 0;
+ fno.lfsize = 0;
+#endif
res = f_opendir(&dir, path);
if (res == FR_OK) {
i = strlen(path);
And both toolchains worked fine when I issued the 'tree' command from the shell. So I think this wasn't a toolchain issue but instead an issue with FILINFO not being properly initialized [2].
Regarding the index into the path char array, I don't know what that was all about. As far as I can tell, it isn't needed.
What is the preferred method for submitting patches? Email, or git(hub) pull requests, or something else?
Luke
[0] GNU Tools for ARM Embedded Processors --
https://launchpad.net/gcc-arm-embedded[1] Linaro GCC --
https://launchpad.net/gcc-linaro[2] FILINFO --
http://elm-chan.org/fsw/ff/en/sfileinfo.html
Re: STM32F107-FATFS demo lands in unhandled exception
Posted: Wed Aug 15, 2012 5:57 am
by hazelnusse
I spoke too soon about the path[i]/path[i++]/path[--i] business. I created a micro SD card with the following structure:
Code: Select all
$ ls -AFR
.:
bar/ foo/ foo.txt foobarfoobar/ foobarfoobarfoobar/
./bar:
./foo:
foo.txt
./foobarfoobar:
foobarfoobar.txt
./foobarfoobarfoobar:
foobarfoobarfoobar.txt
This is the output of the tree shell command when I use path[--i]:
Code: Select all
ch> tree
FS: 478146 free clusters, 8 sectors per cluster, 1958486016 bytes free
ch>
This is the output of the tree shell command when I use path[i]:
Code: Select all
ch> tree
FS: 478146 free clusters, 8 sectors per cluster, 1958486016 bytes free
FOO/FOO.TXT
FOOBAR~1/FOOBAR~1.TXT
FOOBAR~2/FOOBAR~1.TXT
/FOO.TXT
ch>
And this is the output I get when I use path[i++], which is what is in the source tree:
Code: Select all
ch> tree
FS: 478146 free clusters, 8 sectors per cluster, 1958486016 bytes free
/FOO/FOO.TXT
///FOOBAR~1/FOOBAR~1.TXT
////FOOBAR~2/FOOBAR~1.TXT
/////FOO.TXT
ch>
This doesn't vary between the two toolchains I listed in my previous post. So it seems like path[i] is correct, not path[i++] or path[--i].
Luke
Re: STM32F107-FATFS demo lands in unhandled exception
Posted: Sun Aug 19, 2012 9:27 am
by bsteinsbo
hazelnusse wrote:The version of demos/ARMCM4-STM32F407-LWIP-FATFS-USB/main.c that is in the SVN and git repos has:
not
And your patch suggests changing it to:
Originally this was tagged as a toolchain problem, so I'm a bit confused about this part of the patch. I agree that the other part of the patch which initializes the FILINFO fno struct makes sense but I am confused about this part.
Anybody know what is going on here?
Luke
I think you're maybe looking at the wrong line of code. The one I changed in my patch was after having returned from the recursive call, resetting the string to the current directory. You are referring to the one before the call, and I agree that this line is correct in the original code.
Before applying this part of the patch, I get:
Code: Select all
ch> tree
FS: 481859 free clusters, 8 sectors per cluster, 1973694464 bytes free
//foo/foo.txt
///foo.txt
///FOOBAR~1/FOOBAR~1.TXT
////FOOBAR~2/FOOBAR~2.TXT
After, I get:
Code: Select all
ch> tree
FS: 481859 free clusters, 8 sectors per cluster, 1973694464 bytes free
/foo/foo.txt
/foo.txt
/FOOBAR~1/FOOBAR~1.TXT
/FOOBAR~2/FOOBAR~2.TXT
Bjarne
-- Edit: added before and after
Re: STM32F107-FATFS demo lands in unhandled exception
Posted: Wed Aug 22, 2012 7:42 pm
by hazelnusse
Bjarne,
Ah my mistake. So you are saying that this line
is correct. I agree.
Luke
Re: STM32F107-FATFS demo lands in unhandled exception
Posted: Thu Aug 23, 2012 1:00 pm
by Giovanni
Hi,
Fixed in trunk, ticket number 3560980.
Giovanni
Re: STM32F107-FATFS demo lands in unhandled exception
Posted: Thu Aug 23, 2012 9:07 pm
by hazelnusse
Great, thanks!