Date: Tue, 03 Sep 2019 14:07:19 -0000 From: Ian Lepore <ian@FreeBSD.org> 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 Message-ID: <201904220355.x3M3t2or099233@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904220355.x3M3t2or099233>