jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

i2c configuration

Thu May 09, 2013 12:03 pm

Hello,

I have configured I2C in the RaspberryPi and I'm able to see the devices:
[email protected]:/sys/class/gpio# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- 39 3a 3b -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 4f
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Some of the devices are PCF8574 and I'd like to address each pin of it individually. Following the instructions from http://positiveelectrons.blogspot.pt/20 ... gpios.html
I'd just need to load the gpio_pcf857x module by adding this in the /etc/rc.local file:
[email protected]:/sys/class/gpio# cat /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
printf "My IP address is %s\n" "$_IP"
fi

echo pcf8574 0x3a > /sys/bus/i2c/devices/i2c-1/new_device

exit 0

Apparently this goes OK, as I can see in the logs:
[email protected]:/sys/class/gpio# dmesg | tail
[ 18.728360] bcm2835 ALSA chip created!
[ 18.740161] bcm2835 ALSA chip created!
[ 18.750690] bcm2835 ALSA chip created!
[ 18.760257] bcm2835 ALSA chip created!
[ 18.958430] i2c /dev entries driver
[ 19.057258] Driver for 1-wire Dallas network protocol.
[ 19.126939] w1_master_driver w1_bus_master1: Family 28 for 28.0000033a0a89.68 is not registered.
[ 28.015123] smsc95xx 1-1.1:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x45E1
[ 35.817668] Adding 102396k swap on /var/swap. Priority:-1 extents:1 across:102396k SS
[ 55.272557] i2c i2c-1: new_device: Instantiated device pcf8574 at 0x3a
[email protected]:/sys/class/gpio#
However, when loading this driver, I should have a new file in /sys/class/gpio, but not:
[email protected]:/sys/class/gpio# ls -larth /sys/class/gpio/
total 0
drwxr-xr-x 39 root root 0 May 9 12:29 ..
drwxr-xr-x 2 root root 0 May 9 12:37 .
--w------- 1 root root 4.0K May 9 12:37 unexport
lrwxrwxrwx 1 root root 0 May 9 12:37 gpiochip0 -> ../../devices/virtual/gpio/gpiochip0
--w------- 1 root root 4.0K May 9 12:44 export
[email protected]:/sys/class/gpio#
By tentative/error, I tried to export export the GPIO's and found this interesting behavior:
[email protected]:/sys/class/gpio# echo 248 > /sys/class/gpio/export
-su: echo: write error: No such device
[email protected]:/sys/class/gpio# echo 256 > /sys/class/gpio/export
-su: echo: write error: Invalid argument
[email protected]:/sys/class/gpio#
By this, I assume that the correct range to export would be from 256, but somehow I'm using the wrong arguments.

Any idea? Am I missing something here?

Thanks,
Jabss

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: i2c configuration

Thu May 09, 2013 4:28 pm

Are you sure that your device is pcf8574 and not pcf8574a or pca8574? Try those two as a first argument to /sys/bus/i2c/devices/i2c-1/new_device. Hint, you can remove previously created device using

Code: Select all

echo 0x3a >  /sys/bus/i2c/devices/i2c-1/delete_device

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Thu May 09, 2013 5:52 pm

Hi,

I double checked and my chips are Philips PCF8574AP.
Followed your recommendation but had no luck....
echo 0x3a > /sys/bus/i2c/devices/i2c-1/delete_device
echo pcf8574ap 0x3a > /sys/bus/i2c/devices/i2c-1/new_device
As before, seems OK in the logs:
[18276.962082] i2c i2c-1: delete_device: Deleting device pcf8574 at 0x3a
[18299.179806] i2c i2c-1: new_device: Instantiated device pcf8574ap at 0x3a
I expect to see something like gpioXXX in /sys/class/gpio, but nothing:
[email protected]:/sys/bus/i2c/devices/i2c-1# ls -larth /sys/class/gpio/
total 0
drwxr-xr-x 38 root root 0 May 9 13:38 ..
drwxr-xr-x 2 root root 0 May 9 13:40 .
--w------- 1 root root 4.0K May 9 13:41 unexport
lrwxrwxrwx 1 root root 0 May 9 13:41 gpiochip0 -> ../../devices/virtual/gpio/gpiochip0
--w------- 1 root root 4.0K May 9 14:29 export
Any idea what am I doing wrong?
Am I looking into the wrong place, since the instructions in the site are for RASPI Rev1 and mine is Rev2?

