Skip to content

Linux utility to test the large I2C IO chunks' capabilities and benchmark performance of the I2C controllers and Linux kernel I2C bus drivers when used with I2C EEPROM chips.

License

Notifications You must be signed in to change notification settings

MichaelZaidman/i2cperf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Overview

The i2cperf is a Linux utility to test the large I2C IO chunks' capabilities and benchmark performance of the I2C controllers and Linux kernel I2C bus drivers when used with I2C EEPROM chips.

It was originally written to save me the hassle of utilizing the Linux standard i2c tools to debug and test the hid-ft260 Linux kernel driver [1] for the FTDI FT260 chip [2].

This bash script leverages the Linux I2C tools like i2cget, i2cset, i2ctransfer, and i2cdump, simplifying their configuration to issue predefined I2C IO patterns allowing performance benchmarking of any I2C controller and Linux kernel I2C bus driver by measuring payload data rate and efficiency of the IO operations size at different workloads.

 Usage: i2cperf [-h] [-v] -S] [-f MODE] [-d MODE] [-o SIZE] [-s SIZE] [-r FIRST-LAST] BUS ADDRESS

         BUS                    I2C bus master device number
         ADDRESS                EEPROM device address (0x50 - 0x57)

         -h, --help             Show this help message and exit
         -v, --verbose          More verbose output
         -S, --stat             Print statistics

         -d, --dumpmode MODE    Read data mode:
                                1 - Read block via i2cdump byte by byte
                                2 - Read block via i2ctransfer by chunks

         -f, --fillmode MODE    Write data mode:
                                1 - Fill block with zeros via i2ctransfer
                                2 - Fill block with increment via i2ctransfer by chunks
                                3 - Fill block with increment via i2cset byte by byte
                                4 - Fill block with pseudo random via i2ctransfer by chunks

         -r, --range FIRST-LAST Address range to operate
         -s, --xfersize SIZE    Data chunk size in bytes

         -o, --offsize SIZE     Offset (addr in chip addr space) size:
                                1 - One byte offset like in 24C01 - 24C16 EEPROMs
                                2 - Two bytes offest, for larger than 256B EEPROMs

Prerequisites

The i2cperf relies on i2ctransfer, added to the i2c-tools since v4.0 (2017-10-30).

The i2c-tool usually comes with every Linux distribution and likely will already be of the needed version.

We can check it by running the i2ctransfer command. If it does not exist, then the i2c-tools package is not installed, or it is of outdated version.

Tested on

  1. Ubuntu 16.04 (Linux 4.15.0-142), MS-7916 PC (i7-4790K, 16G RAM)
  2. Ubuntu 20.04 (Linux 5.13.0-30), VirtualBox VM on Win10 HP EliteBook 840 G6 (i5-8265U, 16G RAM)

Tested with

  1. EEPROMS: 24c02, 24c32, 24c512
  2. UMFT260EV1A EVB [3] and hid-ft260 kernel driver [1]
  3. CH341A Pro black board [4] and 2c-ch341-usb kernel driver [5] It has issues with voltage as mentioned in [4]. The clock is also far from being accurate. The driver sets 100KHz, but I measured ~350KHz.
  4. CH341A green board (077-53900) [4] and 2c-ch341-usb kernel driver [5] The board is slightly overclocked - about 120KHz when configured to 100KHz.

Usage examples

Setup: 24c512 EEPROM, CH341A green board (077-53900) [4], i2c-ch341-usb kernel driver [5], PC (i7-4790K)

Write 1KB data block with increment via i2cset byte by byte

$ sudo ./i2cperf -f 3 -o 2 -r 0-0x3ff 13 0x50 -S

  Fill block with increment via i2cset byte by byte
  -------------------------------------------------------------------
  data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
  -------------------------------------------------------------------
  7059            21             1024          1024        1

Read 256B block via i2ctransfer by chunks of 8 bytes size

