OpenOCD
angie.c File Reference
Include dependency graph for angie.c:

Go to the source code of this file.

Data Structures

struct  angie
 Describes one driver instance. More...
 
struct  angie_cmd
 ANGIE command (ANGIE command queue element). More...
 

Macros

#define ANGIE_BITSTREAM_FILE   PKGDATADIR "/angie/angie_bitstream.bit"
 Default location of ANGIE firmware image. More...
 
#define ANGIE_FIRMWARE_FILE   PKGDATADIR "/angie/angie_firmware.bin"
 Default location of ANGIE firmware image. More...
 
#define ANGIE_PID   0x414F
 USB Product ID of ANGIE device in unconfigured state (no firmware loaded yet) or with its firmware. More...
 
#define ANGIE_PID_2   0x424e
 
#define ANGIE_PID_3   0x4255
 
#define ANGIE_PID_4   0x4355
 
#define ANGIE_PID_5   0x4a55
 
#define ANGIE_RENUMERATION_DELAY_US   1500000
 Delay (in microseconds) to wait while EZ-USB performs ReNumeration. More...
 
#define ANGIE_VID   0x584e
 USB Vendor ID of ANGIE device in unconfigured state (no firmware loaded yet) or with its firmware. More...
 
#define CPU_RESET   0x01
 Value to write into CPUCS to put EZ-USB ANGIE into reset. More...
 
#define CPU_START   0x00
 Value to write into CPUCS to put EZ-USB ANGIE out of reset. More...
 
#define CPUCS_REG   0xE600
 Address of EZ-USB ANGIE CPU Control & Status register. More...
 
#define FIRMWARE_ADDR   0x0000
 Base address of firmware in EZ-USB ANGIE code space. More...
 
#define REQUEST_FIRMWARE_LOAD   0xA0
 USB Control EP0 bRequest: "Firmware Load". More...
 
#define SECTION_BUFFERSIZE   16384
 Maximum size of a single firmware section. More...
 
#define SPLIT_SCAN_THRESHOLD   10
 Tuning of OpenOCD SCAN commands split into multiple ANGIE commands. More...
 
#define USB_INTERFACE   0
 USB interface number. More...
 

Enumerations

enum  angie_delay_type {
  DELAY_CLOCK_TCK , DELAY_CLOCK_TMS , DELAY_SCAN_IN , DELAY_SCAN_OUT ,
  DELAY_SCAN_IO
}
 
enum  angie_payload_direction { PAYLOAD_DIRECTION_OUT , PAYLOAD_DIRECTION_IN }
 
enum  angie_type { ANGIE }
 ANGIE hardware type. More...
 

Functions

static int angie_allocate_payload (struct angie_cmd *angie_cmd, int size, enum angie_payload_direction direction)
 Allocate and initialize space in memory for ANGIE command payload. More...
 
static int angie_append_clock_tck_cmd (struct angie *device, uint16_t count)
 Generate a defined amount of TCK clock cycles. More...
 
static int angie_append_clock_tms_cmd (struct angie *device, uint8_t count, uint8_t sequence)
 Perform TAP state transitions. More...
 
static int angie_append_configure_tck_cmd (struct angie *device, int delay_scan_in, int delay_scan_out, int delay_scan_io, int delay_tck, int delay_tms)
 Set TCK delay counters. More...
 
static int angie_append_get_signals_cmd (struct angie *device)
 Read JTAG signals. More...
 
static int angie_append_queue (struct angie *device, struct angie_cmd *angie_cmd)
 Add a command to the ANGIE command queue. More...
 
static int angie_append_scan_cmd (struct angie *device, enum scan_type scan_type, int scan_size_bits, uint8_t *tdi, uint8_t *tdo_start, uint8_t *tdo, uint8_t tms_count_start, uint8_t tms_sequence_start, uint8_t tms_count_end, uint8_t tms_sequence_end, struct jtag_command *origin, bool postprocess)
 
static int angie_append_scan_cmd (struct angie *device, enum scan_type scan_type, int scan_size_bits, uint8_t *tdi, uint8_t *tdo_start, uint8_t *tdo, uint8_t tms_count_start, uint8_t tms_sequence_start, uint8_t tms_count_end, uint8_t tms_sequence_end, struct jtag_command *origin, bool postprocess)
 Perform JTAG scan. More...
 
static int angie_append_set_signals_cmd (struct angie *device, uint8_t low, uint8_t high)
 Arbitrarily set JTAG output signals. More...
 
static int angie_append_sleep_cmd (struct angie *device, uint32_t us)
 Sleep for a pre-defined number of microseconds. More...
 
static int angie_append_test_cmd (struct angie *device)
 Test command. More...
 
static int angie_calculate_delay (enum angie_delay_type type, long f, int *delay)
 Calculate delay values for a given TCK frequency. More...
 
static long angie_calculate_frequency (enum angie_delay_type type, int delay)
 Calculate frequency for a given delay value. More...
 
static void angie_clear_queue (struct angie *device)
 Clear the ANGIE command queue. More...
 
static const char * angie_cmd_id_string (uint8_t id)
 Convert an ANGIE command ID (id) to a human-readable string. More...
 
static int angie_cpu_reset (struct angie *device, char reset_bit)
 Writes '0' or '1' to the CPUCS register, putting the EZ-USB CPU into reset or out of reset. More...
 
static void angie_dump_command (struct angie_cmd *angie_cmd)
 Print one ANGIE command to stdout. More...
 
static void angie_dump_queue (struct angie *device)
 Print the ANGIE command queue to stdout. More...
 
static void angie_dump_signal_states (uint8_t input_signals, uint8_t output_signals)
 Print state of interesting signals via LOG_INFO(). More...
 
