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: 
Participant shahid
Participant
9,029 Views
Registered: ‎03-25-2016

Segmentation fault while using UIO

Jump to solution

Hello,

 

I have a simple hardware with the three registors. I have create UIO code is attached. but when i run the code i got following output:

 

Testing UIO driver
Segmentation fault

 

device tree of ip is following:


/ {
amba_pl: amba_pl {
#address-cells = <1>;
#size-cells = <1>;
compatible = "simple-bus";
ranges ;
simpleAlu_0: simpleAlu@43c00000 {
compatible = "generic-uio";
reg = <0x43c00000 0x10000>;
xlnx,s-axi-axilites-addr-width = <0x6>;
xlnx,s-axi-axilites-data-width = <0x20>;
};
};
};

 

I have varified "/dev/uio0" is there. I have checked size by reading "/sys/class/uio/uio0/maps/map0/size".

I have also varified the name of device it is there in  /sys/class/uio/uio0/name.

 

I am using petalinux 2014.4 and wokring with Zedboard.

 

Please help me why it is happening.

 

Thanks.

 

Regards

 

 

 

 

 

Tags (3)
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Participant pete_128
Participant
17,150 Views
Registered: ‎04-02-2016

Re: Segmentation fault while using UIO

Jump to solution

The messages suggest this is an early failure well before you get to doing anything with /dev/uio.

 

One error that I can see, is your error checking on sizeFd = fopen() is incorrect.

fopen returns NULL on error whereas you are testing < 0.

 

I suggest converting your printfs to fprintf(stderr, so you can be sure that none of your prints are getting buffered before the failure.

 

You could also run under the GDB debugger to get a line number for the segfault to provide more clues.

View solution in original post

3 Replies
Highlighted
Participant pete_128
Participant
17,151 Views
Registered: ‎04-02-2016

Re: Segmentation fault while using UIO

Jump to solution

The messages suggest this is an early failure well before you get to doing anything with /dev/uio.

 

One error that I can see, is your error checking on sizeFd = fopen() is incorrect.

fopen returns NULL on error whereas you are testing < 0.

 

I suggest converting your printfs to fprintf(stderr, so you can be sure that none of your prints are getting buffered before the failure.

 

You could also run under the GDB debugger to get a line number for the segfault to provide more clues.

View solution in original post

Participant shahid
Participant
8,963 Views
Registered: ‎03-25-2016

Re: Segmentation fault while using UIO

Jump to solution

Hi,

 

yes there was a problem with file opening.

 

thanks.

0 Kudos
Visitor irshs
Visitor
1,776 Views
Registered: ‎02-05-2015

Re: Segmentation fault while using UIO

Jump to solution

Hi,

 

I run into the same issue. The cause of the segmentation fault is not the error check!

It is the "O_RDONLY" parameter of:

 

sizeFd = fopen("/sys/class/uio/uio0/maps/map0/size", O_RDONLY);

 

Replacing of O_RDONLY to "r" solves the problem:

sizeFd = fopen("/sys/class/uio/uio0/maps/map0/size", "r");

 

Best

0 Kudos