S
S
Sencis2020-04-19 23:01:02
linux
Sencis, 2020-04-19 23:01:02

How to access /dev/mem?

Using the pigpio library, there is no way to access the GPIO two I2C ports through /dev/mem without root. I can access /dev/gpiomem but there is no source for Tinker Board to recompile it, what can I do? Everything works with root: /dev/mem access test: /dev/gpiomem access: No access after group modification and write permission for everyone:

b17bf24f6d11t.jpg


cb321df637ect.jpg


6ffc47d52a4at.jpg


5e8cf6b1c033t.jpg


f2271e8ba147t.jpg

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly Karasik, 2020-04-20
@vitaly_il1

Add the relevant user to the kmem group

S
Sencis, 2020-08-27
@Userpc0101

How to write to I2C port of Tinker Board for imu sensors without using /dev/mem:

#include <sys/ioctl.h>
#include <unistd.h>

#define I2C_SLAVE	0x0703

fd_1 = open("/dev/i2c-1", O_RDWR /*чтение и запись*/);

ioctl( fd_1, I2C_SLAVE, _address /* Адресс устройства*/ );

bool BNO055::write8(bno055_reg_t reg, uint8_t value /*регистр устройства, данные*/)
{
  uint8_t buf[2] = { reg, value };

  if(write( fd_1, &buf, 2) != 2) {
      qDebug()<<"Ошибка записи I2C в регистр: "<<reg;
      return -1;
  }
  return true;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question