UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Adventurer
Adventurer
9,905 Views
Registered: ‎01-24-2014

The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Hi,

 

Recently the Xilinx release a Linux application for power monitoring on ZC702 which is quite promising. I am trying to make it works for ZC706 at the moment. However the values read from the applicaiton are either too large and not fluctuating between each monitoring cycles.

New Bitmap Image.jpg

Does any one also try the Linux application of power monitoring for ZC706? Any thing I missed for modifying the application template for ZC702?

 

Many thanks.

0 Kudos
1 Solution

Accepted Solutions
Xilinx Employee
Xilinx Employee
11,112 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution
0 Kudos
26 Replies
Xilinx Employee
Xilinx Employee
9,904 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

zc702 and zc706 have a rather different setup of power supplies. And judging by the screenshot you posted, you missed quite a lot when porting the application. As far as I know, most - if not all - of the rails you show are not observable on zc706. Also, the power controllers on zc706 are not the same used on zc702. If you didn't make appropriate changes you are likely to read all kinds of garbage from the I2C bus. You may be better off just using the Linux drivers http://www.wiki.xilinx.com/Zynq+Power+Management#Hardware Monitoring

0 Kudos
Adventurer
Adventurer
9,900 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Thanks for the reply!

 

Yes, I can do the monitoring from driver. 

 

So far as I study, the monitoring application using the standard i2c-smbus protocol functions. I did try to change the application according to the user guide.

New Bitmap Image1.jpgNew Bitmap Image2.jpg

I know it is different from ZC702. I have changed the device address in the linux application as well as its power rail. After debuging the valid accessible address is not 65. I have used that address and got the value you see. 

 

Yes, the result looks no good. Can you give some suggestions about proper changes besides the device address and page address? 

 

Many thanks.

0 Kudos
Xilinx Employee
Xilinx Employee
9,897 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Sorry, you're right. The rails look okay. But the numbers are off. I don't know how different the power controllers are. Did you change the code around those? It looks very suspicous that you have the same numbers across all rails.

DId you check that you receive any reasonable raw numbers from the I2C bus?

0 Kudos
Adventurer
Adventurer
9,889 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Thanks for the reply!

 

Yes, the numbers are not correct. That's what I conerned. 

 

According to the zynq power management page, the UCD9000 driver is at /sys/devices/amba.0/e0004000.ps7-i2c/i2c-0/i2c-8/8-0065. I took /dev/i2c-8 instead of /dev/i2c-9 in the original code.

 

I have check the specification of the two TI chips. They are all PMBus standard protocol based controller and the only difference is UCD9000 has some specific parameter to configure but I don't think it is the user's work. It should be done by Xilinx. 

 

Based on the user guide, the only difference is the i2c address. The UCD9248 on ZC702 is at 52,53 while UCD9000 on ZC706 is at 65 according to the user guide. I am not sure if it is the only change I should do since 65 is not a valid address to access for /dev/i2c-8.

 

Any idea about this?

 

Many thanks.

 

0 Kudos
Adventurer
Adventurer
9,882 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

OK. I have tested all the /dev/i2c-0~8 device from 0 to 255 device address. There are no reasonable values using the code.

 

It seems using the linux application code from Xilinx cannot properly monitor the power on ZC706 by only change the i2c device number and the i2c device address. It might still need more advance techniques to design a linux application code for ZC706 which I am not capable of it at the moment. 

 

If you have any clues about this, please help.

 

Many thanks.

0 Kudos
Xilinx Employee
Xilinx Employee
9,879 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Well, I didn't look at the data sheets. But may it be that the register intreface, quantization etc is different? DId you adjust for that?

You could check the source of the Linux driver and find out how that one does obtain values from the HW.

Or - and this is my personal preference - rewrite the Linux app to not directly talk to the HW, but use the driver's sysfs interface to receive values.

0 Kudos
Adventurer
Adventurer
9,863 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Thanks for you reply!

 

I have rewritten the program to call monitoring from driver. Now the value seems good.

New Bitmap Image (3).jpg

 

This still leaves two questions:

1. How do I know which value it is corresponding to the user guide?

2. After several monitoring cycles, the value became constant. Does that mean I can't do the monitoring dynamicaly?

New Bitmap Image (4).jpg

 

 

Thanks.

0 Kudos
Xilinx Employee
Xilinx Employee
9,845 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

That doesn't look right to me. As a reference, I just booted Linux on my zc706 and I read the following numbers (through TI Fusion Power Designer):

Rail1: 1V/120mA

Rail2: 1.78V/20mA

Rail3: 1.5V/20mA

Rail4: 1.8V/450mA

