Skip to content

Commit

Permalink
Initial work on heuristics for attaching i.mx SDMA to SoC TAP
Browse files Browse the repository at this point in the history
  • Loading branch information
azonenberg committed Jul 23, 2018
1 parent 926c810 commit be63e01
Show file tree
Hide file tree
Showing 11 changed files with 306 additions and 96 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(JTAGHAL_SOURCES
FreescaleDevice.cpp
FreescaleMicrocontroller.cpp
FreescaleIMXDevice.cpp
FreescaleIMXSmartDMA.cpp

MicrochipDevice.cpp
MicrochipMicrocontroller.cpp
Expand Down
2 changes: 1 addition & 1 deletion FreescaleDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define FreescaleDevice_h

/**
@brief Abstract base class for all Freescale devices (typically MCUs)
@brief Abstract base class for all Freescale devices (typically MCUs or parts thereof)
\ingroup libjtaghal
*/
Expand Down
84 changes: 56 additions & 28 deletions FreescaleIMXDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,36 @@ FreescaleIMXDevice::FreescaleIMXDevice(
unsigned int devid, unsigned int stepping,
unsigned int idcode, JtagInterface* iface, size_t pos)
: FreescaleMicrocontroller(idcode, iface, pos, 5)
, m_stepping(stepping)
{
if(pos < 2)
{
throw JtagExceptionWrapper(
"FreescaleIMXDevice boundary scan TAP must not be the first or second device in the scan chain. Where's the ARM DAP or SDMA?",
"");
}

//We are the System JTAG Controller (reference manual section 56.2.3)
switch(devid)
{
case IMX_6_SOLO:
m_devid = IMX_6_SOLO;
break;

case IMX_6_DUAL_LITE:
m_devid = IMX_6_DUAL_LITE;
break;

default:
throw JtagExceptionWrapper(
"Invalid i.mx IDCODE",
"");
break;
}

//tie off pointers until PostInitProbes()
m_dap = NULL;
m_sdma = NULL;
}

/**
Expand All @@ -59,33 +87,27 @@ FreescaleIMXDevice::~FreescaleIMXDevice()

void FreescaleIMXDevice::PostInitProbes()
{
/*
m_devid = devid;
m_stepping = stepping;
//Look up device info in the table and make sure it exists
m_devinfo = NULL;
for(auto& x : g_devinfo)
//Get a pointer to our ARM DAP. This should always be one scan chain position before us.
m_dap = dynamic_cast<ARMDebugPort*>(m_iface->GetDevice(m_pos-2));
if(m_dap == NULL)
{
if(x.devid == devid)
m_devinfo = &x;
throw JtagExceptionWrapper(
"FreescaleIMXDevice expects an ARM DAP two chain positions prior",
"");
}

if(!m_devinfo)
//One position back should be a dummy.
//We need to swap that out with the SDMA
size_t sdma_pos = m_pos-1;
auto sdma_dummy = dynamic_cast<JtagDummy*>(m_iface->GetDevice(sdma_pos));
if(sdma_dummy == NULL)
{
throw JtagExceptionWrapper(
"Invalid PIC32 JTAG IDCODE",
"FreescaleIMXDevice expects a dummy SDMA one chain position prior",
"");
}
//Reset both TAPS
EnterMtapMode();
ResetToIdle();
EnterEjtagMode();
ResetToIdle();
//Get our implementation code
GetImpCode();*/
m_sdma = new FreescaleIMXSmartDMA(0x0, 0x0, 0x0, m_iface, sdma_pos);
m_iface->SwapOutDummy(sdma_pos, m_sdma);
}

