cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
greande
Explorer
Explorer
1,301 Views
Registered: ‎02-19-2018

How do I use Linux drivers generated for my HLS IP?

Jump to solution

I have an IP block generated from HLS and it has drivers associated with it that I can see in Xilinx SDK. Specifically, there is a driver file called xmymodule_linux.c. This file seems to expect my device to be mapped to a user IO driver under /sys/class/uio/ in Linux; however, I am not sure how to create that mapping.

I found this page on the wiki and tried following the steps therein but have not had success. I have device tree sources for my module that look like this:

 

/ {
	amba_pl: amba_pl@0 {
		#address-cells = <2>;
		#size-cells = <2>;
		compatible = "simple-bus";
		ranges ;
		mymodule: mymodule@a0000000 {
			/* This is a place holder node for a custom IP, user may need to update the entries */
			clock-names = "ap_clk";
			clocks = <&clk 71>;
			compatible = "generic-uio";
			reg = <0x0 0xa0000000 0x0 0x10000>;
			xlnx,s-axi-axilites-addr-width = <0x5>;
			xlnx,s-axi-axilites-data-width = <0x20>;
		};
		psu_ctrl_ipi: PERIPHERAL@ff380000 {
			/* This is a place holder node for a custom IP, user may need to update the entries */
			compatible = "xlnx,PERIPHERAL-1.0";
			reg = <0x0 0xff380000 0x0 0x80000>;
		};
		psu_message_buffers: PERIPHERAL@ff990000 {
			/* This is a place holder node for a custom IP, user may need to update the entries */
			compatible = "xlnx,PERIPHERAL-1.0";
			reg = <0x0 0xff990000 0x0 0x10000>;
		};
	};
};

and I also included the following in both the chosen DT node and my uEnv.txt U-Boot file:

 

 

uio_pdrv_genirq.of_id=generic-uio

The only thing listed under /sys/class/uio is 

uio0 -> ../../devices/platform/amba/ffa00000.perf-monitor/uio/uio0

How do I create a uio node for my custom IP so that I can use the Vivado generated Linux drivers?

 

0 Kudos
1 Solution

Accepted Solutions
greande
Explorer
Explorer
870 Views
Registered: ‎02-19-2018

I'm going to close this question as I'm no longer seeing this issue. Unfortunately, I don't know what caused it or how I "fixed" it. If anyone else is having the same problem they should go ahead and create a new post.

View solution in original post

0 Kudos
4 Replies
greande
Explorer
Explorer
1,224 Views
Registered: ‎02-19-2018

I was able to get Linux to recognize the IP by adding quotes around generic-uio in the uEnv.txt file. I can now see my "device" under /sys/class/uio.

 

However, I am running into another problem. Any time I try to read from the AXI-Lite control registers (e.g. ap_idle) the entire system hangs and eventually crashes. I am using the unmodified drivers generated by HLS. Here is my simple test application:

#include <stdio.h>
#include <stdlib.h>

#include "drivers/xmatrix_multiply.h"

int main(int argc, char **argv) {

    XMatrix_multiply matrix_multiply;

    int rc;
    if ((rc = XMatrix_multiply_Initialize(&matrix_multiply, "matrix_multiply")) != XST_SUCCESS) {
        fprintf(stderr, "Initialization failed. Return code: %d\n", rc);
        exit(EXIT_FAILURE);
    }

    printf("Initialization successful.\n");

    u32 is_idle = XMatrix_multiply_IsIdle(&matrix_multiply);
    printf("is_idle = %u\n", is_idle);

    if ((rc = XMatrix_multiply_Release(&matrix_multiply)) != XST_SUCCESS) {
        fprintf(stderr, "Release failed. Return code: %d\n", rc);
        exit(EXIT_FAILURE);
    }

    return 0;
}

This file compiles just fine but when I execute it with sudo ./matrix_multiply it prints "Initialization successful." and then the kernel hangs. After a few seconds I see the following in my serial console:

[  265.576532] INFO: rcu_sched detected stalls on CPUs/tasks:
[  265.581943]  3-...: (0 ticks this GP) idle=c1a/140000000000000/0 softirq=12569/12569 fqs=2626
[  265.590528]  (detected by 1, t=5254 jiffies, g=920, c=919, q=124)

Does anyone have any insight into what the problem here is?

0 Kudos
greande
Explorer
Explorer
1,134 Views
Registered: ‎02-19-2018

Bump to maybe get some attention on this issue. I'm still having the same problem.

Is there a User Guide or other piece of documentation that perhaps I missed that fully outlines the process of creating IP in Vivado HLS and using it in Linux?

0 Kudos
viggsy
Observer
Observer
891 Views
Registered: ‎05-16-2019

I have doubt on similar lines. I did change my "compatible" field to 'generic-uio' but my doubt is does it enable the HLS generated drivers on all versions of linux. For e.g I am using Linaro linux distributed by Analog Devices and I m not sure if it works. Can someone help me ?

0 Kudos
greande
Explorer
Explorer
871 Views
Registered: ‎02-19-2018

I'm going to close this question as I'm no longer seeing this issue. Unfortunately, I don't know what caused it or how I "fixed" it. If anyone else is having the same problem they should go ahead and create a new post.

View solution in original post

0 Kudos