Rail5: 3.3V/1A

 

I didn't thoroughly test any of these, but as far as I could see, the values via the external measurement and also in the sysfs entries always got updated.

0 Kudos
Adventurer
Adventurer
9,840 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Thanks for the reply and reference experiment!

 

Yes, I am also borthered by these values as well. However I am very sure that I used the right sysfs interface of PMBus driver at /sys/devices/amba.0/e0004000.ps7-i2c/i2c-0/i2c-8/8-0065. 

New Bitmap Image.jpg

So those are the exact values from Xilinx driver provided for PMBus. I am very curious about it since it is so different from the default values and your measurement from TI Fusion tool. 

 

Can you do me a favour to check the catched voltage and current value by the linux driver as well ? That might help me a lot.

 

Thank you very much!

 

0 Kudos
Xilinx Employee
Xilinx Employee
8,098 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Here it is (unformatted, but easy to reproduce this way):

<7-i2c/i2c-0/i2c-8/8-0065# cat in*_input curr*_input
1004
894
750
894
811
484
31
31
453
1000
<7-i2c/i2c-0/i2c-8/8-0065# cat in*_input curr*_input
999
891
747
891
807
437
31
31
453
984
<7-i2c/i2c-0/i2c-8/8-0065# cat in*_input curr*_input
1000
895
751
895
811
468
31
31
453
984

 

As you can see, the values show slight differences between readings. I don't see values to be fully static.

The current values match 1:1 the reading through the TI tool and are current in milli amps.

The voltage readings though, they don't seem to make too much sense. The first one seems to match the 1V I expect, but all the others are off. The docs say "in[1-12]_input Measured voltage. From READ_VOUT register.". Might those values need some adjustment to be in some reasonable unit?

0 Kudos
Adventurer
Adventurer
8,093 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Thanks for reply!

 

Sorry, I have not mentioned that I have solved the second problem. It is a GCC compiler bug for file handle in the SDK.

 

Your catched values confirms my guess: it is a scaling issue, althrough they are still odd to my result.

 

I already tried to find some related documents to see if there are any scaling rule to those registers. Unfortunately, I have not found any yet. 

New Bitmap Image.jpg

If I do the scaling like this, the value will look 'good'. But there is no principle to do that. I mean I have not found any document to support it yet. 

1st rail * 1 = 0.9970

2nd rail * 2 = 1.800

3th rail * 2 = 1.560

4th rail * 2 = 2.4720

5th rail * 4 = 3.284

 

So far as I know, the values from the driver should be scaled. But I am still digging it at the moment. If you have any suggestion, please do inform me. 

 

Thanks. 

0 Kudos
Xilinx Employee
Xilinx Employee
8,090 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

I did a little bit of digging.

The PMBus spec seems to describe things http://pmbus.org/docs/PMBus_Specification_Part_II_Rev_1-1_20070205.pdf , in particular section 8.3. In case the driver really only returns the value from READ_VOUT without taking VOUT_MODE into account, it could explain missing scaling. But I didn't have a chance to verify whether that is the case.

0 Kudos
Adventurer
Adventurer
8,086 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Thanks for the reply!

 

Yes, I also noticed this scaling. The Linux application from Xilinx does this scaling since its C code obtain the value from the hardware directly. For example, the voltage value in the Xilinx application code is divided by VOUT_SCALE_MONITOR 4096f (2^-12) which is one of the scaling rules of linear16 mode while the current value in the linux application code uses the linear11 scaling rule to transform the format. In the datasheet of UCD90120, the READ_VOUT and READ_IOUT are also linear16 and linear11. However, I think it is for the lower level which should be done by the driver.

 

After that, the processed values from driver should be the real value of voltage or current. Here, obviously, some other scaling factor need to be added to fit the ZC706 user guide. I treat it as a layer beyond the PMBus protocol as well as the device driver and still not find any references yet. 

 

I will keep digging but hopes the Xilinx can make more guideline to the feature of on board PMBus device. 

 

Thanks.

0 Kudos
Xilinx Employee
Xilinx Employee
8,074 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

It's a bug in Linux. When Linux initializes the UCD device, it reads the VOUT_MODE register once, to determine a scaling factor which is used on a per-chip basis. The UCD90120 though, has VOUT_MODE values per-rail. On the zc706 they are:

Rail1: 2^-14

Rail2-4: 2^-13

Rail5: 2^-12

 

The Linux driver reads the 2^-14 and applies it to all rails, which explains why you see the 2x and 4x error.

0 Kudos
Adventurer
Adventurer
8,066 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Thanks for the reply!

 

I got it. Now I totally understand the scaling parameter of voltage in UCD9000 document, but still need to figure out:

 

