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: 
Scholar ronnywebers
Scholar
4,888 Views
Registered: ‎10-10-2014

Petalinux 2017.2 no UIO devices found

Jump to solution

for our custom IP we use the 'generic-uio' driver. When I boot petalinux on my system, under /sys/uio I cannot find any device.

 

Browsing the forum, I can see that issues with this UIO seem to be a regular topic. I read many posts (like this one) , but only got more confused about the best way to do this in the latest Petalinux version 2017.2, which contains Kernel 4.9

 

With Petalinux 2017.2 I tried this so far :

 

1)  <project>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

 

this file allows to override other dtsi entries (instead of trying to modify the pl.dtsi etc as was needed in older petalinux versions - so with the newer petalinux it's easier to customise the device tree!). I'm not sure if the syntax is correct, but this is what I added to the system-user.dtsi file :

 

 

/include/ "system-conf.dtsi"
/ {
};

&my_custom_ip_0 {
    compatible = "generic-uio";
};

 

The '&' overrides the node's 'compatible' string that associates a custom driver in pl.dtsi :

  

/ {
	amba_pl: amba_pl {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "simple-bus";
		ranges ;
		my_custom_ip_0: my_custom_ip@43c20000 {
			compatible = "xlnx,my_custom_ip-1.0";
			reg = <0x43c20000 0x10000>;
			xlnx,s00-axi-addr-width = <0x6>;
			xlnx,s00-axi-data-width = <0x20>;
		};

 

 

2) I checked the kernel configuration (petalinux-config -c kernel)

 

userspace IO.png

 

I left this at this default setting, though I read posts that do modify this :

 

not being a linux programmer, I think to understand that 'M' makes this a loadable driver, so it's not compiled into the kernel, but made available as loadable module (?)

 

some forum posts advise to change the 'M' to '*', some add the driver on the next line too (Userspace platform driver with generic irq and dynamic ...), but I'm not sure what this driver has to do with UIO (?)

 

3) some other posts advise to modify the generic-uio driver code (adding the 'compatible' stuff again), but that seems going back in time to me. 

 

4) some forum posts then say you have to change the kernel bootlargs : bootargs = "console=ttyPS0,115200 earlyprintk uio_pdrv_genirq.of_id=generic-uio";

 

-> I see 2 options here : 

4.1 ) in petalinux-config : disable the automatically generated kernel args, and manually override the bootargs. 

 

4.2) again in system-user.dtsi, override the 'chosen' node which is created (empty) in 'skeleton.dtsi' 

I tried to overwrite this as follows :

 

 

/include/ "system-conf.dtsi"
/ {
};

chosen {
    bootargs = "console=ttyPS0,115200 earlyprintk uio_pdrv_genirq.of_id=generic-uio";
};


&my_custom_ip_0 {
    compatible = "generic-uio";
};

but that gives me a device tree compilation error, so I think there must be a syntax problem with my file, but I don't know where ...?

 

 

also I'm not sure which is the best solution (4.1 or 4.2)

 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
1 Solution

Accepted Solutions
Adventurer
Adventurer
7,408 Views
Registered: ‎10-04-2017

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

You need to build UIO and the UIO platform driver.  Notice that the cmd line arg, uio_pdrv_genirq.of_id=generic-uio, will define the compat string for the uio_pdrv_generic driver and matches what you put in your IP in the dts.  If you build them as modules, they have to get loaded somehow.  So check by running lsmod and load them manually or just build them into the kernel.

 

jeff

12 Replies
Moderator
Moderator
4,876 Views
Registered: ‎09-12-2007

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

I there a clock missing here?

 

for example:

clocks = <&clkc 71>;

 

http://www.wiki.xilinx.com/Common+Clock+Framework

Scholar ronnywebers
Scholar
4,858 Views
Registered: ‎10-10-2014

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

I'm not sure @stephenm, I can see some gpio and AXI DMA, etc from the Zynq under /sys, but nothing in UIO.

 

I'm not very familiar with the meaning of the clocks in the device tree - I've attached my .dts files

 

thanks to the link you gave, I found the ../devicetree/bindings/clock/zynq-7000.txt document. (I use Zynq, not MPSoC), and 'clock-bindings.txt', I'll try to understand this better.

 

I can see the 'slcr' generating fclk0 .. fclk3, I think they are all active, as fclk_enable = 0xF (?). 

