UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
6,427 Views
Registered: ‎09-09-2014

Accessing AXI GPIO using UIO drivers in Linux

Jump to solution

Hi,

I have my device tree setup in order for the linux kernel to recognize the AXI GPIO IP as a "generic-uio" in my design. My design is as shown in the below image, my_design

 

Also there is a device entry in /dev as "uio0" (denoting my axi_gpio device). I have also written a user space driver (attached) to communicate with the "uio" device. The problem is the mmap command is successfully assigning an address, but the value is 0xFFFFFFFF (looks abnormal for a memory allocation to me). Also when I write to any of the device registers using this memory mapped address as a base address, i get a segmentation fault. Please help me with this issue. 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
8,925 Views
Registered: ‎09-09-2014

Re: Accessing AXI GPIO using UIO drivers in Linux

Jump to solution

Hi,

I found the solution. Itis a very silly mistake in the code. In the line open("/dev/uio", O_RDWR), it should be open("/dev/uio0", O_RDWR). No faults now. I am currently working on the interrupt ack. 

View solution in original post

0 Kudos
3 Replies
8,926 Views
Registered: ‎09-09-2014

Re: Accessing AXI GPIO using UIO drivers in Linux

Jump to solution

Hi,

I found the solution. Itis a very silly mistake in the code. In the line open("/dev/uio", O_RDWR), it should be open("/dev/uio0", O_RDWR). No faults now. I am currently working on the interrupt ack. 

View solution in original post

0 Kudos
6,393 Views
Registered: ‎09-09-2014

Re: Accessing AXI GPIO using UIO drivers in Linux

Jump to solution

Also there are some more correction in the code. After mmapping the memory range, the return value should be addressed as an array. The registers are in continuous locations in the user space memory. Change the macro definitions as follows,

 

#define GPIO0_CHAN1_TSR 0x01 // Channel 1 tri sate register offset

#define GPIO0_CHAN2_TSR 0x03 // Channel 2 tri sate register offset

#define GPIO0_CHAN1_DR 0x00 // Channel 1 data register offset

#define GPIO0_CHAN2_DR 0x02 // Channel 2 data register offset

#define GPIO0_CHAN2_IER 0x05 // Channel 2 interrupt enable register offset

#define GPIO0_GIER 0x04 // GPIO global interrupt enable register offset

#define GPIO0_CHAN2_ISR 0x06 // Channel 2 interrupt status register offset

#define PAGE_SIZE sysconf(_SC_PAGESIZE) // Page size is 4Kb (optional change)

 

 

0 Kudos
1,594 Views
Registered: ‎07-31-2018

Re: Accessing AXI GPIO using UIO drivers in Linux

Jump to solution

Dear @shreyask@iith.ac.in, 

could you please provide your device tree setup (.dts) file? It would be a great help during my work.

Thanks in advance and I really hope that you receve this message.

0 Kudos