Thanks,
Jabss

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: i2c configuration

Thu May 09, 2013 7:36 pm

You can write anything you want as a frist argument to new_device. For example this wont give you an error:

Code: Select all

echo blah 0x20 >  /sys/bus/i2c/devices/i2c-0/new_device
Here's what I get from dmesg:

Code: Select all

i2c i2c-0: new_device: Instantiated device blah at 0x20
But of course it doesn't work. There is no driver for id pcf8574ap so it can't work. Here's the list from the actual driver:

Code: Select all

static const struct i2c_device_id pcf857x_id[] = {
    { "pcf8574", 8 },
    { "pcf8574a", 8 },
    { "pca8574", 8 },
    { "pca9670", 8 },
    { "pca9672", 8 },
    { "pca9674", 8 },
    { "pcf8575", 16 },
    { "pca8575", 16 },
    { "pca9671", 16 },
    { "pca9673", 16 },
    { "pca9675", 16 },
    { "max7328", 8 },
    { "max7329", 8 },
    { }
};
So you might want to try pcf8574a, as I suggested, not pcf8574ab.

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Thu May 09, 2013 9:07 pm

Thanks for replying,

I had a NXP PCF8574 and replaced the Philips PCF8574AP.
Unfortunatelly, the behaviour is the same.... I think I should have an entry "gpioXXX" in /sys/class/gpio after initializing the chip but I continue having the initial entries...

I did apt-get update and upgrade, so I shoudl have the latest versions of all packages.
Should I try any other distro? I'm using
Linux raspberrypi 3.6.11+ #371 PREEMPT Thu Feb 7 16:31:35 GMT 2013 armv6l GNU/Linux
Thanks,
Jabss

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 4627
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: i2c configuration

Thu May 09, 2013 10:43 pm

Hi Folks, FWIW I've successfully used a PCF8574P together with a MCP23008 to multiplex a 4-digit 7-seg display (the 8574 drives the cathodes and the 23008 the anodes) which involves setting individual bits of both devices. The circuitry etc. can be found at http://www.cpmspectrepi.webspace.virgin ... oFull.html. The software is based around either 'C' system calls to "i2cset" (for slow testing) or Gordon's "wiringPi library (https://projects.drogon.net/raspberry-pi/wiringpi/ ) for "true" multiplexing (each digit is activated for ~5ms). Unfortunately, as yet, I haven't transferred any "code snippets" for the 8574 to my web pages but the methods used are based upon those for a similar, MCP23017 based setup shown at http://www.cpmspectrepi.webspace.virgin ... OfPio.html . Hope this is of a little help/interest, Trev.
Still running Raspbian Jessie on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W) but Stretch on my 2xP3A+, P3B+, P3B, B+, A+ and a B2. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: i2c configuration

Fri May 10, 2013 11:00 am

jabss wrote:I think I should have an entry "gpioXXX" in /sys/class/gpio after initializing the chip but I continue having the initial entries...
Yes, you should have additional gpioXXX directory in /sys/class/gpio. And it works perfectly fine for me. But it only appears if i specify first argument to new_device correctly. This is why I suspected this is your problem.

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Fri May 10, 2013 11:14 am

I'll change the OS, as I'm not sure which one came with my raspberry pi.
What is your OS? Is there any recommended OS for i2c?
Thanks,
Jabss

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: i2c configuration

Fri May 10, 2013 11:22 am

It's not distribution specific for sure. It may be kernel specific but I doubt it. I'm using latest raspbian image with my custom made kernel. And now that I think about this - this may be the cause of your problem. There is no gpio_pcf857x module in official raspberrypi's kernel. Are you able to load this module by calling:

Code: Select all

modprobe gpio_pcf857x
?

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Sat May 11, 2013 2:51 pm

Hi,

Downloaded a new raspberian image, updated it and configured everyting from scratch. The problem persists.
Searched for the gpio_pcf857x module, and in fact, its not there neither couldn't load it.
[email protected]:/sys/class/gpio# lsmod | grep gpio
w1_gpio 1625 0
wire 24845 2 w1_gpio,w1_therm
leds_gpio 2235 0
led_class 3562 1 leds_gpio
[email protected]:/sys/class/gpio# modprobe gpio_pcf857x
FATAL: Module gpio_pcf857x not found.
[email protected]:/sys/class/gpio#
So, it should be that. How can I include the module?

