WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Enabling i2C under 8.0beta3  (Read 6117 times)

Offline tohox

  • Newbie
  • *
  • Posts: 25
Enabling i2C under 8.0beta3
« on: July 06, 2016, 04:04:35 PM »
Hi,

Just starting with piCore and can't seem to get I2C working with Python or with i2cdetect for that matter.

8.0beta3 release comments mention that:
- VC I2C disabled by default
Which is in line with the error message I'm getting:
Error: Could not open file `/dev/i2c-0' or `/dev/i2c/0': No such file or directory

I poked around to see where I2C could be enabled. So I mounted mmcblk0p1 and looked at config.txt but the only line which mentions I2C is this one which seems to indicate it is already enabled:
dtparam=i2c=on,spi=on,i2s=on

Any hints appreciated!

--
Tobie

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: Enabling i2C under 8.0beta3
« Reply #1 on: July 06, 2016, 04:19:16 PM »
Check in the overlays directory for the i2c device tree.


Sent from my iPad using Tapatalk HD

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Enabling i2C under 8.0beta3
« Reply #2 on: July 06, 2016, 05:54:31 PM »
Read /mnt/mmcblk0p1/overlays/README

It is not piCore specific but RPi kernel. Look for i2c_vc
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline tohox

  • Newbie
  • *
  • Posts: 25
Re: Enabling i2C under 8.0beta3
« Reply #3 on: July 11, 2016, 01:06:25 PM »
Thanks guys,

Well I got it working thanks to your help but I'm still a bit confused as the introduction part of the README states that:

   At this point, all of the optional interfaces (i2c, i2s, spi)
   are disabled, but they can be enabled using Device Tree parameters:
   dtparam=i2c=on,i2s=on,spi=on

Which corresponds to the values I had in config.txt to start with but I still had no i2c devices under /dev/ at that point.

I had to add a line with "dtoverlay=i2c-gpio" following the above dtparam line in order for the i2c devices to appear even though the README says:
   However, this shouldn't be necessary in many use cases because loading an
   overlay that requires one of those interfaces will cause it to be enabled
   automatically

Doesn't this mean that dtparam=i2c=on alone should have been enough?

Again thank you!

Online Paul_123

  • Administrator
  • Hero Member
  • *****
  • Posts: 1267
Re: Enabling i2C under 8.0beta3
« Reply #4 on: July 13, 2016, 11:15:24 AM »
Thanks guys,

Well I got it working thanks to your help but I'm still a bit confused as the introduction part of the README states that:

   At this point, all of the optional interfaces (i2c, i2s, spi)
   are disabled, but they can be enabled using Device Tree parameters:
   dtparam=i2c=on,i2s=on,spi=on

Which corresponds to the values I had in config.txt to start with but I still had no i2c devices under /dev/ at that point.

I had to add a line with "dtoverlay=i2c-gpio" following the above dtparam line in order for the i2c devices to appear even though the README says:
   However, this shouldn't be necessary in many use cases because loading an
   overlay that requires one of those interfaces will cause it to be enabled
   automatically

Doesn't this mean that dtparam=i2c=on alone should have been enough?

Again thank you!

Overlays are still new to everyone.   And the readme doesn't get updated as often as overlay options change.    What board are you using, and what do you see when you type lsmod.

The 2 modules you are looking for are
i2c_bcm2708.ko  and i2c_dev.ko


On a RPI2B, all I needed was dtparam=i2c=on to get both drivers loaded

On an older rpiB    dtparam=i2c=on only loaded the bcm driver.  The i2c_dev.ko was not loaded.      I just loaded that module the old fashion way with modprobe.   

Offline jgrulich

  • Sr. Member
  • ****
  • Posts: 341
    • GRULICH DESIGN - R&D Lab.
Re: Enabling i2C under 8.0beta3
« Reply #5 on: July 13, 2016, 03:45:43 PM »
Hi,
may be useful to little bit more clarify which function if for what.
dtparam=i2c=on ... ONLY enables the hardware for the I2C but no any software for that.
dtoverlay=i2c-gpio is one step above, means that it works like a above PLUS the generic software driver.
You may use this in case that you don't have any exact device which already uses the I2C control.
For example, when you have RTC, or I2S audio board connected, than it uses the I2C for it's control commands and than you will see the rest of the I2C bus even without any of the overlays mentioned above.
Generally, the overlay dtparam=i2c=on,i2s=on,spi=on you never need. dtoverlay enables the corresponding bus automatically.
The only exception is the dtparam=i2c_vc=on which enables the dedicated HAT detection bus and is supported directly by the firmware. Use it only in case that you have some HAT board and you like to use it's internal overlay.
Hence as already stated, the changes are too often and with large steps and changes which means that you need to look at github for the updated state and new functions.


Offline tohox

  • Newbie
  • *
  • Posts: 25
Re: Enabling i2C under 8.0beta3
« Reply #6 on: July 20, 2016, 03:54:27 PM »
Paul_123,

I'm using an RPI3 and dtparam=i2c=on sufficed as well.

Thanks,

Offline tohox

  • Newbie
  • *
  • Posts: 25
Re: Enabling i2C under 8.0beta3
« Reply #7 on: July 21, 2016, 03:16:35 PM »
Correction to my last post:

Adding dtoverlay=i2c-gpio made it work in my case. The objective was to control an I2C step motor driver through the GPIO I2C peripheral which now works.

Thanks,

Offline Benicz

  • Newbie
  • *
  • Posts: 2
Re: Enabling i2C under 8.0beta3
« Reply #8 on: April 25, 2017, 04:10:59 PM »
Hi!

I realized my question belongs here, not here: http://forum.tinycorelinux.net/index.php/topic,17608.msg131122.html#msg131122


So i got my device (mcp3021) showing up. After calling

"sudo modprobe i2c-dev",

"sudo i2cdetect -y 1" gives me a hint there's somebody at home :-D

this leads to two new questions:
- how can i make this modprobe persistent?
    (dtoverlay=i2c-gpio doesn't seem to do the job, editing modprobe.conf + backup wasn't sucessful, and /etc/modules is nonexistent)
- is there a tcz of smbus for python3? There's so much to learn - building tc packages would be too hard for now :-/

thanks in advance!
« Last Edit: April 25, 2017, 04:29:09 PM by Benicz »

Offline tohox

  • Newbie
  • *
  • Posts: 25
Re: Enabling i2C under 8.0beta3
« Reply #9 on: May 08, 2017, 04:26:39 PM »
Benicz,

I was able to use smbus2 0.1.2 successfully with Python 3.5.2 under Picore. I believe I didn't install it through a tcz though but probably using pip and backing up afterwards.

Hope this helps,