cancel
Showing results for 
Search instead for 
Did you mean: 

Using FatFs , i am unable to get long filenames, but i get the short filenames

Javier1
Principal

I am able to read the fixed length fname.

But the pointer to the long filename is always 0.

0693W00000LzKvXQAV.png 

this is how im reading trough the list of files

FRESULT detect_binariesFolder(){
	fresult=f_opendir(&dir, "lu");
	fresult=f_readdir(&dir, &filinfo);
	fresult=f_findfirst(&dir, &filinfo, "lu", "*.bin");//http://elm-chan.org/fsw/ff/doc/findfirst.html
 
	   while (fresult == FR_OK && filinfo.fname[0]) {         /* Repeat while an item is found */
			fresult=f_findnext (&dir, &filinfo);
	   }
 
	fresult=f_closedir(&dir);
	return fresult;
}

I tried the three different cubeMx options for long filenames :

  • static buffer on the BSS
  • dynamic buffer on heap
  • dynamic buffer on stack

None of them works.

0693W00000LzKtSQAV.png 

My setup:

  • stm32f105RBt6 custom board.
  • SD Card trough SPI2, sandisk ultra 16GB.
  • CubeMx version 6.4.0, STM32Cube_FW_F1_V1.8.4 package which uses FatFs version R0.10c, Nov 09, 2014.
  • CubeIDE Version: 1.8.0
we dont need to firmware by ourselves, lets talk
1 ACCEPTED SOLUTION

Accepted Solutions
Javier1
Principal

Okay that wasnt so hard, i just needed to find up to date documentation.

(C:\Users\**your user**\STM32Cube\Repository\STM32Cube_FW_F1_V1.8.4\Middlewares\Third_Party\FatFs\doc)

0693W00000LzL6pQAF.png 

Apparently the pointer needs to be initialiced by you first.

adding this three lines fixes the code:

FRESULT detect_binariesFolder(){
    char lfn[_MAX_LFN + 1];
    filinfo.lfname = lfn;
    filinfo.lfsize = sizeof lfn;
 
    	fresult=f_opendir(&dir, "lu");
    	fresult=f_readdir(&dir, &filinfo);
    	fresult=f_findfirst(&dir, &filinfo, "lu", "*.bin");//http://elm-chan.org/fsw/ff/doc/findfirst.html
     
    	   while (fresult == FR_OK && filinfo.fname[0]) {         /* Repeat while an item is found */
    			fresult=f_findnext (&dir, &filinfo);
    	   }
     
    	fresult=f_closedir(&dir);
    	return fresult;
    }

0693W00000LzL6BQAV.png

we dont need to firmware by ourselves, lets talk

View solution in original post

1 REPLY 1
Javier1
Principal

Okay that wasnt so hard, i just needed to find up to date documentation.

(C:\Users\**your user**\STM32Cube\Repository\STM32Cube_FW_F1_V1.8.4\Middlewares\Third_Party\FatFs\doc)

0693W00000LzL6pQAF.png 

Apparently the pointer needs to be initialiced by you first.

adding this three lines fixes the code:

FRESULT detect_binariesFolder(){
    char lfn[_MAX_LFN + 1];
    filinfo.lfname = lfn;
    filinfo.lfsize = sizeof lfn;
 
    	fresult=f_opendir(&dir, "lu");
    	fresult=f_readdir(&dir, &filinfo);
    	fresult=f_findfirst(&dir, &filinfo, "lu", "*.bin");//http://elm-chan.org/fsw/ff/doc/findfirst.html
     
    	   while (fresult == FR_OK && filinfo.fname[0]) {         /* Repeat while an item is found */
    			fresult=f_findnext (&dir, &filinfo);
    	   }
     
    	fresult=f_closedir(&dir);
    	return fresult;
    }

0693W00000LzL6BQAV.png

we dont need to firmware by ourselves, lets talk