[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
howtos:hardware:arm:interfacing_i2c_devices [2014/12/29 13:24 (UTC)] – interfacing_i2c_devices renamed to howtos:hardware:arm:interfacing_i2c_devices (This was misplaced in the Wiki namespace root) alienbobhowtos:hardware:arm:interfacing_i2c_devices [2023/05/28 14:46 (UTC)] (current) – [Hacking I2C in PC DIMM modules] louigi600
Line 5: Line 5:
  
 ====== Preface ====== ====== Preface ======
-Most modern PC have several internal components that communicate vital information, like internal temperatures of critical components, over I2C bus. This type of stuff is factory wired into your PC and can be dealt with lm_senosts ... what we want to do here is use an I2C bus on your computer to connect some external I2C sensor like an accelerometer. I'm tagging this in the ARM hardware section because I think that, excluding the lm-sensors stuff, most people will be doing this sort of thing on embedded ARM systems ... but the concepts are applicable to any linux capable system with an I2C bus.+Most modern PC have several internal components that communicate vital information, like internal temperatures of critical components, over I2C bus. This type of stuff is factory wired into your PC and is normally dealt with lm_senosrs ... what we want to do here is use an I2C bus on your computer to connect some external I2C sensor like an accelerometer. I'm tagging this in the ARM hardware section because I think that, excluding the lm-sensors stuff, most people will be doing this sort of thing on embedded ARM systems ... but the concepts are applicable to any linux capable system with an I2C bus. 
 + 
 +Should you want to hack one of the many I2C busses on your PC the easiest one to access is the one in the DIMM modules. Modern DIMM modules have an I2C eprom in them that the bios reads to find out the characteristics of the DIMM module. Since the DIMM module can be removed from PC and hacked separately without risking to damage permanently your PC it is probably your safest option. See chapter "Hacking I2C in PC DIMM modules" for more details. 
  
 ====== Preparing Your Host System ====== ====== Preparing Your Host System ======
Line 18: Line 21:
  
 ===== Detecting Connected Devices ===== ===== Detecting Connected Devices =====
-There are probably many ways to determine what's connected to an I2C bus, I chose to use stuff out of the [[http://www.lm-sensors.org/wiki/I2CTools | i2ctools]] project. I was unable to find a Slackware ARM package for i2ctools so I compiled and installed it on my system.+There are probably many ways to determine what's connected to an I2C bus, I chose to use stuff out of the [[http://www.lm-sensors.org/wiki/I2CTools | i2ctools]] project. I was unable to find a Slackware ARM package for i2ctools so I compiled and installed it on my system. On some distribution the package may be called t2c-tools.
  
 First thing you want to know is what I2C busses are present on your system as there may be more then one and looking in the wrong bus may be frustrating: First thing you want to know is what I2C busses are present on your system as there may be more then one and looking in the wrong bus may be frustrating:
Line 258: Line 261:
 ====== Voltage Level Shifting ====== ====== Voltage Level Shifting ======
 You may end up with heterogeneous voltage level devices and if you have many devices the correct way to work around this problem is by using bidirectional I2C voltage level shifters like the [[ http://www.ti.com/lit/ds/symlink/pca9306.pdf |PCA9306]], but if you only have a few devices all grouped up in a neat PCB like the 10DOF IMU unit you might want to give a simpler system a try. You may end up with heterogeneous voltage level devices and if you have many devices the correct way to work around this problem is by using bidirectional I2C voltage level shifters like the [[ http://www.ti.com/lit/ds/symlink/pca9306.pdf |PCA9306]], but if you only have a few devices all grouped up in a neat PCB like the 10DOF IMU unit you might want to give a simpler system a try.
-This is how I connected my 5v IMU pcb to a 3.3v I2C bus on my RaspberryPI: I took as educated guess that 4.4v (5v with a 4148 diode in series) would still be a tolerable power supply voltage for the whole IMU pcb, this would most likely allow all the I2C devices on the IMU pcb to recognize a minimum of 3.08v (4.4 * 0.7) as the lowest reliable logic level 1 tension allowing it to inter-operate with the PI's 3.3v logig levels. I was not able to find if the PI has internal pullups on the I2C bus or if they have to be externally placed so in doubt I put in 10k pullups between the 4.4v power line and the 2 data lines. I was the able to correctly detect the sensors on the IMU pcb.   +This is how I connected my 5v IMU pcb to a 3.3v I2C bus on my RaspberryPI: I took as educated guess that 4.4v (5v with a 4148 diode in series) would still be a tolerable power supply voltage for the whole IMU pcb, this would most likely allow all the I2C devices on the IMU pcb to recognize a minimum of 3.08v (4.4 * 0.7) as the lowest reliable logic level 1 tension allowing it to inter-operate with the PI's 3.3v logic levels. I was not able to find if the PI has internal pullups on the I2C bus or if they have to be externally placed so in doubt I put in 10k pullups between the 4.4v power line and the 2 data lines. I was the able to correctly detect the sensors on the IMU pcb.    
 + 
 + 
 +====== Hacking I2C in PC DIMM modules ====== 
 +As mentioned in the Preface it is possible to hack, in fact, any one of the I2C busses on your PC it's just that the one in DIMM modules it the easiest one. 
 +You will need to identify these 4 connections on your DIMM module's eprom that respectively go to these pins on the DIMM module itself: 
 + 
 +200 pin SO-DIMM 1/2: 
 +^ Pin ^ Function  ^  
 +| 197 | Vcc (3v)  | 
 +| 193 | SDA       | 
 +| 195 | SCL       | 
 +| 185 | GND       | 
 + 
 +204 pin SO-DIMM 3:  
 +^ Pin   ^ Function  ^  
 +| 199     | Vcc (3v)| 
 +| 200     | SDA     | 
 +| 202     | SCL     | 
 +| 203/204 | GND     | 
 + 
 +260 pin SO-DIMM 4: 
 +^ Pin     ^ Function  ^  
 +| 255     | Vcc (2.5v)| 
 +| 254     | SDA       | 
 +| 253     | SCL       | 
 +| 251/252 | GND       | 
 + 
 +Once you have identified them you can stack up another I2C device on the bus provided it will not conflict with the addresses in use on this bus. 
 + 
 +I have an old laptop with a 4Gb SO-DIMM 3 that is perfect for experimenting. 
 +The DIMM has onboard a ST M34: a I2C bus Serial EEPROM, SPD for DRAM. I downloaded the datasheet and found that on the eprom itself 
 +^ Pin ^ Function ^  
 +| 8   | Vcc (3v) | 
 +| 5   | SDA      | 
 +| 6   | SCL      | 
 +| 4   | GND      | 
 + 
 +and I double-checked that these pins are actually connected to the respective pins on the SO-DIMM module. 
 +I was particularly lucky and this module has unused solder pads for a second eprom unit, making it super easy to solder some wires on the unused pats to hack another I2C device into the bus. 
 + 
 +Next you will need to identify which bus is the one reading the eprom on the DIMM modules, there is another tool that is part of the i2ctool that comes in handy for this: decode-dimms. 
 +At the beginning it will sit out a line like this 
 + 
 +Decoding EEPROM: /sys/bus/i2c/drivers/ee1004/0-0050 
 + 
 +The last part 0-0050 identifies bus 0 address 50.  
 + 
 +Looking at what devices are present on bus 0 
 + 
 +  # i2cdetect -y 0 
 +        1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 
 +  00:                         08 -- -- -- -- -- -- --  
 +  10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  30: 30 -- -- -- -- 35 UU UU -- -- -- -- -- -- -- --  
 +  40: -- -- -- -- 44 -- -- -- -- -- -- -- -- -- -- --  
 +  50: UU -- 52 -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  
 +  70: -- -- -- -- -- -- -- -- 
 + 
 +So as long as whatever device I hack into this bus does not use address 8,30,35,36,37,44,50 or 52 it should work fine, provided the voltages are compatible. 
 + 
  
 ====== Sources ====== ====== Sources ======
 howtos:hardware:arm:interfacing_i2c_devices ()