Skip to content

Commit

Permalink
Removed old / vestigial indirect programming API. Added AttachedMemor…
Browse files Browse the repository at this point in the history
…yDevice API.
  • Loading branch information
azonenberg committed Aug 3, 2018
1 parent f43c56a commit a6519b0
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 176 deletions.
15 changes: 0 additions & 15 deletions ARM7TDMISProcessor.cpp
Expand Up @@ -437,18 +437,3 @@ void ARM7TDMISProcessor::Program(FirmwareImage* /*image*/)
{

}

bool ARM7TDMISProcessor::HasIndirectFlashSupport()
{
return false;
}

void ARM7TDMISProcessor::ProgramIndirect(
ByteArrayFirmwareImage* /*image*/,
int /*buswidth*/,
bool /*reboot*/,
unsigned int /*base_address*/,
string /*prog_image*/)
{

}
7 changes: 0 additions & 7 deletions ARM7TDMISProcessor.h
Expand Up @@ -119,13 +119,6 @@ class ARM7TDMISProcessor : public DebuggableDevice
virtual FirmwareImage* LoadFirmwareImage(const unsigned char* data, size_t len);
virtual void Erase();
virtual void Program(FirmwareImage* image);
virtual bool HasIndirectFlashSupport();
virtual void ProgramIndirect(
ByteArrayFirmwareImage* image,
int buswidth,
bool reboot=true,
unsigned int base_address = 0,
std::string prog_image = "");

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CPU register access
Expand Down
38 changes: 38 additions & 0 deletions AttachedMemoryDevice.cpp
@@ -0,0 +1,38 @@
/***********************************************************************************************************************
* *
* 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. *
* *
***********************************************************************************************************************/

#include "jtaghal.h"

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

AttachedMemoryDevice::~AttachedMemoryDevice()
{

}
57 changes: 57 additions & 0 deletions AttachedMemoryDevice.h
@@ -0,0 +1,57 @@
/***********************************************************************************************************************
* *
* 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 AttachedMemoryDevice
*/


#ifndef AttachedMemoryDevice_h
#define AttachedMemoryDevice_h

/**
@brief Base classes for devices which can connect to external memory devices.
Example: FPGA with attached QSPI/BPI flash, MCU with external memory bus
\ingroup libjtaghal
*/
class AttachedMemoryDevice
{
public:
virtual ~AttachedMemoryDevice();

virtual size_t GetNumAttachedMemories() =0;
virtual ProgrammableDevice* GetAttachedMemoryDevice(size_t i) =0;
};

#endif

1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -15,6 +15,7 @@ set(JTAGHAL_SOURCES
SerialNumberedDevice.cpp
LockableDevice.cpp

AttachedMemoryDevice.cpp
DebuggableDevice.cpp
ProgrammableDevice.cpp
ProgrammableLogicDevice.cpp
Expand Down
17 changes: 0 additions & 17 deletions FreescaleMicrocontroller.cpp
Expand Up @@ -48,20 +48,3 @@ FreescaleMicrocontroller::~FreescaleMicrocontroller()
//Nothing here
}

bool FreescaleMicrocontroller::HasIndirectFlashSupport()
{
//MCUs have no external memory
return false;
}

void FreescaleMicrocontroller::ProgramIndirect(
ByteArrayFirmwareImage* /*image*/,
int /*buswidth*/,
bool /*reboot*/,
unsigned int /*base_address*/,
std::string /*prog_image*/)
{
throw JtagExceptionWrapper(
"Freescale MCUs cannot be indirectly programmed",
"");
}
8 changes: 0 additions & 8 deletions FreescaleMicrocontroller.h
Expand Up @@ -47,14 +47,6 @@ class FreescaleMicrocontroller : public FreescaleDevice
public:
FreescaleMicrocontroller(unsigned int idcode, JtagInterface* iface, size_t pos, size_t irlength);
virtual ~FreescaleMicrocontroller();

