Hello TI:
how to convert physical address to virtual address in linux? We use mmap(), but we found that the Operation not permitted.
Best regards
Alun
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello TI:
how to convert physical address to virtual address in linux? We use mmap(), but we found that the Operation not permitted.
Best regards
Alun
Hi
thanks ,we will try. And we get phys address in other app use tivxMemHost2SharedPtr
Best Regards,
Alun
Hello ,
do you have another suggestion if our app run on A72?
Best Regards,
Alun
Hi,
do you have another suggestion if our app run on A72?
We have devmem2 tool for reading the registers from A72 (Linux), which uses mmap only.
Please refer to source code of devmem2 tool from git link, which is using mmap for accessing physical address space.
Best Regards,
Sudheer
hi,
void *appMemMap_local(void *phys_ptr, uint32_t size) { uint32_t pageSize = getpagesize (); uintptr_t taddr; uint32_t tsize; void *virt_ptr = NULL; int32_t status = 0; static int dev_mem_fd = -1; if(dev_mem_fd == -1) { dev_mem_fd = open("/dev/mem",O_RDWR|O_SYNC); if(dev_mem_fd < 0) { ULOGE("[EBD]APP_LOG: ERROR: Unable to open /dev/mem !!!\n"); status = -1; } } if(status==0 && dev_mem_fd >= 0) { #ifdef APP_LOG_DEBUG printf("APP_LOG: Mapping %p ...\n", phys_ptr); #endif /* Mapping this physical address to linux user space */ taddr = (uintptr_t)phys_ptr; tsize = size; /* Align the physical address to page boundary */ tsize = Align(tsize + (taddr % pageSize), pageSize); taddr = Floor(taddr, pageSize); virt_ptr = mmap(0, tsize, (PROT_READ | PROT_WRITE), (MAP_SHARED), dev_mem_fd, taddr); if(virt_ptr==MAP_FAILED) { virt_ptr = NULL; } else { virt_ptr = (void*)((uintptr_t)virt_ptr + ((uintptr_t)phys_ptr % pageSize)); } #ifdef APP_LOG_DEBUG printf("APP_LOG: Mapped %p -> %p of size %d bytes \n", phys_ptr, virt_ptr, size); #endif } if(virt_ptr==NULL) { ULOGE("[EBD]APP_LOG: ERROR: Unable to map memory @ %p of size %d bytes !!!\n", phys_ptr, size); } return virt_ptr; }
this is our function to mmap, but Operation not permitted
Best Regards,
alun
Hi Alun,
mmap
operation is not permitted in dma-heap-carveout
region because it is a reserved memory region for DMA (Direct Memory Access) operations.
This memory region is used by the kernel to allocate memory for DMA operations, which are used by devices to directly access the system’s memory without involving the CPU.
The CONFIG_STRICT_DEVMEM
kernel configuration option restricts access to /dev/mem
files, which provide direct access to the physical memory of the system. When this option is enabled, only privileged users can access these files. Since dma-heap-carveout
is a reserved memory region for DMA operations, it is not accessible through mmap
operation when CONFIG_STRICT_DEVMEM
is enabled.
Regards,
Nikhil
hi Nikhil
so how to get correct image data from other app ? Two app have different graph.
Best Regards,
alun