Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 9 May 2012 10:34:29 +0300 (EEST)
From:      Andriy Gapon <avg@icyb.net.ua>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/167730: [NEW PORT] sysutils/i2c-tools: A heterogeneous set of I2C tools
Message-ID:  <201205090734.q497YT2Q072769@trant.local.>
Resent-Message-ID: <201205090740.q497eAg3047277@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         167730
>Category:       ports
>Synopsis:       [NEW PORT] sysutils/i2c-tools: A heterogeneous set of I2C tools
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 09 07:40:10 UTC 2012
>Closed-Date:
>Last-Modified:
>Originator:     Andriy Gapon
>Release:        FreeBSD 10.0-CURRENT amd64
>Organization:
>Environment:
System: FreeBSD 10.0-CURRENT amd64
>Description:
The i2c-tools package contains a heterogeneous set of I2C tools for
Linux: a bus probing tool, a chip dumper, register-level SMBus access
helpers, EEPROM decoding scripts, EEPROM programming tools, and a python
module for SMBus access.
Only DIMM SPD decoding tool is ported at the moment.

WWW:	http://www.lm-sensors.org/wiki/I2CTools

Generated with FreeBSD Port Tools 0.99_6 (mode: new)
>How-To-Repeat:
>Fix:

--- .shar begins here ---
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	i2c-tools
#	i2c-tools/files
#	i2c-tools/files/patch-eeprom_decode-dimms
#	i2c-tools/pkg-descr
#	i2c-tools/Makefile
#	i2c-tools/distinfo
#
echo c - i2c-tools
mkdir -p i2c-tools > /dev/null 2>&1
echo c - i2c-tools/files
mkdir -p i2c-tools/files > /dev/null 2>&1
echo x - i2c-tools/files/patch-eeprom_decode-dimms
sed 's/^X//' >i2c-tools/files/patch-eeprom_decode-dimms << '575eae25000511bafd9179746343c00b'
X--- eeprom/decode-dimms.orig	2012-04-18 10:02:28.495892381 +0300
X+++ eeprom/decode-dimms	2012-04-18 10:02:38.695897992 +0300
X@@ -41,9 +41,9 @@ use strict;
X use POSIX qw(ceil);
X use Fcntl qw(:DEFAULT :seek);
X use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_merge
X-	    $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width
X+	    $opt_igncheck $use_hexdump $sbs_col_width
X 	    @vendors %decode_callback $revision @dimm $current %hexdump_cache);
X 
X use constant LITTLEENDIAN	=> "little-endian";
X use constant BIGENDIAN		=> "big-endian";
X 
X@@ -252,8 +252,6 @@ $revision =~ s/ \([^()]*\)//;
X  "Edgewater Computer Systems", "XMOS Semiconductor Ltd.", "GENUSION, Inc.", "Memory Corp NV",
X  "SiliconBlue Technologies", "Rambus Inc."]);
X 
X-$use_sysfs = -d '/sys/bus';
X-
X # We consider that no data was written to this area of the SPD EEPROM if
X # all bytes read 0x00 or all bytes read 0xff
X sub spd_written(@)
X@@ -525,16 +523,21 @@ sub sdram_voltage_interface_level($)
X 	return ($_[0] < @levels) ? $levels[$_[0]] : "Undefined!";
X }
X 
X-# Common to SDR and DDR SDRAM
X+# Common to SDR, DDR and DDR2 SDRAM
X sub sdram_module_configuration_type($)
X {
X-	my @types = (
X-		"No Parity",			# 0
X-		"Parity",			# 1
X-		"ECC",				# 2
X-	);
X+	my $byte = $_[0] & 0x07;
X+	my @edc;
X+
X+	return "No Parity" if $byte == 0;
X 
X-	return ($_[0] < @types) ? $types[$_[0]] : "Undefined!";
X+	# Data ECC includes Data Parity so don't print both
X+	push @edc, "Data Parity" if ($byte & 0x03) == 0x01;
X+	push @edc, "Data ECC" if ($byte & 0x02);
X+	# New in DDR2 specification
X+	push @edc, "Address/Command Parity" if ($byte & 0x04);
X+
X+	return join ", ", @edc;
X }
X 
X # Parameter: EEPROM bytes 0-127 (using 3-62)
X@@ -1019,6 +1022,9 @@ sub decode_ddr2_sdram($)
X 	printl("Voltage Interface Level",
X 	       sdram_voltage_interface_level($bytes->[8]));
X 
X+	printl("Module Configuration Type",
X+	       sdram_module_configuration_type($bytes->[11]));
X+
X 	printl("Refresh Rate", ddr2_refresh_rate($bytes->[12]));
X 
X 	my @burst;
X@@ -1557,6 +1563,26 @@ sub spd_sizes($)
X 	}
X }
X 
X+sub freebsd_readbyte ($$) {
X+	my ($offset, $dimm_i) = @_;
X+
X+	my $command = sprintf('/usr/sbin/smbmsg -s %#02x -c %d -i 1 -F %%02x 2>/dev/null', $dimm_i, $offset);
X+	my $output = `$command`;
X+	chomp($output);
X+	my $byte = hex($output);
X+	return $byte;
X+}
X+
X+sub freebsd_readword ($$) {
X+	my ($offset, $dimm_i) = @_;
X+
X+	my $command = sprintf('/usr/sbin/smbmsg -s %#02x -c %d -w -i 2 -F %%04x 2>/dev/null', $dimm_i, $offset);
X+	my $output = `$command`;
X+	chomp($output);
X+	my $word = hex($output);
X+	return $word;
X+}
X+
X # Read bytes from SPD-EEPROM
X # Note: offset must be a multiple of 16!
X sub readspd($$$)
X@@ -1566,22 +1592,14 @@ sub readspd($$$)
X 	if ($use_hexdump) {
X 		@bytes = read_hexdump($dimm_i);
X 		return @bytes[$offset..($offset + $size - 1)];
X-	} elsif ($use_sysfs) {
X-		# Kernel 2.6 with sysfs
X-		sysopen(HANDLE, "$dimm_i/eeprom", O_RDONLY)
X-			or die "Cannot open $dimm_i/eeprom";
X-		binmode HANDLE;
X-		sysseek(HANDLE, $offset, SEEK_SET)
X-			or die "Cannot seek $dimm_i/eeprom";
X-		sysread(HANDLE, my $eeprom, $size)
X-			or die "Cannot read $dimm_i/eeprom";
X-		close HANDLE;
X-		@bytes = unpack("C*", $eeprom);
X 	} else {
X-		# Kernel 2.4 with procfs
X-		for my $i (0 .. ($size-1)/16) {
X-			my $hexoff = sprintf('%02x', $offset + $i * 16);
X-			push @bytes, split(" ", `cat $dimm_i/$hexoff`);
X+#		for my $i (0 .. ($size - 1)) {
X+#			push (@bytes, freebsd_readbyte($offset + $i, $dimm_i));
X+#		}
X+		for my $i (0 .. (($size - 1) / 2)) {
X+			my $word = freebsd_readword($offset + 2 * $i, $dimm_i);
X+			push (@bytes, $word & 0xff);
X+			push (@bytes, $word >> 8);
X 		}
X 	}
X 	return @bytes;
X@@ -1710,60 +1728,20 @@ printh('Memory Serial Presence Detect De
X Jean Delvare, Trent Piepho and others');
X 
X 
X-# From a sysfs device path and an attribute name, return the attribute
X-# value, or undef (stolen from sensors-detect)
X-sub sysfs_device_attribute
X-{
X-	my ($device, $attr) = @_;
X-	my $value;
X-
X-	open(local *FILE, "$device/$attr") or return "";
X-	$value = <FILE>;
X-	close(FILE);
X-	return unless defined $value;
X-
X-	chomp($value);
X-	return $value;
X-}
X-
X sub get_dimm_list
X {
X-	my (@dirs, $dir, $file, @files);
X-
X-	if ($use_sysfs) {
X-		@dirs = ('/sys/bus/i2c/drivers/eeprom', '/sys/bus/i2c/drivers/at24');
X-	} else {
X-		@dirs = ('/proc/sys/dev/sensors');
X-	}
X-
X-	foreach $dir (@dirs) {
X-		next unless opendir(local *DIR, $dir);
X-		while (defined($file = readdir(DIR))) {
X-			if ($use_sysfs) {
X-				# We look for I2C devices like 0-0050 or 2-0051
X-				next unless $file =~ /^\d+-[\da-f]+$/i;
X-				next unless -d "$dir/$file";
X-
X-				# Device name must be eeprom (driver eeprom)
X-				# or spd (driver at24)
X-				my $attr = sysfs_device_attribute("$dir/$file", "name");
X-				next unless defined $attr &&
X-					    ($attr eq "eeprom" || $attr eq "spd");
X-			} else {
X-				next unless $file =~ /^eeprom-/;
X-			}
X-			push @files, { eeprom => "$file",
X-				       file => "$dir/$file" };
X-		}
X-		close(DIR);
X-	}
X-
X-	if (@files) {
X-		return sort { $a->{file} cmp $b->{file} } @files;
X-	} elsif (! -d '/sys/module/eeprom') {
X-		print "No EEPROM found, are you sure the eeprom module is loaded?\n";
X-		exit;
X+	my @dimms;
X+	if (! -c '/dev/smb0') {
X+        	print "SMBus device not found\n";
X+	        exit;
X+	}
X+	for my $spd (0xA0 .. 0xAE) {
X+		next if ($spd % 2 != 0);
X+		my @test_bytes = readspd(0, 4, $spd);
X+		next unless spd_written(@test_bytes);
X+		push @dimms, { eeprom => sprintf('0x%02X', $spd), file => $spd };
X 	}
X+	return @dimms;
X }
X 
X # @dimm is a list of hashes. There's one hash for each EEPROM we found.
X@@ -1954,7 +1932,7 @@ for $current (0 .. $#dimm) {
X 		print "\n\n";
X 	} else {
X 		print "<b><u>" if $opt_html;
X-		printl2("\n\nDecoding EEPROM", $dimm[$current]->{file});
X+		printl2("\n\nDecoding EEPROM", $dimm[$current]->{eeprom});
X 		print "</u></b>" if $opt_html;
X 	}
X 	print "<table border=1>\n" if $opt_html;
575eae25000511bafd9179746343c00b
echo x - i2c-tools/pkg-descr
sed 's/^X//' >i2c-tools/pkg-descr << '186215a26d3ee506adb232938bc6ec5e'
XThe i2c-tools package contains a heterogeneous set of I2C tools for
XLinux: a bus probing tool, a chip dumper, register-level SMBus access
Xhelpers, EEPROM decoding scripts, EEPROM programming tools, and a python
Xmodule for SMBus access.
XOnly DIMM SPD decoding tool is ported at the moment.
X
XWWW:	http://www.lm-sensors.org/wiki/I2CTools
186215a26d3ee506adb232938bc6ec5e
echo x - i2c-tools/Makefile
sed 's/^X//' >i2c-tools/Makefile << '323e0631eee7f074c4576949d85269b2'
X# New ports collection makefile for:	i2c-tools
X# Date created:		2012-04-18
X# Whom:			Andriy Gapon <avg@icyb.net.ua>
X#
X# $FreeBSD$
X#
X
XPORTNAME=	i2c-tools
XPORTVERSION=	3.1.0
XCATEGORIES=	sysutils
XMASTER_SITES=	http://dl.lm-sensors.org/i2c-tools/releases/
X
XMAINTAINER=	avg@icyb.net.ua
XCOMMENT=	A heterogeneous set of I2C tools
X
XUSE_BZIP2=	yes
XNO_BUILD=	yes
XUSE_PERL5_RUN=	yes
X
XPLIST_FILES=	sbin/decode-dimms
X
Xdo-install:
X	${INSTALL_SCRIPT} ${WRKSRC}/eeprom/decode-dimms ${PREFIX}/sbin/decode-dimms
X
X.include <bsd.port.mk>
323e0631eee7f074c4576949d85269b2
echo x - i2c-tools/distinfo
sed 's/^X//' >i2c-tools/distinfo << '9e097e505cb6a78f54000eab2e7da1f8'
XSHA256 (i2c-tools-3.1.0.tar.bz2) = 960023f61de292c6dd757fcedec4bffa7dd036e8594e24b26a706094ca4c142a
XSIZE (i2c-tools-3.1.0.tar.bz2) = 66840
9e097e505cb6a78f54000eab2e7da1f8
exit
--- .shar ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201205090734.q497YT2Q072769>