static int angie_execute_queue (struct jtag_command *cmd_queue)
 Executes the JTAG Command Queue. More...
 
static int angie_execute_queued_commands (struct angie *device, int timeout_ms)
 Sends all queued ANGIE commands to the ANGIE for execution. More...
 
static int angie_get_queue_size (struct angie *device, enum angie_payload_direction direction)
 Get the current number of bytes in the queue, including command IDs. More...
 
static int angie_i2c_write (struct angie *device, uint8_t *i2c_data, uint8_t i2c_data_size)
 Send an i2c write operation to dev-board components. More...
 
static int angie_init (void)
 Initiates the firmware download to the ANGIE adapter and prepares the USB handle. More...
 
static int angie_io_extender_config (struct angie *device, uint8_t i2c_adr, uint8_t cfg_value)
 Configure dev-board gpio extender modules by configuring their register 3 and register 1 responsible for IO directions and values. More...
 
static int angie_khz (int khz, int *jtag_speed)
 Set the TCK frequency of the ANGIE adapter. More...
 
static int angie_load_bitstream (struct angie *device, const char *filename)
 Downloads a bitstream file to the ANGIE's FPGA through the EZ-USB microcontroller over the USB bus. More...
 
static int angie_load_firmware (struct angie *device, const char *filename)
 Downloads a firmware image to the ANGIE's EZ-USB microcontroller over the USB bus. More...
 
static int angie_load_firmware_and_renumerate (struct angie *device, const char *filename, uint32_t delay_us)
 Puts the ANGIE's EZ-USB microcontroller into reset state, downloads the firmware image, resumes the microcontroller and re-enumerates USB devices. More...
 
static int angie_post_process_queue (struct angie *device)
 Perform post-processing of commands after ANGIE queue has been executed. More...
 
static int angie_post_process_scan (struct angie_cmd *angie_cmd)
 Post-process JTAG_SCAN command. More...
 
static int angie_queue_pathmove (struct angie *device, struct jtag_command *cmd)
 Move to one TAP state or several states in succession. More...
 
static int angie_queue_runtest (struct angie *device, struct jtag_command *cmd)
 Run Test. More...
 
static int angie_queue_scan (struct angie *device, struct jtag_command *cmd)
 Perform a scan operation on a JTAG register. More...
 
static int angie_queue_sleep (struct angie *device, struct jtag_command *cmd)
 Sleep for a specific amount of time. More...
 
static int angie_queue_stableclocks (struct angie *device, struct jtag_command *cmd)
 Generate TCK cycles while remaining in a stable state. More...
 
static int angie_queue_statemove (struct angie *device)
 Move from the current TAP state to the current TAP end state. More...
 
static int angie_queue_tlr_reset (struct angie *device, struct jtag_command *cmd)
 Move the TAP into the Test Logic Reset state. More...
 
static int angie_quit (void)
 Closes the USB handle for the ANGIE device. More...
 
static int angie_reset (int trst, int srst)
 Execute a JTAG_RESET command. More...
 
static void angie_set_end_state (tap_state_t endstate)
 Sets the end state follower (see interface.h) if endstate is a stable state. More...
 
static int angie_speed (int speed)
 Set the TCK frequency of the ANGIE adapter. More...
 
static int angie_speed_div (int speed, int *khz)
 Convert adapter-specific speed value to corresponding TCK frequency in kHz. More...
 
static int angie_usb_close (struct angie *device)
 Releases the ANGIE interface and closes the USB device handle. More...
 
static int angie_usb_open (struct angie *device)
 Opens the ANGIE device. More...
 
static int angie_write_firmware_section (struct angie *device, struct image *firmware_image, int section_index)
 Send one contiguous firmware section to the ANGIE's EZ-USB microcontroller over the USB bus. More...
 

Variables

struct adapter_driver angie_adapter_driver
 
static struct angieangie_handle
 
static struct jtag_interface angie_interface
 

Macro Definition Documentation

◆ ANGIE_BITSTREAM_FILE

#define ANGIE_BITSTREAM_FILE   PKGDATADIR "/angie/angie_bitstream.bit"

Default location of ANGIE firmware image.

Definition at line 66 of file angie.c.

◆ ANGIE_FIRMWARE_FILE

#define ANGIE_FIRMWARE_FILE   PKGDATADIR "/angie/angie_firmware.bin"

Default location of ANGIE firmware image.

Definition at line 63 of file angie.c.

◆ ANGIE_PID

#define ANGIE_PID   0x414F

USB Product ID of ANGIE device in unconfigured state (no firmware loaded yet) or with its firmware.

Definition at line 34 of file angie.c.

◆ ANGIE_PID_2

#define ANGIE_PID_2   0x424e

Definition at line 35 of file angie.c.

◆ ANGIE_PID_3

#define ANGIE_PID_3   0x4255

Definition at line 36 of file angie.c.

◆ ANGIE_PID_4

#define ANGIE_PID_4   0x4355

Definition at line 37 of file angie.c.

◆ ANGIE_PID_5

#define ANGIE_PID_5   0x4a55

Definition at line 38 of file angie.c.

◆ ANGIE_RENUMERATION_DELAY_US

#define ANGIE_RENUMERATION_DELAY_US   1500000

Delay (in microseconds) to wait while EZ-USB performs ReNumeration.

Definition at line 60 of file angie.c.

◆ ANGIE_VID

#define ANGIE_VID   0x584e

USB Vendor ID of ANGIE device in unconfigured state (no firmware loaded yet) or with its firmware.

Definition at line 30 of file angie.c.

◆ CPU_RESET

