Saad Zia

  • Content count

  • Joined

  • Last visited

  1. 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
  2. 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
  3. How to detect and handle UIO interrupt.

    That link was for adding UIO. For AXI follow the above code.
  4. How to detect and handle UIO interrupt.

    The code is as above, and for device tree follow this:
  5. 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>; } ;
  6. 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
  7. 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);
  8. 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;
  9. 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?
  10. 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?
  11. 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
  12. 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
  13. How to detect and handle UIO interrupt.

    That worked, thank you so much @yohboy and @sbobrowicz
  14. How to detect and handle UIO interrupt.

    I changed my code in the following manner: /* * File: main.c * Author: fss * * Created on August 23, 2017, 12:35 PM */ #include <sys/mman.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <poll.h> #include <fcntl.h> #include <errno.h> #define GPIO_DATA_OFFSET 0x00 #define GPIO_TRI_OFFSET 0x04 #define GPIO_DATA2_OFFSET 0x08 #define GPIO_TRI2_OFFSET 0x0C #define GPIO_GLOBAL_IRQ 0x11C #define GPIO_IRQ_CONTROL 0x128 #define GPIO_IRQ_STATUS 0x120 unsigned int get_memory_size(char *sysfs_path_file) { FILE *size_fp; unsigned int size; // open the file that describes the memory range size that is based on the // reg property of the node in the device tree size_fp = fopen(sysfs_path_file, "r"); if (size_fp == NULL) { printf("unable to open the uio size file\n"); exit(-1); } // get the size which is an ASCII string such as 0xXXXXXXXX and then be stop // using the file fscanf(size_fp, "0x%08X", &size); fclose(size_fp); return size; } void reg_write(void *reg_base, unsigned long offset, unsigned long value) { *((volatile unsigned long *)(reg_base + offset)) = value; } unsigned long reg_read(void *reg_base, unsigned long offset) { return *((volatile unsigned long *)(reg_base + offset)); } uint8_t wait_for_interrupt(int fd_int, void *gpio_ptr) { static unsigned int count = 0, bntd_flag = 0, bntu_flag = 0; int flag_end=0; int pending = 0; int reenable = 1; unsigned int reg; unsigned int value; // block (timeout for poll) on the file waiting for an interrupt struct pollfd fds = { .fd = fd_int, .events = POLLIN, }; int ret = poll(&fds, 1, 100); printf("ret is : %d\n", ret); if (ret >= 1) { read(fd_int, (void *)&reenable, sizeof(int)); // &reenable -> &pending // channel 1 reading value = reg_read(gpio_ptr, GPIO_DATA_OFFSET); if ((value & 0x00000001) != 0) { printf("Interrupt recieved"); } count++; usleep(50000); // anti rebond if(count == 10) flag_end = 1; // the interrupt occurred for the 1st GPIO channel so clear it reg = reg_read(gpio_ptr, GPIO_IRQ_STATUS); if (reg != 0) reg_write(gpio_ptr, GPIO_IRQ_STATUS, 1); // re-enable the interrupt in the interrupt controller thru the // the UIO subsystem now that it's been handled write(fd_int, (void *)&reenable, sizeof(int)); } return ret; } int main(void) { int fd = open("/dev/uio0", O_RDWR); if (fd < 0) { perror("open"); exit(EXIT_FAILURE); } int gpio_size = get_memory_size("/sys/class/uio/uio0/maps/map0/size"); /* mmap the UIO devices */ void * ptr_axi_gpio = mmap(NULL, gpio_size, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); reg_write(ptr_axi_gpio,GPIO_TRI_OFFSET ,0x1F); reg_write(ptr_axi_gpio,GPIO_IRQ_CONTROL,0x1); reg_write(ptr_axi_gpio,GPIO_GLOBAL_IRQ,0x1); while (1) { wait_for_interrupt(fd,ptr_axi_gpio); } close(fd); exit(EXIT_SUCCESS); } *changes= bold and underlined. But it still won't catch any interrupt.
  15. How to detect and handle UIO interrupt.

    I added #interrupt-cells = <3>; but it is not catching any interrupt on button press.