cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
aaron_b1
Explorer
Explorer
817 Views
Registered: ‎12-20-2017

Monitoring voltages on petaliunx with i2ctools or other software?

I'd like to be able to monitor voltages and currents in the INA226 on the zcu102 with my petalinux software written in C/C++.

As a first step, I'd like to be able to demonstrate functionality by using i2ctools, which I believe might be able to read these i2c values.

Unfortunately, I'm a little stumped at what voltages and currents are available, and how to get to them using the i2ctools suite.

Figure 3-17 and UG1182 displays a topology of i2c devices and  port expanders, and I understand that there are three things on the bus with addresses 0x20, 0x21, and 0x75 (U61, U97, and U60).

The first row of Table 3-22 tells me there is something called U76 (INA226 VCCPSINTFP at address 0x40) connected to U60 (address 0x75).  

UG1182 discusses i2c bus 0 and bus 1.  However, 

# i2cdetect -l | sort
i2c-0 i2c Xilinx DP AUX I2C adapter
i2c-1 i2c Cadence I2C at ff020000 I2C adapter
i2c-10 i2c i2c-6-mux (chan_id 3) I2C adapter
i2c-11 i2c i2c-6-mux (chan_id 4) I2C adapter
i2c-12 i2c i2c-6-mux (chan_id 5) I2C adapter
i2c-13 i2c i2c-6-mux (chan_id 6) I2C adapter
i2c-14 i2c i2c-6-mux (chan_id 7) I2C adapter
i2c-15 i2c i2c-6-mux (chan_id 0) I2C adapter
i2c-16 i2c i2c-6-mux (chan_id 1) I2C adapter
i2c-17 i2c i2c-6-mux (chan_id 2) I2C adapter
i2c-18 i2c i2c-6-mux (chan_id 3) I2C adapter
i2c-19 i2c i2c-6-mux (chan_id 4) I2C adapter
i2c-2 i2c i2c-1-mux (chan_id 0) I2C adapter
i2c-20 i2c i2c-6-mux (chan_id 5) I2C adapter
i2c-21 i2c i2c-6-mux (chan_id 6) I2C adapter
i2c-22 i2c i2c-6-mux (chan_id 7) I2C adapter
i2c-3 i2c i2c-1-mux (chan_id 1) I2C adapter
i2c-4 i2c i2c-1-mux (chan_id 2) I2C adapter
i2c-5 i2c i2c-1-mux (chan_id 3) I2C adapter
i2c-6 i2c Cadence I2C at ff030000 I2C adapter
i2c-7 i2c i2c-6-mux (chan_id 0) I2C adapter
i2c-8 i2c i2c-6-mux (chan_id 1) I2C adapter
i2c-9 i2c i2c-6-mux (chan_id 2) I2C adapter

First of all, bus 0 shows me there is nothing attached, so I assume i2c bus 0 in the document is not the same as i2c0 on the linux system.

# i2cdetect -y -r 0
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- [16578.049765] drm_dp_i2c_do_msg: 69 callbacks suppressed
-- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- [16583.096234] drm_dp_i2c_do_msg: 69 callbacks suppressed
-- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

However, i2cdetect shows me that i2c bus 1 has something at address 0x75 - this might be U60, correct?)

# i2cdetect -y -r 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: UU UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: UU UU UU UU UU UU UU UU -- -- UU UU -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- UU UU -- UU -- --

So why can't I poke at it with i2cget or i2cdump?  Am I using the i2c tools wrong, or is something else wrong?

# i2cdump -y 1 0x75 b
Error: Could not set address to 0x75: Device or resource busy

# i2cget -y 1 0x75 0x40
Error: Could not set address to 0x75: Device or resource busy

I am pretty clueless, so any and all help is very, very welcome.

 

0 Kudos
4 Replies
gudishak
Moderator
Moderator
788 Views
Registered: ‎06-27-2017

Hi @aaron_b1,

 

Syntax which you are using is correct.

You can try reading the same from u-boot using i2c md command.

If you are able to read the values from u-boot, then i2c tools are using different addressing mechanism(like 8-bit slave address) and may be slave supports 16-bit address.If that is the case then you can modify the i2c tools to support 16-bit address. 

 

Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.

Best Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.
0 Kudos
gudishak
Moderator
Moderator
784 Views
Registered: ‎06-27-2017

You can try below u-boot command.
i2c bus
i2c dev 1
i2c md 0x75 0.1 <bytes to read>
Best Regards
Kranthi
--------------------------
Don't forget to reply, kudo, and accept as solution.
0 Kudos
rfs613
Scholar
Scholar
769 Views
Registered: ‎05-28-2013

Have you tried power cycling the board? The i2cdetect program can leave the bus (or devices on the bus) in odd state.

 

After a cold boot (to ensure I2C chips are also reset), try your command again:

i2cget -y 1 0x75 0x40

 

Does it still give you an error about failing to set the address?

0 Kudos
aaron_b1
Explorer
Explorer
711 Views
Registered: ‎12-20-2017

Thank you.  Yes, @rfs613 I still get the same error on a cold boot.  However, with the uboot commands @gudishak suggested, I read all zeros from the address I had intended to read.  this makes me think I am pointing at the wrong address, perhaps.

I'll have to sit down with the system design specs again, I guess, and see if I can figure out where I should be poking and peeking into the i2c.  

Since my addresses must have been wrong, what are the correct ones?  This seems like it would have been a common task, and it might have been accomplished before.  Hasn't anyone read voltages from this chip before?

 

0 Kudos