#define CPU_RESET   0x01

Value to write into CPUCS to put EZ-USB ANGIE into reset.

Definition at line 48 of file angie.c.

◆ CPU_START

#define CPU_START   0x00

Value to write into CPUCS to put EZ-USB ANGIE out of reset.

Definition at line 51 of file angie.c.

◆ CPUCS_REG

#define CPUCS_REG   0xE600

Address of EZ-USB ANGIE CPU Control & Status register.

This register can be written by issuing a Control EP0 vendor request.

Definition at line 42 of file angie.c.

◆ FIRMWARE_ADDR

#define FIRMWARE_ADDR   0x0000

Base address of firmware in EZ-USB ANGIE code space.

Definition at line 54 of file angie.c.

◆ REQUEST_FIRMWARE_LOAD

#define REQUEST_FIRMWARE_LOAD   0xA0

USB Control EP0 bRequest: "Firmware Load".

Definition at line 45 of file angie.c.

◆ SECTION_BUFFERSIZE

#define SECTION_BUFFERSIZE   16384

Maximum size of a single firmware section.

Entire EZ-USB ANGIE code space = 16kB

Definition at line 69 of file angie.c.

◆ SPLIT_SCAN_THRESHOLD

#define SPLIT_SCAN_THRESHOLD   10

Tuning of OpenOCD SCAN commands split into multiple ANGIE commands.

Definition at line 72 of file angie.c.

◆ USB_INTERFACE

#define USB_INTERFACE   0

USB interface number.

Definition at line 57 of file angie.c.

Enumeration Type Documentation

◆ angie_delay_type

Enumerator
DELAY_CLOCK_TCK 
DELAY_CLOCK_TMS 
DELAY_SCAN_IN 
DELAY_SCAN_OUT 
DELAY_SCAN_IO 

Definition at line 84 of file angie.c.

◆ angie_payload_direction

Enumerator
PAYLOAD_DIRECTION_OUT 
PAYLOAD_DIRECTION_IN 

Definition at line 79 of file angie.c.

◆ angie_type

enum angie_type

ANGIE hardware type.

Enumerator
ANGIE 

Definition at line 75 of file angie.c.

Function Documentation

◆ angie_allocate_payload()

static int angie_allocate_payload ( struct angie_cmd angie_cmd,
int  size,
enum angie_payload_direction  direction 
)
static

Allocate and initialize space in memory for ANGIE command payload.

Parameters
angie_cmdpointer to command whose payload should be allocated.
sizethe amount of memory to allocate (bytes).
directionwhich payload to allocate.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 655 of file angie.c.

References direction, ERROR_FAIL, ERROR_OK, angie_cmd::free_payload_in_start, LOG_ERROR, PAYLOAD_DIRECTION_IN, PAYLOAD_DIRECTION_OUT, angie_cmd::payload_in, angie_cmd::payload_in_size, angie_cmd::payload_in_start, angie_cmd::payload_out, angie_cmd::payload_out_size, and size.

Referenced by angie_append_clock_tck_cmd(), angie_append_clock_tms_cmd(), angie_append_configure_tck_cmd(), angie_append_get_signals_cmd(), angie_append_scan_cmd(), angie_append_set_signals_cmd(), angie_append_sleep_cmd(), and angie_append_test_cmd().

◆ angie_append_clock_tck_cmd()

static int angie_append_clock_tck_cmd ( struct angie device,
uint16_t  count 
)
static

Generate a defined amount of TCK clock cycles.

All other JTAG signals are left unchanged.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
countthe number of TCK clock cycles to generate.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1144 of file angie.c.

References angie_allocate_payload(), angie_append_queue(), cmd, CMD_CLOCK_TCK, CMD_SLOW_CLOCK_TCK, count, device, ERROR_FAIL, ERROR_OK, LOG_ERROR, and PAYLOAD_DIRECTION_OUT.

Referenced by angie_queue_runtest(), and angie_queue_stableclocks().

◆ angie_append_clock_tms_cmd()

static int angie_append_clock_tms_cmd ( struct angie device,
uint8_t  count,
uint8_t  sequence 
)
static

Perform TAP state transitions.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
countdefines the number of TCK clock cycles generated (up to 8).
sequencedefines the TMS pin levels for each state transition. The Least-Significant Bit is read first.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1105 of file angie.c.

References angie_allocate_payload(), angie_append_queue(), cmd, CMD_CLOCK_TMS, CMD_SLOW_CLOCK_TMS, count, device, ERROR_FAIL, ERROR_OK, LOG_ERROR, and PAYLOAD_DIRECTION_OUT.

Referenced by angie_queue_pathmove(), angie_queue_statemove(), and angie_queue_tlr_reset().

◆ angie_append_configure_tck_cmd()

static int angie_append_configure_tck_cmd ( struct angie device,
int  delay_scan_in,
int  delay_scan_out,
int  delay_scan_io,
int  delay_tck,
int  delay_tms 
)
static

Set TCK delay counters.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
delay_scan_indelay count top value in jtag_slow_scan_in() function.
delay_scan_outdelay count top value in jtag_slow_scan_out() function.
delay_scan_iodelay count top value in jtag_slow_scan_io() function.
delay_tckdelay count top value in jtag_clock_tck() function.
delay_tmsdelay count top value in jtag_slow_clock_tms() function.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1293 of file angie.c.

References angie_allocate_payload(), angie_append_queue(), cmd, CMD_CONFIGURE_TCK_FREQ, delay_scan_in, delay_scan_io, delay_scan_out, delay_tck, delay_tms, device, ERROR_FAIL, ERROR_OK, LOG_ERROR, and PAYLOAD_DIRECTION_OUT.

