SPI Sniffer

Hacking multi-tool. Get one for $30, including worldwide shipping.

SPI Sniffer

Postby RoadRanger » Fri Feb 04, 2011 2:19 pm

OK, so I'm trying to sniff SPI too fast for the built-in sniffer ("Couldn't keep up") so I downloaded the binary sniffer proggy. Anybody have any idea what it's complaining about? I'm running 4.4/5.10 on the BP. The bus pirate is working normally on com3 otherwise.

-----------------------------------------------------------------------------

Bus Pirate binary mode SPI SNIFFER utility v0.3 (CC-0)
http://dangerousprototypes.com

-----------------------------------------------------------------------------

Parameters used:
Device = COM3, Speed = 115200, Clock Edge= 1, Polarity= 0 RawData= 0

Opening Bus Pirate on COM3 at 115200bps...
Starting SPI sniffer...
Configuring Bus Pirate...
Entering binary mode...
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate:Too many tries in serial read! -exiting
- chip not detected, or not readable/writable
Buspirate cannot switch to binary mode :(
Exiting...
RoadRanger
Newbie
Newbie
 
Posts: 9
Joined: Thu Feb 03, 2011 1:28 pm

Re: SPI Sniffer

Postby RoadRanger » Fri Feb 04, 2011 3:56 pm

I just noticed that the "improved" version I bought has a different USB-to-serial chip that the "official" bus pirate - could this be why the binary sniffer and pirate ship don't work with it?
http://cgi.ebay.com/ws/eBayISAPI.dll?Vi ... 0580280916
As I said it works fine in putty. I'm also running Windows 7 x64 which could be an issue? Thanks!
RoadRanger
Newbie
Newbie
 
Posts: 9
Joined: Thu Feb 03, 2011 1:28 pm

Re: SPI Sniffer

Postby ian » Sat Feb 05, 2011 5:29 am

Entering binary mode...
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1


I'd be more suspicious of the firmware than the converter chip. Maybe the most recent firmware is broken, I added a test to my to-do list.

What happens is the app sends 0x00 20 times to enter binary mode. The Bus Pirate should reply BBIO1. It is saying that doesn't happen.

We could get a closer look if you ran all these apps again while running portmon (free app from MS, google it). Please post the output, then we can see what is sent and what is received. You may need to configure it for HEX display, I forget.

On the other hand, it could be the 'improved' bus pirate. Did you post output earlier? I thought I remember seeing a DEV ID that didn't look right :) The next version of the firmware will tattle on those chips ;) It's 0x044F?
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: SPI Sniffer

Postby RoadRanger » Sat Feb 05, 2011 7:13 pm

Bus Pirate v3b
Firmware v5.10 (r559) Bootloader v4.4
DEVID:0x044F REVID:0x3043 (24FJ64GA002 B5)
http://dangerousprototypes.com

It's got a PL-2303 USB-to-serial chip in it. I don't know it the binary SPi sniffer is trying to put the chip in a >115200 mode or something? That probably requires the original chip :( .

"PortMon" doesn't appear to be compatible with my computer - i get an "Error 2" - I'm running Windows 7 x64.
RoadRanger
Newbie
Newbie
 
Posts: 9
Joined: Thu Feb 03, 2011 1:28 pm

Re: SPI Sniffer

Postby RoadRanger » Sat Feb 05, 2011 7:51 pm

Using "advanced serial port monitor" from AGG software, looks like it tried to boost the baud rate to 10,555,136 ? :

<20110205194726.614 SYS>
COM port is opened
<20110205194726.665 SYS>
Baud rate 10555136
<20110205194726.665 SYS>
DTR off
<20110205194726.665 SYS>
RTS off
<20110205194726.665 SYS>
Data bits=8, Stop bits=1, Parity=None
<20110205194726.665 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x00, Xoff=0x00
<20110205194726.667 SYS>
Handflow: ControlHandShake=(), FlowReplace=(), XonLimit=0, XoffLimit=0
<20110205194726.667 SYS>
Set timeouts: ReadInterval=100, ReadTotalTimeoutMultiplier=10, ReadTotalTimeoutConstant=100, WriteTotalTimeoutMultiplier=10, WriteTotalTimeoutConstant=100
<20110205194726.668 TX>
<NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL><NUL>
<20110205194730.620 SYS>
COM port is closed
Last edited by RoadRanger on Sat Feb 05, 2011 8:04 pm, edited 1 time in total.
RoadRanger
Newbie
Newbie
 
Posts: 9
Joined: Thu Feb 03, 2011 1:28 pm

Re: SPI Sniffer

Postby RoadRanger » Sat Feb 05, 2011 8:04 pm

Just for reference here's the log from connecting with putty, note the expected baud rate:

<20110205200157.165 SYS>
COM port is opened
<20110205200157.228 SYS>
Baud rate 115200
<20110205200157.228 SYS>
RTS on
<20110205200157.228 SYS>
DTR on
<20110205200157.228 SYS>
Data bits=8, Stop bits=1, Parity=None
<20110205200157.228 SYS>
Set chars: Eof=0x00, Error=0x00, Break=0x00, Event=0x00, Xon=0x00, Xoff=0x00
<20110205200157.228 SYS>
Handflow: ControlHandShake=(DTR_CONTROL), FlowReplace=(AUTO_TRANSMIT, AUTO_RECEIVE, TRANSMIT_TOGGLE, RTS_CONTROL), XonLimit=2048, XoffLimit=512
<20110205200157.228 SYS>
Set timeouts: ReadInterval=1, ReadTotalTimeoutMultiplier=0, ReadTotalTimeoutConstant=0, WriteTotalTimeoutMultiplier=0, WriteTotalTimeoutConstant=0
RoadRanger
Newbie
Newbie
 
Posts: 9
Joined: Thu Feb 03, 2011 1:28 pm

Re: SPI Sniffer

Postby ian » Sun Feb 06, 2011 3:47 am

That's probably it. Someone did a bit of work to try it at unsupported high baud rates. They gave me a patch for it, I bet it is set to default to 1Mbaud. There might be a command line option that sets the baud rate (sorry, been a while since I wrote it).

That for the update on portmon, I didn't know it was unsupported on win7 64.
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: SPI Sniffer

Postby chris4711 » Tue Mar 08, 2011 7:15 am

Hi all :)
I bought a BP to sniff some SPI and i have exactly the same problem. My BP is also using the PL-2303 chip instead of the FTDI one. So i wanted to ask if you were able to solve the problem with the SpiSniffer tool?

Thanks!
chris4711
Newbie
Newbie
 
Posts: 2
Joined: Tue Mar 08, 2011 7:09 am

Re: SPI Sniffer

Postby Sandbox » Tue Mar 08, 2011 9:48 am

Hi,

I am the author of the "modified" version of Bus Pirate.

I found the same problem today when I tried to use the utility.After some investigation of the source code of the utility, I found that it tried to force type-cast "a pointer" to "a long" and then pass that casted variable to the serial port setup function. I've fixed this and it works fine now.

The reason why FT232RL doesn't have such problem is not clear. I guess that it has something to do with the error handling capability ofthe chip. In case FT232RL isn't configured properly (e.g. with an invalid baudrate), it will probably use the default setting which is 115200bps.

--------------------------------------------
Some contexts:
typedef long speed_t;
char *param_speed = NULL;

The old function call:
serial_setup(fd,(speed_t) param_speed);

The modified function call:
serial_setup(fd,strtol(param_speed,NULL,0));
--------------------------------------------

The attachement are the revised binary and the source code:
SPIsniffer.zip
Binary
(7.55 KiB) Downloaded 355 times

BusPirate.SPIsniffer.v0.3_revised.zip
Source Code
(107.27 KiB) Downloaded 360 times



Here is the log before the revision is made

===========================================================================================================================================
0 0.23939942 SPIsniffer.exe IRP_MJ_CREATE ProlificSerial0 SUCCESS Options: Open
1 0.00001592 SPIsniffer.exe IOCTL_SERIAL_GET_BAUD_RATE ProlificSerial0 SUCCESS
2 0.00000391 SPIsniffer.exe IOCTL_SERIAL_GET_LINE_CONTROL ProlificSerial0 SUCCESS
3 0.00000391 SPIsniffer.exe IOCTL_SERIAL_GET_CHARS ProlificSerial0 SUCCESS
4 0.00000363 SPIsniffer.exe IOCTL_SERIAL_GET_HANDFLOW ProlificSerial0 SUCCESS
5 0.05434797 SPIsniffer.exe IOCTL_SERIAL_SET_BAUD_RATE ProlificSerial0 SUCCESS Rate: 5574536
6 0.00242042 SPIsniffer.exe IOCTL_SERIAL_CLR_RTS ProlificSerial0 SUCCESS
7 0.00296630 SPIsniffer.exe IOCTL_SERIAL_CLR_DTR ProlificSerial0 SUCCESS
8 0.00400638 SPIsniffer.exe IOCTL_SERIAL_SET_LINE_CONTROL ProlificSerial0 SUCCESS StopBits: 1 Parity: NONE WordLength: 8
9 0.00003855 SPIsniffer.exe IOCTL_SERIAL_SET_CHAR ProlificSerial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:0 XOFF:0
10 0.00000503 SPIsniffer.exe IOCTL_SERIAL_SET_HANDFLOW ProlificSerial0 SUCCESS Shake:0 Replace:0 XonLimit:0 XoffLimit:0
11 0.00000419 SPIsniffer.exe IOCTL_SERIAL_SET_TIMEOUTS ProlificSerial0 SUCCESS RI:100 RM:10 RC:100 WM:10 WC:100
12 0.00047436 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
13 0.15038559 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
14 0.00032211 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
15 0.15040068 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
16 0.00095934 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
17 0.15035877 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
18 0.00067327 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
19 0.15039006 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
20 0.00032993 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
21 0.15039565 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
22 0.00088615 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
23 0.15039034 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
24 0.00058946 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
25 0.15038671 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
26 0.00035423 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
27 0.15039286 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
28 0.00101102 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
29 0.15040962 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
30 0.00093476 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
31 0.15040180 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
32 0.00064366 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
33 0.15039761 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
34 0.00032378 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
35 0.15039425 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
36 0.00096828 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
37 0.15038811 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
38 0.00065539 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
39 0.15039062 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
40 0.00033189 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
41 0.15038783 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
42 0.00096996 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
43 0.15039230 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
44 0.00064561 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
45 0.15039649 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
46 0.00029752 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
47 0.15039705 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
48 0.00093504 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
49 0.15024647 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
50 0.00065818 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
51 0.15038392 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
52 0.00031764 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
53 0.15038615 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
54 0.00074535 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
55 0.15038084 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
56 0.00104008 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
57 0.15038168 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
58 0.00038133 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
59 0.15039481 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
60 0.00103337 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
61 0.15038867 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
62 0.00070819 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
63 0.15039146 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
64 0.00001704 SPIsniffer.exe IRP_MJ_CLEANUP ProlificSerial0 SUCCESS
65 0.07334312 SPIsniffer.exe IRP_MJ_CLOSE ProlificSerial0 SUCCESS
==============================================================================================
Here is the result we got from console BEFORE the revision is made:

C:\Users\Peng\Desktop\BusPirate.SPIsniffer.v0.3\SPISniffer\bin\Release>spisniffer -d COM4
-----------------------------------------------------------------------------

Bus Pirate binary mode SPI SNIFFER utility v0.3 (CC-0)
http://dangerousprototypes.com

-----------------------------------------------------------------------------

Parameters used:
Device = COM4, Speed = 115200, Clock Edge= 1, Polarity= 0 RawData= 0

Opening Bus Pirate on COM4 at 115200bps...
Starting SPI sniffer...
Configuring Bus Pirate...
Entering binary mode...
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate did not respond correctly :( -1
Buspirate:Too many tries in serial read! -exiting
- chip not detected, or not readable/writable
Buspirate cannot switch to binary mode :(
Exiting...

====================================================================================================
Here is the log after the revision is made:

0 0.20366806 SPIsniffer.exe IRP_MJ_CREATE ProlificSerial0 SUCCESS Options: Open
1 0.00001760 SPIsniffer.exe IOCTL_SERIAL_GET_BAUD_RATE ProlificSerial0 SUCCESS
2 0.00000391 SPIsniffer.exe IOCTL_SERIAL_GET_LINE_CONTROL ProlificSerial0 SUCCESS
3 0.00000391 SPIsniffer.exe IOCTL_SERIAL_GET_CHARS ProlificSerial0 SUCCESS
4 0.00000363 SPIsniffer.exe IOCTL_SERIAL_GET_HANDFLOW ProlificSerial0 SUCCESS
5 0.08448057 SPIsniffer.exe IOCTL_SERIAL_SET_BAUD_RATE ProlificSerial0 SUCCESS Rate: 115200
6 0.00280818 SPIsniffer.exe IOCTL_SERIAL_CLR_RTS ProlificSerial0 SUCCESS
7 0.00296071 SPIsniffer.exe IOCTL_SERIAL_CLR_DTR ProlificSerial0 SUCCESS
8 0.00423545 SPIsniffer.exe IOCTL_SERIAL_SET_LINE_CONTROL ProlificSerial0 SUCCESS StopBits: 1 Parity: NONE WordLength: 8
9 0.00002794 SPIsniffer.exe IOCTL_SERIAL_SET_CHAR ProlificSerial0 SUCCESS EOF:0 ERR:0 BRK:0 EVT:0 XON:0 XOFF:0
10 0.00000503 SPIsniffer.exe IOCTL_SERIAL_SET_HANDFLOW ProlificSerial0 SUCCESS Shake:0 Replace:0 XonLimit:0 XoffLimit:0
11 0.00000391 SPIsniffer.exe IOCTL_SERIAL_SET_TIMEOUTS ProlificSerial0 SUCCESS RI:100 RM:10 RC:100 WM:10 WC:100
12 0.00028076 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
13 0.15032497 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
14 0.00075484 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
15 0.00000894 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 SUCCESS Length 5: BBIO1
16 0.00062187 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
17 0.00000810 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 SUCCESS Length 4: SPI1
18 0.00069618 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
19 0.00000615 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 SUCCESS Length 1: .
20 0.00085346 SPIsniffer.exe IRP_MJ_WRITE ProlificSerial0 SUCCESS Length 1: .
21 0.10059016 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 1: .
22 1.10058709 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
23 1.10057647 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
24 1.10058764 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
25 1.10058541 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
26 1.10056138 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
27 1.10057954 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
28 1.10059128 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
29 1.10058401 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 TIMEOUT Length 0:
30 0.39124581 SPIsniffer.exe IRP_MJ_READ ProlificSerial0 CANCELLED Length 100
31 0.00001173 SPIsniffer.exe IRP_MJ_CLEANUP ProlificSerial0 SUCCESS
32 0.07229885 SPIsniffer.exe IRP_MJ_CLOSE ProlificSerial0 SUCCESS
================================================================================================

Here is the result we got from console AFTER the revision is made:

C:\Users\Peng\Desktop\BusPirate.SPIsniffer.v0.3\SPISniffer\bin\Release>spisniffer -d COM4
-----------------------------------------------------------------------------

Bus Pirate binary mode SPI SNIFFER utility v0.3 (CC-0)
http://dangerousprototypes.com

-----------------------------------------------------------------------------

Parameters used:
Device = COM4, Speed = 115200, Clock Edge= 1, Polarity= 0 RawData= 0

Opening Bus Pirate on COM4 at 115200bps...
Starting SPI sniffer...
Configuring Bus Pirate...
Entering binary mode...
Switching to SPI mode
Setting Clockedge/Polarity ...... CKE=1OK
01 Sync
Sandbox
Newbie
Newbie
 
Posts: 1
Joined: Tue Mar 08, 2011 8:21 am

Re: SPI Sniffer

Postby chris4711 » Tue Mar 08, 2011 12:43 pm

Nice! It seeems to work :)
Thank you very much for this quick help :)
chris4711
Newbie
Newbie
 
Posts: 2
Joined: Tue Mar 08, 2011 7:09 am

Re: SPI Sniffer

Postby ian » Sat Mar 12, 2011 3:08 am

Thanks for the update, I'll add the new version to SVN if that is ok.
User avatar
ian
Crew
Crew
 
Posts: 10803
Joined: Mon Jul 06, 2009 6:14 am

Re: SPI Sniffer

Postby andrewhannay » Thu Oct 05, 2017 10:32 am

Hi,
I know it's been 6 years since this topic was discussed, but I am actively using bus pirate and this SPI sniffer utility.
Oddly enough the version of SPI Sniffer I downloaded was not the latest one posted here.
I am using the SPI Sniffer at 2000000 baud and it works really well, but only if I use the updated version posted here.
If the author is still reading this forum I have a few questions.
I'm using it in raw mode and I notice that every byte is displayed twice so I get:-
5B 5B 5C 5C xx xx yy yy 5D 5D when it should be 5B 5C xx yy 5D which is odd. where xx and yy are the MOSI and MISO data
If I monitor the output on realterm I get the [\xy] so I know it's not Bus Pirate sending each byte twice.
Any idea what the reason is for this?
I would like to modify the code if that is Ok as I would like to format and strip the data when I save the output to a file (I'm trying to sniff a serial ADC which outputs 24 clock pulses - where the first 5 clocks are idle followed by 16 clocks of data bits followed by 3 clocks of idle) so a little shifting is required.
What compiler did you use to create the exe for windows command prompt?
I would like to have SPI Sniffer setup Bus Pirate to switch from 115200 to 2000000 baud automatically, or would it be better to modify Bus Pirate to startup in 2000000baud for my application?
Hopefully someone is reading this :-)
Many Thanks,
Andrew
andrewhannay
Newbie
Newbie
 
Posts: 3
Joined: Thu Oct 05, 2017 10:13 am

Re: SPI Sniffer

Postby USBEprom » Thu Oct 05, 2017 2:53 pm

Hi andrewhannay.
What do you mean by writing
andrewhannay wrote:Oddly enough the version of SPI Sniffer I downloaded was not the latest one posted here.
?
Where you downloaded the version you are talking about?
Is your Bus Pirate a revision 3 or a revision 4?
Thanks.
For what i can see SPIsniffer.v0.3.exe is exactly the same as SPIsniffer.v0.3_revised_source code.exe, the two files are exactly identical.
I always used the standard SPIsniffer.v0.3.exe and I have never noticed what you wrote, I use -r 0 though.
Can you provide your settings?
Thanks.
About the SPI sniffer output more instructions are inside the documentation for SPI binary mode as well as the following ones that you surely already know.
For Raw output decoding SPIsniffer.v0.3.exe attempts to decode the output to human-readable format.
The old raw mode is still available with the -r flag.

Here's a quick example:

5B 5C 01 00 5C 02 00 5C 03 00 5D


This output was sniffed from another Bus Pirate that sent [ 0x01 0x02 0x03 ], which is also: CS low, 1, 2, 3, CS high.
5B - ASCII code for [ (CS low).
5C - ASCII code for \, escapes each data pair, this is repeated with each byte pair so you can find your place in the datastream.
01 - Value sniffed on the Bus Pirate MOSI pin.
00 - Value sniffed on the MISO pin.
5C - \, escapes the next data pair.
02 - Value sniffed on the MOSI pin.
00 - Value sniffed on the MISO pin.
5C - \, escapes the next data pair.
03 - Value sniffed on MOSI pin.
00 - Value sniffed on MISO pin.
5D - ASCII code for ] (CS high).

Limitations
Currently only sniffs when CS low with default SPI settings.
This can be changed by modifying the source, but should be added as a command line option.

andrewhannay wrote:What compiler did you use to create the exe for windows command prompt?


I know nothing, sorry, inside the source code I see "C" and framework though.

andrewhannay wrote:I would like to have SPI Sniffer setup Bus Pirate to switch from 115200 to 2000000 baud automatically, or would it be better to modify Bus Pirate to startup in 2000000baud for my application?


For what I know you have to use both.
Via the terminal you have to set Bus Pirate for the baud rate you want, close the terminal and then start SPIsniffer.v0.3.exe using the same speed chosen before.
Please, take a look at this:

viewtopic.php?f=4&t=6765

Be seeing you.

U.Sb
USBEprom
Full Member
Full Member
 
Posts: 158
Joined: Wed Mar 14, 2012 4:09 pm

Re: SPI Sniffer

Postby andrewhannay » Fri Oct 06, 2017 3:41 am

Thanks for the reply No. 6,
I was having issues trying to set up SPI sniffing at high speed baud rates, then I found this thread and downloaded the attachment in one of the posts above(scroll up this page and you'll see it) and it worked.
Bus Pirate v3.6 pcb with v5.10 firmware
I'm using a baud rate of 2000000 so I have to set up the baud rate on Realterm first then quit and start up SPI sniffer with the same baud rate of 2000000 and -r 1
I am sniffing data with a clock rate of 4Mhz with 3 bytes per message and 60 messages every 10ms so I need to pipe 18000 bytes/second (144000 bps) to the PC. It doesn't help having all the extra padding that bus pirate adds for CS as that increases the payload by a factor of 6 which means I am approaching 1Mbps so having 2 of everything can't help.
I would like to use the SPI sniffer to log data to a file so it would be handy to start it up with only one piece of software instead of having to go through the rigmarole of starting up Realterm first.
I understand that the code is written in C I just want to know if it was Microsoft compiler or a command line style compiler.
I have already read the info in the links you included before posting here and have had success, I'm just trying to push it further than most people probably use it.

Thinking about it, It might make more sense to modify the bus pirate source to start up in a higher baud rate and strip out the unnecessary CS info in SPI sniff mode.
Thanks again.
Andrew
andrewhannay
Newbie
Newbie
 
Posts: 3
Joined: Thu Oct 05, 2017 10:13 am

Re: SPI Sniffer

Postby USBEprom » Fri Oct 06, 2017 2:07 pm

Hi andrewhannay.

andrewhannay wrote:Bus Pirate v3.6 pcb with v5.10 firmware
I'm using a baud rate of 2000000 so I have to set up the baud rate on Realterm first then quit and start up SPI sniffer with the same baud rate of 2000000 and -r 1


Firmware v5.10 is pretty old and known as to having problems with SPI, perhaps it is better to upgrade it to something new release.
Maybe that can help.

andrewhannay wrote:I am sniffing data with a clock rate of 4Mhz with 3 bytes per message and 60 messages every 10ms so I need to pipe 18000 bytes/second (144000 bps) to the PC. It doesn't help having all the extra padding that bus pirate adds for CS as that increases the payload by a factor of 6 which means I am approaching 1Mbps so having 2 of everything can't help.


In order to log SPI traffic directly you can try to take a look at this:

viewtopic.php?f=4&t=5851&hilit=app+name+%26amp%3Bgt%3B+output_file.txt

andrewhannay wrote:Thinking about it, It might make more sense to modify the bus pirate source to start up in a higher baud rate and strip out the unnecessary CS info in SPI sniff mode.


As someone already wrote somewhere here in the forum, baudrate entry from the terminal is possible, so it is not really best to change the source.
However wanting it is surely possible to build a own custom firmware.
I have just tried to build a custom firmware by changing line number 171 in main.c and line 247 in binary_io.c of source code, sadly without success though.
I must to deep the matter.
Another way might be to use scripting.

Be seeing you.

U.Sb
USBEprom
Full Member
Full Member
 
Posts: 158
Joined: Wed Mar 14, 2012 4:09 pm

Next

Return to Bus Pirate Support