FCLK0 drives my custom IP (there's a clocking wizard / MMCM in between, but I don't think linux needs to know about this). 

 

slcr: slcr@f8000000 {
    #address-cells = <1>;
    #size-cells = <1>;
    compatible = "xlnx,zynq-slcr", "syscon", "simple-mfd";
    reg = <0xF8000000 0x1000>;
    ranges;
    clkc: clkc@100 {
        #clock-cells = <1>;
        compatible = "xlnx,ps7-clkc";
        fclk-enable = <0xf>;
        clock-output-names = "armpll", "ddrpll", "iopll", "cpu_6or4x",
                "cpu_3or2x", "cpu_2x", "cpu_1x", "ddr2x", "ddr3x",
                "dci", "lqspi", "smc", "pcap", "gem0", "gem1",
                "fclk0", "fclk1", "fclk2", "fclk3", "can0", "can1",
                "sdio0", "sdio1", "uart0", "uart1", "spi0", "spi1",
                "dma", "usb0_aper", "usb1_aper", "gem0_aper",
                "gem1_aper", "sdio0_aper", "sdio1_aper",
                "spi0_aper", "spi1_aper", "can0_aper", "can1_aper",
                "i2c0_aper", "i2c1_aper", "uart0_aper", "uart1_aper",
                "gpio_aper", "lqspi_aper", "smc_aper", "swdt",
                "dbg_trc", "dbg_apb";
        reg = <0x100 0x100>;
    };

devcfg: devcfg@f8007000 {
    compatible = "xlnx,zynq-devcfg-1.0";
    interrupt-parent = <&intc>;
    interrupts = <0 8 4>;
    reg = <0xf8007000 0x100>;
    clocks = <&clkc 12>, <&clkc 15>, <&clkc 16>, <&clkc 17>, <&clkc 18>;
    clock-names = "ref_clk", "fclk0", "fclk1", "fclk2", "fclk3";
    syscon = <&slcr>;
};

I can see clocks being mentioned for example in the 'dma' nodes - in this case it's clkc 15, which corresponds to the PL clock FCLK0 :

 

snap_axi_dma_1: dma@40410000 {
    #dma-cells = <1>;
    clock-names = "s_axi_lite_aclk", "m_axi_sg_aclk", "m_axi_mm2s_aclk", "m_axi_s2mm_aclk";
    clocks = <&clkc 15>, <&clkc 15>, <&clkc 15>, <&clkc 15>;
    compatible = "xlnx,axi-dma-1.00.a";

but not in my custom IP :

 

snap_SnapVersion_0: SnapVersion@43c10000 {
    compatible = "xlnx,SnapVersion-1.0";
    reg = <0x43c10000 0x10000>;
    xlnx,s00-axi-addr-width = <0x5>;
    xlnx,s00-axi-data-width = <0x20>;
};

but maybe custom IP needs no clock binding?

 

Anyway, what are these clock bindings actualy for? Is it for linux to be able to power-off things?

 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Scholar ronnywebers
Scholar
4,852 Views
Registered: ‎10-10-2014

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

@stephenm, if I don't override my custom IP's driver with 'generic-uio', but I leave the (auto-generated) drivers, where should I find my custom IP then? Under /sys/ ... ?

 

I'll remove the override for now, so I can see that my custom IP appears with the 'regular' drivers?

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Adventurer
Adventurer
7,409 Views
Registered: ‎10-04-2017

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

You need to build UIO and the UIO platform driver.  Notice that the cmd line arg, uio_pdrv_genirq.of_id=generic-uio, will define the compat string for the uio_pdrv_generic driver and matches what you put in your IP in the dts.  If you build them as modules, they have to get loaded somehow.  So check by running lsmod and load them manually or just build them into the kernel.

 

jeff

Scholar ronnywebers
Scholar
4,798 Views
Registered: ‎10-10-2014

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

thanks @jrhtech@stephenm for all the tips so far.

 

I think I'm almost there, but at this moment my kernel hangs when it is started by U-Boot. The issue comes up when I modify the bootargs. I wrote detailed steps of what I'm doing, so it might make more sense to you.

 

I recreated my project from scratch to make sure I start from a 'clean' / 'defaul't situation.

 

1) I create a petalinux project, import the hwspec (.hdf file)

 

petalinux-create --type project --template zynq --name my_project
# then I copy the .hdf file into the project petalinux-config --get-hw-description

this launches the main config menu

 

2) I leave everything in it's default config, exit and build, then package

 

