OpenOCD
|
Go to the source code of this file.
Data Structures | |
struct | angie |
Angie device main context. More... | |
struct | read_queue |
List of elements used in a multiple commands reply. More... | |
struct | read_queue_entry |
Entry element used to forge a reply buffer for openocd JTAG core. 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_FW_SECTION_SIZE 16384 |
Maximum size of a single firmware section. More... | |
#define | ANGIE_NPROG_PID 0x424E /* ANGIE non programmed */ |
#define | ANGIE_PROG_NXB2_PID 0x4a55 /* ANGIE programmed Nxbase2 */ |
#define | ANGIE_PROG_OOCD_PID 0x414F /* ANGIE programmed OpenOCD */ |
#define | ANGIE_RENUMERATION_DELAY_US 800000 |
Delay (in microseconds) to wait while EZ-USB performs ReNumeration. More... | |
#define | ANGIE_USB_BULK_SIZE 512 |
#define | ANGIE_USB_TIMEOUT_MS 1000 |
USB timeout delay in milliseconds. More... | |
#define | ANGIE_VID 0x584E /* NX Vendor id */ |
#define | ANGIE_XFER_BUFFER_TOTAL_SIZE (16 * 1024) |
#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 | IN_EP 0x84 |
USB endpoints. More... | |
#define | NSYSRST_GPIO 6 |
#define | NTRST_GPIO 4 |
#define | OUT_EP 0x02 |
#define | REQUEST_FIRMWARE_LOAD 0xA0 |
USB Control EP0 bRequest: "Firmware Load". More... | |
#define | TCK_GPIO 0 |
#define | TDI_GPIO 1 |
#define | TDO_GPIO 2 |
#define | TMS_GPIO 3 |
#define | VR_CFGOPEN 0xB0 |
Vendor Requests. More... | |
#define | VR_DATAOUTOPEN 0xB2 |
Functions | |
static int | angie_buffer_append (struct angie *device, int tck, int tms, int tdi) |
Append a bit-bang JTAG value to the transfer buffer. More... | |
static int | angie_buffer_append_simple (struct angie *device, uint8_t value) |
Append a single byte value to the transfer buffer. More... | |
static int | angie_buffer_flush (struct angie *device) |
Flush Angie transfer buffer. More... | |
static int | angie_buffer_flush_check (struct angie *device, size_t size) |
Check if transfer buffer has enough remaining space for a given size. More... | |
static int | angie_buffer_flush_chunk (struct angie *device, int xfer_size, int offset, int *bytes_sent) |
Flush a chunk of Angie's buffer. More... | |
static size_t | angie_cmd_size (struct angie *device, const struct jtag_command *cmd) |
Process command size in bytes. 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 int | angie_init (void) |
Angie initialization method. More... | |
static bool | angie_is_firmware_needed (struct angie *device) |
Check if Angie firmware must be updated. More... | |
static int | angie_jtag_execute_pathmove (struct angie *device, const struct pathmove_command *cmd) |
Execute JTAG PATHMOVE command. More... | |
static int | angie_jtag_execute_queue (struct jtag_command *cmd_queue) |
Execute JTAG commands queue. More... | |
static int | angie_jtag_execute_reset (struct angie *device, const struct reset_command *cmd) |
Execute JTAG RESET command Control /TRST and /SYSRST pins. More... | |
static int | angie_jtag_execute_runtest (struct angie *device, const struct runtest_command *cmd) |
Execute JTAG RUNTEST command. More... | |
static int | angie_jtag_execute_scan (struct angie *device, const struct scan_command *cmd) |
Execute JTAG SCAN command. More... | |
static int | angie_jtag_execute_stableclocks (struct angie *device, const struct stableclocks_command *cmd) |
Execute JTAG STABLECLOCKS command Issues a number of clock cycles while staying in a stable state. More... | |
static int | angie_jtag_execute_statemove (struct angie *device, const struct statemove_command *cmd) |
Execute JTAG STATEMOVE command. More... | |
static int | angie_jtag_execute_tms (struct angie *device, const struct tms_command *cmd) |
Execute JTAG TMS command Clock a bunch of TMS transitions, to change the JTAG state machine. More... | |
static int | angie_jtag_runtest_size (struct angie *device, const struct runtest_command *cmd) |
Return JTAG RUNTEST command size in bytes. More... | |
static int | angie_jtag_scan_size (struct angie *device, const struct scan_command *cmd) |
Return JTAG SCAN command size in bytes. More... | |
static int | angie_khz (int khz, int *divisor) |
Angie set khz method. 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_quit (void) |
Angie quit method. More... | |
static void | angie_read_queue_add (struct read_queue *queue, struct read_queue_entry *entry) |
Add a single entry to the read queue. More... | |
static void | angie_read_queue_clean (struct read_queue *queue) |
Clear the read queue list. More... | |
static void | angie_read_queue_execute (struct read_queue *queue, struct angie *device) |
Execute elements enqueued in the read queue list. More... | |
static void | angie_read_queue_init (struct read_queue *queue) |
Init read queue list. More... | |
static void | angie_set_end_state (enum tap_state state) |
Set TAP end state. More... | |
static int | angie_speed (int divisor) |
Angie set speed method. More... | |
static int | angie_speed_div (int divisor, int *khz) |
Angie set speed div. More... | |
static int | angie_state_move (struct angie *device, int skip) |
Move TAP to given state. 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) |
Open Angie USB interface. More... | |
static int | angie_write_firmware_section (struct angie *device, uint16_t address, uint8_t *data, size_t size) |
Send one contiguous firmware section to the ANGIE's EZ-USB microcontroller over the USB bus. More... | |
Variables | |
struct adapter_driver | angie_adapter_driver |
struct angie * | angie_handle |
Angie device singleton. More... | |
static struct jtag_interface | angie_interface |
#define ANGIE_BITSTREAM_FILE PKGDATADIR "/angie/angie_bitstream.bit" |
#define ANGIE_FIRMWARE_FILE PKGDATADIR "/angie/angie_firmware.bin" |
#define ANGIE_FW_SECTION_SIZE 16384 |
#define ANGIE_PROG_NXB2_PID 0x4a55 /* ANGIE programmed Nxbase2 */ |
#define ANGIE_PROG_OOCD_PID 0x414F /* ANGIE programmed OpenOCD */ |
#define ANGIE_RENUMERATION_DELAY_US 800000 |
#define ANGIE_USB_TIMEOUT_MS 1000 |
#define CPU_RESET 0x01 |
#define CPU_START 0x00 |
#define CPUCS_REG 0xE600 |
#define FIRMWARE_ADDR 0x0000 |
#define REQUEST_FIRMWARE_LOAD 0xA0 |
|
static |
Append a bit-bang JTAG value to the transfer buffer.
device | Angie device pointer |
tck | value |
tms | value |
tdi | value |
Definition at line 354 of file angie.c.
References angie_buffer_append_simple(), device, NSYSRST_GPIO, NTRST_GPIO, TCK_GPIO, TDI_GPIO, and TMS_GPIO.
Referenced by angie_jtag_execute_pathmove(), angie_jtag_execute_runtest(), angie_jtag_execute_scan(), angie_jtag_execute_stableclocks(), angie_jtag_execute_tms(), and angie_state_move().
|
static |
Append a single byte value to the transfer buffer.
device | Angie device pointer |
value | to append |
Definition at line 334 of file angie.c.
References angie_buffer_flush(), ANGIE_XFER_BUFFER_TOTAL_SIZE, device, and ERROR_OK.
Referenced by angie_buffer_append(), and angie_jtag_execute_reset().
|
static |
Flush Angie transfer buffer.
Flush is done by chunks of 512 bytes to match hardware internal FIFOs. Then the read queue list is executed once the read buffer has been retrieved.
device | Angie device pointer |
Definition at line 289 of file angie.c.
References angie_buffer_flush_chunk(), angie_read_queue_execute(), ANGIE_USB_BULK_SIZE, device, ERROR_OK, and MIN.
Referenced by angie_buffer_append_simple(), angie_buffer_flush_check(), and angie_jtag_execute_queue().
|
static |
Check if transfer buffer has enough remaining space for a given size.
If the buffer is not large enough, flush it.
device | Angie device pointer |
size | to check |
Definition at line 320 of file angie.c.
References angie_buffer_flush(), ANGIE_XFER_BUFFER_TOTAL_SIZE, device, ERROR_OK, and size.
Referenced by angie_jtag_execute_queue().
|
static |
Flush a chunk of Angie's buffer.
USB write is done by configuring GPIF register on the target and calling a USB bulk transfer. Sequentially a USB read transferred is issued of the same size. All the operation are synchronous. Then the read queue list is executed once the read buffer has been retrieved.
device | Angie device pointer |
xfer_size | amount of bytes to transfer |
offset | total bytes already sent during this transfer, this will offset the receive buffer accordingly |
bytes_sent | will contain the amount of bytes sent |
Definition at line 230 of file angie.c.
References ANGIE_USB_TIMEOUT_MS, device, ERROR_FAIL, ERROR_OK, h_u32_to_be(), IN_EP, jtag_libusb_bulk_read(), jtag_libusb_bulk_write(), jtag_libusb_control_transfer(), LOG_ERROR, NULL, offset, OUT_EP, and VR_DATAOUTOPEN.
Referenced by angie_buffer_flush().
|
static |
Process command size in bytes.
device | Angie device pointer |
cmd | JTAG command |
Definition at line 1109 of file angie.c.
References angie_jtag_runtest_size(), angie_jtag_scan_size(), cmd, device, JTAG_PATHMOVE, JTAG_RESET, JTAG_RUNTEST, JTAG_SCAN, JTAG_SLEEP, JTAG_STABLECLOCKS, JTAG_TLR_RESET, JTAG_TMS, LOG_DEBUG_IO, LOG_ERROR, tap_get_state(), and tap_get_tms_path_len().
Referenced by angie_jtag_execute_queue().
|
static |
Writes '0' or '1' to the CPUCS register, putting the EZ-USB CPU into reset or out of reset.
device | Angie device pointer |
reset_bit | 0 to put CPU into reset, 1 to put CPU out of reset. |
Definition at line 431 of file angie.c.
References ANGIE_USB_TIMEOUT_MS, CPUCS_REG, device, jtag_libusb_control_transfer(), NULL, and REQUEST_FIRMWARE_LOAD.
Referenced by angie_load_firmware().
|
static |
Angie initialization method.
Definition at line 1247 of file angie.c.
References ANGIE_BITSTREAM_FILE, ANGIE_FIRMWARE_FILE, angie_handle, angie_is_firmware_needed(), angie_load_bitstream(), angie_load_firmware_and_renumerate(), angie_quit(), angie_read_queue_init(), ANGIE_RENUMERATION_DELAY_US, angie_usb_open(), ERROR_FAIL, ERROR_OK, LOG_ERROR, LOG_INFO, angie::read_queue, and angie::usbdev.
|
static |
Check if Angie firmware must be updated.
device | Angie device pointer |
Definition at line 679 of file angie.c.
References angie_handle, ANGIE_PROG_OOCD_PID, and angie::usbdev.
Referenced by angie_init().
|
static |
Execute JTAG PATHMOVE command.
device | Angie device pointer |
cmd | PATHMOVE command |
Definition at line 1059 of file angie.c.
References angie_buffer_append(), cmd, device, ERROR_JTAG_DEVICE_ERROR, ERROR_OK, LOG_DEBUG_IO, LOG_ERROR, tap_get_state(), tap_set_end_state(), tap_set_state, tap_state_name(), and tap_state_transition().
Referenced by angie_jtag_execute_queue().
|
static |
Execute JTAG commands queue.
cmd_queue | to execute |
Definition at line 1142 of file angie.c.
References angie_buffer_flush(), angie_buffer_flush_check(), angie_cmd_size(), angie_handle, angie_jtag_execute_pathmove(), angie_jtag_execute_reset(), angie_jtag_execute_runtest(), angie_jtag_execute_scan(), angie_jtag_execute_stableclocks(), angie_jtag_execute_statemove(), angie_jtag_execute_tms(), cmd, device, ERROR_OK, JTAG_PATHMOVE, JTAG_RESET, JTAG_RUNTEST, JTAG_SCAN, JTAG_SLEEP, jtag_sleep(), JTAG_STABLECLOCKS, JTAG_TLR_RESET, JTAG_TMS, LOG_DEBUG_IO, and LOG_ERROR.
|
static |
Execute JTAG RESET command Control /TRST and /SYSRST pins.
Perform immediate bitbang transaction.
device | Angie device pointer |
cmd | RESET command |
Definition at line 981 of file angie.c.
References angie_buffer_append_simple(), cmd, device, jtag_get_reset_config(), LOG_DEBUG_IO, NSYSRST_GPIO, NTRST_GPIO, RESET_SRST_PULLS_TRST, TAP_RESET, and tap_set_state.
Referenced by angie_jtag_execute_queue().
|
static |
Execute JTAG RUNTEST command.
device | Angie device pointer |
cmd | SCAN command |
Definition at line 901 of file angie.c.
References angie_buffer_append(), angie_set_end_state(), angie_state_move(), cmd, device, ERROR_OK, LOG_DEBUG_IO, tap_get_end_state(), tap_get_state(), and TAP_IDLE.
Referenced by angie_jtag_execute_queue().
|
static |
Execute JTAG SCAN command.
device | Angie device pointer |
cmd | SCAN command |
Definition at line 789 of file angie.c.
References angie_buffer_append(), angie_read_queue_add(), angie_set_end_state(), angie_state_move(), buffer, read_queue_entry::buffer, read_queue_entry::cmd, cmd, device, ERROR_FAIL, ERROR_OK, jtag_build_buffer(), jtag_scan_size(), jtag_scan_type(), LOG_DEBUG_IO, LOG_ERROR, NULL, read_queue_entry::reply_buffer_offset, SCAN_IN, SCAN_OUT, TAP_DRSHIFT, tap_get_end_state(), tap_get_state(), TAP_IRSHIFT, tap_state_name(), and type.
Referenced by angie_jtag_execute_queue().
|
static |
Execute JTAG STABLECLOCKS command Issues a number of clock cycles while staying in a stable state.
Because the TMS value required to stay in the RESET state is a 1, whereas the TMS value required to stay in any of the other stable states is a 0, this function checks the current stable state to decide on the value of TMS to use.
device | Angie device pointer |
cmd | STABLECLOCKS command |
Definition at line 1016 of file angie.c.
References angie_buffer_append(), cmd, device, ERROR_OK, LOG_DEBUG_IO, tap_get_state(), TAP_RESET, and tap_state_name().
Referenced by angie_jtag_execute_queue().
|
static |
Execute JTAG STATEMOVE command.
device | Angie device pointer |
cmd | STATEMOVE command |
Definition at line 1044 of file angie.c.
References angie_set_end_state(), angie_state_move(), cmd, device, LOG_DEBUG_IO, and tap_state_name().
Referenced by angie_jtag_execute_queue().
|
static |
Execute JTAG TMS command Clock a bunch of TMS transitions, to change the JTAG state machine.
device | Angie device pointer |
cmd | TMS command |
Definition at line 950 of file angie.c.
References angie_buffer_append(), bits, cmd, device, ERROR_OK, and LOG_DEBUG_IO.
Referenced by angie_jtag_execute_queue().
|
static |
Return JTAG RUNTEST command size in bytes.
device | Angie device pointer |
cmd | RUNTEST command |
Definition at line 880 of file angie.c.
References cmd, tap_get_end_state(), tap_get_state(), tap_get_tms_path_len(), and TAP_IDLE.
Referenced by angie_cmd_size().
|
static |
Return JTAG SCAN command size in bytes.
device | Angie device pointer |
cmd | SCAN command |
Definition at line 750 of file angie.c.
References cmd, count, jtag_scan_size(), TAP_DRSHIFT, tap_get_state(), tap_get_tms_path_len(), and TAP_IRSHIFT.
Referenced by angie_cmd_size().
|
static |
Angie set khz method.
khz | |
divisor | returned to caller |
Definition at line 1320 of file angie.c.
References ERROR_FAIL, ERROR_OK, and LOG_DEBUG.
|
static |
Downloads a bitstream file to the ANGIE's FPGA through the EZ-USB microcontroller over the USB bus.
device | Angie device pointer |
filename | an absolute or relative path to the Xilinx .bit file containing the bitstream data. |
Definition at line 607 of file angie.c.
References ANGIE_USB_TIMEOUT_MS, device, ERROR_FAIL, ERROR_OK, h_u32_to_be(), jtag_libusb_bulk_write(), jtag_libusb_control_transfer(), LOG_ERROR, LOG_INFO, NULL, OUT_EP, and VR_CFGOPEN.
Referenced by angie_init().
|
static |
Downloads a firmware image to the ANGIE's EZ-USB microcontroller over the USB bus.
device | Angie device pointer |
filename | an absolute or relative path to the Intel HEX file containing the firmware image. |
Definition at line 494 of file angie.c.
References addr, angie_cpu_reset(), ANGIE_FW_SECTION_SIZE, angie_write_firmware_section(), imagesection::base_address, image::base_address, image::base_address_set, CPU_RESET, CPU_START, device, ERROR_FAIL, ERROR_OK, image_close(), image_open(), image_read_section(), LOG_DEBUG, LOG_ERROR, image::num_sections, image::sections, size, and imagesection::size.
Referenced by angie_load_firmware_and_renumerate().
|
static |
Puts the ANGIE's EZ-USB microcontroller into reset state, downloads the firmware image, resumes the microcontroller and re-enumerates USB devices.
device | Angie device pointer The usb_handle member will be modified during re-enumeration. |
filename | path to the Intel HEX file containing the firmware image. |
delay_us | the delay to wait for the device to re-enumerate. |
Definition at line 568 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::usbdev.
Referenced by angie_init().
|
static |
Angie quit method.
Definition at line 1225 of file angie.c.
References angie_handle, angie_read_queue_clean(), angie_usb_close(), ERROR_OK, NULL, and angie::read_queue.
Referenced by angie_init().
|
static |
Add a single entry to the read queue.
queue | read queue list |
entry | to append |
Definition at line 154 of file angie.c.
References read_queue_entry::list, and list_add_tail().
Referenced by angie_jtag_execute_scan().
|
static |
Clear the read queue list.
queue | read queue list |
Definition at line 202 of file angie.c.
References read_queue_entry::buffer, read_queue_entry::list, list_del(), and list_for_each_entry_safe.
Referenced by angie_quit().
|
static |
Execute elements enqueued in the read queue list.
queue | read queue list |
device | pointer on the angie device |
Definition at line 166 of file angie.c.
References read_queue_entry::buffer, read_queue_entry::cmd, device, jtag_read_buffer(), jtag_scan_size(), read_queue_entry::list, list_del(), list_for_each_entry_safe, read_queue_entry::reply_buffer_offset, and TDO_GPIO.
Referenced by angie_buffer_flush().
|
static |
Init read queue list.
queue | pointer on the read queue head |
Definition at line 142 of file angie.c.
References INIT_LIST_HEAD().
Referenced by angie_init().
|
static |
Set TAP end state.
state |
Definition at line 700 of file angie.c.
References LOG_ERROR, state, tap_is_state_stable(), and tap_set_end_state().
Referenced by angie_jtag_execute_runtest(), angie_jtag_execute_scan(), and angie_jtag_execute_statemove().
|
static |
|
static |
|
static |
Move TAP to given state.
device | Angie device pointer |
skip | number of state to skip during move |
Definition at line 717 of file angie.c.
References angie_buffer_append(), 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_jtag_execute_runtest(), angie_jtag_execute_scan(), and angie_jtag_execute_statemove().
|
static |
Releases the ANGIE interface and closes the USB device handle.
device | Angie device pointer |
Definition at line 406 of file angie.c.
References device, ERROR_FAIL, ERROR_OK, jtag_libusb_close(), LOG_ERROR, and NULL.
Referenced by angie_load_firmware_and_renumerate(), and angie_quit().
|
static |
Open Angie USB interface.
device | Angie device pointer |
Definition at line 373 of file angie.c.
References ANGIE_NPROG_PID, ANGIE_PROG_NXB2_PID, ANGIE_PROG_OOCD_PID, ANGIE_VID, device, ERROR_OK, jtag_libusb_open(), LOG_ERROR, and NULL.
Referenced by angie_init(), and angie_load_firmware_and_renumerate().
|
static |
Send one contiguous firmware section to the ANGIE's EZ-USB microcontroller over the USB bus.
device | Angie device pointer |
address | address of the firmware section |
data | pointer to the data to be sent |
size | size of the data |
Definition at line 449 of file angie.c.
References address, ANGIE_USB_TIMEOUT_MS, device, ERROR_FAIL, ERROR_OK, FIRMWARE_ADDR, jtag_libusb_control_transfer(), REQUEST_FIRMWARE_LOAD, and size.
Referenced by angie_load_firmware().
struct adapter_driver angie_adapter_driver |
struct angie* angie_handle |
Angie device singleton.
Definition at line 135 of file angie.c.
Referenced by angie_init(), angie_is_firmware_needed(), angie_jtag_execute_queue(), angie_load_firmware_and_renumerate(), and angie_quit().
|
static |