Thanks,
jabss

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Sat May 11, 2013 9:58 pm

Hi,

I'm currently compiling a raspbian kernel.
Will post news when trying I2C again.

Thanks,
Jabss

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Sat May 11, 2013 10:51 pm

Just for future reference, quote from

http://raspberrypi.stackexchange.com/qu ... igital-i-o
Additional solutions

If running low on GPIO pins, you can sometimes easily extend it's number by using some additional (but simple) hardware. For output for example, you can use shift registers or I²C I/O expanders (also called `I²C bus expanders), both easily to buy and use. You can find example of it's usage here.

PFC8574 (or similar from this family) are so popular that there is a ready to use kernel module that handles all the communication for you (it's not enabled in the official RaspberryPi kernel, you will need to compile your own kernel to use it). The module is called gpio_pcf857x, providing that you loaded it with modprobe (along with I²C drivers) and that you have the chip connected to I²C bus, you can activate it like this:
echo pcf8574 0x27 > /sys/class/i2c-adapter/i2c-0/new_device

where pcf8574 is your actual chip name (this module can handle few different chips like pca967x and max732x) and 0x27 is its address on I²C (you can configure the address of the chip when wiring it).

This will create entries in /sys/class/gpio/ directory that will allow you to use them the same way as other GPIO ports in RaspberryPi, providing you are using sys interface (for example wiringPiSetupSys() in wiringPi). Unfortunately, Python's RPi.GPIO module does not support this mode so it won't be able to use this pins with this library. The pins will have some high numbers like 248-255 or similar.
Just added this comment to explain why I am compiling the kernel.

Cheers,
Jabss

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Sat May 11, 2013 11:59 pm

Hello,

Just a final update. Its confirmed that in order to use the I2C GPIO expanders (PCF8574x) is needed to compile the kernel with the gpio_pcf857x module. It took the change and also included some more modules for a Real Time Clock, a PCF8591 ADC/DAC and a LM75 temperature sensor... 8-)

I did it, and now there is the result (BTW, the driver works with PCF8574AP as it would PCF8574)
[email protected] ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- UU UU UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- 4b -- -- -- 4f
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[email protected] ~ $ ls /sys/class/gpio/
export gpio233 gpio236 gpio239 gpio241 gpio244 gpio247 gpio25 gpio252 gpio255 gpiochip232 unexport
gpio23 gpio234 gpio237 gpio24 gpio242 gpio245 gpio248 gpio250 gpio253 gpio8 gpiochip240
gpio232 gpio235 gpio238 gpio240 gpio243 gpio246 gpio249 gpio251 gpio254 gpiochip0 gpiochip248
[email protected] ~ $
Lots of happy gpios!

Thanks for the help.
Jabss

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: i2c configuration

Sun May 12, 2013 7:40 am

This is exacly what I was expecting when writing my last post in this thread. Good to hear that you managed to figure out yourself how to compile those modules. And by the way, the answer from SE that you quoted is actually mine. Noticed that in the middle of reading it :)

User avatar
FTrevorGowen
Forum Moderator
Forum Moderator
Posts: 4627
Joined: Mon Mar 04, 2013 6:12 pm
Location: Bristol, U.K.
Contact: Website

Re: i2c configuration

Sun May 12, 2013 3:19 pm

jabss wrote: ...
http://raspberrypi.stackexchange.com/qu ... igital-i-o
Additional solutions

If running low on GPIO pins, you can sometimes easily extend it's number by using some additional (but simple) hardware. For output for example, you can use shift registers or I²C I/O expanders (also called `I²C bus expanders), both easily to buy and use. You can find example of it's usage here.

