User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Thu Apr 24, 2014 3:48 pm

The data stream for piscope, the Python code, and the C code is from exactly the same source. I suppose Python might start to lose data if it's flooded with information faster than it can process.

Are the I2C messages sent repeatedly? If so at what rate?

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Thu Apr 24, 2014 4:16 pm

The same source yes but, the c code is more steady ?

No, actually not repeated, click button to send message but i can every 1s or 2s or 500ms repeat the measurement.

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Thu Apr 24, 2014 4:50 pm

box24 wrote:The same source yes but, the c code is more steady ?

No, actually not repeated, click button to send message but i can every 1s or 2s or 500ms repeat the measurement.
At that data rate we can ignore the possibility that Python isn't keeping up with the data.

There may be an error in the Python, it's just something I wrote out of interest. Of course there might be the same error in the C code. That said it's certainly worth trying.

Code: Select all

joan@soft /ram $ gcc -o pig2i2c pig2i2c.c
joan@soft /ram $ sudo pigpiod -s 2
joan@soft /ram $ pigs no
0
joan@soft /ram $ ls -l /dev/pig*
prw-rw-r-- 1 root root 0 Apr 24 16:43 /dev/pigerr
prw-rw-r-- 1 root root 0 Apr 24 16:43 /dev/pigout
prw-rw--w- 1 root root 0 Apr 24 16:43 /dev/pigpio
prw-rw-r-- 1 root root 0 Apr 24 16:43 /dev/pigpio0
joan@soft /ram $ ./pig2i2c 1 0 </dev/pigpio0 &
[1] 2306
joan@soft /ram $ pigs nb 0 -1
joan@soft /ram $ # in another window do i2cdetect -y 0 or 1
[06-]
[08-]
[0A-]
[0C-]
[0E-]
[10-]
[12-]
[14-]
[16-]
[18-]
[1A-]
[1C-]
[1E-]
[20+]
[22+]
[24-]
[26-]
[28-]
[2A-]
[2C-]
[2E-]
[30-]
[32-]
[34-]
[36-]
[38-]
[3A-]
[3C-]
[3E-]
[40-]
[42-]
[44-]
[46-]
[48-]
[4A-]
[4C-]
[4E-]
[50-]
[52-]
[54-]
[56-]
[58-]
[5A-]
[5C-]
[5E-]
[61-]
[63-]
[65-]
[67-]
[69-]
[6B-]
[6D-]
[6F-]
[70-]
[72-]
[74-]
[76-]
[78-]
[7A-]
[7C-]
[7E-]
[80-]
[82-]
[84-]
[86-]
[88-]
[8A-]
[8C-]
[8E-]
[90-]
[92-]
[94-]
[96-]
[98-]
[9A-]
[9C-]
[9E-]
[A1-]
[A3-]
[A5-]
[A7-]
[A9-]
[AB-]
[AD-]
[AF-]
[B1-]
[B3-]
[B5-]
[B7-]
[B9-]
[BB-]
[BD-]
[BF-]
[C0+]
[C2-]
[C4-]
[C6-]
[C8-]
[CA-]
[CC-]
[CE-]
[D0-]
[D2-]
[D4-]
[D6-]
[D8-]
[DA-]
[DC-]
[DE-]
[E0-]
[E2-]
[E4-]
[E6-]
[E8-]
[EA-]
[EC-]
[EE-]
pigs nc 0
[1]+  Done                    ./pig2i2c 1 0 < /dev/pigpio0
joan@soft /ram $ 
I used i2cdetect -y 0 to generate some traffic on my Rev.1 Pi.

NOTE: I use ./pig2i2c 1 0. You need to replace 1 0 with the gpios you are using for SCL and SDA.

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Thu Apr 24, 2014 7:48 pm

Mistake in your code ? it's ok with i2c so....

pig2i2c it's to watch/save some traffics ?

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Fri Apr 25, 2014 7:22 am

pig2i2c should produce exactly the same output as the Python version. It was coded slightly differently so it is certainly worth trying.

I am concerned that you are still using the Pi's I2C gpios to monitor an external I2C bus The 1K8 pull-ups to 3V3 on the gpios WILL alter the operation of the external I2C bus.