virtual bool HasIndirectFlashSupport();
virtual void ProgramIndirect(
ByteArrayFirmwareImage* image,
int buswidth,
bool reboot = true,
unsigned int base_address = 0,
std::string prog_image = "");
};

#endif
Expand Down
19 changes: 0 additions & 19 deletions MicrochipMicrocontroller.cpp
Expand Up @@ -48,22 +48,3 @@ MicrochipMicrocontroller::~MicrochipMicrocontroller()
//Nothing here
}

bool MicrochipMicrocontroller::HasIndirectFlashSupport()
{
//MCUs have no external memory
return false;
}

void MicrochipMicrocontroller::ProgramIndirect(
ByteArrayFirmwareImage* /*image*/,
int /*buswidth*/,
bool /*reboot*/,
unsigned int /*base_address*/,
std::string /*prog_image*/)
{
//TODO: Support indirect programming since the on-die flash in PIC32s requires a bootloader

throw JtagExceptionWrapper(
"Microchip MCUs cannot be indirectly programmed",
"");
}
8 changes: 0 additions & 8 deletions MicrochipMicrocontroller.h
Expand Up @@ -47,14 +47,6 @@ class MicrochipMicrocontroller : public MicrochipDevice
public:
MicrochipMicrocontroller(unsigned int idcode, JtagInterface* iface, size_t pos, size_t irlength);
virtual ~MicrochipMicrocontroller();

virtual bool HasIndirectFlashSupport();
virtual void ProgramIndirect(
ByteArrayFirmwareImage* image,
int buswidth,
bool reboot = true,
unsigned int base_address = 0,
std::string prog_image = "");
};

#endif
Expand Down
17 changes: 0 additions & 17 deletions ProgrammableDevice.h
Expand Up @@ -96,23 +96,6 @@ class ProgrammableDevice
@param image The parsed image to load
*/
virtual void Program(FirmwareImage* image) =0;

/**
@brief Checks if we support indirect flash programming.
*/
virtual bool HasIndirectFlashSupport() =0;

/**
@brief Uses indirect flash programming to load a bitstream onto the target device
Bus width indicates boot mode: 1-2-4 are SPI, 8-16 are BPI. Other values reserved.
*/
virtual void ProgramIndirect(
ByteArrayFirmwareImage* image,
int buswidth,
bool reboot=true,
unsigned int base_address = 0,
std::string prog_image = "") =0;
};

#endif
Expand Down
22 changes: 1 addition & 21 deletions STMicroMicrocontroller.cpp
Expand Up @@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* 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 *
Expand Down Expand Up @@ -53,23 +53,3 @@ STMicroMicrocontroller::~STMicroMicrocontroller()
{
//Nothing here
}

bool STMicroMicrocontroller::HasIndirectFlashSupport()
{
//MCUs have no external memory
return false;
}

void STMicroMicrocontroller::ProgramIndirect(
ByteArrayFirmwareImage* /*image*/,
int /*buswidth*/,
bool /*reboot*/,
unsigned int /*base_address*/,
std::string /*prog_image*/)
{
//TODO: Support indirect programming since the on-die flash in PIC32s requires a bootloader

throw JtagExceptionWrapper(
"STMicro MCUs cannot be indirectly programmed",
"");
}
10 changes: 1 addition & 9 deletions STMicroMicrocontroller.h
Expand Up @@ -2,7 +2,7 @@
* *
* ANTIKERNEL v0.1 *
* *
* Copyright (c) 2012-2016 Andrew D. Zonenberg *
* 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 *
Expand Down Expand Up @@ -47,14 +47,6 @@ class STMicroMicrocontroller : public STMicroDevice
public:
STMicroMicrocontroller(unsigned int devicetype, unsigned int stepping, unsigned int idcode, JtagInterface* iface, size_t pos);
virtual ~STMicroMicrocontroller();

