STM32F107-FATFS demo lands in unhandled exception
Moderators: RoccoMarco, lbednarz, tfAteba
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F107-FATFS demo lands in unhandled exception
Hi,
Thanks for finding, could you edit your post and embed the patch in "code" tags?
Giovanni
Thanks for finding, could you edit your post and embed the patch in "code" tags?
Giovanni
-
hazelnusse
- Posts: 77
- Joined: Thu May 24, 2012 8:01 am
Re: STM32F107-FATFS demo lands in unhandled exception
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
Code: Select all
path[i++] = '/';
not
Code: Select all
path[i] = '\';
And your patch suggests changing it to:
Code: Select all
path[--i] = '\';
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
-
hazelnusse
- Posts: 77
- Joined: Thu May 24, 2012 8:01 am
Re: STM32F107-FATFS demo lands in unhandled exception
I just tested the STM32F107-FATFS demo with both toolchains [0], [1], with only the following patch:
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
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
-
hazelnusse
- Posts: 77
- Joined: Thu May 24, 2012 8:01 am
Re: STM32F107-FATFS demo lands in unhandled exception
I spoke too soon about the path[i]/path[i++]/path[--i] business. I created a micro SD card with the following structure:
This is the output of the tree shell command when I use path[--i]:
This is the output of the tree shell command when I use path[i]:
And this is the output I get when I use path[i++], which is what is in the source tree:
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
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
hazelnusse wrote:The version of demos/ARMCM4-STM32F407-LWIP-FATFS-USB/main.c that is in the SVN and git repos has:Code: Select all
path[i++] = '/';
notCode: Select all
path[i] = '\';
And your patch suggests changing it to:Code: Select all
path[--i] = '\';
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
-
hazelnusse
- Posts: 77
- Joined: Thu May 24, 2012 8:01 am
Re: STM32F107-FATFS demo lands in unhandled exception
Bjarne,
Ah my mistake. So you are saying that this line
is correct. I agree.
Luke
Ah my mistake. So you are saying that this line
Code: Select all
path[i]=0;Luke
- Giovanni
- Site Admin
- Posts: 14895
- Joined: Wed May 27, 2009 8:48 am
- Has thanked: 1202 times
- Been thanked: 997 times
Re: STM32F107-FATFS demo lands in unhandled exception
Hi,
Fixed in trunk, ticket number 3560980.
Giovanni
Fixed in trunk, ticket number 3560980.
Giovanni
-
hazelnusse
- Posts: 77
- Joined: Thu May 24, 2012 8:01 am