cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Contributor
Contributor
11,061 Views
Registered: ‎11-17-2014

Dealing with multiple UIO devices

Jump to solution

I have a couple of AXI BRAM controllers I want to access with UIO in petalinux, and I just got them to show up in /sys/class/uio using the compatible="generic-uio" keyword. One thing that I find a little nerve wracking is one shows up as uio0 and the other shows up as uio1 and I have to delve into their directories to know which one is which.

 

Am I always gaurneteed that the two memory controllers will show up in the order I first discovered them in? What if I add more IP cores using UIO? Does it still hold true?

 

Is there a way to change these 'directory' names so I can have a better way to differentiate the devices like using bram0, and bram1?

Tags (2)
0 Kudos
Reply
1 Solution

Accepted Solutions
Contributor
Contributor
19,950 Views
Registered: ‎11-17-2014

I found the libuio project on github that Linutronix created to help users interface with UIO devices. The library had a search by name function and I ended up adding a search by base address function based on it.

 

Now I'm able to write drivers for my ip cores that are very similar to what I would write for an AXI core for standalone and xilkernel based projects. It sure makes life a little easier, now if there was only an Eclipse plugin for Petalinux 2014.2 and later.

 

https://github.com/asm2750/libuio

View solution in original post

0 Kudos
Reply
4 Replies
Xilinx Employee
Xilinx Employee
11,057 Views
Registered: ‎09-10-2008

Hi,

 

You have to realize you are using a generic driver such that figuring out which one is which by the directory seems reasonable to me. There may be a way but I don't know of it. The alternative is to write your own custom driver which you could base on the UIO driver.  I believe the UIO number will be based on the order it's discovered in the device tree (90% sure) such that if you don't change the order they should be the same.

 

Thanks

John

0 Kudos
Reply
Contributor
Contributor
11,054 Views
Registered: ‎11-17-2014

Thanks for the reply. I'll try making a custom module using uio as a foundation then, or trying to parse the name file in each uio device directory. It's a shame the creator for uio didnt include a method of overtly naming the devices but each programmer has their own way of implmenting a solution. Has anyone made an example with two or more uio devices?

0 Kudos
Reply
Contributor
Contributor
11,043 Views
Registered: ‎11-17-2014

Looks like the author assumes users will use the name file from /sys/class/uio/uioX/name to determine if the user is pointing to the right driver. As described in section 6 of the pdf linked below.

 

https://www.osadl.org/fileadmin/dam/rtlws/12/Koch.pdf

 

I can manage with this but I would prefer the name to be a little simpler. Petalinux likes to name IP cores in the device tree as: "core_name : axi-bram-cntrl@40000000". uio likes to list it as axi-bram-cntrl@40000000 due to the device being located at /sys/bus/platform/amba.0/axi-bram-cntrl@40000000. Is there a way I can override that name in the device tree in system-top.dts and make it use the core_name?

0 Kudos
Reply
Contributor
Contributor
19,951 Views
Registered: ‎11-17-2014

I found the libuio project on github that Linutronix created to help users interface with UIO devices. The library had a search by name function and I ended up adding a search by base address function based on it.

 

Now I'm able to write drivers for my ip cores that are very similar to what I would write for an AXI core for standalone and xilkernel based projects. It sure makes life a little easier, now if there was only an Eclipse plugin for Petalinux 2014.2 and later.

 

https://github.com/asm2750/libuio

View solution in original post

0 Kudos
Reply