virtual bool HasIndirectFlashSupport();
virtual void ProgramIndirect(
ByteArrayFirmwareImage* image,
int buswidth,
bool reboot = true,
unsigned int base_address = 0,
std::string prog_image = "");
};

#endif
Expand Down
18 changes: 0 additions & 18 deletions XilinxCPLD.cpp
Expand Up @@ -47,21 +47,3 @@ XilinxCPLD::~XilinxCPLD()
{
//Nothing here
}

bool XilinxCPLD::HasIndirectFlashSupport()
{
//CPLDs have no external memory
return false;
}

void XilinxCPLD::ProgramIndirect(
ByteArrayFirmwareImage* /*image*/,
int /*buswidth*/,
bool /*reboot*/,
unsigned int /*base_address*/,
std::string /*prog_image*/)
{
throw JtagExceptionWrapper(
"Xilinx CPLDs cannot be indirectly programmed",
"");
}
8 changes: 0 additions & 8 deletions XilinxCPLD.h
Expand Up @@ -48,14 +48,6 @@ class XilinxCPLD : public XilinxDevice
public:
XilinxCPLD(unsigned int idcode, JtagInterface* iface, size_t pos, size_t irlength);
virtual ~XilinxCPLD();

virtual bool HasIndirectFlashSupport();
virtual void ProgramIndirect(
ByteArrayFirmwareImage* image,
int buswidth,
bool reboot = true,
unsigned int base_address = 0,
std::string prog_image = "");
};

#endif
Expand Down
31 changes: 12 additions & 19 deletions XilinxFPGA.cpp
Expand Up @@ -258,20 +258,14 @@ void XilinxFPGA::ParseBitstreamCore(
ParseBitstreamInternals(data, len, bitstream, fpos);
}

bool XilinxFPGA::HasIndirectFlashSupport()
{
return false;
//return true;
}

/*
void XilinxFPGA::ProgramIndirect(
ByteArrayFirmwareImage* /*image*/,
int /*buswidth*/,
bool /*reboot*/,
unsigned int /*base_address*/,
string /*prog_image*/)
ByteArrayFirmwareImage* image,
int buswidth,
bool reboot,
unsigned int base_address,
string prog_image)
{
/*
//Program the FPGA with the indirect bitstream
uint16_t faddr = LoadIndirectProgrammingImage(buswidth, prog_image);
Expand Down Expand Up @@ -382,15 +376,15 @@ void XilinxFPGA::ProgramIndirect(
"",
JtagException::EXCEPTION_TYPE_BOARD_FAULT);
}
*/
}
*/

/**
@brief Loads an indirect programming image suitable for the given bus width
*/
uint16_t XilinxFPGA::LoadIndirectProgrammingImage(int /*buswidth*/, string /*image_fname*/)
/*
uint16_t XilinxFPGA::LoadIndirectProgrammingImage(int buswidth, string image_fname)
{
/*
//Only support QSPI for now
if(buswidth != 4)
{
Expand Down Expand Up @@ -472,13 +466,12 @@ uint16_t XilinxFPGA::LoadIndirectProgrammingImage(int /*buswidth*/, string /*ima
uint16_t faddr = nameserver.ForwardLookup("flash");
printf(" Flash is at NoC address %04x\n", faddr);
return faddr;
*/
return 0;
}
void XilinxFPGA::DumpIndirect(int /*buswidth*/, string /*fname*/)
void XilinxFPGA::DumpIndirect(int buswidth, string fname)
{
/*
//Program the FPGA with the indirect bitstream
uint16_t faddr = LoadIndirectProgrammingImage(buswidth);
Expand Down Expand Up @@ -511,5 +504,5 @@ void XilinxFPGA::DumpIndirect(int /*buswidth*/, string /*fname*/)
}
fclose(fp);
*/
}
*/

0 comments on commit a6519b0

Please sign in to comment.