1. I also downloaded a TI Fusion Digital Power Designer to have a try. I can see that the scaling factors can be set for each rail separately which is good. Since I cannot found any setting from the linux driver, is that means this bug can only be fixed by reprogramming the controller to set the VOUT_MODE (of cause besides the compensation to the output value)? 

 

2. The IOUT_CAL_GAIN and IOUT_CAL_OFFSET as well as VOUT_SCALE_MONITOR are shown in the TI Fusion tool. The current calculation of PMBus is :

             READ_IOUT = V_measure (at I_out pin) / IOUT_CAL_GAIN + IOUT_CAL_OFFSET

So the READ_IOUT value will also be affect by the different scaling factor of voltage between rails. How to determine IOUT_CAL_GAIN and IOUT_CAL_OFFSET without TI Fusion? Because without that the correct current value cannot be obtained.

(I notice that, in the PMBus standard, the IOUT_CAL_GAIN should be the output resister of the board for each rail while the IOUT_CAL_OFFSET is a manufacturer's setting for calibration, since I didn't find any value for UCD9012A in the linux driver.)

 

Thanks. 

0 Kudos
Adventurer
Adventurer
8,065 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

OK, I found some IOUT_CAL_GAIN, IOUT_CAL_OFFSET value in the zc706_revb_ti_xml_power_script_r9_with_alternates.zip package for reprogramming the PMBus controller through TI Fusion Tool. But I am not sure if the value provided is the exact value for all the rails. 

 

In the package, there are only three folder corresponding to 3V3_VADJ, 2V5_VADJ_DEFAULT and 1V8_VADJ. I have checked the IOUT_CAL_GAIN, IOUT_CAL_OFFSET, which are the same for all the rails. 

 

Do you have any idea about this?

 

Thanks.

0 Kudos
Adventurer
Adventurer
8,061 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Hi, 

 

Interesting. The files provided from Xilinx does provide some typical parameter to the TI power controller. Although the files are provided for the VCC2V5/ADJ not the rails of PL, I guess it is still the common value for the power rails.  

 

It clearly specifies the VOUT_SCALE_MONITOR, IOUT_CAL_GAIN and IOUT_CAL_OFFSET. Here comes the problem.

 

1. In the previous discussion, your measurement with TI Fusion is:

 

Rail1: 1V/120mA

Rail2: 1.78V/20mA

Rail3: 1.5V/20mA

Rail4: 1.8V/450mA

Rail5: 3.3V/1A

 

but the value in the xml script is:

...