petalinux-build
petalinux-package --boot --fsbl zynq_fsbl.elf --u-boot u-boot.elf --fpga design_1_wrapper.bit --force

Then I copy the entire ../images/linux folder to an SD-card with FAT32 (I probably don't need all these files, but at this point I don't bother which are needed and which not)

 

-> This boot's fine, I get a login prompt and login works

 

Then I want to add the UIO driver so I can talk with my custom IP

 

3) I configure the kernel :

 

petalinux-config -c kernel

I go to : Device Drivers -> Userspace I/O drivers, and I enable the 2 drivers so they get built-into the kernel.

 

Question1 : if I understand it correctly, this should allow the kernel to 'auto-mount' my custom IP as UIO devices to /sys/class/uio, is this correct? So no 'manual load' is needed?

 

UIO kernel driver enable.png

 

Then I need to pass in the correct bootargs, so I launch petalinux-config, and set these as follows :

 

bootargs.png

 

so that is :

 

console=ttyPS0,115200 earlyprintk uio_pdrv_genirq.of_id=generic-uio

 

Also in system-conf.dtsi I make the following modifications to the nodes of my custom IP (which I found in pl.dtsi) :

 

/include/ "system-conf.dtsi"
/ {
};

&snap_SnapFifoMonitor_0 {
    compatible = "generic-uio";
};
&snap_SnapPort0_0 {
    compatible = "generic-uio";
};
&snap_SnapPort1_0 {
    compatible = "generic-uio";
};
&snap_SnapTraceLogger_0 {
    compatible = "generic-uio";
};
&snap_SnapVersion_0 {
    compatible = "generic-uio";
};

 

Question 2: is this the correct syntax? Should these entries be between the / {} or is it ok like this?

 

then I run petalinux-build again, repackage, and copy all files under /images/linux to the SD card

 

Then I boot again, but my kernel hangs :

 

kernel hang.png

 

If I put back the auto-generated bootargs, the kernel does boot until login prompt. So it must have something to do with these arguments, or something missing for the UIO drivers?

 

What more can I do? Can I get enable more verbose logging in the console so I can see where the kernel gets stuck?

 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Scholar ronnywebers
Scholar
4,794 Views
Registered: ‎10-10-2014

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

I decompiled the device tree, but that looks ok : I can see for example one of my custom IP's like this :

 

	amba_pl {
		#address-cells = <0x1>;
		#size-cells = <0x1>;
		compatible = "simple-bus";
		ranges;

		SnapFifoMonitor@43c20000 {
			compatible = "generic-uio";
			reg = <0x43c20000 0x10000>;
			xlnx,s00-axi-addr-width = <0x6>;
			xlnx,s00-axi-data-width = <0x20>;
		};

so looks like the 'generic-uio' was correctly picked up.

 

The 'chosen' node looks like this :

 

chosen {
	bootargs = "console=ttyPS0,115200 earlyprintk uio_pdrv_genirq.of_id=generic-uio";
	stdout-path = "serial0:115200n8";
};

So the bootargs were picked up too.

 

I'm not sure about the diff between 'console' and 'stdout-path', I hope both point to the same UART (not that the kernel suddenly switches to some other UART , so I don't see any output once the kernel starts?).

 

I know that on my board the Zynq communicates through UART1, not UART0. In the decompiled dtb I could see that 'serial0' is an alias for the UART1 of the Zynq :

 

serial0 = "/amba/serial@e0001000";

 

not sure how ttyS0 is actually linked to this same UART1 (and not UART0), does console use the 'stdout-path' ?

 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Scholar ronnywebers
Scholar
4,780 Views
Registered: ‎10-10-2014

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

I also tried to manually load the UIO drivers :

I reconfigured the kernel to make the UIO drivers 'loadable' ( <M> instead of < * >)

 

I used the default bootargs, so without the 'uio_pdrv_genirq.of_id=generic-uio' , because otherwise my kernel won't boot

 

when I enter 'modprobe -l', I can see that 'uio_pdrv_genirq.ko'  and 'uio_dmem_genirq.ko' is present

 

if I enter 'modprobe uio_pdrv_genirq_ko' and 'modprobe uio_dmem_genirq.ko', both drivers get loaded, I check this with lsmod, it says that both drivers are live.

 

