User avatar
rikas
Posts: 17
Joined: Sun Jul 31, 2011 1:28 pm
Location: Austria y Argentina

i2c-0 shows strange behaviour

Wed Jul 17, 2013 5:56 am

Hi,

(hope this is the right place )

I have 3 RPi's, two with external USB-Disk (for development), one booting from SD (aufs, modified kernel) for testing - which shows the strange results.

What I did:
  • changed cmdline.txt to get all boot messages to serial (and logging!)

    Code: Select all

    dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline rootwait  rwfs=tmpfs  
    (removed console=tty1)
  • "home brew" Kernel

    Code: Select all

    Linux raspberrypi 3.8.132013-07-10, rfk+ #4 PREEMPT Tue Jul 16 21:36:01 CEST 2013 armv6l GNU/Linux 
    with aufs and removed lots of kernel drivers (which I do not use)
  • Gertboard connected (but behaviour is same after removing it)
What I get:

Code: Select all

root@raspberrypi:~# i2cdetect -F 0
Functionalities implemented by /dev/i2c-0:
I2C                              yes
SMBus Quick Command              yes
SMBus Send Byte                  yes
SMBus Receive Byte               yes
SMBus Write Byte                 yes
SMBus Read Byte                  yes
SMBus Write Word                 yes
SMBus Read Word                  yes
SMBus Process Call               yes
SMBus Block Write                yes
SMBus Block Read                 no
SMBus Block Process Call         no
SMBus PEC                        yes
I2C Block Write                  yes
I2C Block Read                   yes

Code: Select all

root@raspberrypi:~# i2cdetect -l 0
i2c-0	i2c       	bcm2708_i2c.0                   	I2C adapter
i2c-1	i2c       	bcm2708_i2c.1                   	I2C adapter

Code: Select all

root@raspberrypi:~# i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 
30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f 
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 
70: 70 71 72 73 74 75 76 77                         
For comparison:

Code: Select all

root@raspberrypi:~# i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
Any hints?


-- rikas
-- rikas

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

Re: i2c-0 shows strange behaviour

Wed Jul 17, 2013 9:08 pm

Just to clarify matters what versions are your RPi boards? The "available" I2C bus changed between Model B1 (256Mb) and B2 (512Mb). Model A (256Mb) uses the same I2C bus as B2.
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
rikas
Posts: 17
Joined: Sun Jul 31, 2011 1:28 pm
Location: Austria y Argentina

Re: i2c-0 shows strange behaviour

Thu Jul 18, 2013 6:37 am

ooops sorry, forgot to mention:
Model B, Rev2
512 MB
-- rikas

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

Re: i2c-0 shows strange behaviour

Thu Jul 18, 2013 2:24 pm

