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: 
Highlighted
Adventurer
Adventurer
7,715 Views
Registered: ‎01-10-2014

Making skeleton driver for Linux on Zynq ZC7020

Jump to solution

Hello everyone!

I have a question about drivers on Zedboard.

I have Linux launched on Zedboard and I'd like to make a custom skeleton peripheral without any functionality with several (4) registers so that I could try to read and write those registers via AXI in Linux.

I have created a custom AXI-Lite slave peripheral in Vivado and attached it to my Processor System, made FSBL and generated a device tree entry using Xilinx Device tree generator. Here is the entry:

 

axi_register_0: axi-register@43c00000 {
   compatible = "xlnx,axi-register-1.0";
   reg = <0x43c00000 0x1000>;
   xlnx,s00-axi-addr-width = <0x4>;
   xlnx,s00-axi-data-width = <0x20>;
} ;

 

Here are the questions:

1) axi-register-1.0 is the name of my custom peripheral. Is that o'k ro have a custom name in compatible parameter? My experience says that this device tree entry looks good except the compatible line.

2) I've picked sort of "Generate driver" button in Vivado so, as I understand, a driver for this skeleton device is generated automatically. So how should I check if it is okay and include it into my Linux uImage?

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
Xilinx Employee
Xilinx Employee
12,272 Views
Registered: ‎03-13-2012

Re: Making skeleton driver for Linux on Zynq ZC7020

Jump to solution

The link should work if you remove the punctuation that the forum wrongly declared to be part of the link: http://lwn.net/Articles/232575/

 

There is another reference in the forum which has further links: http://forums.xilinx.com/t5/Embedded-Linux/help-with-simple-Zynq-PL-device-access-via-Linux-UIO-based-user/td-p/270836

 

As I said, you need some sort of driver. The ugliest and dirtiest solution would be to remap /dev/mem and access that from user-space. Okay for a quck initial test, but for everything else, please don't do that.

 

For your purpose UIO should be the perfect fit. Please have a look at the references above and see whether that works. I think for your case it only needs a small fragment to be added to the DT to make the registers available to user-space in sysfs (given that UIO is enabled in your kernel config).

 

For more complex use-cases, a "real" driver is unavoidable. It's the only way to correctly handle interrupts etc.

0 Kudos
5 Replies
Adventurer
Adventurer
7,697 Views
Registered: ‎01-10-2014

Re: Making skeleton driver for Linux on Zynq ZC7020

Jump to solution

UPD:

All in all, do I need a driver for a device that contains only AXI registers? Maybe I can just mention is the device tree?

0 Kudos
Xilinx Employee
Xilinx Employee
7,689 Views
Registered: ‎03-13-2012

Re: Making skeleton driver for Linux on Zynq ZC7020

Jump to solution

It really depends on what you want to do. If you need to control your IP in any way, you must have some sort of driver.

 

For super simple applications that require to read/write a few registers only, UIO is probably sufficient (http://lwn.net/Articles/232575/).

As soon as you need to handle interrupts though, you really should have proper IRQ handling in a kernel driver (which could be built based on a custom UIO driver though).

 

Compatible strings are essentially arbitrary strings. The kernel uses the string it gets trhough DT to load the proper driver for a device. So, it is essential that:

1. compatible strings must uniquely identify a certain device

2. drivers for that device must list the same compatible string.

 

Just listing a node in DT won't hurt anything, but without a driver which lists the used compatible string, nothing will happen.

0 Kudos
Adventurer
Adventurer
7,679 Views
Registered: ‎01-10-2014

Re: Making skeleton driver for Linux on Zynq ZC7020

Jump to solution

Thank you for your reply!

 

Actually, I don't want my core to do anything. I want it to be just an array of registers. This will help me to perform AXI read/write memory tests and make some examples of using /dev/mem without hurting the remaining system.

 

I don't want to handle any interrupts yet. I just want to make some kind of memory tests. And I would also prefer to write no driver rather than write one.

 

So do I have to make a driver? And if I have then how should I make it and how should I connect it to my Linux?

 

Sorry but your link gives 404: Not found.

0 Kudos
Xilinx Employee
Xilinx Employee
12,273 Views
Registered: ‎03-13-2012

Re: Making skeleton driver for Linux on Zynq ZC7020

Jump to solution

The link should work if you remove the punctuation that the forum wrongly declared to be part of the link: http://lwn.net/Articles/232575/

 

There is another reference in the forum which has further links: http://forums.xilinx.com/t5/Embedded-Linux/help-with-simple-Zynq-PL-device-access-via-Linux-UIO-based-user/td-p/270836

 

As I said, you need some sort of driver. The ugliest and dirtiest solution would be to remap /dev/mem and access that from user-space. Okay for a quck initial test, but for everything else, please don't do that.

 

For your purpose UIO should be the perfect fit. Please have a look at the references above and see whether that works. I think for your case it only needs a small fragment to be added to the DT to make the registers available to user-space in sysfs (given that UIO is enabled in your kernel config).

 

For more complex use-cases, a "real" driver is unavoidable. It's the only way to correctly handle interrupts etc.

0 Kudos
Adventurer
Adventurer
7,667 Views
Registered: ‎01-10-2014

Re: Making skeleton driver for Linux on Zynq ZC7020

Jump to solution
Thanks!
Well, I think I will try to use /dev/mem for the first time and it will be enough for my university task. If I understand it right, I won't have to change something in Linux or make a driver - I will be able just to write to the address.
Maybe I will try UIO as a further improvement.
0 Kudos