1

I want to enable the I2C interface, but without having to boot, login, and the whole sudo raspi-config.

I tried editing /boot/config.txt right after sudo dd the image to the disk, still in my main computer, and uncommented the dtparam=i2c_arm=on line.

Now, everytime I reboot, it's like the interface is disabled. The line is still uncommented, and i2c-dev is the only thing in the /etc/modules file. Now everytime I reboot, I have to do sudo raspi-config all over again to make it work.

Is it something about permissions? I don't know where to look for problems here.

Edit as requested:

I wrote aversion of the INA219 library in C++, INA uses i2c.

This is how you can try it: git clone http://github.com/regisin/pi_ina219cpp make ./build/profiler

The library works fine if I use the sudo raspi-config (not even trying the manual part), and ev en when rebooting it continues to work.

However, when I tried to edit the /boot/config.txt file, it only works if I do a sudo modprobe i2c-dev manually, after the boot.

Edit 2:

If you read the previous section you noticed I used modprobe. I looked into the /usr/bin/raspi-config file, and noticed that the i2c function does a few commands:

1 - uncomment or add dtparam=i2c_arm=on line to /boot/config.txt 2 - insert i2c-dev to the /etc/modules 3 - dtparam i2c_arm=on 4 - modprobe i2c-dev

What puzzles me is that after editing /boot/config.txt directly in the sd card from another machine, raspi-config does not work as expected. It's like some configuration is resetting at boot time. I guess I could work around this by doing modprobe when booting, but it does not sound like that's the intended behavior.

  • 1
    As far as I know that should have worked. You need to edit your question and tell us why you don't think it is enabled and other relevant information such as Pi and operating system details. – joan Apr 30 '18 at 19:33
  • but without having to boot ... i think that you have to run some sort of sofware ... you have to boot the RPi .... make your question clearer as to what you are actually asking – jsotola May 1 '18 at 1:04
3

The information supplied seems contradictory.

You need to do two things to enable the I2C bus.

  1. Edit /boot/config.txt and enable the device tree entry.
  2. Add the line i2c-dev to /etc/modules.

I suspect you are not adding i2c-dev to /etc/modules prior to the first boot.

  • Great, it worked. I didn't know about /etc/modules before, then tried modifying after booted. Tried again with a fresh install and now it works. – regisin May 3 '18 at 19:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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