Referenced by angie_khz().

◆ angie_append_get_signals_cmd()

static int angie_append_get_signals_cmd ( struct angie device)
static

Read JTAG signals.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1179 of file angie.c.

References angie_allocate_payload(), angie_append_queue(), cmd, CMD_GET_SIGNALS, device, ERROR_FAIL, ERROR_OK, LOG_ERROR, and PAYLOAD_DIRECTION_IN.

Referenced by angie_init().

◆ angie_append_queue()

static int angie_append_queue ( struct angie device,
struct angie_cmd angie_cmd 
)
static

Add a command to the ANGIE command queue.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
angie_cmdpointer to command that shall be appended to the ANGIE command queue.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 778 of file angie.c.

References angie_clear_queue(), angie_execute_queued_commands(), angie_get_queue_size(), angie_post_process_queue(), device, ERROR_OK, LIBUSB_TIMEOUT_MS, PAYLOAD_DIRECTION_IN, PAYLOAD_DIRECTION_OUT, angie_cmd::payload_in_size, and angie_cmd::payload_out_size.

Referenced by angie_append_clock_tck_cmd(), angie_append_clock_tms_cmd(), angie_append_configure_tck_cmd(), angie_append_get_signals_cmd(), angie_append_scan_cmd(), angie_append_set_signals_cmd(), angie_append_sleep_cmd(), and angie_append_test_cmd().

◆ angie_append_scan_cmd() [1/2]

static int angie_append_scan_cmd ( struct angie device,
enum scan_type  scan_type,
int  scan_size_bits,
uint8_t *  tdi,
uint8_t *  tdo_start,
uint8_t *  tdo,
uint8_t  tms_count_start,
uint8_t  tms_sequence_start,
uint8_t  tms_count_end,
uint8_t  tms_sequence_end,
struct jtag_command origin,
bool  postprocess 
)
static

Referenced by angie_queue_scan().

◆ angie_append_scan_cmd() [2/2]

static int angie_append_scan_cmd ( struct angie device,
enum scan_type  scan_type,
int  scan_size_bits,
uint8_t *  tdi,
uint8_t *  tdo_start,
uint8_t *  tdo,
uint8_t  tms_count_start,
uint8_t  tms_sequence_start,
uint8_t  tms_count_end,
uint8_t  tms_sequence_end,
struct jtag_command origin,
bool  postprocess 
)
static

Perform JTAG scan.

Creates and appends a JTAG scan command to the ANGIE command queue. A JTAG scan consists of three steps:

  • Move to the desired SHIFT state, depending on scan type (IR/DR scan).
  • Shift TDI data into the JTAG chain, optionally reading the TDO pin.
  • Move to the desired end state.
Parameters
devicepointer to struct angie identifying ANGIE driver instance.
scan_typethe type of the scan (IN, OUT, IO (bidirectional)).
scan_size_bitsnumber of bits to shift into the JTAG chain.
tdipointer to array containing TDI data.
tdo_startpointer to first element of array where TDO data shall be stored. See angie_cmd for details.
tdopointer to array where TDO data shall be stored
tms_count_startnumber of TMS state transitions to perform BEFORE shifting data into the JTAG chain.
tms_sequence_startsequence of TMS state transitions that will be performed BEFORE shifting data into the JTAG chain.
tms_count_endnumber of TMS state transitions to perform AFTER shifting data into the JTAG chain.
tms_sequence_endsequence of TMS state transitions that will be performed AFTER shifting data into the JTAG chain.
originpointer to OpenOCD command that generated this scan command.
postprocesswhether this command needs to be post-processed after execution.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1004 of file angie.c.

References angie_allocate_payload(), angie_append_queue(), cmd, CMD_SCAN_IN, CMD_SCAN_IO, CMD_SCAN_OUT, CMD_SLOW_SCAN_IN, CMD_SLOW_SCAN_IO, CMD_SLOW_SCAN_OUT, device, DIV_ROUND_UP, ERROR_FAIL, ERROR_OK, LOG_ERROR, PAYLOAD_DIRECTION_IN, PAYLOAD_DIRECTION_OUT, SCAN_IN, SCAN_IO, and SCAN_OUT.

◆ angie_append_set_signals_cmd()

static int angie_append_set_signals_cmd ( struct angie device,
uint8_t  low,
uint8_t  high 
)
static

Arbitrarily set JTAG output signals.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
lowdefines which signals will be de-asserted. Each bit corresponds to a JTAG signal:
  • SIGNAL_TDI
  • SIGNAL_TMS
  • SIGNAL_TCK
  • SIGNAL_TRST
  • SIGNAL_BRKIN
  • SIGNAL_RESET
  • SIGNAL_OCDSE
highdefines which signals will be asserted.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1220 of file angie.c.

References angie_allocate_payload(), angie_append_queue(), cmd, CMD_SET_SIGNALS, device, ERROR_FAIL, ERROR_OK, LOG_ERROR, low, and PAYLOAD_DIRECTION_OUT.

Referenced by angie_queue_stableclocks(), and angie_reset().

◆ angie_append_sleep_cmd()

static int angie_append_sleep_cmd ( struct angie device,
uint32_t  us 
)
static

Sleep for a pre-defined number of microseconds.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
usthe number microseconds to sleep.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1255 of file angie.c.

References angie_allocate_payload(), angie_append_queue(), cmd, CMD_SLEEP_US, device, ERROR_FAIL, ERROR_OK, LOG_ERROR, and PAYLOAD_DIRECTION_OUT.

Referenced by angie_queue_sleep().

◆ angie_append_test_cmd()

