access error i2c device file

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

access error i2c device file

1,101 Views
janmennen
Contributor II

I  get EACCESS error when opening i2c-2 device file when using Android-NDK build and called via JNI

When using i2c tools i don't have this problem.

int i2cbus = 2;
sprintf(fileName, "/dev/i2c-%d", i2cbus);

if ((file = open(fileName,O_RDWR)) < 0) {
    LOGE("Error opening %s file=%d error=%d", fileName, file, errno);
    if (errno == EACCES) LOGE("Run as root?\n");
    return -1;
}

Seems  i have to change the access rights of the device file. How to do this permanently. When i do chmod 666  setting is changed but after reboot it is getting its old value.

Does someone knows how to solve this issue

Thanks Jan

Tags (2)
2 Replies

992 Views
janmennen
Contributor II

Problem is related to security mode avc: denied kernel error

When i enable permissive mode the problem is solved see:

https://source.android.com/security/selinux

androidboot.selinux=permissive

992 Views
jimmychan
NXP TechSupport
NXP TechSupport
0 Kudos