You really should NOT monitor external I2C buses using P1-3, P1-5, P5-3, or P5-4.

kekmokus
Posts: 6
Joined: Fri Apr 25, 2014 8:04 am

Re: Using RPI to listen SMBus(I2C)

Fri Apr 25, 2014 8:23 am

Hi Gents,

let me have a question about using i2c BUS. My problem is, that the result of the i2cdetect command is always the same as you can see on the attachment (nothing is connected to the bus).
- Bus1 shows nothing but "UU" on the address "3B" all the time with and without connecting anything to the bus.
- Bus0 showing all the addresses all the time with and without connecting anything to the bus. Strange to me...
Currently I'm using Raspberry pi model B with 256MB ram, so normally the bus0 should work. All my settings are looks correct according to the tutorials (blacklist, modprobe.d ect.)
Actually the system is running on an USB pendrive, and some SWs are installed as well..but nothing should have affect on i2c.
Am I killed the hardware? Or is this something with configurations?

Thank you for your help in advance!

Egon
i2cissue.PNG
results on both i2c bus
i2cissue.PNG (11.39 KiB) Viewed 4782 times

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Fri Apr 25, 2014 10:04 am

@Egon

I just tried with a 256MB model B.

Code: Select all

i2cdetect -y 0
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- -- 
10: 10 11 -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --
Have you double checked there is nothing connected to P1-3 and P1-5?

kekmokus
Posts: 6
Joined: Fri Apr 25, 2014 8:04 am

Re: Using RPI to listen SMBus(I2C)

Fri Apr 25, 2014 10:14 am

Hi Joan!

Thanks for the reply... Absolutely nothing is connected, the pi is on the desk without any wires around.
Just wondering..even if anything connected, the full address list is still strange isn't?

Thanks again

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Fri Apr 25, 2014 10:21 am

I get the same results as you for the other bus (-- apart from UU for address 0x3B).

I vaguely remember seeing something similar before, but can't remember why or when.

If you don't get any help in this thread it might be worth starting a new post with your problem. A new post will bet a wider audience.

kekmokus
Posts: 6
Joined: Fri Apr 25, 2014 8:04 am

Re: Using RPI to listen SMBus(I2C)

Fri Apr 25, 2014 10:35 am

Will try in a new topic, good idea!

thanks again

best regards
Egon

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Fri Apr 25, 2014 11:48 am

joan wrote:pig2i2c should produce exactly the same output as the Python version. It was coded slightly differently so it is certainly worth trying.

I am concerned that you are still using the Pi's I2C gpios to monitor an external I2C bus The 1K8 pull-ups to 3V3 on the gpios WILL alter the operation of the external I2C bus.

You really should NOT monitor external I2C buses using P1-3, P1-5, P5-3, or P5-4.
i will try with gpio 23&24 to monitor SMBus (without pull-ups), and i will come back with results and screen ;)

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Mon Apr 28, 2014 7:53 am

Joan, pig2i2c is the same to pig2cvd ?

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Mon Apr 28, 2014 8:02 am

No.

pig2vcd takes notifications and converts then to Value Change Dump (VCD) format which is a standard for this sort of data. VCD files can be read by programs such as GtkWave.

pig2i2c takes notifications and analyses activity on the two specified gpios which are assumed to be the I2C SCL and SDA signals. This activity is converted to a textual representation of the Start/Stop conditions, data bytes, and ACK/NACK bits.

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Mon Apr 28, 2014 8:14 am

Where can i find pig2i2c.c file :? ?


box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Mon Apr 28, 2014 3:20 pm

Works fine with other GPIO :)

A question with target adress, normally is 0x16 for bq20z655. But i see 2 adress but not 0x16. I see 0x48 and 0x0b.

I want to read data flash on the device. What is the mistake with RPI ?

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Mon Apr 28, 2014 3:38 pm

box24 wrote:Works fine with other GPIO :)

A question with target adress, normally is 0x16 for bq20z655. But i see 2 adress but not 0x16. I see 0x48 and 0x0b.