rikas wrote:ooops sorry, forgot to mention:
Model B, Rev2
512 MB
O.K. that means that "i2c-1" physically appears on the main GPIO connector (P1) {for "B1" boards it was "i2c-0"}. However "i2c-0" SDA and SCL now appear on the new P5 connector (see http://elinux.org/Rpi_Low-level_peripherals#P5_header). Do you have anything connected there? NB: the output from "i2cdetect -F 0" and "i2cdetect -F 1" is a bit of a "red herring" - I get the same result for "both channels" without any i2c devices connected.
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
rikas
Posts: 17
Joined: Sun Jul 31, 2011 1:28 pm
Location: Austria y Argentina

Re: i2c-0 shows strange behaviour

Thu Jul 18, 2013 5:19 pm

Trev,


problems comes from brewing my own kernel:

tried as in my original post on another RPi (B /R2) - nothing connected but my custom kernel.

Get the same wierd output for i2c-0: address = data whereas i2c-1 gives the "normal" output (with the dashes only)

i2c-1 works fine, never connected anything to i2c-0.
Should I be worried?

-- rikas
-- rikas

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

Re: i2c-0 shows strange behaviour

Thu Jul 18, 2013 6:07 pm

rikas wrote: ...
problems comes from brewing my own kernel:
...
I suspected that might be the issue, but needed to cross-check with on of my Pi's first.
i2c-1 works fine, never connected anything to i2c-0.
Should I be worried?
I guess if nothing's ever connected to i2c-0 you may "get away with it" :-)

Have you tried to use any i2c devices yet? FWIW I started with this: http://www.cpmspectrepi.webspace.virgin ... OfPio.html and then move on to try other (GPIO) prototyping boards etc. As (these days) I'm mainly a 'C' programmer I make use of the "wiringPi" library too.
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

User avatar
rikas
Posts: 17
Joined: Sun Jul 31, 2011 1:28 pm
Location: Austria y Argentina

Re: i2c-0 shows strange behaviour

Thu Jul 18, 2013 9:08 pm

I use an ATMega328 (currently for ease of development an arduino) to drive some sensors, a display and a thermal printer. Connected via i2c - it works, used it in other projects. And yes, it works on my "virgin" RPi's (with the standard kernel)

The self brewn kernel seems necesary to overcome the wearout problems if SD / CF cards. So I use aufs to reduce writes to the card.
I also do C but mainly working with Perl - specially, since I am currently implementing a small monitoring solution with nagios on the RPi.

BTW: just had a look at your homepage - do you really still work with CP/M and Z80 ???? OMG how long is that back, what a time, when we used the IO-Bit at 0x05 to switch to the second 64k bank :lol: before that came the 6500 and my first AIM-65 (Rockwell) with 8kB RAM and it had even a PL/65 Compiler ...


-- rikas
-- rikas

User avatar
Gert van Loo
Posts: 2487
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: i2c-0 shows strange behaviour

Fri Jul 19, 2013 7:22 am

Just an idea:
The detection probably checks if it receives an ACK after sending the address.
Now if there is no pull-up the SDA is always low an you will always seem to get an get ACK.
Mr Oscilloscope is your friend!

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

Re: i2c-0 shows strange behaviour

Fri Jul 19, 2013 7:37 am

rikas wrote: ...
BTW: just had a look at your homepage - do you really still work with CP/M and Z80 ???? OMG how long is that back, what a time, when we used the IO-Bit at 0x05 to switch to the second 64k bank :lol: before that came the 6500 and my first AIM-65 (Rockwell) with 8kB RAM and it had even a PL/65 Compiler ...
Strictly speaking no (esp. since I'm retired). But I do have a small collection of z80 based computers (and spare chips), most of which still work (but I might have to find an "elastic band" or two for the 3" disc drives :-) ) - better than the 4 or 5 of the P.C.'s I've had since. One of my "Pi projects" is to get it working with ~30 year old "Super Number Cruncher" I.C. (I think I've got two of them) thus "re-visiting" the "design" of the first computer (kit) I built (from a design published in "Wireless World" c.1979).
Trev.
Still running Raspbian Jessie or Stretch on some older Pi's (an A, B1, 2xB2, B+, P2B, 3xP0, P0W, 2xP3A+, P3B+, P3B, B+, and a A+) but Buster on the P4B's. See: https://www.cpmspectrepi.uk/raspberry_pi/raspiidx.htm

adenin
Posts: 16
Joined: Fri Jul 06, 2012 7:01 am

Re: i2c-0 shows strange behaviour

Mon Jan 06, 2014 9:35 pm

I had the same problem and have just solved it:

you need to install wiringpi

then run

Code: Select all

gpio readall
and if you get ( mode for sda is 'out' instead of 'alt0' ):

Code: Select all

pi@raspberrypi ~ $ gpio readall
+----------+-Rev1-+------+--------+------+-------+
| wiringPi | GPIO | Phys | Name   | Mode | Value |
+----------+------+------+--------+------+-------+
|      0   |  17  |  11  | GPIO 0 | IN   | Low   |
|      1   |  18  |  12  | GPIO 1 | IN   | Low   |
|      2   |  21  |  13  | GPIO 2 | IN   | Low   |
|      3   |  22  |  15  | GPIO 3 | OUT  | Low   |
|      4   |  23  |  16  | GPIO 4 | IN   | High  |
|      5   |  24  |  18  | GPIO 5 | IN   | Low   |
|      6   |  25  |  22  | GPIO 6 | IN   | Low   |
|      7   |   4  |   7  | GPIO 7 | IN   | High  |
|      8   |   0  |   3  | SDA    | OUT  | High  |
|      9   |   1  |   5  | SCL    | ALT0 | High  |
|     10   |   8  |  24  | CE0    | IN   | Low   |
|     11   |   7  |  26  | CE1    | IN   | Low   |
|     12   |  10  |  19  | MOSI   | IN   | Low   |
|     13   |   9  |  21  | MISO   | IN   | Low   |
|     14   |  11  |  23  | SCLK   | IN   | Low   |
|     15   |  14  |   8  | TxD    | ALT0 | High  |
|     16   |  15  |  10  | RxD    | ALT0 | High  |
+----------+------+------+--------+------+-------+


then you simply need to

Code: Select all

gpio -g mode 0 alt0
and everything works: (here are connected: 24c256 and lcd 20x04 with i2c converter )

Code: Select all

pi@raspberrypi ~ $ sudo i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: 20 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

User avatar
valver
Posts: 137
Joined: Fri Mar 22, 2013 10:01 pm

Re: i2c-0 shows strange behaviour

Tue Aug 05, 2014 11:47 am

I have the same problem.
Rpi Mod B, Revi 2.


Cant solve wicht wiringpi

Code: Select all

pi@raspberrypi ~ $ sudo i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: 30 31 32 33 34 35 36 37 38 39 3a UU 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b UU 4d 4e 4f
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77

Code: Select all

 +-----+-----+---------+------+---+-Model B2-+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 | ALT0 | 0 |  3 || 4  |   |      | 5V      |     |     |
 |   3 |   9 |   SCL.1 | ALT0 | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 0 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI | ALT0 | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO | ALT0 | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK | ALT0 | 0 | 23 || 24 | 1 | ALT0 | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 1 | ALT0 | CE1     | 11  | 7   |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |  28 |  17 | GPIO.17 |   IN | 0 | 51 || 52 | 0 | IN   | GPIO.18 | 18  | 29  |
 |  30 |  19 | GPIO.19 |   IN | 0 | 53 || 54 | 0 | IN   | GPIO.20 | 20  | 31  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+-Model B2-+---+------+---------+-----+-----+
MPU6050 ------------------ Raspi
VCC ------------------------ 3V3 Pin 1
GND ------------------------ GND Pin 6
SCL ------------------------ SCL Pin 5
SDA ------------------------ SDA Pin 3

It is correct?

Thanks in advance

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