swuser@comex-usb01:~/sw/i2cperf$ sudo ./i2cperf -d 2 -o 2 -s 8 -r 0-0xff 13 0x50 -S
0x0000: 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07
0x0008: 0x08 0x09 0x0a 0x0b 0x0c 0x0d 0x0e 0x0f
0x0010: 0x10 0x11 0x12 0x13 0x14 0x15 0x16 0x17
0x0018: 0x18 0x19 0x1a 0x1b 0x1c 0x1d 0x1e 0x1f
0x0020: 0x20 0x21 0x22 0x23 0x24 0x25 0x26 0x27
0x0028: 0x28 0x29 0x2a 0x2b 0x2c 0x2d 0x2e 0x2f
0x0030: 0x30 0x31 0x32 0x33 0x34 0x35 0x36 0x37
0x0038: 0x38 0x39 0x3a 0x3b 0x3c 0x3d 0x3e 0x3f
0x0040: 0x40 0x41 0x42 0x43 0x44 0x45 0x46 0x47
0x0048: 0x48 0x49 0x4a 0x4b 0x4c 0x4d 0x4e 0x4f
0x0050: 0x50 0x51 0x52 0x53 0x54 0x55 0x56 0x57
0x0058: 0x58 0x59 0x5a 0x5b 0x5c 0x5d 0x5e 0x5f
0x0060: 0x60 0x61 0x62 0x63 0x64 0x65 0x66 0x67
0x0068: 0x68 0x69 0x6a 0x6b 0x6c 0x6d 0x6e 0x6f
0x0070: 0x70 0x71 0x72 0x73 0x74 0x75 0x76 0x77
0x0078: 0x78 0x79 0x7a 0x7b 0x7c 0x7d 0x7e 0x7f
0x0080: 0x80 0x81 0x82 0x83 0x84 0x85 0x86 0x87
0x0088: 0x88 0x89 0x8a 0x8b 0x8c 0x8d 0x8e 0x8f
0x0090: 0x90 0x91 0x92 0x93 0x94 0x95 0x96 0x97
0x0098: 0x98 0x99 0x9a 0x9b 0x9c 0x9d 0x9e 0x9f
0x00a0: 0xa0 0xa1 0xa2 0xa3 0xa4 0xa5 0xa6 0xa7
0x00a8: 0xa8 0xa9 0xaa 0xab 0xac 0xad 0xae 0xaf
0x00b0: 0xb0 0xb1 0xb2 0xb3 0xb4 0xb5 0xb6 0xb7
0x00b8: 0xb8 0xb9 0xba 0xbb 0xbc 0xbd 0xbe 0xbf
0x00c0: 0xc0 0xc1 0xc2 0xc3 0xc4 0xc5 0xc6 0xc7
0x00c8: 0xc8 0xc9 0xca 0xcb 0xcc 0xcd 0xce 0xcf
0x00d0: 0xd0 0xd1 0xd2 0xd3 0xd4 0xd5 0xd6 0xd7
0x00d8: 0xd8 0xd9 0xda 0xdb 0xdc 0xdd 0xde 0xdf
0x00e0: 0xe0 0xe1 0xe2 0xe3 0xe4 0xe5 0xe6 0xe7
0x00e8: 0xe8 0xe9 0xea 0xeb 0xec 0xed 0xee 0xef
0x00f0: 0xf0 0xf1 0xf2 0xf3 0xf4 0xf5 0xf6 0xf7
0x00f8: 0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff

  Read block via i2ctransfer by chunks
  -------------------------------------------------------------------
  data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
  -------------------------------------------------------------------
  28340           57             256           32          8

Write 1KB data block with pseudo random via i2ctransfer by 4 bytes chunks

swuser@comex-usb01:~/sw/i2cperf$ sudo ./i2cperf -f 4 -o 2 -s 4 -r 0-0x1ff 13 0x50 -S

  Fill block with pseudo random via i2ctransfer by chunks
  -------------------------------------------------------------------
  data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
  -------------------------------------------------------------------
  27437           49             512           128         4

Read 256B block via i2ctransfer by chunks of 16 bytes size

