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: 
Highlighted
Contributor
Contributor
194 Views
Registered: ‎05-02-2019

Linux memory access using mmap

Hello all,

I have seen other posts about accessing RAM through mmap(). Unfortunately those other post have not helped yet, which is why I am hoping for your help to access physical addresses within Linux through mmap()-calls. I am using the Ultrazed-EG from Avnet with a 4.19.0 Linux Kernel and Debian, and I am currently debugging both kernel module and user space application. 

In the driver I am using kmalloc to get a memory area. using the following functions I am trying to map this area directly to userspace:

 

pfn = ( virt_to_phys( virt_addr_from_kmalloc ) >> PAGE_SHIFT );

remap_pfn_range(vma, vma->vm_start, pfn, vma->vm_end - vma->vm_start, vma->vm_page_prot)

But unfortunately this memory area always stays random and using a bare-metal program I have validated that the PL is working correctly. Does anyone have experience with this or a similar issue?

 

I would add further code, screenshots, etc. if required.

Furthermore I am using the write functions to write from userspace to kernel, and using iowrite32/ioread32 to write from kernel to PL which seems to work. I dont have that much experience with Embedded Linux which is why I would appreciate all tips I can get.

Best regards,

Bjorn Hoevding

0 Kudos
2 Replies
Moderator
Moderator
166 Views
Registered: ‎09-12-2007

Re: Linux memory access using mmap

Can you try the following in petalinux

 

petalinux-config -c kernel

  • kernel hacking → [] Filter access to /dev/mem
0 Kudos
Contributor
Contributor
100 Views
Registered: ‎05-02-2019

Re: Linux memory access using mmap

Hello @stephenm,

by default this was enabled within PetaLinux Tools.

I have disabled [ ] Filter access to /dev/mem but still the output image is random.

Do you have another idea?

Regards

0 Kudos