static int angie_append_test_cmd ( struct angie device)
static

Test command.

Used to check if the ANGIE device is ready to accept new commands.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1350 of file angie.c.

References angie_allocate_payload(), angie_append_queue(), cmd, CMD_TEST, device, ERROR_FAIL, ERROR_OK, LOG_ERROR, and PAYLOAD_DIRECTION_OUT.

Referenced by angie_init().

◆ angie_calculate_delay()

static int angie_calculate_delay ( enum angie_delay_type  type,
long  f,
int *  delay 
)
static

Calculate delay values for a given TCK frequency.

The ANGIE firmware uses five different speed values for different commands. These speed values are calculated in these functions.

The five different commands which support variable TCK frequency are implemented twice in the firmware:

  1. Maximum possible frequency without any artificial delay
  2. Variable frequency with artificial linear delay loop

To set the ANGIE to maximum frequency, it is only necessary to use the corresponding command IDs. To set the ANGIE to a lower frequency, the delay loop top values have to be calculated first. Then, a CMD_CONFIGURE_TCK_FREQ command needs to be sent to the ANGIE device.

The delay values are described by linear equations: t = k * x + d (t = period, k = constant, x = delay value, d = constant)

Thus, the delay can be calculated as in the following equation: x = (t - d) / k

The constants in these equations have been determined and validated by measuring the frequency resulting from different delay values.

Parameters
typefor which command to calculate the delay value.
fTCK frequency for which to calculate the delay value in Hz.
delaywhere to store resulting delay value.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1408 of file angie.c.

References DELAY_CLOCK_TCK, DELAY_CLOCK_TMS, DELAY_SCAN_IN, DELAY_SCAN_IO, DELAY_SCAN_OUT, ERROR_FAIL, ERROR_OK, and type.

Referenced by angie_khz().

◆ angie_calculate_frequency()

static long angie_calculate_frequency ( enum angie_delay_type  type,
int  delay 
)
static

Calculate frequency for a given delay value.

Similar to the angie_calculate_delay function, this function calculates the TCK frequency for a given delay value by using linear equations of the form: t = k * x + d (t = period, k = constant, x = delay value, d = constant)

Parameters
typefor which command to calculate the delay value.
delayvalue for which to calculate the resulting TCK frequency.
Returns
the resulting TCK frequency

Definition at line 1468 of file angie.c.

References DELAY_CLOCK_TCK, DELAY_CLOCK_TMS, DELAY_SCAN_IN, DELAY_SCAN_IO, DELAY_SCAN_OUT, and type.

Referenced by angie_khz().

◆ angie_clear_queue()

static void angie_clear_queue ( struct angie device)
static

Clear the ANGIE command queue.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.

Definition at line 736 of file angie.c.

References device, angie_cmd::free_payload_in_start, angie_cmd::next, NULL, angie_cmd::payload_in, angie_cmd::payload_in_start, and angie_cmd::payload_out.

Referenced by angie_append_queue(), angie_execute_queue(), angie_init(), and angie_reset().

◆ angie_cmd_id_string()

static const char* angie_cmd_id_string ( uint8_t  id)
static

Convert an ANGIE command ID (id) to a human-readable string.

Parameters
idthe ANGIE command ID.
Returns
the corresponding human-readable string.

Definition at line 899 of file angie.c.

References CMD_CLOCK_TCK, CMD_CLOCK_TMS, CMD_CONFIGURE_TCK_FREQ, CMD_GET_SIGNALS, CMD_SCAN_IN, CMD_SCAN_IO, CMD_SCAN_OUT, CMD_SET_LEDS, CMD_SET_SIGNALS, CMD_SLEEP_MS, CMD_SLEEP_US, CMD_SLOW_CLOCK_TCK, CMD_SLOW_CLOCK_TMS, CMD_SLOW_SCAN_IN, CMD_SLOW_SCAN_IO, CMD_SLOW_SCAN_OUT, and CMD_TEST.

Referenced by angie_dump_command().

◆ angie_cpu_reset()

static int angie_cpu_reset ( struct angie device,
char  reset_bit 
)
static

Writes '0' or '1' to the CPUCS register, putting the EZ-USB CPU into reset or out of reset.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
reset_bit0 to put CPU into reset, 1 to put CPU out of reset.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 308 of file angie.c.

References CPUCS_REG, device, jtag_libusb_control_transfer(), LIBUSB_TIMEOUT_MS, NULL, and REQUEST_FIRMWARE_LOAD.

Referenced by angie_load_firmware().

◆ angie_dump_command()

static void angie_dump_command ( struct angie_cmd angie_cmd)
static

Print one ANGIE command to stdout.

Parameters
angie_cmdpointer to ANGIE command.

Definition at line 946 of file angie.c.

References angie_cmd_id_string(), angie_cmd::id, LOG_DEBUG_IO, angie_cmd::payload_in_size, angie_cmd::payload_out, and angie_cmd::payload_out_size.

Referenced by angie_dump_queue().

◆ angie_dump_queue()

static void angie_dump_queue ( struct angie device)
static

Print the ANGIE command queue to stdout.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.

Definition at line 964 of file angie.c.

References angie_dump_command(), device, LOG_DEBUG_IO, and angie_cmd::next.

Referenced by angie_execute_queued_commands().

◆ angie_dump_signal_states()

static void angie_dump_signal_states ( uint8_t  input_signals,
uint8_t  output_signals 
)
static

Print state of interesting signals via LOG_INFO().

Parameters
input_signalsinput signal states as returned by CMD_GET_SIGNALS
output_signalsoutput signal states as returned by CMD_GET_SIGNALS

Definition at line 632 of file angie.c.

