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: 
Visitor ambe
Visitor
1,165 Views
Registered: ‎07-17-2018

BUS Error is occured when get data from mmap() address

Jump to solution

Hi,

I'm developping peripheral interfaces on PetaLinux with ZynqMPSoC Architecture.
I try porting from standalone application code to petalinux application using mmap().
Then, Getting virtual address via mmap(), I try to access address considering offset.
But BUS error is occured.

My code is below:

#define BASE_ADDR_MASK 0xFFFF0000

static INLINE u32 Xil_In32(UINTPTR Addr)
{
	printf("Xil_In32 start.\n");
	UINT64 *vptr = NULL;
	static int fd;
	unsigned int page_size = getpagesize();
	UINTPTR base = Addr&BASE_ADDR_MASK;

    if ((fd = open(DEVMEM_PATH, O_RDWR | O_SYNC)) == -1) {
    	perror("open error");
    	return 0x0;
    }
    vptr = (UINT64 *)mmap(NULL, page_size, PROT_READ|PROT_WRITE, MAP_SHARED,
        						fd, base);
    if (*vptr == -1){
	    	perror("mmap error");
	    	return 0x0;
	}
    close(fd);

    printf("Xil_In32 end.\n");

    UINT32 ret =  0;
    ret = (UINT32)*(vptr + (Addr - base));
    munmap(vptr, page_size);
    return ret;

//	return *(volatile u32 *) Addr;
}
0 Kudos
1 Solution

Accepted Solutions
Highlighted
Visitor ambe
Visitor
1,073 Views
Registered: ‎07-17-2018

Re: BUS Error is occured when get data from mmap() address

Jump to solution

Hi,

Thank you for replying.

I tried the source code that is shown at wiki page.
Then, it is necessary for using mmap that add below code to target device in the devicetree(system-user.dtsi).

status = "disabled";

This setting works and BUS error is stopped.

 

 

0 Kudos
6 Replies
Moderator
Moderator
1,112 Views
Registered: ‎02-07-2018

Re: BUS Error is occured when get data from mmap() address

Jump to solution

HI @ambe

 

Please refer below link for mmap() usage.

:https://xilinx-wiki.atlassian.net/wiki/spaces/A/pages/18842018/Linux+User+Mode+Pseudo+Driver

 

Thanks & regards

Aravind

----------------------------------------------------------------------------------------------
Kindly note- Please mark the Answer as "Accept as solution" if information provided is helpful.
Give Kudos to a post which you think is helpful and reply oriented.
----------------------------------------------------------------------------------------------

0 Kudos
Highlighted
Visitor ambe
Visitor
1,074 Views
Registered: ‎07-17-2018

Re: BUS Error is occured when get data from mmap() address

Jump to solution

Hi,

Thank you for replying.

I tried the source code that is shown at wiki page.
Then, it is necessary for using mmap that add below code to target device in the devicetree(system-user.dtsi).

status = "disabled";

This setting works and BUS error is stopped.

 

 

0 Kudos
Observer magonmonkey
Observer
940 Views
Registered: ‎09-20-2018

Re: BUS Error is occured when get data from mmap() address

Jump to solution

Hi ambe,

We're now countering a similar problem. We try to port working standalone code to petalinux application. We access the AXI_DMA using mmap() but it will cause bus error. The AXI_DMA is in our pl.dtsi and our system-user.dtsi is empty.

Could you please elaborate on what changes needed to be made in the device tree file, what does the status = "disabled"; mean? Or can you please share your working .dtsi files? Any help would be greatly appreciated!

0 Kudos
Visitor ambe
Visitor
925 Views
Registered: ‎07-17-2018

Re: BUS Error is occured when get data from mmap() address

Jump to solution

Hi,

My case is I2C.
I couldnt find suitable device driver, then I tried to direct access to the target I2C device.
And my system-user.dtsi source was below:

/include/ "system-conf.dtsi"
/ {
   memory {
       device_type = "memory";
       reg = <0x0 0x0 0x0 0x80000000>, <0x0 0xFF020000 0x0 0x40000>, <0x00000008 0x00000000 0x0 0x80000000>;
   };
   reserved-memory {
       #size-cells = <2>;
       #address-cells = <2>;
       ranges;
       reserved {
           reg = <0x0 0xFF020000 0x0 0x40000>;
       };
   };
};
&i2c0 {
        status = "disabled";
};

 

disabling I2C device and adding reserved-memory for I2C device address.
But finally, I found a suitable I2C device driver for my product used.

Observer magonmonkey
Observer
917 Views
Registered: ‎09-20-2018

Re: BUS Error is occured when get data from mmap() address

Jump to solution

We resolve our problem by disabling our axi-dma in the device tree.

Thanks a lot!

0 Kudos
Visitor zhouchch
Visitor
374 Views
Registered: ‎12-24-2018

Re: BUS Error is occured when get data from mmap() address

Jump to solution

Please tell me more detail about how to disable axi-dma in the device tree?

0 Kudos