Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: tohox 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
-
Check in the overlays directory for the i2c device tree.
Sent from my iPad using Tapatalk HD
-
Read /mnt/mmcblk0p1/overlays/README
It is not piCore specific but RPi kernel. Look for i2c_vc
-
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!
-
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.
-
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.
-
Paul_123,
I'm using an RPI3 and dtparam=i2c=on sufficed as well.
Thanks,
-
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,
-
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!
-
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,