References LOG_INFO, SIGNAL_SRST, SIGNAL_TCK, SIGNAL_TDI, SIGNAL_TDO, SIGNAL_TMS, and SIGNAL_TRST.

Referenced by angie_init().

◆ angie_execute_queue()

static int angie_execute_queue ( struct jtag_command cmd_queue)
static

Executes the JTAG Command Queue.

This is done in three stages: First, all OpenOCD commands are processed into queued ANGIE commands. Next, the ANGIE command queue is sent to the ANGIE device and data received from the ANGIE device is cached. Finally, the post-processing function writes back data to the corresponding OpenOCD commands.

Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 2041 of file angie.c.

References angie_clear_queue(), angie_execute_queued_commands(), angie_handle, angie_post_process_queue(), angie_queue_pathmove(), angie_queue_runtest(), angie_queue_scan(), angie_queue_sleep(), angie_queue_stableclocks(), angie_queue_tlr_reset(), cmd, angie::commands_in_queue, ERROR_FAIL, ERROR_OK, JTAG_PATHMOVE, JTAG_RUNTEST, JTAG_SCAN, JTAG_SLEEP, JTAG_STABLECLOCKS, JTAG_TLR_RESET, LIBUSB_TIMEOUT_MS, and LOG_ERROR.

◆ angie_execute_queued_commands()

static int angie_execute_queued_commands ( struct angie device,
int  timeout_ms 
)
static

Sends all queued ANGIE commands to the ANGIE for execution.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
timeout_ms
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 830 of file angie.c.

References angie_dump_queue(), buffer, device, ERROR_FAIL, ERROR_OK, angie_cmd::id, jtag_libusb_bulk_write(), LOG_ERROR, LOG_LEVEL_IS, LOG_LVL_DEBUG_IO, angie_cmd::next, angie_cmd::payload_in, angie_cmd::payload_in_size, angie_cmd::payload_out, and angie_cmd::payload_out_size.

Referenced by angie_append_queue(), angie_execute_queue(), angie_init(), and angie_reset().

◆ angie_get_queue_size()

static int angie_get_queue_size ( struct angie device,
enum angie_payload_direction  direction 
)
static

Get the current number of bytes in the queue, including command IDs.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
directionthe transfer direction for which to get byte count.
Returns
the number of bytes currently stored in the queue for the specified direction.

Definition at line 709 of file angie.c.

References device, direction, angie_cmd::next, PAYLOAD_DIRECTION_IN, PAYLOAD_DIRECTION_OUT, angie_cmd::payload_in_size, and angie_cmd::payload_out_size.

Referenced by angie_append_queue().

◆ angie_i2c_write()

static int angie_i2c_write ( struct angie device,
uint8_t *  i2c_data,
uint8_t  i2c_data_size 
)
static

Send an i2c write operation to dev-board components.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
i2c_datatable of i2c data that we want to write to slave device.
i2c_data_sizethe size of i2c data table.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 502 of file angie.c.

References device, ERROR_FAIL, ERROR_OK, jtag_libusb_bulk_write(), and LOG_ERROR.

Referenced by angie_io_extender_config().

◆ angie_init()

◆ angie_io_extender_config()

static int angie_io_extender_config ( struct angie device,
uint8_t  i2c_adr,
uint8_t  cfg_value 
)
static

Configure dev-board gpio extender modules by configuring their register 3 and register 1 responsible for IO directions and values.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
i2c_adri2c address of the gpio extender.
cfg_valueIOs configuration to be written in register Number 3.
valuethe IOs value to be written in register Number 1.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 547 of file angie.c.

References angie_i2c_write(), device, and ERROR_OK.

Referenced by angie_init().

◆ angie_khz()

static int angie_khz ( int  khz,
int *  jtag_speed 
)
static

Set the TCK frequency of the ANGIE adapter.

Parameters
khzdesired JTAG TCK frequency.
jtag_speedwhere to store corresponding adapter-specific speed value.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 2101 of file angie.c.

References angie_append_configure_tck_cmd(), angie_calculate_delay(), angie_calculate_frequency(), angie_handle, DELAY_CLOCK_TCK, angie::delay_clock_tck, DELAY_CLOCK_TMS, angie::delay_clock_tms, DELAY_SCAN_IN, angie::delay_scan_in, DELAY_SCAN_IO, angie::delay_scan_io, DELAY_SCAN_OUT, angie::delay_scan_out, ERROR_FAIL, ERROR_OK, LOG_DEBUG_IO, and LOG_ERROR.

Referenced by angie_speed().

◆ angie_load_bitstream()

static int angie_load_bitstream ( struct angie device,
const char *  filename 
)
static

Downloads a bitstream file to the ANGIE's FPGA through the EZ-USB microcontroller over the USB bus.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
filenamean absolute or relative path to the Xilinx .bit file containing the bitstream data.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 417 of file angie.c.

References device, ERROR_FAIL, ERROR_OK, h_u32_to_be(), jtag_libusb_bulk_write(), jtag_libusb_control_transfer(), LIBUSB_TIMEOUT_MS, LOG_ERROR, LOG_INFO, and NULL.

Referenced by angie_init().

◆ angie_load_firmware()

static int angie_load_firmware ( struct angie device,
const char *  filename 
)
static

Downloads a firmware image to the ANGIE's EZ-USB microcontroller over the USB bus.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
filenamean absolute or relative path to the Intel HEX file containing the firmware image.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 367 of file angie.c.

References angie_cpu_reset(), angie_write_firmware_section(), image::base_address, image::base_address_set, CPU_RESET, CPU_START, device, ERROR_OK, image_close(), image_open(), LOG_ERROR, and image::num_sections.

