Author Topic: f_getcwd command for SD1 in Zynq ultrascale+ returns failure  (Read 206 times)

sandeep

  • Active Member
  • *
  • Posts: 6
f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« on: February 11, 2019, 09:42:32 AM »
Hello,

I'm trying to obtain the current working directory on SD1 of the Zynq Ultrascale+ device (TE0820) for FTP application. however, the command f_getcwd is returning failure. It works fine for SD0. Below is the example code:

#include "xparameters.h" /* SDK generated parameters */
#include "xsdps.h" /* SD device driver */
#include "xil_printf.h"
#include "ff.h"
#include "xil_cache.h"
#include "xplatform_info.h"

static FIL fil; /* File object */
static FATFS fatfs;
static char FileName[32] = "1:/Test.bin";
static char *SD_File;

u8 DestinationAddress[10*1024*1024] __attribute__ ((aligned(32)));
u8 SourceAddress[10*1024*1024] __attribute__ ((aligned(32)));


#define TEST 7

int main(void)

{
   int Status;
   
   xil_printf("SD Polled File System Example Test \r\n");
   
   FRESULT Res;
   UINT NumBytesRead;
   UINT NumBytesWritten;
   u32 BuffCnt;
   BYTE work[FF_MAX_SS];
   u32 FileSize = (8*1024*1024);
   
   TCHAR *Path = "1:/";
   
   for(BuffCnt = 0; BuffCnt < FileSize; BuffCnt++){
   SourceAddress[BuffCnt] = TEST + BuffCnt;
   }
   
   Res = f_mount(&fatfs, Path, 0);
   
   if (Res != FR_OK) {
      print ("mount failed\n");
   return XST_FAILURE;
   
   }
   
   Res = f_mkfs(Path, FM_FAT32, 0, work, sizeof work);
   if (Res != FR_OK) {
      print ("mkfs failed\n");
   return XST_FAILURE;
   }

   #define SZ_STR 255
   TCHAR str[SZ_STR];

    /* Get current directory path */
    Res = f_getcwd(str, SZ_STR);
    if (Res != FR_OK) {
       xil_printf ("Current working directory return failed cwd\n",);
            return XST_FAILURE;
        }
    xil_printf ("Current working directory success cwd= %s\n", str);

}

I'm using TE0720 SOM and Vivado version is 2018.3. And below is the BSP settings of generic fat file system library . Any idea where I am going wrong?
Thank you.

Kind regards,
Sandeep

JH

  • Hero Member
  • *****
  • Posts: 770
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #1 on: February 11, 2019, 01:15:42 PM »
Hello,
can you tell me the error message?

And which module did you use, your wrote:
Quote
Zynq Ultrascale+ device (TE0820)
and
Quote
I'm using TE0720 SOM and Vivado version is 2018.3.

Is the second one a typo?

SD0 is eMMC and SD1 is the SD Card on TE0820.
Does our Linux example design boot from SD?
If yes, than it seems to be more Xilinx  barmetal driver specific, maybe you should also write a post to Xilinx forum.

br
John


sandeep

  • Active Member
  • *
  • Posts: 6
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #2 on: February 11, 2019, 02:22:36 PM »
Hello John,

Sorry about the confusion. I'm using TE0820 on TE0703 carrier board. The booting from SD card works fine.

The error I'm getting is "FR_NOT_ENABLED".

And I've posted the issue in Xilinx forum too, but no luck there (https://forums.xilinx.com/t5/Embedded-Processor-System-Design/The-f-getcwd-command-for-SD1-in-Zynq-ultrascale-returns-failure/m-p/937078#M43965). I was hoping someone in here would have come across this issue for this particular device.

Kind regards,
Sandeep

JH

  • Hero Member
  • *****
  • Posts: 770
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #3 on: February 11, 2019, 02:27:40 PM »
Hi,
http://irtos.sourceforge.net/FAT32_ChaN/doc/en/rc.html
Quote
FR_NOT_ENABLED
    Work area for the logical drive has not been registered by f_mount function.
so your f_mount returns no error? Your SD has only one partition?
br
John



sandeep

  • Active Member
  • *
  • Posts: 6
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #4 on: February 11, 2019, 03:21:33 PM »
Hi John,

The f_mount() function does not return any error and yes, SD has only one partition and is been formatted as FAT32. The f_getcwd () works fine with eMMC (SD0) returns the correct CWD,  but fails for SD card.

Kind regards,
Sandeep

JH

  • Hero Member
  • *****
  • Posts: 770
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #5 on: February 11, 2019, 04:44:45 PM »
Hi,
you should start SDK debugger and jump into this function to find out what's exactly failed.

I thing either something is not configured correctly or it's bug if the driver. But I can't help much more in this case.

Here are also notes and links from Xilinx:


br
John

sandeep

  • Active Member
  • *
  • Posts: 6
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #6 on: February 11, 2019, 05:25:59 PM »
Hi John,

When f_getcwd() function calls the get_ldnumber(), instead of returning '1', it returns '0'. Because of this, the function fails. I'm debugging why this is happening.

I want to go for editing the BSP as my last option, but thanks for the quick response John!

Kind regards,
Sandeep

JH

  • Hero Member
  • *****
  • Posts: 770
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #7 on: February 12, 2019, 09:07:59 AM »
Hi,
get_ldnumber() seems to be xilffs. You must check, why he think it's one and not zero. But it can also happens that Zero is from eMMC mounting and one is from SD...?
If I see it correctly only -1 is invalid:
https://github.com/Xilinx/embeddedsw/blob/master/lib/sw_services/xilffs/src/ff.c

Enable debugging of Xilinx BSP Libs:
https://forums.xilinx.com/t5/Embedded-Development-Tools/Xilinx-SDK-IDE-Enable-Debug-With-BSP-Sources/td-p/751507
br
John

sandeep

  • Active Member
  • *
  • Posts: 6
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #8 on: February 12, 2019, 09:56:08 AM »
Hi John,

Yes, working on it. I'll update here if I figure out the issue.

Kind regards,
Sandeep

sandeep

  • Active Member
  • *
  • Posts: 6
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #9 on: February 27, 2019, 04:22:18 PM »
Hi John,

To resolve this error, The f_chdrive() function should be called before f_getcwd(), then it returns the correct CWD.

Kind regards,
Sandeep

 

JH

  • Hero Member
  • *****
  • Posts: 770
Re: f_getcwd command for SD1 in Zynq ultrascale+ returns failure
« Reply #10 on: March 01, 2019, 04:55:36 PM »
Hi,
thanks for this notes it's good to hear that it works now.
br
John