Take the 2-minute tour ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

I'm trying to get I2C to run on Arch Linux with Kernel 3.6.11+ #352 PREEMPT with Raspberry Firmware from Jan 9, 2013 updated via rpi-update.

So far I have got good results by just loading the i2c-dev module via

# echo "i2c-dev" > /etc/modules-load.d/i2c-dev.conf

on system start. As mentioned in this I2C tutorial, the permissions on the devices /dev/i2c-* are only set to root, but can be made accessible to anyone via

sudo chmod 666 /dev/i2c-*

temporarily. (After this, the C example at the bottom of that page works, with minor tweaks). The permissions are not persistent after reboot. There is some discussion on how to make that persistent, and one user states that installing the package i2c-tools also should create a group i2c which allows any member to access /dev/i2c-*.

Unfortunately, inspecting /etc/group, there is no such group i2c after installing i2c-tools. Any idea why this group isn't there, or good alternatives how to give user-programs access to i2c?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

There are two ways to do that:

  1. Just a couple of commands in the rc.local script, the same as you use to do it manually (be sure that the kernel module is loaded)

  2. The better option (but a little more complicated) is to use udev, I assume for the moment that arch linux has that package. But it uses a configuration file (in /etc/udev on my Fedora system), in this config file you can specify all sorts of rules and things that need to be done to some (or any) file during creation of these device files.

For a total overview of what you can put in the configuration of udev, this page called Writing udev rules is a good source of information, the permission and ownership options are a in a paragraph a little down in the index. You can change the owner to whatever user you like, or set the permissions (file mode bits) to a specified value.

share|improve this answer
    
Ok, so the info that i2c-tools will do that automatically is not (anymore) true, at least on Arch? –  fabb Jan 13 '13 at 18:07
    
I don't know, it might do that, you need to check that in the info of those tools, the 2nd option I proposed is a general way to do that, so it will work in a similar way with other /dev files, independent of what individual tools might do. –  ikku Jan 13 '13 at 18:08
    
Thank you, I used the 2nd option to solve the issue (see my answer). –  fabb Jan 13 '13 at 18:14

I fixed the issue by manually adding the i2c group and setting the group for i2c-* devices in udev. Thanks @ikku for the hints.

# groupadd i2c
# usermod -aG i2c myusername
# echo 'KERNEL=="i2c-[0-9]*", GROUP="i2c"' >> /etc/udev/rules.d/10-local_i2c_group.rules

There is no need to install i2c-tools to access the I2C bus for users in the group i2c (but the tools might help with development).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.