<IDAndCode>READ_IOUT [0x8C,Rail #1]</IDAndCode>
<ValueText>0.23 A</ValueText>

...

<IDAndCode>READ_IOUT [0x8C,Rail #2]</IDAndCode>
<ValueText>0.09 A</ValueText>

...
<IDAndCode>READ_IOUT [0x8C,Rail #3]</IDAndCode>
<ValueText>0.03 A</ValueText>

...
<IDAndCode>READ_IOUT [0x8C,Rail #4]</IDAndCode>
<ValueText>0.11 A</ValueText>

...
<IDAndCode>READ_IOUT [0x8C,Rail #5]</IDAndCode>
<ValueText>0.06 A</ValueText>

..

 

The current value in the xml script does match the value monitored from the driver. 

 

2. The VOUT_SCALE_MONITOR of rail #4 and #5 is not 1.000 but

...
<IDAndCode>VOUT_SCALE_MONITOR [0x2A,Rail #4]</IDAndCode>
<ValueText>0.606 </ValueText>

...
<IDAndCode>VOUT_SCALE_MONITOR [0x2A,Rail #5]</IDAndCode>
<ValueText>0.606 </ValueText>

...

So when considering the REAM_VOUT, do we still need to consider this scaling as well?

 

Thanks. 

0 Kudos
Xilinx Employee
Xilinx Employee
8,056 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Honestly, I cannot answer most of those questions. And reprogramming the UCD devices would just be a workaround (and be warned, by reprogramming the power supplies you have a chance to fry the board!). I still see Linux at fault here and reported the bug upstream http://thread.gmane.org/gmane.linux.drivers.sensors/34707 . There is already a patch in that thread that fixes the UCD90120. I expect something like this will go to mainline Linux and we'll apply the final fix in the Xilinx tree as well, once it is available.

0 Kudos
Adventurer
Adventurer
8,052 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Hi, 

 

Thanks for the reply!

 

Great! It is good to know it can be fixed in a proper way. And I am very appreciate your help.

 

Can I ask a last quesiton about the PMBus driver? So basically the PMBus driver will call the i2c bus function to reach a specific physical address on board to obtain the value. The Linux application for power monitor of ZC702 successfully accesses the given PMBus controller address and catches the voltage values, which , to me, it does the same thing as the driver does by calling the ioctl() function. 

 

The device address for UCD9012A should be 65. So I did a little experiment to find if there is an address 65 on the i2c bus. The result shows no such address exist. My method is using the provided code from xilinx but change the i2c device index and test a address with feedback value using i2c read command.

 

It shows that only following address can be accessed:

/dev/i2c-0        N/A

/dev/i2c-1        116
/dev/i2c-2        56,57,60,62,63,116
/dev/i2c-3        116
/dev/i2c-4        48,80,116
/dev/i2c-5        104,116
/dev/i2c-6        116
/dev/i2c-7        116
/dev/i2c-8        116

 

And only following address can reture values:

/dev/i2c-1        116

/dev/i2c-2        116

/dev/i2c-3        80,116

/dev/i2c-4        116

/dev/i2c-5        104,116
/dev/i2c-6        116
/dev/i2c-7        116
/dev/i2c-8        116

 

Actually, those are all invalid address for power monitoring. But we definitely can see the /sys/device/amba.0/e0004000.ps7-i2c/i2c-8-8-0056 in the linux system and catch voltage/current values. So what 'things' mismatched here?

 

Thanks.

 

0 Kudos
Xilinx Employee
Xilinx Employee
7,288 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Actually, I have never looked at the sources of that application.

I don't know if your device detection mechanism is buggy or something else, but when I run i2cdetect I get the following:

root@zynq:~# i2cdetect -r 0
WARNING! This program can confuse your I2C bus, cause data loss and worse!
I will probe file /dev/i2c-0 using read byte commands.
I will probe address range 0x03-0x77.
Continue? [Y/n] y
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- UU -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- UU -- -- UU UU UU UU -- -- -- -- -- UU -- --
60: -- -- -- -- -- UU -- -- 68 -- -- -- -- -- -- --
70: -- -- -- -- UU -- -- --

 

That matches with DT data and the schematic.

0 Kudos
Adventurer
Adventurer
7,281 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Hi, 

 

Thanks for the reply!

 

Please check this. At the device address 65, there is 'UU'. What is this mean?

New Bitmap Image.jpg

 

Thanks

0 Kudos
Xilinx Employee
Xilinx Employee
7,279 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

The man page helps with output interpretation: http://linux.die.net/man/8/i2cdetect

 

""UU". Probing was skipped, because this address is currently in use by a driver. This strongly suggests that there is a chip at this address."

0 Kudos
Adventurer
Adventurer
7,264 Views
Registered: ‎01-24-2014

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Hi, 

 

I don't know why but after several tries, the register can be read by i2cget from 0x68. 

I also tried to catch the register value from 0x65 as well. It fails. 

New Bitmap Image.jpg

Actually, all the registers at 0x65 are not visible. 

New Bitmap Image (2).jpg

My guess this is the reason that the linux application from Xilinx can not access to the correct address since the register is even invisible to i2cget. 

 

I thought is might because it is occupied by the driver. I also try using a Linux application on a Linux kernel without the PMBus driver. But that failed as well. Now I have to give up that approach and using the directly value catched by the driver on zc706, although I am still confused why it works for zc702. 

 

So if 0x65 address is accessible by i2cget, how should I  determine  the READ_VOUT and READ_IOUT registers? There are page address for those register, can I catch the value for specific page address from this?

 

Thanks.

0 Kudos
Xilinx Employee
Xilinx Employee
7,258 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Well, my guess - and really just a guess - would be, that the PMBus protocol is just different enough to let simple i2cget etc. fail to read. The methods used in the zc702 application should still work, IMHO, but I have no idea how much changes it might require due to the different UCD chip used.

Anyway, I expect this fix http://thread.gmane.org/gmane.linux.drivers.sensors/34711 to be applied to Linux soon. That should fix the driver issue and userspace apps can simply be built on top of the driver API.

0 Kudos
Xilinx Employee
Xilinx Employee
11,113 Views
Registered: ‎03-13-2012

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution
0 Kudos
Visitor mrihani
Visitor
3,837 Views
Registered: ‎02-10-2016

Re: The Linux application for power monitoring for ZC706 using the ZC702 application reference from Xilinx

Jump to solution

Hi,

I am trying to monitor voltage and current from the ZC706 Board using a baremetal application, I also used the code from Xilinx wiki which was for ZC702

I changed the address to 0x65 and the rail numbers but i have different voltage values than it should be, so what i should change in the code to get the right values

0 Kudos