cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor
Contributor
547 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
3 Replies
Highlighted
Moderator
Moderator
519 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
Highlighted
Contributor
Contributor
453 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
Highlighted
Visitor
Visitor
226 Views
Registered: ‎06-01-2016

Re: Linux memory access using mmap

Ever figure this out?
0 Kudos