Skip to content

Commit

Permalink
Continued initial SWD implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Aug 29, 2018
1 parent 0ea4bc3 commit 3120a2c
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 37 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ set(JTAGHAL_SOURCES
DebuggerInterface.cpp
GPIOInterface.cpp
JtagInterface.cpp
SWDInterface.cpp
TestInterface.cpp
DigilentJtagInterface.cpp
FTDIDriver.cpp
FTDIJtagInterface.cpp
FTDISWDInterface.cpp
NetworkedJtagInterface.cpp
PipeJtagInterface.cpp

Expand Down
30 changes: 30 additions & 0 deletions FTDIDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,36 @@

/**
@brief Common logic used by all FTDI adapters, regardless of transport layer selected
This adapter queues up to 4096 bytes of command+data before comitting to hardware.
GPIO pin mapping:
Index | Name
--------|--------
0 | GPIOL0 (ADBUS4)
1 | GPIOL1 (ADBUS5)
2 | GPIOL2 (ADBUS6)
3 | GPIOL3 (ADBUS7)
4 | GPIOH0 (ACBUS0)
5 | GPIOH1 (ACBUS1)
6 | GPIOH2 (ACBUS2)
7 | GPIOH3 (ACBUS3)
8 | GPIOH4 (ACBUS4)
9 | GPIOH5 (ACBUS5)
10 | GPIOH6 (ACBUS6)
11 | GPIOH7 (ACBUS7)
Supported layouts:
Name | Example hardware | Pin configuration
-----|------------------|--------------------
hs1 | Digilent JTAG-HS1, Digilent JTAG-SMT2, azonenberg's usb-jtag-mini | ADBUS7 is active-high output enable
hs2 | Digilent JTAG-HS2 | ADBUS7...5 are active-high output enable
jtagkey | Amontec JTAGkey, Bus Blaster w/ JTAGkey compatible buffer | ADBUS4 is active-low output enable, ACBUS0 is TRST_N, ACBUS2 is active-low output enable for TRST_N
\ingroup interfaces
*/
class FTDIDriver : public GPIOInterface
{
Expand Down
27 changes: 0 additions & 27 deletions FTDIJtagInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,33 +43,6 @@
/**
@brief A JTAG adapter using the FTDI chipset, accessed through libftd2xx (proprietary driver from FTDI)
This adapter supports split scanning and queues up to 4096 bytes of command+data before comitting to hardware.
GPIO pin mapping:
Index | Name
--------|--------
0 | GPIOL0 (ADBUS4)
1 | GPIOL1 (ADBUS5)
2 | GPIOL2 (ADBUS6)
3 | GPIOL3 (ADBUS7)
4 | GPIOH0 (ACBUS0)
5 | GPIOH1 (ACBUS1)
6 | GPIOH2 (ACBUS2)
7 | GPIOH3 (ACBUS3)
8 | GPIOH4 (ACBUS4)
9 | GPIOH5 (ACBUS5)
10 | GPIOH6 (ACBUS6)
11 | GPIOH7 (ACBUS7)
Supported layouts:
Name | Example hardware | Pin configuration
-----|------------------|--------------------
hs1 | Digilent JTAG-HS1, Digilent JTAG-SMT2, azonenberg's usb-jtag-mini | ADBUS7 is active-high output enable
hs2 | Digilent JTAG-HS2 | ADBUS7...5 are active-high output enable
jtagkey | Amontec JTAGkey, Bus Blaster w/ JTAGkey compatible buffer | ADBUS4 is active-low output enable, ACBUS0 is TRST_N, ACBUS2 is active-low output enable for TRST_N
\ingroup interfaces
*/
class FTDIJtagInterface : public JtagInterface
Expand Down
116 changes: 116 additions & 0 deletions FTDISWDInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2018 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of FTDISWDInterface
*/

#include "jtaghal.h"

#ifdef HAVE_FTD2XX

#include <ftd2xx/ftd2xx.h>

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

/**
@brief Connects to an FTDI JTAG interface
@throw SWDException if the connection could not be establishes or the serial number is invalid
@param serial Serial number of the device to connect to
@param layout Adapter layout to use
*/
FTDISWDInterface::FTDISWDInterface(const string& serial, const string& layout)
: FTDIDriver(serial, layout)
{
}

/**
@brief Interface destructor
Closes handles and disconnects from the adapter.
*/
FTDISWDInterface::~FTDISWDInterface()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Shim overrides to push SWDInterface functions into FTDIDriver

void FTDISWDInterface::Commit()
{
FTDIDriver::Commit();
}

string FTDISWDInterface::GetName()
{
return GetName();
}

string FTDISWDInterface::GetSerial()
{
return GetSerial();
}

string FTDISWDInterface::GetUserID()
{
return FTDIDriver::GetUserID();
}

int FTDISWDInterface::GetFrequency()
{
return FTDIDriver::GetFrequency();
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Low level

/**
@brief Performs a SW-DP write transaction
*/
void FTDISWDInterface::WriteWord(uint8_t reg_addr, uint32_t wdata)
{

}

/**
@brief Performs a SW-DP read transaction
*/
uint32_t FTDISWDInterface::ReadWord(uint8_t reg_addr)
{

}

#endif
68 changes: 68 additions & 0 deletions FTDISWDInterface.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2018 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Declaration of FTDISWDInterface
*/

#ifndef FTDISWDInterface_h
#define FTDISWDInterface_h

#include "SWDInterface.h"

#ifdef HAVE_FTD2XX

/**
@brief A SWD adapter using the FTDI chipset, accessed through libftd2xx (proprietary driver from FTDI)
\ingroup interfaces
*/
class FTDISWDInterface : public SWDInterface
, public FTDIDriver
{
public:
FTDISWDInterface(const std::string& serial, const std::string& layout);
virtual ~FTDISWDInterface();

//SWD bus transactions
virtual void WriteWord(uint8_t reg_addr, uint32_t wdata);
virtual uint32_t ReadWord(uint8_t reg_addr);

//Overrides to push SWDInterface functions into FTDIDriver implementations
virtual void Commit();
virtual std::string GetName();
virtual std::string GetSerial();
virtual std::string GetUserID();
virtual int GetFrequency();
};

#endif
#endif
54 changes: 54 additions & 0 deletions SWDInterface.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/***********************************************************************************************************************
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2018 Andrew D. Zonenberg *
* All rights reserved. *
* *
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the *
* following conditions are met: *
* *
* * Redistributions of source code must retain the above copyright notice, this list of conditions, and the *
* following disclaimer. *
* *
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the *
* following disclaimer in the documentation and/or other materials provided with the distribution. *
* *
* * Neither the name of the author nor the names of any contributors may be used to endorse or promote products *
* derived from this software without specific prior written permission. *
* *
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL *
* THE AUTHORS BE HELD LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR *
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE *
* POSSIBILITY OF SUCH DAMAGE. *
* *
***********************************************************************************************************************/

/**
@file
@author Andrew D. Zonenberg
@brief Implementation of SWDInterface
*/

#include "jtaghal.h"

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Construction / destruction

SWDInterface::SWDInterface()
{
}

SWDInterface::~SWDInterface()
{
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Autodetection

void SWDInterface::InitializeDevice()
{
}
10 changes: 0 additions & 10 deletions SWDInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ class SWDInterface : public ARMDebugPort
@brief Connects to the interface and figures out what we have attached to us
*/
virtual void InitializeDevice();

//Device(s) found on the SWD interface
//For now: only support for one
/*
protected:
SWDDevice* m_device;
public:
SWDDevice* GetDevice()
{ return m_device; }*/
};

#endif
1 change: 1 addition & 0 deletions jtaghal.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#include "DigilentJtagInterface.h"
#include "FTDIDriver.h"
#include "FTDIJtagInterface.h"
#include "FTDISWDInterface.h"
#include "NetworkedJtagInterface.h"
#include "PipeJtagInterface.h"
//#include "NocJtagInterface.h"
Expand Down

0 comments on commit 3120a2c

Please sign in to comment.