Referenced by angie_load_firmware_and_renumerate().

◆ angie_load_firmware_and_renumerate()

static int angie_load_firmware_and_renumerate ( struct angie device,
const char *  filename,
uint32_t  delay_us 
)
static

Puts the ANGIE's EZ-USB microcontroller into reset state, downloads the firmware image, resumes the microcontroller and re-enumerates USB devices.

Parameters
devicepointer to struct angie identifying ANGIE driver instance. The usb_handle member will be modified during re-enumeration.
filenamepath to the Intel HEX file containing the firmware image.
delay_usthe delay to wait for the device to re-enumerate.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 327 of file angie.c.

References angie_handle, angie_load_firmware(), angie_usb_close(), angie_usb_open(), delay_us(), device, ERROR_FAIL, ERROR_OK, and angie::usb_device_handle.

Referenced by angie_init().

◆ angie_post_process_queue()

static int angie_post_process_queue ( struct angie device)
static

Perform post-processing of commands after ANGIE queue has been executed.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1984 of file angie.c.

References angie_post_process_scan(), angie_cmd::cmd_origin, device, ERROR_FAIL, ERROR_OK, JTAG_PATHMOVE, JTAG_RUNTEST, JTAG_SCAN, JTAG_SLEEP, JTAG_STABLECLOCKS, JTAG_TLR_RESET, LOG_ERROR, angie_cmd::needs_postprocessing, angie_cmd::next, and jtag_command::type.

Referenced by angie_append_queue(), and angie_execute_queue().

◆ angie_post_process_scan()

static int angie_post_process_scan ( struct angie_cmd angie_cmd)
static

Post-process JTAG_SCAN command.

Parameters
angie_cmdpointer to ANGIE command that shall be processed.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1954 of file angie.c.

References cmd, angie_cmd::cmd_origin, ERROR_FAIL, ERROR_OK, jtag_read_buffer(), jtag_scan_type(), LOG_ERROR, angie_cmd::payload_in_start, SCAN_IN, SCAN_IO, and SCAN_OUT.

Referenced by angie_post_process_queue().

◆ angie_queue_pathmove()

static int angie_queue_pathmove ( struct angie device,
struct jtag_command cmd 
)
static

Move to one TAP state or several states in succession.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
cmdpointer to the command that shall be executed.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1837 of file angie.c.

References angie_append_clock_tms_cmd(), angie_handle, buf_set_u32(), cmd, ERROR_FAIL, ERROR_OK, LOG_ERROR, LOG_INFO, tap_get_state(), tap_set_state, tap_state_name(), and tap_state_transition().

Referenced by angie_execute_queue().

◆ angie_queue_runtest()

static int angie_queue_runtest ( struct angie device,
struct jtag_command cmd 
)
static

Run Test.

Generate TCK clock cycles while remaining in the Run-Test/Idle state.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
cmdpointer to the command that shall be executed.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1766 of file angie.c.

References angie_append_clock_tck_cmd(), angie_queue_statemove(), angie_set_end_state(), cmd, device, ERROR_OK, tap_get_state(), TAP_IDLE, and tap_set_end_state().

Referenced by angie_execute_queue().

◆ angie_queue_scan()

static int angie_queue_scan ( struct angie device,
struct jtag_command cmd 
)
static

Perform a scan operation on a JTAG register.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
cmdpointer to the command that shall be executed.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1566 of file angie.c.

References angie_append_scan_cmd(), angie_set_end_state(), cmd, device, DIV_ROUND_UP, ERROR_FAIL, ERROR_OK, jtag_build_buffer(), jtag_scan_size(), jtag_scan_type(), NULL, SCAN_IN, SCAN_IO, SCAN_OUT, TAP_DRPAUSE, TAP_DRSHIFT, tap_get_end_state(), tap_get_state(), tap_get_tms_path(), tap_get_tms_path_len(), TAP_IRPAUSE, TAP_IRSHIFT, tap_set_end_state(), tap_set_state, tdi_buffer, tdo_buffer, and type.

Referenced by angie_execute_queue().

◆ angie_queue_sleep()

static int angie_queue_sleep ( struct angie device,
struct jtag_command cmd 
)
static

Sleep for a specific amount of time.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
cmdpointer to the command that shall be executed.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1897 of file angie.c.

References angie_append_sleep_cmd(), cmd, and device.

Referenced by angie_execute_queue().

◆ angie_queue_stableclocks()

static int angie_queue_stableclocks ( struct angie device,
struct jtag_command cmd 
)
static

Generate TCK cycles while remaining in a stable state.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
cmdpointer to the command that shall be executed.

Definition at line 1910 of file angie.c.

References angie_append_clock_tck_cmd(), angie_append_set_signals_cmd(), cmd, device, ERROR_FAIL, ERROR_OK, LOG_ERROR, SIGNAL_TMS, tap_get_state(), tap_is_state_stable(), and TAP_RESET.

Referenced by angie_execute_queue().

◆ angie_queue_statemove()

static int angie_queue_statemove ( struct angie device)
static

Move from the current TAP state to the current TAP end state.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1537 of file angie.c.

References angie_append_clock_tms_cmd(), device, ERROR_OK, tap_get_end_state(), tap_get_state(), tap_get_tms_path(), tap_get_tms_path_len(), and tap_set_state.

Referenced by angie_queue_runtest().

◆ angie_queue_tlr_reset()

static int angie_queue_tlr_reset ( struct angie device,
struct jtag_command cmd 
)
static

Move the TAP into the Test Logic Reset state.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
cmdpointer to the command that shall be executed.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1745 of file angie.c.