Now I think I need to do something more to make my custom IP appear under /sys/class/uio, but not sure what to do ... ?

 

 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Adventurer
Adventurer
4,768 Views
Registered: ‎10-04-2017

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

  If you have something in your devicetree that tried to talk to non-existent HW then linux won't boot.  I guess you could have the opposite problem also, you have the right bit file but when the driver is trying to setup UIO there is something wrong on the design. 

Are you sure you connect the interrupt of your IP to the ARM? 

  If you just load the drivers there is no compat string in the driver so it won't connect with any devices.  I haven't worked on this for a while and I don't have a design to look at but I don't recall really having much of an issue.  I doubt the driver is broken but you could debug it to see where it is hanging when you load it.

Scholar ronnywebers
Scholar
4,752 Views
Registered: ‎10-10-2014

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

thanks @jrhtech

 

* my custom IP have no interrupt outputs, they have simple AXI4-Lite registers that are memory mapped

 

* can I somehow see output from the kernel (by enabling some flag) where it gets stuck? I checked uio.c, it contains some 'dev_err' calls, I guess these can be output somehow on the console?

 

* you write 'If you just load the drivers there is no compat string in the driver', would you mind explaining that a bit more? Is this why you need to pass the argument 'uio_pdrv_genirq.of_id=generic-uio' in bootargs? Does it mean that when 'generic-uio' is discovered in the dtb, it needs to load this 'uio_pdrf_genirq' driver to talk to this device?

 

I've seen patches on the internet of the uio_pdrv_genirq.c file where the compatible string is just added : see for example this discussion on the forum. 

 

 

so here you can see the removal of the compatible string on github

 

So I think this is replaced by the kernel bootargs, but as soon as I add this, my kernel stops booting.

 

I'll now first try with bare metal code to talk with my IP, to make sure bitstream etc. is ok, but I'm almost sure it's linux related, it worked in 2015.4, but now when ported to 2017.2 I run into this issue. I've also seen that our previous linux programmer had added the compatible string back into place in the uio_pdrv_genirq.c file. So maybe I could try that too... but it's strange as you didn't have any issues.

 

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos
Xilinx Employee
Xilinx Employee
2,648 Views
Registered: ‎02-20-2014

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

 

Hi ronnywebers,

 

As a quick debug, we can stop in u-boot console and do a memory read/write to custom peripheral. It will rule out any IP access issue.

http://www.denx.de/wiki/publish/DULG/to-delete/UBootCmdGroupMemory.html

5.9.2.5. md - memory display

5.9.2.6. mm - memory modify (auto-incrementing)

 

Hope it helps.

 

Thanks,

Radhey

Adventurer
Adventurer
2,639 Views
Registered: ‎10-04-2017

Re: Petalinux 2017.2 no UIO devices found

Jump to solution
You can’t get an interrupt if you don’t connect it to the PS which would explain why this is not working for you.

Scholar ronnywebers
Scholar
2,630 Views
Registered: ‎10-10-2014

Re: Petalinux 2017.2 no UIO devices found

Jump to solution

thanks @radheys for the great tip to test IP from U-boot!

 

@jrhtech - i have no interrupt coming out of my custom IP, just AXI memory mapped registers, so I guess there's no irq to connect (?)

 

I've solved my issues - long story, all tips here have been very usefull, and I now have a much better understanding of loading UIO drivers, checking where the issues are, ...

 

In the end after everything was setup correctly (enabled both UIO drivers, added manual bootargs ...) I was also dealing with an outdated .hdf file (checked out wrong git branch :-( ...). That caused a lot of confusion too ... So after re-starting everything from scratch, using the correct .hdf, UIO drivers and bootargs, everything suddenly worked fine. I can access my devices using the UIO drivers!

 

Jeff's tip was the crucial one : I needed to enable both drivers so I accepted is answer as solution. Initially I only had the first driver, enabled (as loadable module) as it is selected by default - I was thinking Petalinux figured this out on itself from the compatible string 'generic-uio' in my system-user.dtsi file, but seems like that is not the case... )

 

UIO kernel driver enable.png

 

I decided to compile them into the kernel for now. I don't know if there's any advantage in making them loadable, as I do need them anyway?

 

thanks @jrhtech@stephenm@radheys

** kudo if the answer was helpful. Accept as solution if your question is answered **
0 Kudos