PFC8574 (or similar from this family) are so popular that there is a ready to use kernel module that handles all the communication for you (it's not enabled in the official RaspberryPi kernel, you will need to compile your own kernel to use it). The module is called gpio_pcf857x, providing that you loaded it with modprobe (along with I²C drivers) and that you have the chip connected to I²C bus, you can activate it like this:
echo pcf8574 0x27 > /sys/class/i2c-adapter/i2c-0/new_device

where pcf8574 is your actual chip name (this module can handle few different chips like pca967x and max732x) and 0x27 is its address on I²C (you can configure the address of the chip when wiring it).

This will create entries in /sys/class/gpio/ directory that will allow you to use them the same way as other GPIO ports in RaspberryPi, providing you are using sys interface (for example wiringPiSetupSys() in wiringPi). Unfortunately, Python's RPi.GPIO module does not support this mode so it won't be able to use this pins with this library. The pins will have some high numbers like 248-255 or similar.
Just added this comment to explain why I am compiling the kernel.
Jabss
Now I understand what you were doing. Since I didn't need to generate new "single GPIO pins" or use "gpio export" methods Gordon's WirinPi I2C library (https://projects.drogon.net/raspberry-p ... c-library/ ) provided enough 'C' functionality for my purposes and doesn't require "chip specific" kernel drivers. Although the multiplexing code sets only one PCF8574 output "active low" at a time (per digit) all outputs are reset high whilst the 7-segment data (via an MCP23008 chip) is changed, thus briefly blanking the display between digits and avoiding "ghost segments" from the previous digit.
Trev.
Still running Raspbian Jessie on some older Pi's (an A, B1, B2, B+, P2B, 3xP0, P0W) but Stretch on my 2xP3A+, P3B+, P3B, B+, A+ and a B2. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Sun May 12, 2013 9:01 pm

Everything was going fine, with the compiled kernel...

So I though: "humm maybe I should update the system with a apt-get upgrade"

Bad move: It's now broken. Any idea why?

Thanks,
Jabss

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Sun May 12, 2013 10:24 pm

Solved by copying the compiled image file again to /boot directiory.
sudo cp Image /boot/kernel.img
However, this brokes the 1-W drivers.
No DS18B20 temperature anymore.... Any suggestion?

Thanks,
Jabss

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: i2c configuration

Mon May 13, 2013 6:36 am

Check that you have w1-gpio and w1-therm kernel modules.

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Tue May 14, 2013 2:18 pm

Hi,

Comming back to this topic.
I have a build the kernel and successfullt have all I2C devices working.
[email protected] ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- UU UU UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- UU
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[email protected] ~ $ sensors
bcm2835_thermal-virtual-0
Adapter: Virtual device
temp1: +39.0°C

lm75-i2c-1-4b
Adapter: bcm2708_i2c.1
temp1: +20.5°C (high = +80.0°C, hyst = +75.0°C)

pcf8591-i2c-1-4f
Adapter: bcm2708_i2c.1
in0: +0.72 V
in1: +0.00 V
in2: +0.00 V
in3: +0.00 V

[email protected] ~ $ sudo hwclock -r
Tue 14 May 2013 14:52:50 WEST -0.649160 seconds
That is: 3x PCF8574AP, 1x DS1037 Real Time Clock, 1x LM75 Temperature sensor and 1x PCF8591. The UU in the i2cdetect output means something like "Under Use". Awsome :P

I also have a DHT-22 temperature and humidity sensor, connected directly to GPIO7 of the Raspberry:
[email protected] ~ $ sudo /home/pi/dht-22/Adafruit-Raspberry-Pi-Python-Code/Adafruit_DHT_Driver/Adafruit_DHT 22 7
Using pin #7
Data (40): 0x2 0x1c 0x0 0xe3 0x1
Temp = 22.7 *C, Hum = 54.0 %
Now, in order to have it complete I'd like to add the DS18B20 temperature sensor.
This was already working before, when I had broken the I2C drivers, so it should not be an HW problem.
[email protected] ~ $ cd /sys/bus/w1/devices/
[email protected] /sys/bus/w1/devices $ ls
[email protected] /sys/bus/w1/devices $ cat /etc/modules
# /etc/modules: kernel modules to load at boot time.
#
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.
# Parameters can be specified after the module name.

snd-bcm2835
spi-bcm2708
i2c-bcm2708
i2c-dev
w1-gpio
w1-therm
[email protected] /sys/bus/w1/devices $ dmesg | grep w1
[ 22.079667] wire: exports duplicate symbol w1_add_master_device (owned by kernel)
[ 22.156680] wire: exports duplicate symbol w1_add_master_device (owned by kernel)
It seems something went wrong during the module load...

I've read somewhere that there was some kind of incompatibility when using I2C and W1 at the same time, and a patch was needed (thread "kernel patch for Dallas 1-wire interface"). However, acording to some posts, it shouldn't be needed anymore because it was included in the newer versions of kernel...

Maybe the bug is back?

Cheers,
Jabss

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Tue May 14, 2013 3:23 pm

Update:

One more apt-get update / apt-get upgrade and the I2C is broken again (and the W-1 driver is back!).
[email protected] ~/webiopi $ sudo apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
libraspberrypi-bin libraspberrypi-dev libraspberrypi-doc libraspberrypi0 raspberrypi-bootloader
5 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 60.3 MB of archives.
After this operation, 104 kB disk space will be freed.
Do you want to continue [Y/n]? y
....
[/quote]

Doing a reboot shows the I2C devices as not "Under Use" anymore (only the RTC is working):
[email protected] ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- 39 3a 3b -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- 4b -- -- -- 4f
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[email protected] /sys/bus/w1/devices/28-0000033a0a89 $ sudo hwclock -r
Tue 14 May 2013 16:12:23 WEST -0.239878 seconds
[email protected] /sys/bus/w1/devices/28-0000033a0a89 $ sensors
No sensors found!
Make sure you loaded all the kernel drivers you need.
Try sensors-detect to find out which these are.
And now I have the DS18B20 back online.
[email protected] /sys/bus/w1/devices/28-0000033a0a89 $ cat /sys/bus/w1/devices/28-0000033a0a89/w1_slave
55 01 4b 46 7f ff 0b 10 d0 : crc=d0 YES
55 01 4b 46 7f ff 0b 10 d0 t=21312
Soo, in order to have the I2C devices back, I repeated the same procedure as described before, which is copying the compiled image back to the boot directory: sudo cp Image /boot/kernel.img and after reboot:
[email protected] ~ $ sudo i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- UU UU UU -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- UU -- -- -- UU
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- UU -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
[email protected] ~ $ cat /sys/bus/w1/devices/28-0000033a0a89/w1_slave
cat: /sys/bus/w1/devices/28-0000033a0a89/w1_slave: No such file or directory
So, I believe its safe to assume there is some incompatibility between these drivers.
Is there someone to whom I should report it?

Cheers,
Jabss

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: i2c configuration

Tue May 14, 2013 3:28 pm

When you update the system with apt-get, your kernel may be updated (and it seems it was the case). The kernel consists of kernel.img file in /boot/ directory and of modules files in /lib/modules directory. It seems that you only overrides kernel.img file and not modules files. This causes your incopatibility problems.

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Tue May 14, 2013 3:42 pm

Hi,

It makes sense. How can I solve this?

Thanks,
Jabss

kadamski
Posts: 187
Joined: Fri Jun 08, 2012 10:56 pm

Re: i2c configuration

Tue May 14, 2013 7:26 pm

Since you are using your own compiled kernel, you have to ensure that it is not overwriten by apt-get update. There are couple of ways you can achieve this. What I'm doing is to rename kernel.img to kernel-my.img and add

Code: Select all

kernel=kernel_my.img
line to config.txt. This makes bootloader use kernel_my.img instead of kernel.img so it doesn't matter if it's updated or not. And I alsways have stable, working kernel as a backup in case my custom kernel is not working.

But you also have to ensure that you kernel modules are not overwriten. In order to do that, I'm using custom kernel postfix. You can do this by using CONFIG_LOCALVERSION=-my kernel config parameter and recompiling the kernel and modules. Now your modules will be in /lib/modules/3.X.Y-my+/ instead of /lib/modules/3.X.Y+/. This means you will still have proper kernel modules for original kernel.img installed. Whenever you want to switch back to original kernel, all you have to do is to comment out the kernel= line in config.txt.

Of course in all cases you have to ensure that you have an upto date version of the kernel by yourself.

jabss
Posts: 65
Joined: Thu May 09, 2013 11:47 am

Re: i2c configuration

Tue Oct 01, 2013 11:43 pm

Hello again,

I was wondering if the I2C and W-1 support have been included in any of latest kernel versions?
Anyone knows how to check it out?
I was hoping to update my RPI without loosing the I2C/1-W functionality...

Cheers,
Jabss

mayap
Posts: 1
Joined: Mon Feb 09, 2015 8:01 am

Re: i2c configuration

Mon Feb 09, 2015 9:05 am

u said its needed to compile the kernel, but how to compile it? im using ubuntu 13.10.. plzzz help :?

Return to “Interfacing (DSI, CSI, I2C, etc.)”