cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
zwilcox
Contributor
Contributor
651 Views
Registered: ‎02-19-2016

Reading and Writing to GPIO over PCIe

Jump to solution

Hey All!

I'm attempting to read and write some bytes in Python to GPIO over PCIe on my AC701.

I've done this same task with the same Python code and it worked.  I have since recreated the Project in Vivado and now it doesn't work.  Thus I suspect there's something up with my Vivado stuff.

Here's my block diagram and addressing

block.PNG

 

address.PNG

gpio_address.PNG

 

The device enumerates.   When I run the lspci -vv I get the following:

lspci.PNG

My python code:

import os
import mmap

os.system('setpci -s "01:00.0" COMMAND=0x02')
resource0 = os.open("/sys/bus/pci/devices/0000:01:00.0/resource0", os.O_RDWR | os.O_SYNC)

memFile = os.open("/dev/mem",  os.O_RDWR | os.O_SYNC)

startAddr = 0xe0000000;

resourceSize = os.fstat(resource0).st_size

print 'size is ' + str(resourceSize) + ' bytes'
mem1 = mmap.mmap(memFile, resourceSize, flags=mmap.MAP_SHARED, prot=mmap.PROT_WRITE|mmap.PROT_READ, offset = startAddr)
mem2 = mmap.mmap(resource0, resourceSize, flags=mmap.MAP_SHARED, prot=mmap.PROT_WRITE|mmap.PROT_READ, offset = 0)

mem1[0] = '\xFF'
mem2[0] = '\xFF' #this used to work!!

Writing either mem1[0] and mem2[0] does nothing.

I get an error when I read either mem1 or mem2.

[  180.156142] nwl-pcie fd0e0000.pcie: Non-Fatal Error Detected
0 Kudos
1 Solution

Accepted Solutions
zwilcox
Contributor
Contributor
619 Views
Registered: ‎02-19-2016

Ugh!

My reset was wrong.  *sigh*

View solution in original post

0 Kudos
1 Reply
zwilcox
Contributor
Contributor
620 Views
Registered: ‎02-19-2016

Ugh!

My reset was wrong.  *sigh*

View solution in original post

0 Kudos