I want to read data flash on the device. What is the mistake with RPI ?
I have no idea.

Did you say this was part of an evaluation board? If so perhaps there are other components talking on the SMBus.

Have you got any sample output?

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Mon Apr 28, 2014 3:51 pm

joan wrote:
box24 wrote:Works fine with other GPIO :)

A question with target adress, normally is 0x16 for bq20z655. But i see 2 adress but not 0x16. I see 0x48 and 0x0b.

I want to read data flash on the device. What is the mistake with RPI ?
I have no idea.

Did you say this was part of an evaluation board? If so perhaps there are other components talking on the SMBus.

Have you got any sample output?
You want piscope sample or just console screen ?

Yes, it's an evaluation board, but i'm plug in direct with SMBus, i think there are other components talking on the bus but why i can't see the 0x16 which normally the address device for the bq20z655.

I can show the data with the sniffer in python so i'm lost :o
Maybe the address in the datasheet is not true ?

I write a c code to just read the voltage register ( 0x09) and show the value in console, but never works because i can't find the good address.

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Mon Apr 28, 2014 4:03 pm

Can't you access the device with the evaluation board software?

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Mon Apr 28, 2014 4:08 pm

joan wrote:Can't you access the device with the evaluation board software?
No, i can and the target address is 0x16 but with RPI i can't because only two address are using 0x48 and 0x0b but not 0x16 :(

With Evaluation software it's ok.
Attachments
coms.PNG
com
coms.PNG (59.05 KiB) Viewed 4480 times

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Tue Apr 29, 2014 9:52 am

Strange because, the address is 0x0b, i can read/write register with this address.

But i want to extract the memory flash and in datasheet, i read 0x16 so i don't know

User avatar
joan
Posts: 14935
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Using RPI to listen SMBus(I2C)

Tue Apr 29, 2014 10:14 am

I've lost track of how you are set-up at the moment.

Are you currently using the Pi to passively monitor an external I2C bus?

Could you list the connections you have between the Pi and the equipment you are monitoring?

box24
Posts: 41
Joined: Fri Apr 18, 2014 3:57 pm

Re: Using RPI to listen SMBus(I2C)

Tue Apr 29, 2014 11:54 am

joan wrote:I've lost track of how you are set-up at the moment.

Are you currently using the Pi to passively monitor an external I2C bus?

Could you list the connections you have between the Pi and the equipment you are monitoring?
For monitoring external I2C Bus with RPI, it's ok. Thanks you for your help.

Now i want to read and write the data flash memory of my component (BQ20Z655) which link is SMBus. Texas instrument wrote a pdf (http://www.ti.com/lit/an/slua379e/slua379e.pdf) to explain how you can do that.

I convert VB code into C (see attachment) code and i want using RPI to do that.

Now with the RPI, i can read a register in the bq20z655 using SMBus command but i can't write. For exemple i need to put the device into rom mode using a specific command. But doesn't work and i don't understand why.

Image

kris85pl
Posts: 1
Joined: Mon Aug 28, 2017 6:02 am

Re: Using RPI to listen SMBus(I2C)

Mon Aug 28, 2017 10:51 am

Hi. My name is Kris. I'm new here. I would like also build smbus/i2c sniffer, main to listen laptop batteries. What install, how to connect ? I'm using ev2300 interface and lpt interface to read and write battery data. Do I need to connect to sda, scl and gnd lines from RPi to ev2300 or lpt interface in parallel ? I have RPi 1, model B, what else hardware is needed ? Could somebody guide me in few steps, what to do ?
Best regards, Kris

reachparagm
Posts: 10
Joined: Fri Dec 19, 2014 11:24 am

Re: Using RPI to listen SMBus(I2C)

Wed Sep 05, 2018 5:22 am

Joan,

Is it possible to ACK/NACK WR transaction of remote end using RPI BSC slave? Does this fall in listen mode as most of the discussion here are related to RD transaction.

After injecting WR from remote-side using pigs, I captured trace with both total-phase i2c sniffer and/or native I2C sniffer; but none bytes is observed as WR transactions.

If I perform RD, I get the same bytes I injected. is my setup missing any configuration ?

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