References angie_append_clock_tms_cmd(), device, ERROR_OK, TAP_RESET, and tap_set_state.

Referenced by angie_execute_queue().

◆ angie_quit()

static int angie_quit ( void  )
static

Closes the USB handle for the ANGIE device.

Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 2376 of file angie.c.

Referenced by angie_init().

◆ angie_reset()

static int angie_reset ( int  trst,
int  srst 
)
static

Execute a JTAG_RESET command.

Parameters
device
trstindicate if trst signal is activated.
srstindicate if srst signal is activated.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 1799 of file angie.c.

References angie_append_set_signals_cmd(), angie_clear_queue(), angie_execute_queued_commands(), angie_handle, device, ERROR_OK, LIBUSB_TIMEOUT_MS, low, SIGNAL_SRST, SIGNAL_TRST, TAP_RESET, and tap_set_state.

◆ angie_set_end_state()

static void angie_set_end_state ( tap_state_t  endstate)
static

Sets the end state follower (see interface.h) if endstate is a stable state.

Parameters
endstatethe state the end state follower should be set to.

Definition at line 1522 of file angie.c.

References LOG_ERROR, tap_is_state_stable(), tap_set_end_state(), and tap_state_name().

Referenced by angie_queue_runtest(), and angie_queue_scan().

◆ angie_speed()

static int angie_speed ( int  speed)
static

Set the TCK frequency of the ANGIE adapter.

Because of the way the TCK frequency is set up in the ANGIE firmware, there are five different speed settings. To simplify things, the adapter-specific speed setting value is identical to the TCK frequency in khz.

Parameters
speeddesired adapter-specific speed value.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 2196 of file angie.c.

References angie_khz(), and dummy.

◆ angie_speed_div()

static int angie_speed_div ( int  speed,
int *  khz 
)
static

Convert adapter-specific speed value to corresponding TCK frequency in kHz.

Because of the way the TCK frequency is set up in the ANGIE firmware, there are five different speed settings. To simplify things, the adapter-specific speed setting value is identical to the TCK frequency in khz.

Parameters
speedadapter-specific speed value.
khzwhere to store corresponding TCK frequency in kHz.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 2216 of file angie.c.

References ERROR_OK.

◆ angie_usb_close()

static int angie_usb_close ( struct angie device)
static

Releases the ANGIE interface and closes the USB device handle.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 283 of file angie.c.

References device, ERROR_FAIL, ERROR_OK, jtag_libusb_close(), LOG_ERROR, and NULL.

Referenced by angie_load_firmware_and_renumerate().

◆ angie_usb_open()

static int angie_usb_open ( struct angie device)
static

Opens the ANGIE device.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 257 of file angie.c.

References ANGIE, ANGIE_PID, ANGIE_PID_2, ANGIE_PID_3, ANGIE_PID_4, ANGIE_PID_5, ANGIE_VID, device, ERROR_OK, jtag_libusb_open(), LOG_ERROR, and NULL.

Referenced by angie_init(), and angie_load_firmware_and_renumerate().

◆ angie_write_firmware_section()

static int angie_write_firmware_section ( struct angie device,
struct image firmware_image,
int  section_index 
)
static

Send one contiguous firmware section to the ANGIE's EZ-USB microcontroller over the USB bus.

Parameters
devicepointer to struct angie identifying ANGIE driver instance.
firmware_imagepointer to the firmware image that contains the section which should be sent to the ANGIE's EZ-USB microcontroller.
section_indexindex of the section within the firmware image.
Returns
on success: ERROR_OK
on failure: ERROR_FAIL

Definition at line 569 of file angie.c.

References addr, imagesection::base_address, device, ERROR_FAIL, ERROR_OK, FIRMWARE_ADDR, image_read_section(), jtag_libusb_control_transfer(), LIBUSB_TIMEOUT_MS, LOG_DEBUG, REQUEST_FIRMWARE_LOAD, SECTION_BUFFERSIZE, image::sections, size, and imagesection::size.

Referenced by angie_load_firmware().

Variable Documentation

◆ angie_adapter_driver

struct adapter_driver angie_adapter_driver
Initial value:
= {
.name = "angie",
.transports = jtag_only,
.init = angie_init,
.quit = angie_quit,
.reset = angie_reset,
.speed = angie_speed,
.khz = angie_khz,
.speed_div = angie_speed_div,
.jtag_ops = &angie_interface,
}
const char *const jtag_only[]
Definition: adapter.c:27
static int angie_speed(int speed)
Set the TCK frequency of the ANGIE adapter.
Definition: angie.c:2196
static int angie_reset(int trst, int srst)
Execute a JTAG_RESET command.
Definition: angie.c:1799
static int angie_init(void)
Initiates the firmware download to the ANGIE adapter and prepares the USB handle.
Definition: angie.c:2230
static struct jtag_interface angie_interface
Definition: angie.c:2385
static int angie_khz(int khz, int *jtag_speed)
Set the TCK frequency of the ANGIE adapter.
Definition: angie.c:2101
static int angie_speed_div(int speed, int *khz)
Convert adapter-specific speed value to corresponding TCK frequency in kHz.
Definition: angie.c:2216
static int angie_quit(void)
Closes the USB handle for the ANGIE device.
Definition: angie.c:2376

Definition at line 2376 of file angie.c.

◆ angie_handle

struct angie* angie_handle
static

◆ angie_interface

struct jtag_interface angie_interface
static
Initial value:
= {
.execute_queue = angie_execute_queue,
}
static int angie_execute_queue(struct jtag_command *cmd_queue)
Executes the JTAG Command Queue.
Definition: angie.c:2041

Definition at line 2376 of file angie.c.