├── vc2017
├── Resource.rc
├── version.h
├── resource.h
├── SpiFlash.sln
├── SpiFlash.vcxproj.filters
└── SpiFlash.vcxproj
├── prebuilt
├── SpiFlashSetup_1.0.3.0.msi
├── win32
│ └── SpiFlashAnalyzer.dll
├── win64
│ └── SpiFlashAnalyzer.dll
└── SpiFlashSetup_1.0.3.0.x64.msi
├── LICENSE
├── README.md
├── vc2015
├── SpiFlash.sln
├── SpiFlash.vcxproj.filters
└── SpiFlash.vcxproj
├── rename_analyzer.py
├── source
├── SpiFlashAnalyzerResults.h
├── SpiFlashSimulationDataGenerator.h
├── SpiFlashAnalyzerSettings.h
├── SpiFlashAnalyzer.h
├── SpiFlashSimulationDataGenerator.cpp
├── SpiFlashAnalyzerSettings.cpp
├── SpiFlashAnalyzerResults.cpp
├── SpiFlash.h
├── SpiFlashAnalyzer.cpp
└── SpiFlash.cpp
└── .gitignore
/vc2017/Resource.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kasjer/saleae_spiflash/HEAD/vc2017/Resource.rc
--------------------------------------------------------------------------------
/prebuilt/SpiFlashSetup_1.0.3.0.msi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kasjer/saleae_spiflash/HEAD/prebuilt/SpiFlashSetup_1.0.3.0.msi
--------------------------------------------------------------------------------
/prebuilt/win32/SpiFlashAnalyzer.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kasjer/saleae_spiflash/HEAD/prebuilt/win32/SpiFlashAnalyzer.dll
--------------------------------------------------------------------------------
/prebuilt/win64/SpiFlashAnalyzer.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kasjer/saleae_spiflash/HEAD/prebuilt/win64/SpiFlashAnalyzer.dll
--------------------------------------------------------------------------------
/prebuilt/SpiFlashSetup_1.0.3.0.x64.msi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kasjer/saleae_spiflash/HEAD/prebuilt/SpiFlashSetup_1.0.3.0.x64.msi
--------------------------------------------------------------------------------
/vc2017/version.h:
--------------------------------------------------------------------------------
1 | #ifndef VERSION_H
2 | #define VERSION_H
3 |
4 | #ifndef VERSION_MAJOR
5 | #define VERSION_MAJOR 1
6 | #endif
7 | #ifndef VERSION_MINOR
8 | #define VERSION_MINOR 0
9 | #endif
10 | #ifndef VERSION_3
11 | #define VERSION_3 3
12 | #endif
13 | #ifndef VERSION_4
14 | #define VERSION_4 0
15 | #endif
16 |
17 | #ifndef VERSION_STRING
18 | #define VERSION_STRING "1.0.3.0"
19 | #endif
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/vc2017/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by Resource.rc
4 |
5 | // Next default values for new objects
6 | //
7 | #ifdef APSTUDIO_INVOKED
8 | #ifndef APSTUDIO_READONLY_SYMBOLS
9 | #define _APS_NEXT_RESOURCE_VALUE 101
10 | #define _APS_NEXT_COMMAND_VALUE 40001
11 | #define _APS_NEXT_CONTROL_VALUE 1001
12 | #define _APS_NEXT_SYMED_VALUE 101
13 | #endif
14 | #endif
15 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 kasjer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SPI flash protocol analyzer for Saleae
2 |
3 | Protocol analyzer for SPI flash decodes single, dual and quad commands.
4 | Several manufacturer specific command sets can be used.
5 | Most flashes can work in SPI mode 0 and 3, analyzer detects mode automatically or it can be set manually.
6 |
7 | # Features
8 | - SPI0 and SPI3 mode
9 | - Single, dual and quad mode
10 | - Commands for changing between single and quad or dual mode detected
11 | - Continues read mode detected
12 | - Register bit fields decoded
13 | - Following manufacturers command sets supported:
14 | - Winbond
15 | - Macronix
16 | - GigaDevice
17 | - Adesto
18 | - Microchip
19 | - Micron
20 | - Cypress
21 | - Issi
22 |
23 | # Installation
24 |
25 | For Windows there are two msi files in prebuilt folder, that will add analyzer to the existing Saleae Logic installation folder.
26 |
27 | Manual installation
28 | Simply put SpiFlashAnalyzer.dll in the Saleae *Analyzers* folder (typically: C:\Program Files\Saleae LLC\Analyzers).
29 |
30 | For Linux and Mac OSX library needs to be build with Saleae provided build_analyzer.py script. The library then can be copied to *Analyzer* folder in the Logic installation folder.
31 |
--------------------------------------------------------------------------------
/vc2015/SpiFlash.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpiFlash", "SpiFlash.vcxproj", "{B396B091-5789-4294-A4EE-956A3E8CD46E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Debug|x64.ActiveCfg = Debug|x64
17 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Debug|x64.Build.0 = Debug|x64
18 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Debug|x86.ActiveCfg = Debug|Win32
19 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Debug|x86.Build.0 = Debug|Win32
20 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Release|x64.ActiveCfg = Release|x64
21 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Release|x64.Build.0 = Release|x64
22 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Release|x86.ActiveCfg = Release|Win32
23 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/vc2017/SpiFlash.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SpiFlashAnalyzer", "SpiFlash.vcxproj", "{B396B091-5789-4294-A4EE-956A3E8CD46E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Debug|x64.ActiveCfg = Debug|x64
17 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Debug|x64.Build.0 = Debug|x64
18 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Debug|x86.ActiveCfg = Debug|Win32
19 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Debug|x86.Build.0 = Debug|Win32
20 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Release|x64.ActiveCfg = Release|x64
21 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Release|x64.Build.0 = Release|x64
22 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Release|x86.ActiveCfg = Release|Win32
23 | {B396B091-5789-4294-A4EE-956A3E8CD46E}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/vc2015/SpiFlash.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 | Header Files
43 |
44 |
45 | Header Files
46 |
47 |
48 | Header Files
49 |
50 |
51 |
--------------------------------------------------------------------------------
/rename_analyzer.py:
--------------------------------------------------------------------------------
1 | import os
2 | import glob
3 |
4 | # Fix Python 2.x.
5 | try:
6 | input = raw_input
7 | except NameError: pass
8 |
9 | print("")
10 | print("")
11 | print("What would you like to call your new analyzer?")
12 | print("")
13 | print(">>The files under '/source' will be modified to use it.")
14 | print(">>Examples include Serial, MySerial, JoesSerial, Gamecube, Wiimote, 2Wire, etc.")
15 | print(">>Do not inclide the trailing word 'Analyzer' this will be added automaticly.")
16 | print("")
17 | print("(press CTRL-C to cancel)")
18 | print("")
19 |
20 | new_analyzer_name = input( "Your new analyzer name: " )
21 |
22 | print("")
23 | print("")
24 | print("What is the analyzer's title? (as shown in the add new anlayzer drop down)")
25 | print("")
26 | print(">>Examples include Async Serial, I2C, Joe's Serial, Gamecube, Wiimote, 2Wire, etc.")
27 | print("")
28 | print("(press CTRL-C to cancel)")
29 | print("")
30 |
31 | new_analyzer_title = input( "Your new analyzer's title: " )
32 |
33 | source_path = "source"
34 | os.chdir( source_path )
35 |
36 | files = dict()
37 |
38 | original_name = "SimpleSerial"
39 |
40 | cpp_files = glob.glob( "*.cpp" );
41 | h_files = glob.glob( "*.h" );
42 |
43 | for file in cpp_files:
44 | files[file] = ".cpp"
45 |
46 | for file in h_files:
47 | files[ file ] = ".h"
48 |
49 | new_files = []
50 |
51 | for file, extension in files.items():
52 | name_root = file.replace( original_name, "" )
53 | new_name = new_analyzer_name + name_root
54 | #print "renaming file " + file + " to " + new_name
55 | os.rename( file, new_name )
56 | new_files.append( new_name )
57 |
58 | for file in new_files:
59 | contents = open( file, 'r' ).read()
60 | contents = contents.replace( original_name + "Analyzer", new_analyzer_name + "Analyzer" )
61 | contents = contents.replace( original_name.upper() + "_ANALYZER_", new_analyzer_name.upper() + "_ANALYZER_" )
62 | contents = contents.replace( original_name.upper() + "_SIMULATION_DATA_GENERATOR", new_analyzer_name.upper() + "_SIMULATION_DATA_GENERATOR" )
63 | contents = contents.replace( original_name + "SimulationDataGenerator", new_analyzer_name + "SimulationDataGenerator" )
64 | contents = contents.replace( "Simple Serial", new_analyzer_title )
65 | open( file, 'w' ).write( contents )
66 |
67 |
--------------------------------------------------------------------------------
/vc2017/SpiFlash.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 | Source Files
29 |
30 |
31 | Source Files
32 |
33 |
34 |
35 |
36 | Header Files
37 |
38 |
39 | Header Files
40 |
41 |
42 | Header Files
43 |
44 |
45 | Header Files
46 |
47 |
48 | Header Files
49 |
50 |
51 | Header Files
52 |
53 |
54 | Header Files
55 |
56 |
57 |
58 |
59 | Resource Files
60 |
61 |
62 |
--------------------------------------------------------------------------------
/source/SpiFlashAnalyzerResults.h:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright(c) 2017 Jerzy Kasenberg
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files(the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions :
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | #ifndef SPIFLASH_ANALYZER_RESULTS
25 | #define SPIFLASH_ANALYZER_RESULTS
26 |
27 | #include
28 |
29 | enum FrameType
30 | {
31 | FT_OUT_BYTE,
32 | FT_OUT_ADDR24,
33 | FT_OUT_ADDR32,
34 | FT_IN_BYTE,
35 | FT_CMD,
36 | FT_CMD_BYTE,
37 | FT_DUMMY,
38 | FT_IN_OUT,
39 | FT_M,
40 | FT_IN_REG,
41 | FT_OUT_REG,
42 | };
43 |
44 | class SpiFlashAnalyzer;
45 | class SpiFlashAnalyzerSettings;
46 | class RegisterData;
47 |
48 | class SpiFlashAnalyzerResults : public AnalyzerResults
49 | {
50 | void AddResult(const std::string &str) { AddResultString(str.c_str()); }
51 | void AddRegisterResult(RegisterData *reg, U64 val, DisplayBase display_base);
52 | public:
53 | SpiFlashAnalyzerResults( SpiFlashAnalyzer* analyzer, SpiFlashAnalyzerSettings* settings );
54 | virtual ~SpiFlashAnalyzerResults();
55 |
56 | virtual void GenerateBubbleText( U64 frame_index, Channel& channel, DisplayBase display_base );
57 | virtual void GenerateExportFile( const char* file, DisplayBase display_base, U32 export_type_user_id );
58 |
59 | virtual void GenerateFrameTabularText(U64 frame_index, DisplayBase display_base );
60 | virtual void GeneratePacketTabularText( U64 packet_id, DisplayBase display_base );
61 | virtual void GenerateTransactionTabularText( U64 transaction_id, DisplayBase display_base );
62 |
63 | protected: //functions
64 |
65 | protected: //vars
66 | SpiFlashAnalyzerSettings* mSettings;
67 | SpiFlashAnalyzer* mAnalyzer;
68 | };
69 |
70 | #endif //SPIFLASH_ANALYZER_RESULTS
71 |
--------------------------------------------------------------------------------
/source/SpiFlashSimulationDataGenerator.h:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright(c) 2017 Jerzy Kasenberg
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files(the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions :
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | #ifndef SPIFLASH_SIMULATION_DATA_GENERATOR
25 | #define SPIFLASH_SIMULATION_DATA_GENERATOR
26 |
27 | #include
28 | #include
29 | #include
30 |
31 | class SpiFlashAnalyzerSettings;
32 |
33 | class SpiFlashSimulationDataGenerator
34 | {
35 | // Bit sequence generated for command
36 | std::vector mPendingBits;
37 | // Current index in mPendingBits sequence
38 | size_t mPendingBitsIx;
39 |
40 | void GenerateNext();
41 | void setBit(SimulationChannelDescriptor *channel, U8 high)
42 | {
43 | if (channel)
44 | channel->TransitionIfNeeded(high ? BIT_HIGH : BIT_LOW);
45 | }
46 | public:
47 | SpiFlashSimulationDataGenerator();
48 | ~SpiFlashSimulationDataGenerator();
49 |
50 | void Initialize(U32 simulation_sample_rate, SpiFlashAnalyzerSettings* settings);
51 | U32 GenerateSimulationData(U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channel);
52 |
53 | protected:
54 | ClockGenerator mClockGenerator;
55 | SpiFlashAnalyzerSettings* mSettings;
56 | U32 mSimulationSampleRateHz;
57 |
58 | protected:
59 | SimulationChannelDescriptorGroup mSimulationChannels;
60 |
61 | SimulationChannelDescriptor *mChipSelectSimulationData;
62 | SimulationChannelDescriptor *mClockSimulationData;
63 | SimulationChannelDescriptor *mMosiSimulationData;
64 | SimulationChannelDescriptor *mMisoSimulationData;
65 | SimulationChannelDescriptor *mD2SimulationData;
66 | SimulationChannelDescriptor *mD3SimulationData;
67 | };
68 | #endif //SPIFLASH_SIMULATION_DATA_GENERATOR
69 |
--------------------------------------------------------------------------------
/source/SpiFlashAnalyzerSettings.h:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright(c) 2017 Jerzy Kasenberg
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files(the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions :
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | #ifndef SPIFLASH_ANALYZER_SETTINGS
25 | #define SPIFLASH_ANALYZER_SETTINGS
26 |
27 | #include
28 | #include
29 |
30 | class SpiFlashAnalyzerSettings : public AnalyzerSettings
31 | {
32 | public:
33 | SpiFlashAnalyzerSettings();
34 | virtual ~SpiFlashAnalyzerSettings();
35 |
36 | virtual bool SetSettingsFromInterfaces();
37 | void UpdateInterfacesFromSettings();
38 | virtual void LoadSettings( const char* settings );
39 | virtual const char* SaveSettings();
40 |
41 |
42 | Channel mChipSelect;
43 | Channel mClock;
44 | Channel mMosi;
45 | Channel mMiso;
46 | Channel mD2;
47 | Channel mD3;
48 | U32 mManufacturer;
49 | U32 mAddressLength;
50 | U32 mSpiMode;
51 | U32 mBusMode;
52 | U32 mContinuousRead;
53 |
54 | protected:
55 | std::auto_ptr mManufacturerInterface;
56 | std::auto_ptr mAddressLengthInterface;
57 | std::auto_ptr mSpiModeInterface;
58 | std::auto_ptr mBusModeInterface;
59 | std::auto_ptr mContinuousReadInterface;
60 |
61 | std::auto_ptr mChipSelectInterface;
62 | std::auto_ptr mClockInterface;
63 | std::auto_ptr mMosiInterface;
64 | std::auto_ptr mMisoInterface;
65 | std::auto_ptr mD2Interface;
66 | std::auto_ptr mD3Interface;
67 | };
68 |
69 | #endif //SPIFLASH_ANALYZER_SETTINGS
70 |
--------------------------------------------------------------------------------
/source/SpiFlashAnalyzer.h:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright(c) 2017 Jerzy Kasenberg
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files(the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions :
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | #ifndef SPIFLASH_ANALYZER_H
25 | #define SPIFLASH_ANALYZER_H
26 |
27 | #include
28 | #include "SpiFlashAnalyzerResults.h"
29 | #include "SpiFlashSimulationDataGenerator.h"
30 |
31 | #include "SpiFlash.h"
32 |
33 | class SpiFlashAnalyzerSettings;
34 | class ANALYZER_EXPORT SpiFlashAnalyzer : public Analyzer2
35 | {
36 | public:
37 | SpiFlashAnalyzer();
38 | virtual ~SpiFlashAnalyzer();
39 | virtual void WorkerThread();
40 |
41 | virtual U32 GenerateSimulationData(U64 newest_sample_requested, U32 sample_rate, SimulationChannelDescriptor** simulation_channels);
42 | virtual U32 GetMinimumSampleRateHz();
43 |
44 | virtual const char *GetAnalyzerName() const;
45 | virtual bool NeedsRerun();
46 |
47 | AnalyzerChannelData *GetAnalyzerChannelData(Channel& channel);
48 | protected: //vars
49 | std::auto_ptr mSettings;
50 | std::auto_ptr mResults;
51 | AnalyzerChannelData *mSerial;
52 |
53 | SpiFlashSimulationDataGenerator mSimulationDataGenerator;
54 | bool mSimulationInitilized;
55 |
56 | AnalyzerChannelData *mChipSelect;
57 | AnalyzerChannelData *mClock;
58 | AnalyzerChannelData *mMosi;
59 | AnalyzerChannelData *mMiso;
60 | AnalyzerChannelData *mD2;
61 | AnalyzerChannelData *mD3;
62 |
63 | //Serial analysis vars:
64 | U32 mSampleRateHz;
65 | U32 mStartOfStopBitOffset;
66 | U32 mEndOfStopBitOffset;
67 | BusMode mCurrentBusMode;
68 | BusMode mDefaultBusMode;
69 | bool mDirIn;
70 |
71 | // Starting sample, CS activated
72 | U64 mCommandStart;
73 | // Ending sample, CS deactivated
74 | U64 mCommandEnd;
75 | BitState mClockIdleState;
76 | // Continues read mode active after CS is activated
77 | SpiCmdData *mLockedCmd;
78 | private:
79 | void AddFrame(U64 start, U64 end, U64 d1, U64 d2, U8 type, U8 flags);
80 | void Setup();
81 | void AdvanceToCommandStart();
82 | void AdvanceDataToAbsPosition(U64 AbsolutePosition);
83 | void SetupResults();
84 | void AnalyzeCommandBits();
85 | void UpdateBusMode(BusMode busMode) { if (busMode) mCurrentBusMode = busMode; }
86 | U8 GetBits(BusMode busMode, bool dirIn);
87 | int ExtractBits(U64 &start, U64 &end, U32 &val, U8 bitCount);
88 | int ExtractMosiMiso(U64 &start, U64 &end, U8 &mosi, U8 &miso);
89 |
90 | void CacheClock(int num, U64 limit = 0);
91 | void CacheDropOlderClocks(U64 limit);
92 |
93 | U64 mCachedClocks[64];
94 | U8 mCachedClockCount;
95 |
96 | };
97 |
98 | extern "C" ANALYZER_EXPORT const char* __cdecl GetAnalyzerName();
99 | extern "C" ANALYZER_EXPORT Analyzer* __cdecl CreateAnalyzer();
100 | extern "C" ANALYZER_EXPORT void __cdecl DestroyAnalyzer(Analyzer* analyzer);
101 |
102 | #endif //SPIFLASH_ANALYZER_H
103 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.userosscache
8 | *.sln.docstates
9 |
10 | # User-specific files (MonoDevelop/Xamarin Studio)
11 | *.userprefs
12 |
13 | # Build results
14 | [Dd]ebug/
15 | [Dd]ebugPublic/
16 | [Rr]elease/
17 | [Rr]eleases/
18 | x64/
19 | x86/
20 | bld/
21 | [Bb]in/
22 | [Oo]bj/
23 | [Ll]og/
24 |
25 | # Visual Studio 2015 cache/options directory
26 | .vs/
27 | # Uncomment if you have tasks that create the project's static files in wwwroot
28 | #wwwroot/
29 |
30 | # MSTest test Results
31 | [Tt]est[Rr]esult*/
32 | [Bb]uild[Ll]og.*
33 |
34 | # NUNIT
35 | *.VisualState.xml
36 | TestResult.xml
37 |
38 | # Build Results of an ATL Project
39 | [Dd]ebugPS/
40 | [Rr]eleasePS/
41 | dlldata.c
42 |
43 | # DNX
44 | project.lock.json
45 | artifacts/
46 |
47 | *_i.c
48 | *_p.c
49 | *_i.h
50 | *.ilk
51 | *.meta
52 | *.obj
53 | *.pch
54 | *.pdb
55 | *.pgc
56 | *.pgd
57 | *.rsp
58 | *.sbr
59 | *.tlb
60 | *.tli
61 | *.tlh
62 | *.tmp
63 | *.tmp_proj
64 | *.log
65 | *.vspscc
66 | *.vssscc
67 | .builds
68 | *.pidb
69 | *.svclog
70 | *.scc
71 |
72 | # Chutzpah Test files
73 | _Chutzpah*
74 |
75 | # Visual C++ cache files
76 | ipch/
77 | *.aps
78 | *.ncb
79 | *.opendb
80 | *.opensdf
81 | *.sdf
82 | *.cachefile
83 | *.VC.db
84 | *.VC.VC.opendb
85 |
86 | # Visual Studio profiler
87 | *.psess
88 | *.vsp
89 | *.vspx
90 | *.sap
91 |
92 | # TFS 2012 Local Workspace
93 | $tf/
94 |
95 | # Guidance Automation Toolkit
96 | *.gpState
97 |
98 | # ReSharper is a .NET coding add-in
99 | _ReSharper*/
100 | *.[Rr]e[Ss]harper
101 | *.DotSettings.user
102 |
103 | # JustCode is a .NET coding add-in
104 | .JustCode
105 |
106 | # TeamCity is a build add-in
107 | _TeamCity*
108 |
109 | # DotCover is a Code Coverage Tool
110 | *.dotCover
111 |
112 | # NCrunch
113 | _NCrunch_*
114 | .*crunch*.local.xml
115 | nCrunchTemp_*
116 |
117 | # MightyMoose
118 | *.mm.*
119 | AutoTest.Net/
120 |
121 | # Web workbench (sass)
122 | .sass-cache/
123 |
124 | # Installshield output folder
125 | [Ee]xpress/
126 |
127 | # DocProject is a documentation generator add-in
128 | DocProject/buildhelp/
129 | DocProject/Help/*.HxT
130 | DocProject/Help/*.HxC
131 | DocProject/Help/*.hhc
132 | DocProject/Help/*.hhk
133 | DocProject/Help/*.hhp
134 | DocProject/Help/Html2
135 | DocProject/Help/html
136 |
137 | # Click-Once directory
138 | publish/
139 |
140 | # Publish Web Output
141 | *.[Pp]ublish.xml
142 | *.azurePubxml
143 | # TODO: Comment the next line if you want to checkin your web deploy settings
144 | # but database connection strings (with potential passwords) will be unencrypted
145 | *.pubxml
146 | *.publishproj
147 |
148 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
149 | # checkin your Azure Web App publish settings, but sensitive information contained
150 | # in these scripts will be unencrypted
151 | PublishScripts/
152 |
153 | # NuGet Packages
154 | *.nupkg
155 | # The packages folder can be ignored because of Package Restore
156 | **/packages/*
157 | # except build/, which is used as an MSBuild target.
158 | !**/packages/build/
159 | # Uncomment if necessary however generally it will be regenerated when needed
160 | #!**/packages/repositories.config
161 | # NuGet v3's project.json files produces more ignoreable files
162 | *.nuget.props
163 | *.nuget.targets
164 |
165 | # Microsoft Azure Build Output
166 | csx/
167 | *.build.csdef
168 |
169 | # Microsoft Azure Emulator
170 | ecf/
171 | rcf/
172 |
173 | # Windows Store app package directories and files
174 | AppPackages/
175 | BundleArtifacts/
176 | Package.StoreAssociation.xml
177 | _pkginfo.txt
178 |
179 | # Visual Studio cache files
180 | # files ending in .cache can be ignored
181 | *.[Cc]ache
182 | # but keep track of directories ending in .cache
183 | !*.[Cc]ache/
184 |
185 | # Others
186 | ClientBin/
187 | ~$*
188 | *~
189 | *.dbmdl
190 | *.dbproj.schemaview
191 | *.pfx
192 | *.publishsettings
193 | node_modules/
194 | orleans.codegen.cs
195 |
196 | # Since there are multiple workflows, uncomment next line to ignore bower_components
197 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
198 | #bower_components/
199 |
200 | # RIA/Silverlight projects
201 | Generated_Code/
202 |
203 | # Backup & report files from converting an old project file
204 | # to a newer Visual Studio version. Backup files are not needed,
205 | # because we have git ;-)
206 | _UpgradeReport_Files/
207 | Backup*/
208 | UpgradeLog*.XML
209 | UpgradeLog*.htm
210 |
211 | # SQL Server files
212 | *.mdf
213 | *.ldf
214 |
215 | # Business Intelligence projects
216 | *.rdl.data
217 | *.bim.layout
218 | *.bim_*.settings
219 |
220 | # Microsoft Fakes
221 | FakesAssemblies/
222 |
223 | # GhostDoc plugin setting file
224 | *.GhostDoc.xml
225 |
226 | # Node.js Tools for Visual Studio
227 | .ntvs_analysis.dat
228 |
229 | # Visual Studio 6 build log
230 | *.plg
231 |
232 | # Visual Studio 6 workspace options file
233 | *.opt
234 |
235 | # Visual Studio LightSwitch build output
236 | **/*.HTMLClient/GeneratedArtifacts
237 | **/*.DesktopClient/GeneratedArtifacts
238 | **/*.DesktopClient/ModelManifest.xml
239 | **/*.Server/GeneratedArtifacts
240 | **/*.Server/ModelManifest.xml
241 | _Pvt_Extensions
242 |
243 | # Paket dependency manager
244 | .paket/paket.exe
245 | paket-files/
246 |
247 | # FAKE - F# Make
248 | .fake/
249 |
250 | # JetBrains Rider
251 | .idea/
252 | *.sln.iml
253 |
--------------------------------------------------------------------------------
/source/SpiFlashSimulationDataGenerator.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | MIT License
3 |
4 | Copyright(c) 2017 Jerzy Kasenberg
5 |
6 | Permission is hereby granted, free of charge, to any person obtaining a copy
7 | of this software and associated documentation files(the "Software"), to deal
8 | in the Software without restriction, including without limitation the rights
9 | to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
10 | copies of the Software, and to permit persons to whom the Software is
11 | furnished to do so, subject to the following conditions :
12 |
13 | The above copyright notice and this permission notice shall be included in all
14 | copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 | SOFTWARE.
23 | */
24 | #include
25 | #include
26 | #include
27 | #include