Saad Zia

  • Content count

  • Joined

  • Last visited

About Saad Zia

  • Rank

Recent Profile Visitors

362 profile views
  1. 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; }
  2. @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.
  3. 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
  4. Saad Zia

    QSPI memory usage for file read write

    Found the solution, the solution is as follows: Goto system-conf.dtsi file: in qspi, find flash0 and change: compatible = "spansion,s25fl256s1"; Hope that helps other people. Regards
  5. Dear Experts, I have a Zedboard and I am running Petallinux 2015.4, now I want to read and write to file that should be stored on QSPI. I followed this tutorial, but when I write cat /proc/mtd, it does not show any partitions but my device tree contains the same partitions. Kindly help me in this regard. Regards
  6. Saad Zia

    How to detect and handle UIO interrupt.

    That link was for adding UIO. For AXI follow the above code.
  7. Saad Zia

    How to detect and handle UIO interrupt.

    The code is as above, and for device tree follow this:
  8. Saad Zia

    USB OTG not enabled in Petalinux 2015.4

    Got the solution, it is as follows: update the device tree (system-top.dts) file to add the following entry: /{ 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>; } ;
  9. Dear MembersI am working on Petalinux 2015.4 and ZedBoard, I am trying to connect a CF Card through USB OTG, but the device doesnot gets registered and won't show up in /dev and I cannot mount it. Kindly help me in this regard.Regard
  10. Saad Zia

    GPIO Input value won't change from Userspace

    the issue was solved by changing fd_done = open("/sys/class/gpio/gpio903/value", O_WRONLY); to fd_done = open("/sys/class/gpio/gpio903/value", 2);
  11. Dear Experts I am using Petalinux 2015.4 and Zedboard. I am reading a GPIO which is supposed to go from 0 to 1 and in commandline, I can see that it happens. But when I execute it in the code, the value always remain 0 as initial value is 0. My code is as follows: int number=-1; unsigned char error = 0; int fd_done; //Export GPIO fd_done = open("/sys/class/gpio/export", O_WRONLY); if(fd_done < 0) { #if DEBUG_GPIOBit printf("ERROR:\tGPIO Export Failed\n\r"); #endif error=1; } write(fd_done,"903",3); close(fd_done); //Set GPIO as input fd_done = open("/sys/class/gpio/gpio903/direction", O_WRONLY); if(fd_done < 0) { #if DEBUG_GPIOBit printf("ERROR:\tGPIO Direction Failed\n\r"); #endif error=1; } write(fd_done,"in",2); close(fd_done); char value; fd_done = open("/sys/class/gpio/gpio903/value", O_WRONLY); lseek(fd_done, 0, SEEK_SET); read(fd_done, &value, 8); printf("Done Value: \t %d \n",value); close(fd_done); fd_done = open("/sys/class/gpio/unexport", O_WRONLY); write( fd_done,"903",3); close(fd_done); return number;
  12. I change scratch_mem to following: scratch_mem@1fc00000 { #address-cells = <1>; #size-cells = <1>; reg = <0x1fc00000 0x400000>; compatible = "generic-uio"; interrupts = < 0 58 0 >; interrupt-parent = <0x1>; }; Is this correct approach?
  13. Dear @miguel_rodrigues, thank you for the reply, I was able to export UIO for mem= 256, Now I want to do the following: The size of ZedBoards Ram is 512 mb, What I am gonna go is mem= 508 so that I have enough space for my buffer. Now for this, what should be address of scratch_mem@20000000, i.e. what should be replaced by 20000000? And what will be the physical base address of my 4MBs?
  14. Dear @sbobrowicz Can you kindly guide me through the steps needed for reserved memory, as how will I get: -Its Physical Base Address -Can it work in Userspace Regards
  15. Dear Expert I am working on Petalinux 2015.4 and Zedboard. I want to have a contagious 4 MB block of DDR to communicate with PL and have the physical address of the its Base. -Can I have this much memory allocated? -How can I get physical address of the memory? Regards