Change the permission for open("/dev/mem", O_RDWR)

62 views
Skip to first unread message

sleung

unread,
Feb 23, 2010, 12:20:26 PM2/23/10
to Virtual Platform-Users
I've currently encountered an issues of calling open("/dev/mem",
O_RDWR) in in PVOMX_Init() of the /external/opencore/codecs_v2/OMX/
OMX_Common/src/pv_omxcore.cpp
I’ve discovered open(/dev/mem, O_RDWR) function failed with returned
file handle = -1 and errno = 1. I’ve checked with the header file and
it seems to me that it was returning an EPERM (“operation not
permitted”) error.
I've also tried two things to resolve this permission issue:
1) Modifying Android's system/core/rootdir/init.rc file by adding
"chmod 666 /dev/mem" in "# create basic filesystem structure" section,
then rebuilding the platfrom.
2) Add "chmod 666 /dev/mem" in "# create basic filesystem structure"
section in the init.rc file resided in the android_root_fs.ext2 file
system.
Both method does not seems to work for me, do know why?
Thanks!

AchimNohl

unread,
Feb 26, 2010, 3:59:26 AM2/26/10
to Virtual Platform-Users
Hi Steve,

can you point to the exact file/line info? I could not find the place
where it opens "/dev/mem". Note: It is very un-usual that user-space
opens "/dev/mem", typically you should go via a driver. At least, I
guess you would need root permissions. To debug it using a VP I would
use the Context and Function tracing after loading the symbols of the
shared library.

I would strongly recommend to write your own device driver. It is
really very simple and I have created a skeleton for you.

From your user-space code you would go and use it like this

#include “sys/ioctl.h”

int device = open( “/dev/steves_device”, O_RDWR)

#define READ_REG_A 0

int value= ioctl(device, READ_REG_A,0);


READ_REG_A is an arbitrary command that is passed to the Linux driver
which handles it:

static int steves_device_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
/* TODO: Check parameter cmd (define your own codes) and return
something, e.g contents of a register */
switch (cmd) {
case 0:
/* E.g.:*/
return steves_device_control.memory[0];
break;
}
}

The driver example can be found here:

http://groups.google.de/group/virtual-platform-users/web/steves_device.c


Put it into “kernel\arch\arm\mach-versatile” and add it to the
makefile there.

Regards,
Achim

Reply all
Reply to author
Forward
0 new messages