From owner-svn-src-stable-11@freebsd.org Mon Apr 22 03:55:04 2019 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E74ED158DDF7; Mon, 22 Apr 2019 03:55:03 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 8E0256F804; Mon, 22 Apr 2019 03:55:03 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 684AF7630; Mon, 22 Apr 2019 03:55:03 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x3M3t3ZP099237; Mon, 22 Apr 2019 03:55:03 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x3M3t2or099233; Mon, 22 Apr 2019 03:55:02 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201904220355.x3M3t2or099233@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Mon, 22 Apr 2019 03:55:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r346518 - in stable/11/usr.sbin: . spi X-SVN-Group: stable-11 X-SVN-Commit-Author: ian X-SVN-Commit-Paths: in stable/11/usr.sbin: . spi X-SVN-Commit-Revision: 346518 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 8E0256F804 X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.98 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.98)[-0.976,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Apr 2019 03:55:04 -0000 Author: ian Date: Mon Apr 22 03:55:02 2019 New Revision: 346518 URL: https://svnweb.freebsd.org/changeset/base/346518 Log: MFC r335527, r335529, r335593 r335527: Add spi(8), a utility for communicating with a device on a SPI bus from userland, conceptually similar to what i2c(8) provides for i2c devices. Submitted by: Bob Frazier Differential Revision: https://reviews.freebsd.org/D15029 r335529: Eliminate gcc "shadowed declaration" warnings by using idx rather than index as a variable name. r335593: Add an example for displaying the manufacturer and size info from a standard spiflash chip. Added: stable/11/usr.sbin/spi/ - copied from r335527, head/usr.sbin/spi/ Modified: stable/11/usr.sbin/Makefile stable/11/usr.sbin/spi/spi.8 stable/11/usr.sbin/spi/spi.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.sbin/Makefile ============================================================================== --- stable/11/usr.sbin/Makefile Mon Apr 22 03:52:11 2019 (r346517) +++ stable/11/usr.sbin/Makefile Mon Apr 22 03:55:02 2019 (r346518) @@ -82,6 +82,7 @@ SUBDIR= adduser \ setpmac \ smbmsg \ snapinfo \ + spi \ spray \ syslogd \ sysrc \ Modified: stable/11/usr.sbin/spi/spi.8 ============================================================================== --- head/usr.sbin/spi/spi.8 Fri Jun 22 01:59:19 2018 (r335527) +++ stable/11/usr.sbin/spi/spi.8 Mon Apr 22 03:55:02 2019 (r346518) @@ -191,6 +191,12 @@ as binary data, piped through displaying it as two hexadecimal unsigned short integer values. .Pp echo "00 01" | spi -A -b -d rw -c 4 | od -t x2 +.It +Query the manufacturer ID and size from a standard spiflash device, by +sending the command byte 0x9f and displaying the 3-byte reply in ASCII hex. +.Pp +spi -f spigen0.0 -m 0 -s 1000000 -d r -c 3 -A -C 9f + .El .Pp .Sh SEE ALSO Modified: stable/11/usr.sbin/spi/spi.c ============================================================================== --- head/usr.sbin/spi/spi.c Fri Jun 22 01:59:19 2018 (r335527) +++ stable/11/usr.sbin/spi/spi.c Mon Apr 22 03:55:02 2019 (r346518) @@ -722,7 +722,7 @@ _read_write(int hdev, void *bufw, void *bufr, int cbrw static int _do_data_output(void *pr, struct spi_options *popt) { - int err, index, icount; + int err, idx, icount; const char *sz_bytes, *sz_byte2; const uint8_t *pbuf; @@ -758,8 +758,8 @@ _do_data_output(void *pr, struct spi_options *popt) sz_bytes); /* ASCII output */ - for (index = 0; !err && index < icount; index++) { - if (index) { + for (idx = 0; !err && idx < icount; idx++) { + if (idx) { /* * not the first time, insert separating space */ @@ -767,7 +767,7 @@ _do_data_output(void *pr, struct spi_options *popt) } if (!err) - err = fprintf(stdout, "%02hhx", pbuf[index]) < 0; + err = fprintf(stdout, "%02hhx", pbuf[idx]) < 0; } if (!err) @@ -902,7 +902,7 @@ static void verbose_dump_buffer(void *pbuf, int icount, int lsb) { uint8_t ch; - int ictr, ictr2, index; + int ictr, ictr2, idx; fputs(" | 0 1 2 3 4 5 6 7 8 9 A B C D E F " "| |\n", stderr); @@ -911,10 +911,10 @@ verbose_dump_buffer(void *pbuf, int icount, int lsb) fprintf(stderr, " %6x | ", ictr & 0xfffff0); for (ictr2 = 0; ictr2 < 16; ictr2++) { - index = ictr + ictr2; + idx = ictr + ictr2; - if (index < icount) { - ch = ((uint8_t *) pbuf)[index]; + if (idx < icount) { + ch = ((uint8_t *) pbuf)[idx]; if (lsb) ch = reversebits[ch]; @@ -929,10 +929,10 @@ verbose_dump_buffer(void *pbuf, int icount, int lsb) fputs("| ", stderr); for (ictr2 = 0; ictr2 < 16; ictr2++) { - index = ictr + ictr2; + idx = ictr + ictr2; - if (index < icount) { - ch = ((uint8_t *) pbuf)[index]; + if (idx < icount) { + ch = ((uint8_t *) pbuf)[idx]; if (lsb) ch = reversebits[ch]; @@ -942,7 +942,7 @@ verbose_dump_buffer(void *pbuf, int icount, int lsb) fprintf(stderr, "%c", ch); } - else if (index < icount) { + else if (idx < icount) { out_of_range: fputc('.', stderr); }