OpenCores
URL https://opencores.org/ocsvn/or1k_soc_on_altera_embedded_dev_kit/or1k_soc_on_altera_embedded_dev_kit/trunk

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [sw/] [adv_jtag_bridge/] [chain_commands.c] - Diff between revs 12 and 21

Show entire file | Details | Blame | View Log

Rev 12 Rev 21
Line 1... Line 1...
/* chain_commands.c -- JTAG protocol bridge between GDB and Advanced debug module.
/* chain_commands.c -- JTAG protocol bridge between GDB and Advanced debug module.
   Copyright(C) Nathan Yawn, nyawn@opencores.net
   Copyright(C) 2008 - 2010 Nathan Yawn, nyawn@opencores.net
   based on code from jp2 by Marko Mlinar, markom@opencores.org
   based on code from jp2 by Marko Mlinar, markom@opencores.org
 
 
   This file contains functions which perform mid-level transactions
   This file contains functions which perform mid-level transactions
   on a JTAG, such as setting a value in the TAP IR
   on a JTAG, such as setting a value in the TAP IR
   or doing a burst write on the JTAG chain.
   or doing a burst write on the JTAG chain.
Line 337... Line 337...
// There is no way to automatically determine the length of the IR registers - 
// There is no way to automatically determine the length of the IR registers - 
// this must be read from a BSDL file, if IDCODE is supported.
// this must be read from a BSDL file, if IDCODE is supported.
// When IDCODE is not supported, IR length of the target device must be entered on the command line.
// When IDCODE is not supported, IR length of the target device must be entered on the command line.
 
 
#define ALLOC_SIZE 64
#define ALLOC_SIZE 64
 
#define MAX_DEVICES 1024
int jtag_enumerate_chain(uint32_t **id_array, int *num_devices)
int jtag_enumerate_chain(uint32_t **id_array, int *num_devices)
{
{
  uint32_t invalid_code = 0x7f;  // Shift this out, we know we're done when we get it back
  uint32_t invalid_code = 0x7f;  // Shift this out, we know we're done when we get it back
  const unsigned int done_code = 0x3f;  // invalid_code is altered, we keep this for comparison (minus the start bit)
  const unsigned int done_code = 0x3f;  // invalid_code is altered, we keep this for comparison (minus the start bit)
  int devindex = 0;  // which device we are currently trying to detect
  int devindex = 0;  // which device we are currently trying to detect
Line 366... Line 367...
 
 
  printf("Enumerating JTAG chain...\n");
  printf("Enumerating JTAG chain...\n");
 
 
  // Putting a limit on the # of devices supported has the useful side effect
  // Putting a limit on the # of devices supported has the useful side effect
  // of insuring we still exit in error cases (we never get the 0x7f manuf. id)
  // of insuring we still exit in error cases (we never get the 0x7f manuf. id)
  while(devindex < max_devices) {
  while(devindex < MAX_DEVICES) {
    // get 1 bit. 0 = BYPASS, 1 = start of IDCODE
    // get 1 bit. 0 = BYPASS, 1 = start of IDCODE
    err |= jtag_read_write_bit(invalid_code&0x01, &start_bit);
    err |= jtag_read_write_bit(invalid_code&0x01, &start_bit);
    invalid_code >>= 1;
    invalid_code >>= 1;
 
 
    if(start_bit == 0) {
    if(start_bit == 0) {
Line 410... Line 411...
 
 
    if(err)  // Don't try to keep probing if we get a comm. error
    if(err)  // Don't try to keep probing if we get a comm. error
      return err;
      return err;
  }
  }
 
 
  if(devindex >= max_devices)
  if(devindex >= MAX_DEVICES)
    printf("WARNING: maximum supported devices on JTAG chain (%i) exceeded.\n", max_devices);
    printf("WARNING: maximum supported devices on JTAG chain (%i) exceeded.\n", MAX_DEVICES);
 
 
  // Put in IDLE mode
  // Put in IDLE mode
  err |= jtag_write_bit(TMS); /* EXIT1_DR */
  err |= jtag_write_bit(TMS); /* EXIT1_DR */
  err |= jtag_write_bit(TMS); /* UPDATE_DR */
  err |= jtag_write_bit(TMS); /* UPDATE_DR */
  err |= jtag_write_bit(0); /* IDLE */
  err |= jtag_write_bit(0); /* IDLE */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.