cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Observer
Observer
462 Views
Registered: ‎04-06-2020

XGPIO via petalinux

Jump to solution

So I'm having to readdress a GPIO issue I thought I had solved. 

The short of it is I need to access GPIO from the PL, which I had been working under the assumption that I would need access to the EMIO GPIO banks. It appears, at least I think, that is not the case. The gentleman I'm working with has gotten a piece of example code that he has used for testing. He's using a number of libraries that doesn't seem to be present in my petalinux build. 

#include "xparameters.h"
#include "xil_types.h"
#include "xstatus.h"
#include "xil_printf.h"
#include "xgpio.h"
#include "xbram.h"

 

These libraries, from what I'm looking at should be apart of the sdk. I've attempted to follow the quick start and just a simple test by adding one of the above libraries, but it fails each time when I try to build it. I obviously haven't linked the sdk properly and can't seem to be able to figure out what step I missed. 

 

fatal error: xparameters: no such file or directory

 

Beyond the fact I need to learn how to use vitis properly, I was told all development would be done in Petalinux, I am actually wondering how I can utilize the sdk through Petalinux. At this point I would rather just use the libraries and build the software application in Petalinux, seeing how 90% of the application has already been written and built there. 

 

0 Kudos
1 Solution

Accepted Solutions
Highlighted
Voyager
Voyager
452 Views
Registered: ‎06-28-2018

Re: XGPIO via petalinux

Jump to solution

Hi @mascenzi 

Those libraries are for baremetal applications.

You need a kernel driver/module to access the GPIO from Linux user space. Read the section titled "Using the GPIO driver from User Space" on this wiki page.

View solution in original post

6 Replies
Highlighted
Voyager
Voyager
453 Views
Registered: ‎06-28-2018

Re: XGPIO via petalinux

Jump to solution

Hi @mascenzi 

Those libraries are for baremetal applications.

You need a kernel driver/module to access the GPIO from Linux user space. Read the section titled "Using the GPIO driver from User Space" on this wiki page.

View solution in original post

Highlighted
Observer
Observer
431 Views
Registered: ‎04-06-2020

Re: XGPIO via petalinux

Jump to solution

@baltintop 

Ok THAT makes sense now. Ok, so with that said, how do I find the gpio pins that he's manipulating from the PL? I already have access to and have been working on software that accesses the EMIO GPIO pins. This is my first time working in this environment, dealing with PL and PS. So I'm all over the place and I'm playing catchup in a race I should have started a year ago. 

I'm trying to reach out to the person writing the PL side, but he is in and out often due to some family issues. So I'm attempting to figure this out. 

I can't find any reference to some of the code he's using so I'm having issues piecing things together. For instance. I've searched in xparamenter.h for "XPAR_AXI_GPIO_0_DEVICE_ID" and nothing is there that I can see. Along with I believe other xparameter values. 

 

 

0 Kudos
Highlighted
Voyager
Voyager
426 Views
Registered: ‎06-28-2018

Re: XGPIO via petalinux

Jump to solution

@mascenzi 

If I understood correctly you want to read some GPIO EMIO pins that are input to the PS (driven by the PL). Do you have access to the hardware (Vivado) design? That would be the easiest way to learn what's happening inside the PL.

0 Kudos
Highlighted
Observer
Observer
415 Views
Registered: ‎04-06-2020

Re: XGPIO via petalinux

Jump to solution

@baltintop I'm not entirely sure. I know I have access to the to a folder that contains the .xsa file. Its in a folder that has other folders and files such as main_bd_wrapper.bit .mmi .xsa  ps7_init.c .h .html etc. 

I can't seem to find a schematic file anywhere, which is what the import is looking for. 

0 Kudos
Highlighted
Observer
Observer
405 Views
Registered: ‎04-06-2020

Re: XGPIO via petalinux

Jump to solution

@baltintop 

Yea I have it. I'll dig into see what I can . I figured it out, that I was looking for the .xpr file. Thank you for your help. 

0 Kudos
Highlighted
Scholar
Scholar
367 Views
Registered: ‎05-28-2013

Re: XGPIO via petalinux

Jump to solution

@mascenzi wrote:

I can't find any reference to some of the code he's using so I'm having issues piecing things together. For instance. I've searched in xparamenter.h for "XPAR_AXI_GPIO_0_DEVICE_ID" and nothing is there that I can see. Along with I believe other xparameter values. 


Googling for XPAR_AXI_GPIO_0_DEVICE_ID turns up a couple of Zynq tutorials. In each of these cases, they are controlling GPIO pins which are neither MIO nor EMIO, but rather, which have been instantiated in the PL using a custom GPIO controller.

So in that case, all the previous stuff about MIO and EMIO access to the Zynq's built-in GPIO does not apply. Instead, you'll need to determine the base address, and the register layout, of whatever logic was instantiated. And then write code to access it (you can start with devmem for testing).

The base address will be unique to your design, it will be found in the Address Editor in Vivado (in your colleague's design). The bare metal code would also need to know this value, unfortunately I do not know exactly where to look for it.

The register layout depends on what logic was used, but there is a reasonable chance that it is the AXI GPIO controller offered by Xilinx, see https://www.xilinx.com/support/documentation/ip_documentation/axi_gpio/v2_0/pg144-axi-gpio.pdf. Page 10 of that document shows the register layout.