Enable I2C, I2s, SPI in boot-config file?

starting with the info given in the post KnReLe, i write a little app in C++ that uses i2c0 bus. This works but requires the app to be executed as root. As i'm not a linux expert, i were looking for a solution and find the following so that this i2c bus could be used all the time outside root:

  1. create a user group (for instance i2cuser) and add rock64 (my user account) to the group 
       $sudo addgroup i2cuser   $sudo usermod -a -G i2cuser rock64
  2. create a script /usr/local/sbin/i2c0add.sh :
    #script to add i2c-0 to the devices
    echo Create /dev/i2c-0
    enable_dtoverlay i2c0 i2c@ff150000 okay
    #change owner:group of /dev/i2c-0
    chown root:i2cuser /dev/i2c-0

  3. create a systemd service file /etc/systemd/system/i2c0add.service :
    Description=Service to create i2c0 device



  4. enable the execution of the service at startup:
      $sudo systemctl enable /etc/systemd/system/i2c0add.service
I hope that i did not forget something. I not sure that this is the best solution but this works.
In addition, linux version is 18.04 LTS (Bionic Beaver)
I am also looking for a solution for using the gpio lines as non root, but until now without success. 
If someone has a solution....


Messages In This Thread
RE: Enable I2C, I2s, SPI in boot-config file? - by pas059 - 08-14-2018, 10:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Rock64 enable 1-wire to read DS18B20 or Dallas temperature sensor Perry 2 1,358 02-12-2021, 08:02 PM
Last Post: Perry
  boot hdd usb3 philipe 1 646 01-27-2021, 02:12 PM
Last Post: tllim
  Libreelec Rock64 - 4GB no boot spiker15 3 1,519 11-02-2020, 12:36 AM
Last Post: wilsonYan
  Rock64 - boot helpmerock 2 1,251 10-08-2020, 01:29 PM
Last Post: helpmerock
  No boot up after power on Whoopsadaisy 4 2,246 09-26-2020, 05:14 PM
Last Post: simonsouth
Bug u-boot (forks) status mcerveny 14 7,447 08-27-2020, 01:44 PM
Last Post: globaltree
Sad No boot, garbage console text and blinking red light ... jean_bruder 2 1,483 07-19-2020, 08:37 AM
Last Post: jean_bruder
  Graphical boot manager john3voltas 0 730 03-25-2020, 02:27 PM
Last Post: john3voltas
  doesn't boot, no video cjyar 7 2,868 11-15-2019, 03:45 PM
Last Post: ab1jx
  Hoe to Update Buildroot Package config from SDK build.sh file shivarj89 0 692 09-09-2019, 09:39 AM
Last Post: shivarj89

Forum Jump:

Users browsing this thread: 1 Guest(s)