Initial commit
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
STATE RESET;
|
||||
HDR 0;
|
||||
HIR 0;
|
||||
TDR 0;
|
||||
TIR 0;
|
||||
ENDDR DRPAUSE;
|
||||
ENDIR IRPAUSE;
|
||||
! FREQUENCY 1.00e+006 HZ;
|
||||
STATE IDLE;
|
||||
SIR 8 TDI (E0);
|
||||
SDR 32 TDI (00000000)
|
||||
TDO (012B5043)
|
||||
MASK (FFFFFFFF);
|
||||
SIR 8 TDI (1C);
|
||||
SDR 664 TDI (FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
|
||||
FFFFFF);
|
||||
SIR 8 TDI (3C);
|
||||
RUNTEST IDLE 2 TCK 1.00E-003 SEC;
|
||||
SDR 32 TDI (00000000)
|
||||
TDO (00000000)
|
||||
MASK (00000020);
|
||||
SIR 8 TDI (C6);
|
||||
SDR 8 TDI (00);
|
||||
RUNTEST IDLE 2 TCK 1.00E-003 SEC;
|
||||
SIR 8 TDI (0E);
|
||||
SDR 8 TDI (01);
|
||||
RUNTEST IDLE 2 TCK 1.00E+000 SEC;
|
||||
SIR 8 TDI (FF)
|
||||
TDO (00)
|
||||
MASK (C0);
|
||||
SIR 8 TDI (C6);
|
||||
SDR 8 TDI (08);
|
||||
RUNTEST IDLE 2 TCK 1.00E-003 SEC;
|
||||
SIR 8 TDI (3C);
|
||||
RUNTEST IDLE 2 TCK 1.00E-003 SEC;
|
||||
SDR 32 TDI (00000000)
|
||||
TDO (00000000)
|
||||
MASK (00024040);
|
||||
SIR 8 TDI (0E);
|
||||
SDR 8 TDI (0E);
|
||||
RUNTEST IDLE 2 TCK 3.00E+001 SEC;
|
||||
SIR 8 TDI (F0);
|
||||
SDR 1 TDI (0)
|
||||
TDO (0);
|
||||
SIR 8 TDI (3C);
|
||||
RUNTEST IDLE 2 TCK 1.00E-003 SEC;
|
||||
SDR 32 TDI (00000000)
|
||||
TDO (00000000)
|
||||
MASK (00003000);
|
||||
SIR 8 TDI (26);
|
||||
RUNTEST IDLE 2 TCK 1.00E+000 SEC;
|
||||
SIR 8 TDI (FF);
|
||||
RUNTEST IDLE 100 TCK 1.00E-001 SEC;
|
||||
STATE RESET;
|
||||
+67679
File diff suppressed because it is too large
Load Diff
+33872
File diff suppressed because it is too large
Load Diff
+13
@@ -0,0 +1,13 @@
|
||||
CFLAGS += -Wall
|
||||
OBJS = main.o ast-jtag.o svf.o
|
||||
EXE = svf
|
||||
.c.o:
|
||||
$(CC) -c $<
|
||||
$(EXE): $(OBJS)
|
||||
$(CC) $(OBJS) -o $@
|
||||
all:$(EXE)
|
||||
clean:
|
||||
rm -f $(EXE) $(OBJS)
|
||||
install:
|
||||
cp $(EXE) $(INSTALL_DIR)
|
||||
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright 2020 Aspeed Technology Inc.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include "ast-jtag.h"
|
||||
|
||||
int jtag_fd;
|
||||
|
||||
#define DEBUG 0
|
||||
|
||||
#if DEBUG
|
||||
#define ast_jtag_printf(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define ast_jtag_printf(...)
|
||||
#endif
|
||||
|
||||
/*************************************************************************************/
|
||||
/* AST JTAG LIB */
|
||||
int ast_jtag_open(char *dev)
|
||||
{
|
||||
jtag_fd = open(dev, O_RDWR);
|
||||
if (jtag_fd == -1) {
|
||||
printf("Can't open %s, please install driver!! \n", dev);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ast_jtag_close(void)
|
||||
{
|
||||
close(jtag_fd);
|
||||
}
|
||||
|
||||
unsigned int ast_get_jtag_freq(void)
|
||||
{
|
||||
int retval;
|
||||
unsigned int freq = 0;
|
||||
retval = ioctl(jtag_fd, JTAG_GIOCFREQ, &freq);
|
||||
if (retval == -1) {
|
||||
perror("ioctl JTAG get freq fail!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return freq;
|
||||
}
|
||||
|
||||
int ast_set_jtag_mode(uint8_t sw_mode)
|
||||
{
|
||||
struct jtag_mode jtag_mode;
|
||||
int retval;
|
||||
|
||||
jtag_mode.feature = JTAG_XFER_MODE;
|
||||
jtag_mode.mode = sw_mode ? JTAG_XFER_SW_MODE : JTAG_XFER_HW_MODE;
|
||||
retval = ioctl(jtag_fd, JTAG_SIOCMODE, &jtag_mode);
|
||||
if (retval == -1) {
|
||||
perror("ioctl JTAG set mode fail!\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_set_jtag_freq(unsigned int freq)
|
||||
{
|
||||
int retval;
|
||||
unsigned int jtag_freq = freq;
|
||||
retval = ioctl(jtag_fd, JTAG_SIOCFREQ, &jtag_freq);
|
||||
if (retval == -1) {
|
||||
perror("ioctl JTAG set freq fail!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_get_tap_state(enum jtag_tapstate* tap_state)
|
||||
{
|
||||
int retval;
|
||||
|
||||
if (tap_state == NULL)
|
||||
return -1;
|
||||
retval = ioctl(jtag_fd, JTAG_GIOCSTATUS, tap_state);
|
||||
if (retval == -1) {
|
||||
perror("ioctl JTAG get tap state fail!\n");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ast_jtag_run_test_idle(unsigned char end, unsigned int tck)
|
||||
{
|
||||
|
||||
int retval;
|
||||
struct jtag_tap_state run_idle;
|
||||
|
||||
run_idle.from = JTAG_STATE_CURRENT;
|
||||
run_idle.reset = JTAG_NO_RESET;
|
||||
run_idle.endstate = end;
|
||||
run_idle.tck = tck;
|
||||
|
||||
ast_jtag_printf("from:%d, reset:%d, endstate:%d, tck:%d\n", run_idle.from, run_idle.reset, run_idle.endstate, run_idle.tck);
|
||||
|
||||
retval = ioctl(jtag_fd, JTAG_SIOCSTATE, &run_idle);
|
||||
if (retval == -1) {
|
||||
printf("ioctl JTAG run reset fail! error:%s\n",strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(end)
|
||||
usleep(tck*2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
extern int svf_line_number;
|
||||
int ast_jtag_xfer(unsigned char endsts, unsigned int len, unsigned int *out, unsigned int *in, enum jtag_xfer_type type)
|
||||
{
|
||||
int retval;
|
||||
enum jtag_tapstate current_state;
|
||||
struct jtag_xfer xfer;
|
||||
unsigned int send_len_byte;
|
||||
|
||||
ast_get_tap_state(¤t_state);
|
||||
xfer.type = type;
|
||||
xfer.direction = JTAG_READ_WRITE_XFER;
|
||||
xfer.from = current_state;
|
||||
xfer.endstate = endsts;
|
||||
xfer.padding = 0;
|
||||
xfer.length = len;
|
||||
xfer.tdio = (unsigned int)out;
|
||||
send_len_byte = DIV_ROUND_UP(xfer.length, BITS_PER_BYTE);
|
||||
|
||||
#if DEBUG
|
||||
int i;
|
||||
for (i = 0; i < DIV_ROUND_UP(send_len_byte, 4); i++)
|
||||
printf("tdo:%08x\n", out[i]);
|
||||
#endif
|
||||
retval = ioctl(jtag_fd, JTAG_IOCXFER, &xfer);
|
||||
if (retval == -1) {
|
||||
perror("ioctl JTAG sir fail!\n");
|
||||
return -1;
|
||||
}
|
||||
memcpy(in, out, send_len_byte);
|
||||
#if DEBUG
|
||||
for (i = 0; i < DIV_ROUND_UP(send_len_byte, 4); i++)
|
||||
printf("tdi:%08x\n",out[i]);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright 2020 Aspeed Technology Inc.
|
||||
*/
|
||||
#include "stdint.h"
|
||||
typedef uint8_t __u8;
|
||||
typedef uint32_t __u32;
|
||||
typedef unsigned long long __u64;
|
||||
|
||||
#include "jtag.h"
|
||||
|
||||
#define DIV_ROUND_UP(n, d) (((n) + (d)-1) / (d))
|
||||
#define BITS_PER_BYTE 8
|
||||
/******************************************************************************************************************/
|
||||
int ast_jtag_open(char *dev);
|
||||
void ast_jtag_close(void);
|
||||
int ast_set_jtag_mode(uint8_t sw_mode);
|
||||
unsigned int ast_get_jtag_freq(void);
|
||||
int ast_set_jtag_freq(unsigned int freq);
|
||||
int ast_jtag_run_test_idle(unsigned char end, unsigned int tck);
|
||||
int ast_jtag_xfer(unsigned char endsts, unsigned int len, unsigned int *out, unsigned int *in, enum jtag_xfer_type type);
|
||||
+246
@@ -0,0 +1,246 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0 */
|
||||
/* Copyright (c) 2018 Mellanox Technologies. All rights reserved. */
|
||||
/* Copyright (c) 2018 Oleksandr Shamray <oleksandrs@mellanox.com> */
|
||||
/* Copyright (c) 2019 Intel Corporation */
|
||||
|
||||
#ifndef __UAPI_LINUX_JTAG_H
|
||||
#define __UAPI_LINUX_JTAG_H
|
||||
|
||||
/*
|
||||
* JTAG_XFER_MODE: JTAG transfer mode. Used to set JTAG controller transfer mode
|
||||
* This is bitmask for feature param in jtag_mode for ioctl JTAG_SIOCMODE
|
||||
*/
|
||||
#define JTAG_XFER_MODE 0
|
||||
/*
|
||||
* JTAG_CONTROL_MODE: JTAG controller mode. Used to set JTAG controller mode
|
||||
* This is bitmask for feature param in jtag_mode for ioctl JTAG_SIOCMODE
|
||||
*/
|
||||
#define JTAG_CONTROL_MODE 1
|
||||
/*
|
||||
* JTAG_MASTER_OUTPUT_DISABLE: JTAG master mode output disable, it is used to
|
||||
* enable other devices to own the JTAG bus.
|
||||
* This is bitmask for mode param in jtag_mode for ioctl JTAG_SIOCMODE
|
||||
*/
|
||||
#define JTAG_MASTER_OUTPUT_DISABLE 0
|
||||
/*
|
||||
* JTAG_MASTER_MODE: JTAG master mode. Used to set JTAG controller master mode
|
||||
* This is bitmask for mode param in jtag_mode for ioctl JTAG_SIOCMODE
|
||||
*/
|
||||
#define JTAG_MASTER_MODE 1
|
||||
/*
|
||||
* JTAG_XFER_HW_MODE: JTAG hardware mode. Used to set HW drived or bitbang
|
||||
* mode. This is bitmask for mode param in jtag_mode for ioctl JTAG_SIOCMODE
|
||||
*/
|
||||
#define JTAG_XFER_HW_MODE 1
|
||||
/*
|
||||
* JTAG_XFER_SW_MODE: JTAG software mode. Used to set SW drived or bitbang
|
||||
* mode. This is bitmask for mode param in jtag_mode for ioctl JTAG_SIOCMODE
|
||||
*/
|
||||
#define JTAG_XFER_SW_MODE 0
|
||||
|
||||
/**
|
||||
* enum jtag_tapstate:
|
||||
*
|
||||
* @JTAG_STATE_TLRESET: JTAG state machine Test Logic Reset state
|
||||
* @JTAG_STATE_IDLE: JTAG state machine IDLE state
|
||||
* @JTAG_STATE_SELECTDR: JTAG state machine SELECT_DR state
|
||||
* @JTAG_STATE_CAPTUREDR: JTAG state machine CAPTURE_DR state
|
||||
* @JTAG_STATE_SHIFTDR: JTAG state machine SHIFT_DR state
|
||||
* @JTAG_STATE_EXIT1DR: JTAG state machine EXIT-1 DR state
|
||||
* @JTAG_STATE_PAUSEDR: JTAG state machine PAUSE_DR state
|
||||
* @JTAG_STATE_EXIT2DR: JTAG state machine EXIT-2 DR state
|
||||
* @JTAG_STATE_UPDATEDR: JTAG state machine UPDATE DR state
|
||||
* @JTAG_STATE_SELECTIR: JTAG state machine SELECT_IR state
|
||||
* @JTAG_STATE_CAPTUREIR: JTAG state machine CAPTURE_IR state
|
||||
* @JTAG_STATE_SHIFTIR: JTAG state machine SHIFT_IR state
|
||||
* @JTAG_STATE_EXIT1IR: JTAG state machine EXIT-1 IR state
|
||||
* @JTAG_STATE_PAUSEIR: JTAG state machine PAUSE_IR state
|
||||
* @JTAG_STATE_EXIT2IR: JTAG state machine EXIT-2 IR state
|
||||
* @JTAG_STATE_UPDATEIR: JTAG state machine UPDATE IR state
|
||||
* @JTAG_STATE_CURRENT: JTAG current state, saved by driver
|
||||
*/
|
||||
enum jtag_tapstate {
|
||||
JTAG_STATE_TLRESET,
|
||||
JTAG_STATE_IDLE,
|
||||
JTAG_STATE_SELECTDR,
|
||||
JTAG_STATE_CAPTUREDR,
|
||||
JTAG_STATE_SHIFTDR,
|
||||
JTAG_STATE_EXIT1DR,
|
||||
JTAG_STATE_PAUSEDR,
|
||||
JTAG_STATE_EXIT2DR,
|
||||
JTAG_STATE_UPDATEDR,
|
||||
JTAG_STATE_SELECTIR,
|
||||
JTAG_STATE_CAPTUREIR,
|
||||
JTAG_STATE_SHIFTIR,
|
||||
JTAG_STATE_EXIT1IR,
|
||||
JTAG_STATE_PAUSEIR,
|
||||
JTAG_STATE_EXIT2IR,
|
||||
JTAG_STATE_UPDATEIR,
|
||||
JTAG_STATE_CURRENT
|
||||
};
|
||||
|
||||
/**
|
||||
* enum jtag_reset:
|
||||
*
|
||||
* @JTAG_NO_RESET: JTAG run TAP from current state
|
||||
* @JTAG_FORCE_RESET: JTAG force TAP to reset state
|
||||
*/
|
||||
enum jtag_reset {
|
||||
JTAG_NO_RESET = 0,
|
||||
JTAG_FORCE_RESET = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum jtag_xfer_type:
|
||||
*
|
||||
* @JTAG_SIR_XFER: SIR transfer
|
||||
* @JTAG_SDR_XFER: SDR transfer
|
||||
*/
|
||||
enum jtag_xfer_type {
|
||||
JTAG_SIR_XFER = 0,
|
||||
JTAG_SDR_XFER = 1,
|
||||
};
|
||||
|
||||
/**
|
||||
* enum jtag_xfer_direction:
|
||||
*
|
||||
* @JTAG_READ_XFER: read transfer
|
||||
* @JTAG_WRITE_XFER: write transfer
|
||||
* @JTAG_READ_WRITE_XFER: read & write transfer
|
||||
*/
|
||||
enum jtag_xfer_direction {
|
||||
JTAG_READ_XFER = 1,
|
||||
JTAG_WRITE_XFER = 2,
|
||||
JTAG_READ_WRITE_XFER = 3,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct jtag_tap_state - forces JTAG state machine to go into a TAPC
|
||||
* state
|
||||
*
|
||||
* @reset: 0 - run IDLE/PAUSE from current state
|
||||
* 1 - go through TEST_LOGIC/RESET state before IDLE/PAUSE
|
||||
* @end: completion flag
|
||||
* @tck: clock counter
|
||||
*
|
||||
* Structure provide interface to JTAG device for JTAG set state execution.
|
||||
*/
|
||||
struct jtag_tap_state {
|
||||
__u8 reset;
|
||||
__u8 from;
|
||||
__u8 endstate;
|
||||
__u32 tck;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* union pad_config - Padding Configuration:
|
||||
*
|
||||
* @type: transfer type
|
||||
* @pre_pad_number: Number of prepadding bits bit[11:0]
|
||||
* @post_pad_number: Number of prepadding bits bit[23:12]
|
||||
* @pad_data : Bit value to be used by pre and post padding bit[24]
|
||||
* @int_value: unsigned int packed padding configuration value bit[32:0]
|
||||
*
|
||||
* Structure provide pre and post padding configuration in a single __u32
|
||||
*/
|
||||
union pad_config {
|
||||
struct {
|
||||
__u32 pre_pad_number : 12;
|
||||
__u32 post_pad_number : 12;
|
||||
__u32 pad_data : 1;
|
||||
__u32 rsvd : 7;
|
||||
};
|
||||
__u32 int_value;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct jtag_xfer - jtag xfer:
|
||||
*
|
||||
* @type: transfer type
|
||||
* @direction: xfer direction
|
||||
* @from: xfer current state
|
||||
* @endstate: xfer end state
|
||||
* @padding: xfer padding
|
||||
* @length: xfer bits length
|
||||
* @tdio : xfer data array
|
||||
*
|
||||
* Structure provide interface to JTAG device for JTAG SDR/SIR xfer execution.
|
||||
*/
|
||||
struct jtag_xfer {
|
||||
__u8 type;
|
||||
__u8 direction;
|
||||
__u8 from;
|
||||
__u8 endstate;
|
||||
__u32 padding;
|
||||
__u32 length;
|
||||
__u64 tdio;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct bitbang_packet - jtag bitbang array packet:
|
||||
*
|
||||
* @data: JTAG Bitbang struct array pointer(input/output)
|
||||
* @length: array size (input)
|
||||
*
|
||||
* Structure provide interface to JTAG device for JTAG bitbang bundle execution
|
||||
*/
|
||||
struct bitbang_packet {
|
||||
struct tck_bitbang *data;
|
||||
__u32 length;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* struct jtag_bitbang - jtag bitbang:
|
||||
*
|
||||
* @tms: JTAG TMS
|
||||
* @tdi: JTAG TDI (input)
|
||||
* @tdo: JTAG TDO (output)
|
||||
*
|
||||
* Structure provide interface to JTAG device for JTAG bitbang execution.
|
||||
*/
|
||||
struct tck_bitbang {
|
||||
__u8 tms;
|
||||
__u8 tdi;
|
||||
__u8 tdo;
|
||||
} __attribute__((__packed__));
|
||||
|
||||
/**
|
||||
* struct jtag_mode - jtag mode:
|
||||
*
|
||||
* @feature: 0 - JTAG feature setting selector for JTAG controller HW/SW
|
||||
* 1 - JTAG feature setting selector for controller bus master
|
||||
* mode output (enable / disable).
|
||||
* @mode: (0 - SW / 1 - HW) for JTAG_XFER_MODE feature(0)
|
||||
* (0 - output disable / 1 - output enable) for JTAG_CONTROL_MODE
|
||||
* feature(1)
|
||||
*
|
||||
* Structure provide configuration modes to JTAG device.
|
||||
*/
|
||||
struct jtag_mode {
|
||||
__u32 feature;
|
||||
__u32 mode;
|
||||
};
|
||||
|
||||
/* ioctl interface */
|
||||
#define __JTAG_IOCTL_MAGIC 0xb2
|
||||
|
||||
#define JTAG_SIOCSTATE _IOW(__JTAG_IOCTL_MAGIC, 0, struct jtag_tap_state)
|
||||
#define JTAG_SIOCFREQ _IOW(__JTAG_IOCTL_MAGIC, 1, unsigned int)
|
||||
#define JTAG_GIOCFREQ _IOR(__JTAG_IOCTL_MAGIC, 2, unsigned int)
|
||||
#define JTAG_IOCXFER _IOWR(__JTAG_IOCTL_MAGIC, 3, struct jtag_xfer)
|
||||
#define JTAG_GIOCSTATUS _IOWR(__JTAG_IOCTL_MAGIC, 4, enum jtag_tapstate)
|
||||
#define JTAG_SIOCMODE _IOW(__JTAG_IOCTL_MAGIC, 5, unsigned int)
|
||||
#define JTAG_IOCBITBANG _IOW(__JTAG_IOCTL_MAGIC, 6, unsigned int)
|
||||
|
||||
|
||||
/******************************************************************************************************************/
|
||||
int ast_jtag_open(char *dev);
|
||||
void ast_jtag_close(void);
|
||||
unsigned int ast_get_jtag_freq(void);
|
||||
int ast_set_jtag_freq(unsigned int freq);
|
||||
int ast_jtag_run_test_idle(unsigned char end, unsigned int tck);
|
||||
int ast_jtag_xfer(unsigned char endsts, unsigned int len, unsigned int *out, unsigned int *in, enum jtag_xfer_type type);
|
||||
int ast_jtag_state_reset_force(unsigned char end, unsigned int tck);
|
||||
|
||||
#endif /* __UAPI_LINUX_JTAG_H */
|
||||
+159
@@ -0,0 +1,159 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* Copyright 2020 Aspeed Technology Inc.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
|
||||
#include <sys/mman.h>
|
||||
#include "ast-jtag.h"
|
||||
#include "svf.h"
|
||||
|
||||
#define ERROR_OK (0)
|
||||
#define ERROR_NO_CONFIG_FILE (-2)
|
||||
#define ERROR_BUF_TOO_SMALL (-3)
|
||||
#define ERROR_FAIL (-4)
|
||||
#define ERROR_WAIT (-5)
|
||||
#define ERROR_TIMEOUT_REACHED (-6)
|
||||
|
||||
enum { LOG_TRACE, LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
|
||||
int loglevel = LOG_WARN;
|
||||
|
||||
static void
|
||||
usage(FILE *fp, int argc, char **argv)
|
||||
{
|
||||
if(0)
|
||||
{
|
||||
argc = argc;
|
||||
}
|
||||
fprintf(fp,
|
||||
"Usage: %s [options]\n\n"
|
||||
"Options:\n"
|
||||
" -h | --help Print this message\n"
|
||||
" -d | --debug Set log level, default = 3\n"
|
||||
" -n | --node jtag device node\n"
|
||||
" -f | --frequency frequency\n"
|
||||
" -p | --play play SVF file\n"
|
||||
" -s | --software software mode\n"
|
||||
"",
|
||||
argv[0]);
|
||||
}
|
||||
|
||||
static const char short_options [] = "hsd:n:f:p:";
|
||||
|
||||
|
||||
|
||||
static const struct option
|
||||
long_options [] = {
|
||||
{ "help", no_argument, NULL, 'h' },
|
||||
{ "debug", required_argument, NULL, 'd' },
|
||||
{ "node", required_argument, NULL, 'n' },
|
||||
{ "fequency", required_argument, NULL, 'f' },
|
||||
{ "play", required_argument, NULL, 'p' },
|
||||
{ "software", no_argument, NULL, 's' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
|
||||
/*********************************************************************************/
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
|
||||
/*************************************************************************************/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret;
|
||||
char option;
|
||||
char svf_name[100] = "";
|
||||
char dev_name[100] = "";
|
||||
int svf = 0;
|
||||
unsigned int freq = 0;
|
||||
unsigned int jtag_freq = 0;
|
||||
uint8_t sw_mode = 0;
|
||||
|
||||
while ((option = getopt_long(argc, argv, short_options, long_options, NULL)) != (char) -1) {
|
||||
switch (option) {
|
||||
case 'h':
|
||||
usage(stdout, argc, argv);
|
||||
exit(EXIT_SUCCESS);
|
||||
break;
|
||||
case 'd':
|
||||
loglevel = atol(optarg);
|
||||
printf("loglevel %d\n", loglevel);
|
||||
break;
|
||||
case 'n':
|
||||
strcpy(dev_name, optarg);
|
||||
if (!strcmp(dev_name, "")) {
|
||||
printf("No dev file name!\n");
|
||||
usage(stdout, argc, argv);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'f':
|
||||
freq = atol(optarg);
|
||||
printf("frequency %d\n", freq);
|
||||
break;
|
||||
case 'p':
|
||||
svf = 1;
|
||||
strcpy(svf_name, optarg);
|
||||
if (!strcmp(svf_name, "")) {
|
||||
printf("No out file name!\n");
|
||||
usage(stdout, argc, argv);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 's':
|
||||
sw_mode = 1;
|
||||
break;
|
||||
default:
|
||||
usage(stdout, argc, argv);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
if (!svf){
|
||||
usage(stdout, argc, argv);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
#if 1
|
||||
if (ast_jtag_open(dev_name))
|
||||
exit(1);
|
||||
|
||||
ast_set_jtag_mode(sw_mode);
|
||||
//show current ast jtag configuration
|
||||
jtag_freq = ast_get_jtag_freq();
|
||||
|
||||
if (jtag_freq == 0) {
|
||||
perror("Jtag freq error !! \n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (freq) {
|
||||
ast_set_jtag_freq(freq);
|
||||
printf("JTAG Set Freq %d\n", freq);
|
||||
} else {
|
||||
printf("JTAG Freq %d\n", jtag_freq);
|
||||
}
|
||||
#endif
|
||||
if (svf) {
|
||||
printf("Playing %s \n", svf_name);
|
||||
ret = handle_svf_command(svf_name);
|
||||
if (ret == ERROR_OK) {
|
||||
printf("Success!\n");
|
||||
} else {
|
||||
printf("Error: %d\n", ret);
|
||||
}
|
||||
}
|
||||
|
||||
out:
|
||||
ast_jtag_close();
|
||||
|
||||
return 0;
|
||||
}
|
||||
+1560
File diff suppressed because it is too large
Load Diff
+93
@@ -0,0 +1,93 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0+ */
|
||||
/*
|
||||
* Copyright (C) 2005 by Dominic Rath
|
||||
* Dominic.Rath@gmx.de
|
||||
*
|
||||
* Copyright (C) 2007-2010 Øyvind Harboe
|
||||
* oyvind.harboe@zylin.com
|
||||
*/
|
||||
|
||||
#ifndef SVF_H
|
||||
#define SVF_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*-----</Macros>-------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Defines JTAG Test Access Port states.
|
||||
*
|
||||
* These definitions were gleaned from the ARM7TDMI-S Technical
|
||||
* Reference Manual and validated against several other ARM core
|
||||
* technical manuals.
|
||||
*
|
||||
* FIXME some interfaces require specific numbers be used, as they
|
||||
* are handed-off directly to their hardware implementations.
|
||||
* Fix those drivers to map as appropriate ... then pick some
|
||||
* sane set of numbers here (where 0/uninitialized == INVALID).
|
||||
*/
|
||||
typedef enum tap_state {
|
||||
TAP_INVALID = -1,
|
||||
/* Proper ARM recommended numbers */
|
||||
TAP_DREXIT2 = 0x0,
|
||||
TAP_DREXIT1 = 0x1,
|
||||
TAP_DRSHIFT = 0x2,
|
||||
TAP_DRPAUSE = 0x3,
|
||||
TAP_IRSELECT = 0x4,
|
||||
TAP_DRUPDATE = 0x5,
|
||||
TAP_DRCAPTURE = 0x6,
|
||||
TAP_DRSELECT = 0x7,
|
||||
TAP_IREXIT2 = 0x8,
|
||||
TAP_IREXIT1 = 0x9,
|
||||
TAP_IRSHIFT = 0xa,
|
||||
TAP_IRPAUSE = 0xb,
|
||||
TAP_IDLE = 0xc,
|
||||
TAP_IRUPDATE = 0xd,
|
||||
TAP_IRCAPTURE = 0xe,
|
||||
TAP_RESET = 0x0f,
|
||||
} tap_state_t;
|
||||
|
||||
/**
|
||||
* Defines arguments for reset functions
|
||||
*/
|
||||
#define SRST_DEASSERT 0
|
||||
#define SRST_ASSERT 1
|
||||
#define TRST_DEASSERT 0
|
||||
#define TRST_ASSERT 1
|
||||
|
||||
/**
|
||||
* Function tap_state_name
|
||||
* Returns a string suitable for display representing the JTAG tap_state
|
||||
*/
|
||||
const char *tap_state_name(tap_state_t state);
|
||||
|
||||
/** Provides user-friendly name lookup of TAP states. */
|
||||
tap_state_t tap_state_by_name(const char *name);
|
||||
|
||||
/** The current TAP state of the pending JTAG command queue. */
|
||||
extern tap_state_t cmd_queue_cur_state;
|
||||
|
||||
/**
|
||||
* This structure defines a single scan field in the scan. It provides
|
||||
* fields for the field's width and pointers to scan input and output
|
||||
* values.
|
||||
*
|
||||
* In addition, this structure includes a value and mask that is used by
|
||||
* jtag_add_dr_scan_check() to validate the value that was scanned out.
|
||||
*/
|
||||
struct scan_field {
|
||||
/** The number of bits this field specifies */
|
||||
int num_bits;
|
||||
/** A pointer to value to be scanned into the device */
|
||||
const uint8_t *out_value;
|
||||
/** A pointer to a 32-bit memory location for data scanned out */
|
||||
uint8_t *in_value;
|
||||
|
||||
/** The value used to check the data scanned out. */
|
||||
uint8_t *check_value;
|
||||
/** The mask to go with check_value */
|
||||
uint8_t *check_mask;
|
||||
};
|
||||
|
||||
int handle_svf_command(char *filename);
|
||||
#endif /* SVF_H */
|
||||
Reference in New Issue
Block a user