JtagDevice* FreescaleIMXDevice::CreateDevice(
Expand All @@ -100,18 +122,24 @@ JtagDevice* FreescaleIMXDevice::CreateDevice(

string FreescaleIMXDevice::GetDescription()
{
/*
const char* desc = "";
switch(m_devid)
{
case IMX_6_DUAL_LITE:
desc = "Dual Lite";
break;

case IMX_6_SOLO:
desc = "Solo";
break;
}

char srev[256];
snprintf(srev, sizeof(srev), "Microchip %s (%u KB SRAM, %u KB code flash, %.2f KB boot flash, stepping %u)",
m_devinfo->name,
m_devinfo->sram_size,
m_devinfo->program_flash_size,
m_devinfo->boot_flash_size,
snprintf(srev, sizeof(srev), "Freescale i.mx6 %s (stepping %u)",
desc,
m_stepping);

return string(srev);
*/
return "i.mx unimplemented";
}

bool FreescaleIMXDevice::IsProgrammed()
Expand Down
82 changes: 34 additions & 48 deletions FreescaleIMXDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@
#define FreescaleIMXDevice_h

#include "FreescaleMicrocontroller.h"
class FreescaleIMXSmartDMA;

#include <list>
#include <string>

enum ImxDeviceIDs
{
IMX_6_SOLO = 0x891B,
IMX_6_DUAL_LITE = 0x891A
};

/**
@brief A Freescale i.mx applications processor
Expand Down Expand Up @@ -69,54 +76,32 @@ class FreescaleIMXDevice : public FreescaleMicrocontroller

virtual void PostInitProbes();

/*
///5-bit-wide JTAG instructions (from BSDL file and datasheet)
///5-bit-wide JTAG instructions (from datasheet table 56-3)
enum instructions
{
///Standard JTAG bypass
INST_BYPASS = 0x1F,
///Read ID code
INST_IDCODE = 0x01,
///Read implementation code
INST_IMPCODE = 0x03,
///Selects Microchip scan chain
INST_MTAP_SW_MCHP = 0x04,
///Selects EJTAG scan chain
INST_MTAP_SW_EJTAG = 0x05,
///Command to Microchip virtualized JTAG
INST_MTAP_COMMAND = 0x07,
///Select address register for memory ops
INST_ADDRESS = 0x08,
///Select data register for memory ops
INST_DATA = 0x09,
///Control register of some sort?
INST_CONTROL = 0x0A,
///Selects address, data, control end to end in one DR
INST_ALL = 0x0B,
///Makes the CPU trap to debugger after a reset
INST_DEBUGBOOT = 0x0C,
///Boot normally after a reset
INST_NORMALBOOT = 0x0D,
///Register used for moving data to/from the debug bridge
INST_FASTDATA = 0x0E,
//Sample the program counter (used for profiling... not implemented?)
INST_PCSAMPLE = 0x14
INST_IDCODE = 0x00,

///Boundary scan stuff
INST_SAMPLE_PRELOAD = 0x01,
INST_EXTEST = 0x02,
INST_HIZ = 0x03,
INST_EXTEST_PULSE = 0x08,
INST_EXTEST_TRAIN = 0x09,

//Debug security
INST_EXTRADEBUG = 0x04,
INST_ENTER_DEBUG = 0x05,
INST_SECURE_CHALL = 0x0c,
INST_SECURE_RESP = 0x0d,

//TAP selection mode
INST_TAP_SELECT = 0x07,

//Not used
INST_BYPASS = 0x1f
};
*/

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// General device info

Expand Down Expand Up @@ -153,17 +138,18 @@ class FreescaleIMXDevice : public FreescaleMicrocontroller
FreescaleIMXDeviceStatusRegister GetStatus();
EjtagImplementationCodeRegister GetImpCode();
*/
protected:

///Device ID code
unsigned int m_devid;
ImxDeviceIDs m_devid;

///Stepping number
unsigned int m_stepping;

///Device info
const FreescaleIMXDeviceInfo* m_devinfo;*/
//Pointers to our other JTAG devices
ARMDebugPort* m_dap;
FreescaleIMXSmartDMA* m_sdma;
};

#endif
82 changes: 82 additions & 0 deletions FreescaleIMXSmartDMA.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/***********************************************************************************************************************
* *
* 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 FreescaleIMXSmartDMA
*/

#include "jtaghal.h"
#include "FreescaleIMXSmartDMA.h"
#include "STMicroDeviceID_enum.h"
#include "memory.h"

using namespace std;

FreescaleIMXSmartDMA::FreescaleIMXSmartDMA(
unsigned int devid, unsigned int stepping,
unsigned int idcode, JtagInterface* iface, size_t pos)
: FreescaleDevice(idcode, iface, pos, 4)
{
//page 4753 has sdma info
if(pos < 1)
{
throw JtagExceptionWrapper(
"FreescaleIMX Smart DMA boundary scan TAP must not be the first device in the scan chain. Where's the ARM DAP?",
"");
}
}

void FreescaleIMXSmartDMA::PostInitProbes()
{

}

/**
@brief Destructor
*/
FreescaleIMXSmartDMA::~FreescaleIMXSmartDMA()
{
}

JtagDevice* FreescaleIMXSmartDMA::CreateDevice(
unsigned int devid, unsigned int stepping, unsigned int idcode, JtagInterface* iface, size_t pos)
{
//TODO: Sanity checks
return new FreescaleIMXSmartDMA(devid, stepping, idcode, iface, pos);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Device property queries

string FreescaleIMXSmartDMA::GetDescription()
{
return "Freescale i.mx6 Smart DMA";
}
Loading

0 comments on commit be63e01

Please sign in to comment.