cancel
Showing results for 
Search instead for 
Did you mean: 

Bootloader loading File Object Structure Not Returning FR_OK

danielblesener9
Associate II
Posted on May 17, 2018 at 18:45

Hi, I am a bit stumped at the moment. I attached the files that use the main code.

In usbh_usr.c, the function 'USBH_USR_ReadWriteFirmware(void)' is the ffucntion that attempts to open the file. 

The line 'if(f_open(&file, '0:g4_firmware.bin',FA_READ) == FR_OK)' is not returning true even though I have a bin file with that name.

f_open is in ff.c

It looks good to me? Does anyone see something wrong?

I am using Keil 5.18, and an STM32F2.

Thanks for you help,

Daniel

4 REPLIES 4
Posted on May 17, 2018 at 19:18

But what error specifically is it returning?

Are long file names supported?

Is this an EXFAT volume?

Is the volume mounted?

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
danielblesener9
Associate II
Posted on May 17, 2018 at 19:40

Good question.

When entering f_open, this is the order of events.

After chk_mounted, res = 0.

After follow_path, res = 0x4 --> FR_NO_FILE

But I have a file there. 

I believe this is FAT32.

danielblesener9
Associate II
Posted on May 17, 2018 at 19:49

It returns that value from the function static FRESULT dir_next(DIR *pDir, BOOL bStreach) 

At this point:

wi = pDir->index + 1;

if((wi == 0) || (pDir->sect == 0)){

//Report EOT when index has reached 65535

return FR_NO_FILE; //Hitting here

}0690X0000060KowQAE.png

This is pDire when I hit the 

FR_NO_FILE in the code shown above.

Posted on May 17, 2018 at 19:56

 ,

 ,

Probably should review setting in ffconf.h, these would be controlling.

Would expect the FatFs code to be fine, issues going to be with other code and settings.

♯ if 1 // DIR-CONSOLE

 ,

 , puts('Display Directory'),

 , {

 ,

 , , , FRESULT res,

 ,

 , , , DIR dir,

 ,

 , , , char *path,

 ,

 , , , UINT BytesWritten,

 , , , path = '',

 , , , res = f_opendir(&,dir, path),

♯ ifdef DBG

 ,

 , , , if (res != FR_OK)

 ,

 , , , , , printf('res = %d f_opendir\n', res),

 ,

♯ endif

 , , , if (res == FR_OK)

 ,

 , , , {

 ,

 , , , , , while(1)

 ,

 , , , , , {

 ,

 , , , , , , , FILINFO fno,

 ,

 , , , , , , , char str[256],

 ,

 , , , , , , , char *s = str,

 , , , , , , , res = f_readdir(&,dir, &,fno),

♯ ifdef DBG

 ,

 , , , , , , , if (res != FR_OK)

 ,

 , , , , , , , , , printf('res = %d f_readdir\n', res),

 ,

♯ endif

 , , , , , , , if ((res != FR_OK) || (fno.fname[0] == 0))

 ,

 , , , , , , , , , break,

 , , , , , , , printf('%c%c%c%c ',

 ,

 , , , , , , , , , ((fno.fattrib &, AM_DIR) ? 'D' : '-'),

 ,

 , , , , , , , , , ((fno.fattrib &, AM_RDO) ? 'R' : '-'),

 ,

 , , , , , , , , , ((fno.fattrib &, AM_SYS) ? 'S' : '-'),

 ,

 , , , , , , , , , ((fno.fattrib &, AM_HID) ? 'H' : '-') ),

 , , , , , , , printf('%10d ', (int)fno.fsize),

 , , , , , , , printf('%s/%s\n', path, fno.fname),

 ,

 , , , , , }

 ,

 , , , }

 ,

 , }

 ,

♯ endif // DIR-CONSOLE
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..