I am working on some userspace validation tool. In which I need to validate i2c freq.
In my DT file, I set clock-frequency = <400000>;, And I read it back from /proc/device-tree/i2c@XXXXX/clock-frequency from userspace. But I am getting some garbage data.
Output:
root@mymachine:~# od -bc /proc/device-tree/i2c\@XXXXXX/clock-frequency
0000000 000 006 032 200
\0 006 032 200
0000004
Is it in compressed form? If yes, How can I decompress it?
Output of file command:
root@nvidia:/proc/device-tree# file i2c\@7000*/clock-frequency
i2c@7000XXXX/clock-frequency: TTComp archive data
i2c@7000XXXX/clock-frequency: raw G3 data, byte-padded
i2c@7000XXXX/clock-frequency: TTComp archive data
i2c@7000XXXX/clock-frequency: raw G3 data, byte-padded
i2c@7000XXXX/clock-frequency: TTComp archive data
i2c@7000XXXX/clock-frequency: TTComp archive data
It's not compressed, it's just a raw binary unsigned 32-bit int stored big-endian. The four bytes you have there are shown in octal: 0, 6, 32, 200, in decimal are 0, 6, 26, and 128, and as a 32-bit int is 6*65536 + 26*256 + 128 = 400000.
There are many ways to unpack that; from python, on my RPi 2, which currently has an i2c freq of 100000: