Thu Oct 28 20:18:21 2021 UTC ()
decode-dimms: Update to upstream v4.3

Change log:

	decode-dimms: Actually decode LPDDR3 modules

	In commit 78ed68308b58 ("decode-dimms: Decode manufacturing
	data for LPDDR3") we said we would handle LPDDR3 the same as
	DDR3, however it was actually only done for the manufacturing
	data. Extend the idea to the rest of the script.


(pgoyette)
diff -r1.30 -r1.31 pkgsrc/sysutils/decode-dimms/Makefile
diff -r1.23 -r1.24 pkgsrc/sysutils/decode-dimms/distinfo
diff -r1.18 -r1.19 pkgsrc/sysutils/decode-dimms/patches/patch-decode-dimms

cvs diff -r1.30 -r1.31 pkgsrc/sysutils/decode-dimms/Makefile (expand / switch to unified diff)

--- pkgsrc/sysutils/decode-dimms/Makefile 2021/05/24 19:54:10 1.30
+++ pkgsrc/sysutils/decode-dimms/Makefile 2021/10/28 20:18:20 1.31
@@ -1,36 +1,35 @@ @@ -1,36 +1,35 @@
1# $NetBSD: Makefile,v 1.30 2021/05/24 19:54:10 wiz Exp $ 1# $NetBSD: Makefile,v 1.31 2021/10/28 20:18:20 pgoyette Exp $
2 2
3# Track upstream's HEAD 3# Track upstream's HEAD
4PKG_DATE= 20201004 4PKG_DATE= 20210722
5GIT_COMMIT= 9cba52b9626413307b994af44695b8a9c0e058be 5GIT_COMMIT= d8bc1f1ff4b00a6bd988aa114100ae9b787f50d8
6DISTNAME= i2c-tools-${GIT_COMMIT} 6DISTNAME= i2c-tools-${GIT_COMMIT}
7PKGNAME= decode-dimms-4.2.${PKG_DATE} 7PKGNAME= decode-dimms-4.3.${PKG_DATE}
8PKGREVISION= 1 
9CATEGORIES= sysutils 8CATEGORIES= sysutils
10MASTER_SITES= https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/snapshot/ 9MASTER_SITES= https://git.kernel.org/pub/scm/utils/i2c-tools/i2c-tools.git/snapshot/
11 10
12MAINTAINER= pgoyette@NetBSD.org 11MAINTAINER= pgoyette@NetBSD.org
13HOMEPAGE= https://git.kernel.org/pub/scm/utils/i2c-tools/ 12HOMEPAGE= https://git.kernel.org/pub/scm/utils/i2c-tools/
14COMMENT= Decode memory DIMM SPD ROM info 13COMMENT= Decode memory DIMM SPD ROM info
15LICENSE= gnu-gpl-v2 14LICENSE= gnu-gpl-v2
16 15
17USE_TOOLS+= perl:run 16USE_TOOLS+= perl:run
18REPLACE_PERL= eeprom/decode-dimms 17REPLACE_PERL= eeprom/decode-dimms
19 18
20SUBST_CLASSES+= rev 19SUBST_CLASSES+= rev
21SUBST_STAGE.rev= post-extract 20SUBST_STAGE.rev= post-patch
22SUBST_FILES.rev= eeprom/decode-dimms 21SUBST_FILES.rev= eeprom/decode-dimms
23SUBST_SED.rev= -e '/I2C_TOOLS_VER/s/4.2/4.2-${PKG_DATE}/' 22SUBST_SED.rev= -e '/I2C_TOOLS_VER/s/4.3/4.3-${PKG_DATE}/'
24 23
25NO_BUILD= yes 24NO_BUILD= yes
26 25
27USE_LANGUAGES= # empty 26USE_LANGUAGES= # empty
28 27
29# This package's primary purpose is to introduce use of hw.spdmem* sysctl 28# This package's primary purpose is to introduce use of hw.spdmem* sysctl
30# as the source of SPD data; these sysctl variables are only available on 29# as the source of SPD data; these sysctl variables are only available on
31# NetBSD (and only if the spdmem(4) device is configured). 30# NetBSD (and only if the spdmem(4) device is configured).
32ONLY_FOR_PLATFORM= NetBSD-*-* 31ONLY_FOR_PLATFORM= NetBSD-*-*
33 32
34INSTALLATION_DIRS= bin ${PKGMANDIR}/man1 33INSTALLATION_DIRS= bin ${PKGMANDIR}/man1
35 34
36do-install: 35do-install:

cvs diff -r1.23 -r1.24 pkgsrc/sysutils/decode-dimms/distinfo (expand / switch to unified diff)

--- pkgsrc/sysutils/decode-dimms/distinfo 2021/10/26 11:19:29 1.23
+++ pkgsrc/sysutils/decode-dimms/distinfo 2021/10/28 20:18:20 1.24
@@ -1,7 +1,7 @@ @@ -1,7 +1,7 @@
1$NetBSD: distinfo,v 1.23 2021/10/26 11:19:29 nia Exp $ 1$NetBSD: distinfo,v 1.24 2021/10/28 20:18:20 pgoyette Exp $
2 2
3BLAKE2s (i2c-tools-9cba52b9626413307b994af44695b8a9c0e058be.tar.gz) = bcd5b5f2563c4d3447dac5bccba8175073c2c94bb4eb1089d66cc859855eb87f 3BLAKE2s (i2c-tools-d8bc1f1ff4b00a6bd988aa114100ae9b787f50d8.tar.gz) = 874d17dd335c827df520f4617c4becb612a9b252fdab5a6d734d718cc7661d94
4SHA512 (i2c-tools-9cba52b9626413307b994af44695b8a9c0e058be.tar.gz) = 1008fbf6135fa1e1ed53c679cb76b3f4d6d2cfe1ed8f79516625c80b57c5b9b03e6cec391402f43d1cfd35cd75d642e13413a0f52cb1c164d3525a3493860fc1 4SHA512 (i2c-tools-d8bc1f1ff4b00a6bd988aa114100ae9b787f50d8.tar.gz) = 37a8fb5b517bc91595e2faf04c76d95ccaa17ef1e3d1e2ca6feb55130361ea27242997c743201269abba493b0ba495f477a19ffe21061a7181b4be149cf85912
5Size (i2c-tools-9cba52b9626413307b994af44695b8a9c0e058be.tar.gz) = 102950 bytes 5Size (i2c-tools-d8bc1f1ff4b00a6bd988aa114100ae9b787f50d8.tar.gz) = 95051 bytes
6SHA1 (patch-decode-dimms) = 8f8f03cb1bae03a5572bb65f88dfce216f98549f 6SHA1 (patch-decode-dimms) = b964e5df41acb192d04cea01c21ec95222aefc99
7SHA1 (patch-decode-dimms.1) = 349c0af6c639f7752e03f78d089bbb414bc1a2e7 7SHA1 (patch-decode-dimms.1) = 349c0af6c639f7752e03f78d089bbb414bc1a2e7

cvs diff -r1.18 -r1.19 pkgsrc/sysutils/decode-dimms/patches/patch-decode-dimms (expand / switch to unified diff)

--- pkgsrc/sysutils/decode-dimms/patches/patch-decode-dimms 2020/09/07 14:50:25 1.18
+++ pkgsrc/sysutils/decode-dimms/patches/patch-decode-dimms 2021/10/28 20:18:21 1.19
@@ -1,114 +1,114 @@ @@ -1,114 +1,114 @@
1$NetBSD: patch-decode-dimms,v 1.18 2020/09/07 14:50:25 pgoyette Exp $ 1$NetBSD: patch-decode-dimms,v 1.19 2021/10/28 20:18:21 pgoyette Exp $
2 2
3Add NetBSD-specific ability to use spdmem(4)'s sysctl values as 3Add NetBSD-specific ability to use spdmem(4)'s sysctl values as
4input. Remove attempts to use linux-specific data sources. 4input. Remove attempts to use linux-specific data sources.
5 5
6--- eeprom/decode-dimms.orig 2020-09-07 07:41:27.782730720 -0700 6--- eeprom/decode-dimms.orig 2021-07-22 04:10:34.000000000 -0700
7+++ eeprom/decode-dimms 2020-09-07 07:42:58.255264706 -0700 7+++ eeprom/decode-dimms 2021-10-28 13:01:32.530284359 -0700
8@@ -45,8 +45,9 @@ 8@@ -45,8 +45,9 @@
9 use Fcntl qw(:DEFAULT :seek); 9 use Fcntl qw(:DEFAULT :seek);
10 use File::Basename; 10 use File::Basename;
11 use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_merge 11 use vars qw($opt_html $opt_bodyonly $opt_side_by_side $opt_merge
12- $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width 12- $opt_igncheck $use_sysfs $use_hexdump $sbs_col_width
13- @vendors %decode_callback @dimm $current %hexdump_cache); 13- @vendors %decode_callback @dimm $current %hexdump_cache);
14+ $opt_igncheck $use_sysctl $use_hexdump $sbs_col_width 14+ $opt_igncheck $use_sysctl $use_hexdump $sbs_col_width
15+ @vendors %decode_callback @dimm $current %hexdump_cache 15+ @vendors %decode_callback @dimm $current %hexdump_cache
16+ %sysctl_cache); 16+ %sysctl_cache);
17  17
18 use constant LITTLEENDIAN => "little-endian"; 18 use constant LITTLEENDIAN => "little-endian";
19 use constant BIGENDIAN => "big-endian"; 19 use constant BIGENDIAN => "big-endian";
20@@ -497,7 +498,7 @@ 20@@ -497,7 +498,7 @@
21 die "Unexpected number of vendor names in page $page" unless @{$vendors[$page]} == 126; 21 die "Unexpected number of vendor names in page $page" unless @{$vendors[$page]} == 126;
22 } 22 }
23  23
24-$use_sysfs = -d '/sys/bus'; 24-$use_sysfs = -d '/sys/bus';
25+$use_sysctl = 0; 25+$use_sysctl = 0;
26  26
27 # We consider that no data was written to this area of the SPD EEPROM if 27 # We consider that no data was written to this area of the SPD EEPROM if
28 # all bytes read 0x00 or all bytes read 0xff 28 # all bytes read 0x00 or all bytes read 0xff
29@@ -2436,6 +2437,26 @@ 29@@ -2437,6 +2438,26 @@
30 } 30 }
31 } 31 }
32  32
33+# read data from a NetBSD (or equivalent) sysctl variable 33+# read data from a NetBSD (or equivalent) sysctl variable
34+ 34+
35+sub read_sysctl($) 35+sub read_sysctl($)
36+{ 36+{
37+ 37+
38+ # Look in the cache first 38+ # Look in the cache first
39+ return @{$sysctl_cache{$_[0]}} if exists $sysctl_cache{$_[0]}; 39+ return @{$sysctl_cache{$_[0]}} if exists $sysctl_cache{$_[0]};
40+ 40+
41+ my $sysctl_var = sprintf("hw.%s.spd_data", $_[0]); 41+ my $sysctl_var = sprintf("hw.%s.spd_data", $_[0]);
42+ open(PIPE, "-|", "sysctl -r $sysctl_var") 42+ open(PIPE, "-|", "sysctl -r $sysctl_var")
43+ or die "Cannot read sysctl variable $sysctl_var"; 43+ or die "Cannot read sysctl variable $sysctl_var";
44+ sysread(PIPE, my $eeprom, 512); # XXX Assumed maximum size! XXX 44+ sysread(PIPE, my $eeprom, 512); # XXX Assumed maximum size! XXX
45+ close PIPE or die "sysctl returned $?"; 45+ close PIPE or die "sysctl returned $?";
46+ my @bytes = unpack("C*", $eeprom); 46+ my @bytes = unpack("C*", $eeprom);
47+ 47+
48+ # Cache the data for later use 48+ # Cache the data for later use
49+ $sysctl_cache{$_[0]} = \@bytes; 49+ $sysctl_cache{$_[0]} = \@bytes;
50+ return @bytes; 50+ return @bytes;
51+} 51+}
52+ 52+
53 # Read bytes from SPD-EEPROM 53 # Read bytes from SPD-EEPROM
54 # Note: offset must be a multiple of 16! 54 # Note: offset must be a multiple of 16!
55 sub readspd($$$) 55 sub readspd($$$)
56@@ -2449,20 +2470,13 @@ 56@@ -2450,20 +2471,13 @@
57 $size = @bytes - $offset; 57 $size = @bytes - $offset;
58 } 58 }
59 return @bytes[$offset..($offset + $size - 1)]; 59 return @bytes[$offset..($offset + $size - 1)];
60- } elsif ($use_sysfs) { 60- } elsif ($use_sysfs) {
61- # Kernel 2.6 with sysfs 61- # Kernel 2.6 with sysfs
62- sysopen(HANDLE, "$dimm_i/eeprom", O_RDONLY) 62- sysopen(HANDLE, "$dimm_i/eeprom", O_RDONLY)
63- or die "Cannot open $dimm_i/eeprom"; 63- or die "Cannot open $dimm_i/eeprom";
64- binmode HANDLE; 64- binmode HANDLE;
65- sysseek(HANDLE, $offset, SEEK_SET) 65- sysseek(HANDLE, $offset, SEEK_SET)
66- or die "Cannot seek $dimm_i/eeprom"; 66- or die "Cannot seek $dimm_i/eeprom";
67- $read = sysread(HANDLE, my $eeprom, $size) 67- $read = sysread(HANDLE, my $eeprom, $size)
68- or die "Cannot read $dimm_i/eeprom"; 68- or die "Cannot read $dimm_i/eeprom";
69- close HANDLE; 69- close HANDLE;
70- if ($read < $size) { 70- if ($read < $size) {
71- print STDERR "WARNING: $dimm_i/eeprom is smaller than expected\n"; 71- print STDERR "WARNING: $dimm_i/eeprom is smaller than expected\n";
72+ } elsif ($use_sysctl) { 72+ } elsif ($use_sysctl) {
73+ @bytes = read_sysctl($dimm_i); 73+ @bytes = read_sysctl($dimm_i);
74+ if (@bytes < $offset + $size) { 74+ if (@bytes < $offset + $size) {
75+ print STDERR "WARNING: sysctl for $dimm_i is truncated\n"; 75+ print STDERR "WARNING: sysctl for $dimm_i is truncated\n";
76+ $size = @bytes - $offset; 76+ $size = @bytes - $offset;
77 } 77 }
78- @bytes = unpack("C*", $eeprom); 78- @bytes = unpack("C*", $eeprom);
79+ return return @bytes[$offset..($offset + $size - 1)]; 79+ return return @bytes[$offset..($offset + $size - 1)];
80 } else { 80 } else {
81 # Kernel 2.4 with procfs 81 # Kernel 2.4 with procfs
82 for my $i (0 .. ($size-1)/16) { 82 for my $i (0 .. ($size-1)/16) {
83@@ -2528,7 +2542,7 @@ 83@@ -2529,7 +2543,7 @@
84 # Parse command-line 84 # Parse command-line
85 foreach (@ARGV) { 85 foreach (@ARGV) {
86 if ($_ eq '-h' || $_ eq '--help') { 86 if ($_ eq '-h' || $_ eq '--help') {
87- print "Usage: $0 [-c] [-f [-b]] [-x|-X file [files..]]\n", 87- print "Usage: $0 [-c] [-f [-b]] [-x|-X file [files..]]\n",
88+ print "Usage: $0 [-c] [-f [-b]] [-x|-X|-s file [files..]]\n", 88+ print "Usage: $0 [-c] [-f [-b]] [-x|-X|-s file [files..]]\n",
89 " $0 -h\n\n", 89 " $0 -h\n\n",
90 " -f, --format Print nice html output\n", 90 " -f, --format Print nice html output\n",
91 " -b, --bodyonly Don't print html header\n", 91 " -b, --bodyonly Don't print html header\n",
92@@ -2542,6 +2556,8 @@ 92@@ -2543,6 +2557,8 @@
93 " -x, Read data from hexdump files\n", 93 " -x, Read data from hexdump files\n",
94 " -X, Same as -x except treat multibyte hex\n", 94 " -X, Same as -x except treat multibyte hex\n",
95 " data as little endian\n", 95 " data as little endian\n",
96+ " -s, Use NetBSD-compatible sysctl(8) to obtain\n", 96+ " -s, Use NetBSD-compatible sysctl(8) to obtain\n",
97+ " EEPROM data\n", 97+ " EEPROM data\n",
98 " -h, --help Display this usage summary\n"; 98 " -h, --help Display this usage summary\n";
99 print <<"EOF"; 99 print <<"EOF";
100  100
101@@ -2586,85 +2602,25 @@ 101@@ -2587,85 +2603,25 @@
102 $use_hexdump = LITTLEENDIAN; 102 $use_hexdump = LITTLEENDIAN;
103 next; 103 next;
104 } 104 }
105+ if ($_ eq '-s') { 105+ if ($_ eq '-s') {
106+ if (-x "/sbin/sysctl") { 106+ if (-x "/sbin/sysctl") {
107+ $use_sysctl = 1; 107+ $use_sysctl = 1;
108+ } else { die "No /sbin/sysctl available for -s"; } 108+ } else { die "No /sbin/sysctl available for -s"; }
109+ next; 109+ next;
110+ } 110+ }
111  111
112 if (m/^-/) { 112 if (m/^-/) {
113 print STDERR "Unrecognized option $_\n"; 113 print STDERR "Unrecognized option $_\n";
114 exit; 114 exit;
@@ -182,30 +182,30 @@ input. Remove attempts to use linux-spe @@ -182,30 +182,30 @@ input. Remove attempts to use linux-spe
182- } 182- }
183- 183-
184- if (!$opened) { 184- if (!$opened) {
185- print STDERR "No EEPROM found, try loading the eeprom, at24 or ee1004 module\n"; 185- print STDERR "No EEPROM found, try loading the eeprom, at24 or ee1004 module\n";
186- exit; 186- exit;
187- } 187- }
188- 188-
189- return sort { $a->{file} cmp $b->{file} } @files; 189- return sort { $a->{file} cmp $b->{file} } @files;
190-} 190-}
191- 191-
192 # @dimm is a list of hashes. There's one hash for each EEPROM we found. 192 # @dimm is a list of hashes. There's one hash for each EEPROM we found.
193 # Each hash has the following keys: 193 # Each hash has the following keys:
194 # * eeprom: Name of the eeprom data file 194 # * eeprom: Name of the eeprom data file
195@@ -2677,7 +2633,6 @@ 195@@ -2678,7 +2634,6 @@
196 # * chk_spd: The checksum or CRC value found in the EEPROM 196 # * chk_spd: The checksum or CRC value found in the EEPROM
197 # * chk_calc: The checksum or CRC computed from the EEPROM data 197 # * chk_calc: The checksum or CRC computed from the EEPROM data
198 # Keys are added over time. 198 # Keys are added over time.
199-@dimm = get_dimm_list() unless $use_hexdump; 199-@dimm = get_dimm_list() unless $use_hexdump;
200  200
201 for my $i (0 .. $#dimm) { 201 for my $i (0 .. $#dimm) {
202 my @bytes = readspd(0, 128, $dimm[$i]->{file}); 202 my @bytes = readspd(0, 128, $dimm[$i]->{file});
203@@ -2729,7 +2684,7 @@ 203@@ -2730,7 +2685,7 @@
204 printl("Decoding EEPROM", $dimm[$current]->{eeprom}); 204 printl("Decoding EEPROM", $dimm[$current]->{eeprom});
205 } 205 }
206  206
207- if (!$use_hexdump) { 207- if (!$use_hexdump) {
208+ if (!$use_hexdump && !$use_sysctl) { 208+ if (!$use_hexdump && !$use_sysctl) {
209 if ($dimm[$current]->{file} =~ /-([\da-f]+)$/i) { 209 if ($dimm[$current]->{file} =~ /-([\da-f]+)$/i) {
210 my $dimm_num = hex($1) - 0x50 + 1; 210 my $dimm_num = hex($1) - 0x50 + 1;
211 if ($dimm_num >= 1 && $dimm_num <= 8) { 211 if ($dimm_num >= 1 && $dimm_num <= 8) {