cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
2,703 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
Visitor
2,610 Views
Registered: ‎07-17-2018

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.

 

 

View solution in original post

0 Kudos
6 Replies
Highlighted
Moderator
Moderator
2,649 Views
Registered: ‎02-07-2018

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
Visitor
2,611 Views
Registered: ‎07-17-2018

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.

 

 

View solution in original post

0 Kudos
Highlighted
Observer
Observer
2,476 Views
Registered: ‎09-20-2018

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
Highlighted
Visitor
Visitor
2,461 Views
Registered: ‎07-17-2018

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.

Highlighted
Observer
Observer
2,453 Views
Registered: ‎09-20-2018

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

Thanks a lot!

0 Kudos
Highlighted
Visitor
Visitor
1,910 Views
Registered: ‎12-24-2018

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

0 Kudos