swuser@comex-usb01:~/sw/i2cperf$ sudo ./i2cperf -d 2 -o 2 -s 16 -r 0-0xff 13 0x50 -S
0x0000: 0x00 0x50 0xb0 0x71 0x01 0x4e 0xc4 0xd9 0x02 0x4c 0xc8 0xc1 0x03 0x4a 0xbc 0x69
0x0010: 0x04 0x58 0xa0 0x91 0x05 0x56 0xb4 0x79 0x06 0x54 0xb8 0x61 0x07 0x52 0xac 0x89
0x0020: 0x08 0x40 0xd0 0xb1 0x09 0x3e 0x64 0x19 0x0a 0x3c 0x68 0x01 0x0b 0x3a 0x5c 0xa8
0x0030: 0x0c 0x48 0xc0 0xd1 0x0d 0x46 0xd4 0xb9 0x0e 0x44 0xd8 0xa1 0x0f 0x42 0xcc 0xc9
0x0040: 0x10 0x30 0x70 0xf0 0x11 0x2e 0x84 0x59 0x12 0x2c 0x88 0x41 0x13 0x2a 0x7c 0xe8
0x0050: 0x14 0x38 0x60 0x11 0x15 0x36 0x74 0xf8 0x16 0x34 0x78 0xe0 0x17 0x32 0x6c 0x09
0x0060: 0x18 0x20 0x90 0x31 0x19 0x1e 0x24 0x98 0x1a 0x1c 0x28 0x80 0x1b 0x1a 0x1c 0x28
0x0070: 0x1c 0x28 0x80 0x51 0x1d 0x26 0x94 0x39 0x1e 0x24 0x98 0x21 0x1f 0x22 0x8c 0x49
0x0080: 0x20 0x90 0x31 0x6e 0x21 0x8e 0x45 0xd6 0x22 0x8c 0x49 0xbe 0x23 0x8a 0x3d 0x66
0x0090: 0x24 0x98 0x21 0x8e 0x25 0x96 0x35 0x76 0x26 0x94 0x39 0x5e 0x27 0x92 0x2d 0x86
0x00a0: 0x28 0x80 0x51 0xae 0x29 0x7e 0xe4 0x18 0x2a 0x7c 0xe8 0x00 0x2b 0x7a 0xdc 0xa9
0x00b0: 0x2c 0x88 0x41 0xce 0x2d 0x86 0x55 0xb6 0x2e 0x84 0x59 0x9e 0x2f 0x82 0x4d 0xc6
0x00c0: 0x30 0x70 0xf0 0xf1 0x31 0x6e 0x05 0x56 0x32 0x6c 0x09 0x3e 0x33 0x6a 0xfc 0xe9
0x00d0: 0x34 0x78 0xe0 0x10 0x35 0x76 0xf4 0xf9 0x36 0x74 0xf8 0xe1 0x37 0x72 0xec 0x08
0x00e0: 0x38 0x60 0x11 0x2e 0x39 0x5e 0xa4 0x99 0x3a 0x5c 0xa8 0x81 0x3b 0x5a 0x9c 0x29
0x00f0: 0x3c 0x68 0x01 0x4e 0x3d 0x66 0x15 0x36 0x3e 0x64 0x19 0x1e 0x3f 0x62 0x0d 0x46

  Read block via i2ctransfer by chunks
  -------------------------------------------------------------------
  data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
  -------------------------------------------------------------------
  42491           69             256           16          16

Setup: 24c512 EEPROM, UMFT260EV1A EVB @200KHz [3], hid-ft260 kernel driver [1], PC (i7-4790K)

Write 256B block via i2ctransfer by chunks of 128 bytes size

$ sudo ./i2cperf -f 2 -o 2 -s 128 -r 0-0xff 13 0x51 -S

  Fill block with increment via i2ctransfer by chunks
  -------------------------------------------------------------------
  data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
  -------------------------------------------------------------------
  110668          86             256           2           128

Read 256B block via i2ctransfer by chunks of 128 bytes size

$ sudo ./i2cperf -d 2 -o 2 -s 128 -r 0-0xff 13 0x51 -S
0x0000: 0x00 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x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0xe9 0xea 0xeb 0xec 0xed 0xee 0xef 0xf0 0xf1 0xf2 0xf3 0xf4 0xf5 0xf6 0xf7 0xf8 0xf9 0xfa 0xfb 0xfc 0xfd 0xfe 0xff

  Read block via i2ctransfer by chunks
  -------------------------------------------------------------------
  data rate(bps)  efficiency(%)  data size(B)  total IOs   IO size(B)
  -------------------------------------------------------------------
  77663           85             256           2           128

Source

https://github.com/MichaelZaidman/i2cperf.git

References

[1] https://github.com/MichaelZaidman/hid-ft260

[2] https://ftdichip.com/wp-content/uploads/2020/08/DS_FT260.pdf

[3] https://www.ftdichip.com/Support/Documents/DataSheets/Modules/DS_UMFT260EV1A.pdf

[4] https://www.onetransistor.eu/2017/08/ch341a-mini-programmer-schematic.html

[5] https://github.com/allanbian1017/i2c-ch341-usb

About

Linux utility to test the large I2C IO chunks' capabilities and benchmark performance of the I2C controllers and Linux kernel I2C bus drivers when used with I2C EEPROM chips.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages