Code for on-board power monitor, INA3221?

Hi folks,

I was looking at the OEM design guide, and saw that the module incorporates an INA3221 chip for bus and shunt monitoring. I’d like to get power usage numbers for the module and SoC.

Has someone already written code that reads from this chip, for this board? I’m really not sure if there is some daemon or logger or nvsomething tool already existing to do exactly this.

Beyond that, it looks like the power monitor chip should be on I2C2, which I assume maps to /dev/i2c-1.
Looking at pg 29 in the INA3221 datasheet (http://www.ti.com/lit/ds/symlink/ina3221.pdf), it looks like the device should be at address 0x40-0x43.

‘i2cdetect 1’ report nothing in the 0x40 range, but ‘i2cdetect -r 1’ reports hits at 0x40, 0x42, and 0x43.

This is a bit out of my depth, so if this has already been coded up, that would be very helpful

P2180 module board have 1 INA3221 with 7bit i2c address 0x40.
P2597 Carrier board have 2 INA3221 with 7bit i2c address 0x42 and 0x43.
All these 3 INA3221 were attached on GEN2_I2C(I2C_GP1), The controller is I2C1

7bit0x40 INA3221: CH1 VDD_IN, CH2 VDD_GPU, CH3 VDD_CPU
7bit0x42 INA3221: CH1 VDD_MUX, CH2 VDD_5V, CH3 VDD_3V3
7bit0x43 INA3221: CH1 VDD_3V3_IO, CH2 VDD_1V8, CH3 VDD_3V3_M.2

Thanks for the details.

Unfortunately, it looks like the INA3221 module in the kernel source tree is not enabled in the kernel image bundled with JetPack/L4T. Rats. And it seems like the kernel can’t be built on the module itself.
I think I’ll have to do this by manually getting data from the INA3221 regs with a python script.

Apullin,

Did you figure out how to get power numbers for the SoC? I’m facing the same problem here.

I can read the INA3221 registers using i2cdump:

$ i2cdump -y 1 0x40 w
0,8 1,9 2,a 3,b 4,c 5,d 6,e 7,f
00: 2771 1803 b04a 0800 b04a 7000 a84a f87f
08: f87f f87f f87f f87f f87f 0000 …

However, going from this values to meaningful (decimal) values doesn’t seem straightforward. I understand that the first register is for configuration (value 0x2771 in the example above). But it’s not clear to me what are the values corresponding to CPU and GPU Vdd and if I can safely convert them from binary to decimal. It’s not clear either where to read the current values from in order to compute power consumption. Have you went through these issues in your case?

Thanks in advance!

I did not revisit this after getting stuck on the kernel module. There is probably a new kernel out now with support for it, especially if you are getting i2c data back.

There should be 3 pairs of values for each INA3221 chip, each corresponding to a shunt voltage and a bus voltage. Shunt voltage can be converted to current, and power will be V*I.
I don’t understand quite what transaction i2cdump is doing or what it is telling us in the output.

A good check would be to check register FEh (or 0xFE) for the Manufacter ID, which should be 5449h (or 0x5449).

Converting to useful values is likely going to just be multiplication. Looking at the datasheet, the bus voltages (0xb04a, 0xb04a, and 0x a84a) should be 8mV per LSB , but those values don’t make sense. So, shrug, I don’ tknow.

It would be great if NVidia could just get one of their embedded devs to just sort this out. @dusty_nv (not sure if mentions work like that on this forums)

Thanks, Apullin.

I think I finally managed to read the CPU and GPU voltage measurements and compute their corresponding power. The hex values in my previous post should be swapped (they are in little-endian byte order and should be in big-endian in order to match the description in the INA3221 datasheet). Then they have to be shifted three positions to the right (again, based on the INA3221 datasheet), and that’s it: these are the actual voltage measurements provided by INA3221. You’ll also need to know the values of the shunt resistors, which are specified in the “Product OEM Design Guide” in order to compute the current: http://developer.nvidia.com/embedded/dlc/jetson-tx1-oem-product-design-guide

The voltage measurements on the shunt resistors allow you to compute current. Then, if you multiply this current value by the voltage measured on the bus, you’ll have power consumption.

I hope this helps.

I forgot to mention that, after shifting, the shunt and bus values have to be scaled by 40 uV and 8 mV, respectively (based on the INA3221 datasheet). 40 uV is the LSB for the shunt-voltage register and 8 mV is the LSB for the bus-voltage register.

Newer revisions of the TX1 module enable the use of INA power monitors, see [url]Jetson TX1 - INA226 (Power Monitor with i2C Interface) - Jetson TX1 - NVIDIA Developer Forums