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: 
Visitor ali.ebrahimi
Visitor
5,631 Views
Registered: ‎12-08-2013

Problem with writing to AXI GPIO in Linux

Hello,

 

I have two 32-bits AXI GPIO, one set as all-input and the other one as all-outpu. I have a device driver for linux which creates two nodes in /dev, one to write to and the other to read from.

I have a simple C++ user application which reads and writes to these nodes using open(), read() and write().

My problem is with the write part. It works fine for a few cycles and then for some unknown reasons, I get some random byte values on the PL side, instead of the bytes which are written to the device node. I print the all 4 bytes before writing them to the node, so I'm sure that it's correct.

Any idea where I can look for the reason or any advice on debuggin AXI GPIO in general?

 

 

This is how I write to the node file:

 

unsigned char rd_buf[4096]={}; // A buffer which holds a series of bytes to be transmitted to PL

int  total_dword; // Number of Dwords (32-bits) to be transmitted

 

 

// Write command to PL

fhwr = open(WR_PATH,O_WRONLY | O_NOCTTY | O_SYNC);

if (fhwr < 0) error("ERROR opening PL device to write to");

 

 

for(int i = 0; i <= total_dword; i++) {

    n = write (fhwr, (rd_buf+i*4), 4);

    if (n < 0)

       error("ERROR writing to the PL device");

    else printf("Bytes written to the PL: %d\n", n);

}

close(fhwr);

0 Kudos
2 Replies
Visitor ali.ebrahimi
Visitor
5,627 Views
Registered: ‎12-08-2013

Re: Problem with writing to AXI GPIO in Linux

Also, I just noticed this happens much more often when I use usb Uart on the zedboard to connect to the PS than when I use SSH! Could be some memory overlapping between the two?
0 Kudos
Visitor ali.ebrahimi
Visitor
5,501 Views
Registered: ‎12-08-2013

Re: Problem with writing to AXI GPIO in Linux

I've not found any solution to this problem. Any ideas?

Meanwhile I've found out that when I write to the gpio using dd, it can can get stuck with interupts of other processes. This can be another termianl running top command, ls, or even printing output of dd on the same terminal.

When a small script which runs dd in a loop to write to the gpio is running, system gets something between 300 to 500 rescheduling interrupts and 10 IRQ work interrupts per second.


I have tested the othere direction, PL to PS, and it works fine under very heavy load.

0 Kudos