• 0
Saad Zia

CF Card Hot Swap issue on Zedboard and Petalinux 2015.4

Question

Dear Experts

I am currently using Petalinux 2015.4 on Zedboard. I have connected a Transcend CF Card through USB 2250 Evaluation Board through USB-OTG. Now the issue I am facing right now is I can't hot swap CF cards, i.e. if I plug out the CF card from EVB and plug it in, the linux doesnot enumerates it until Zedboard is restarted. Kindly help me in this issue.

P.S. I got USB-OTG working by adding following lines to system-top.dts:

/dts-v1/;
/include/ "system-conf.dtsi"

/{

    usb_phy0:phy0 {

        compatible="ulpi-phy";

        #phy-cells = <0>;

       reg = <0xe0002000 0x1000>;

       view-port=<0x170>;

       drv-vbus;

    };

};

 

 

&usb0 {

        status = "okay";

        dr_mode = "host";

        usb-phy = <&usb_phy0>;

} ;

Regards

Edited by Saad Zia

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

I have solved this issue in userspace, below is the code, if someone wants that to work:

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

//this system call resets USB OTG

char resetCfCard()
{
    int fd;
    fd = open("sys/bus/usb/devices/usb1/authorized", O_WRONLY);
    if(fd < 0)
    {
        printf("ERROR:\tGPIO Export Failed\n\r");
        return 0;
    }
    write(fd,"0",1);
    write(fd,"1",1);
    close(fd);
    printf("CF restarted\n\r");
    return 1;
}

//my CF card was of Fat type so this search works

char checkCfCard()
{
    FILE *fp;
    char path[1035];
    char cfName[5];
    char returnVar;
    /* Open the command for reading. */
    fp = popen("fdisk -l | grep FAT16", "r");
    if (fp == NULL)
    {
        printf("Failed to run command\n" );
        returnVar = 0;
    }

    if(fgets(path, sizeof(path)-1, fp) != NULL)
    {
      printf("CF Card Present\n");
      cfName[0]=path[5];
      cfName[1]=path[6];
      cfName[2]=path[7];
      cfName[3]=path[8];
      printf("%s\n", cfName);
      returnVar = 1;
    }
    else
    {
      printf("No CF Card\n");
      resetCfCard();
      returnVar = 0;
    }
      /* close */
    pclose(fp);
    return returnVar;
}

int main( int argc, char *argv[] )
{
    char inputBytes[10];
    int option;
    printf("Enter 1 to hot swap\n");
    while(1)
    {
        if(fgets(inputBytes, 10, stdin))
        {
            option = strtol(inputBytes, NULL, 10);
        
            if(option==1)
            {
                checkCfCard();
            }
        }
    } 
  return 0;
}

Share this post


Link to post
Share on other sites
  • 0

Hi @Saad Zia,

We have reached out to some engineers with more experience with our Petalinux materials about your question.

Thank you for your patience,
JColvin

Share this post


Link to post
Share on other sites
  • 0

This sounds like it might not be an issue specific to ZedBoard. What I mean by that, is that I would bet a desktop running Linux might experience the same issue. Do you have a linux PC to test this? Also, maybe try Windows PC too, just for comparison. If this is an issue that is common to Linux, you might have better luck asking people on a forum for general linux questions, such as stack exchange.

I might still be able to help you one way or the other. What rootfs are you running, e.g. Ubuntu, Petalinux built system, prebuilt ramdisk? 

Share this post


Link to post
Share on other sites
  • 0

@sbobrowicz Tried hot swapping on Windows and Ubuntu running systems. It was working fine. The issue is of petalinux most probably as tried the same thing on a picozed board and hot swapping was not happening there also. I am running petalinux pre built rootfs.

Edited by Saad Zia

Share this post


Link to post
Share on other sites
  • 0

I don't have the same card reader, so best I can do is issue some guesses:

My best guess is that the kernel included with 2015.4 is not allowing the hotswapping feature of your card reader for some reason. It could be an issue with the USB host driver, or maybe even the card reader driver. You could try updating to a newer version of petalinux and seeing if the newer kernel resolves the issue. 

Another possibility is that the card reader driver is requiring a USB PHY reset to perform a hotswap properly, in which case you should double check that the device tree is properly declaring the usb-reset gpio for the Zedboard.

One more, you might need to manually obtain the driver source for the card reader and build it as a kernel module.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now