OpenOCD
|
This driver implements a bitbang jtag interface using gpio lines via sysfs. More...
Go to the source code of this file.
Functions | |
static void | cleanup_all_fds (void) |
static void | cleanup_fd (int fd, int gpio) |
COMMAND_HANDLER (sysfsgpio_handle_jtag_gpionum_srst) | |
COMMAND_HANDLER (sysfsgpio_handle_jtag_gpionum_tck) | |
COMMAND_HANDLER (sysfsgpio_handle_jtag_gpionum_tdi) | |
COMMAND_HANDLER (sysfsgpio_handle_jtag_gpionum_tdo) | |
COMMAND_HANDLER (sysfsgpio_handle_jtag_gpionum_tms) | |
COMMAND_HANDLER (sysfsgpio_handle_jtag_gpionum_trst) | |
COMMAND_HANDLER (sysfsgpio_handle_jtag_gpionums) | |
COMMAND_HANDLER (sysfsgpio_handle_swd_gpionum_swclk) | |
COMMAND_HANDLER (sysfsgpio_handle_swd_gpionum_swdio) | |
COMMAND_HANDLER (sysfsgpio_handle_swd_gpionums) | |
static bool | is_gpio_valid (int gpio) |
static int | open_write_close (const char *name, const char *valstr) |
static int | setup_sysfs_gpio (int gpio, int is_output, int init_high) |
static int | sysfsgpio_init (void) |
static bool | sysfsgpio_jtag_mode_possible (void) |
static int | sysfsgpio_quit (void) |
static bb_value_t | sysfsgpio_read (void) |
static int | sysfsgpio_reset (int trst, int srst) |
static bool | sysfsgpio_swd_mode_possible (void) |
static int | sysfsgpio_swd_write (int swclk, int swdio) |
static void | sysfsgpio_swdio_drive (bool is_output) |
static int | sysfsgpio_swdio_read (void) |
static int | sysfsgpio_write (int tck, int tms, int tdi) |
static void | unexport_sysfs_gpio (int gpio) |
Variables | |
static bool | last_stored |
static int | last_swclk |
static int | last_swdio |
static int | srst_fd = -1 |
static int | srst_gpio = -1 |
static int | swclk_fd = -1 |
static int | swclk_gpio = -1 |
static int | swdio_fd = -1 |
static int | swdio_gpio = -1 |
static bool | swdio_input |
struct adapter_driver | sysfsgpio_adapter_driver |
static struct bitbang_interface | sysfsgpio_bitbang |
static const struct command_registration | sysfsgpio_command_handlers [] |
static struct jtag_interface | sysfsgpio_interface |
static const struct command_registration | sysfsgpio_subcommand_handlers [] |
static const char *const | sysfsgpio_transports [] = { "jtag", "swd", NULL } |
static int | tck_fd = -1 |
static int | tck_gpio = -1 |
static int | tdi_fd = -1 |
static int | tdi_gpio = -1 |
static int | tdo_fd = -1 |
static int | tdo_gpio = -1 |
static int | tms_fd = -1 |
static int | tms_gpio = -1 |
static int | trst_fd = -1 |
static int | trst_gpio = -1 |
This driver implements a bitbang jtag interface using gpio lines via sysfs.
The aim of this driver implementation is use system GPIOs but avoid the need for a additional kernel driver. (Note memory mapped IO is another option, however it doesn't mix well with the kernel gpiolib driver - which makes sense I guess.)
A gpio is required for tck, tms, tdi and tdo. One or both of srst and trst must be also be specified. The required jtag gpios are specified via the sysfsgpio_jtag_nums command or the relevant sysfsgpio_XXX_num commands. The srst and trst gpios are set via the sysfsgpio_srst_num and sysfsgpio_trst_num respectively. GPIO numbering follows the kernel convention of starting from 0.
The gpios should not be in use by another entity, and must not be requested by a kernel driver without also being exported by it (otherwise they can't be exported by sysfs).
The sysfs gpio interface can only manipulate one gpio at a time, so the bitbang write handler remembers the last state for tck, tms, tdi to avoid superfluous writes. For speed the sysfs "value" entry is opened at init and held open. This results in considerable gains over open-write-close (45s vs 900s)
Further work could address: -srst and trst open drain/ push pull -configurable active high/low for srst & trst
Definition in file sysfsgpio.c.
|
static |
Definition at line 588 of file sysfsgpio.c.
References cleanup_fd(), srst_fd, srst_gpio, swclk_fd, swclk_gpio, swdio_fd, swdio_gpio, tck_fd, tck_gpio, tdi_fd, tdi_gpio, tdo_fd, tdo_gpio, tms_fd, tms_gpio, transport_is_jtag(), transport_is_swd(), trst_fd, and trst_gpio.
Referenced by sysfsgpio_init(), and sysfsgpio_quit().
|
static |
Definition at line 578 of file sysfsgpio.c.
References unexport_sysfs_gpio().
Referenced by cleanup_all_fds().
COMMAND_HANDLER | ( | sysfsgpio_handle_jtag_gpionum_srst | ) |
Definition at line 408 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and srst_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_jtag_gpionum_tck | ) |
Definition at line 372 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and tck_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_jtag_gpionum_tdi | ) |
Definition at line 399 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and tdi_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_jtag_gpionum_tdo | ) |
Definition at line 390 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and tdo_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_jtag_gpionum_tms | ) |
Definition at line 381 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and tms_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_jtag_gpionum_trst | ) |
Definition at line 417 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and trst_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_jtag_gpionums | ) |
Definition at line 354 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, tck_gpio, tdi_gpio, tdo_gpio, and tms_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_swd_gpionum_swclk | ) |
Definition at line 442 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and swclk_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_swd_gpionum_swdio | ) |
Definition at line 451 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_OK, and swdio_gpio.
COMMAND_HANDLER | ( | sysfsgpio_handle_swd_gpionums | ) |
Definition at line 426 of file sysfsgpio.c.
References CMD, CMD_ARGC, CMD_ARGV, COMMAND_PARSE_NUMBER, command_print(), ERROR_COMMAND_SYNTAX_ERROR, ERROR_OK, swclk_gpio, and swdio_gpio.
|
static |
Definition at line 54 of file sysfsgpio.c.
Referenced by setup_sysfs_gpio(), sysfsgpio_jtag_mode_possible(), sysfsgpio_swd_mode_possible(), and unexport_sysfs_gpio().
|
static |
Definition at line 65 of file sysfsgpio.c.
References name.
Referenced by setup_sysfs_gpio(), sysfsgpio_swdio_drive(), and unexport_sysfs_gpio().
|
static |
Definition at line 102 of file sysfsgpio.c.
References ERROR_FAIL, ERROR_OK, gettimeofday(), is_gpio_valid(), jtag_sleep(), LOG_ERROR, LOG_WARNING, NULL, open_write_close(), timeval_add_time(), timeval_compare(), and unexport_sysfs_gpio().
Referenced by sysfsgpio_init().
|
static |
Definition at line 626 of file sysfsgpio.c.
References cleanup_all_fds(), ERROR_JTAG_INIT_FAILED, ERROR_OK, LOG_ERROR, LOG_INFO, setup_sysfs_gpio(), srst_fd, srst_gpio, swclk_fd, swclk_gpio, swdio_fd, swdio_gpio, sysfsgpio_bitbang, sysfsgpio_jtag_mode_possible(), sysfsgpio_swd_mode_possible(), tck_fd, tck_gpio, tdi_fd, tdi_gpio, tdo_fd, tdo_gpio, tms_fd, tms_gpio, transport_is_jtag(), transport_is_swd(), trst_fd, and trst_gpio.
|
static |
Definition at line 604 of file sysfsgpio.c.
References is_gpio_valid(), tck_gpio, tdi_gpio, tdo_gpio, and tms_gpio.
Referenced by sysfsgpio_init().
|
static |
Definition at line 697 of file sysfsgpio.c.
References cleanup_all_fds(), and ERROR_OK.
|
static |
Definition at line 258 of file sysfsgpio.c.
References BB_HIGH, BB_LOW, LOG_WARNING, and tdo_fd.
|
static |
Definition at line 330 of file sysfsgpio.c.
References ERROR_OK, LOG_DEBUG, LOG_WARNING, srst_fd, and trst_fd.
|
static |
Definition at line 617 of file sysfsgpio.c.
References is_gpio_valid(), swclk_gpio, and swdio_gpio.
Referenced by sysfsgpio_init().
|
static |
Definition at line 223 of file sysfsgpio.c.
References ERROR_OK, last_stored, last_swclk, last_swdio, LOG_WARNING, swclk_fd, swdio_fd, and swdio_input.
|
static |
Definition at line 191 of file sysfsgpio.c.
References last_stored, LOG_ERROR, open_write_close(), swdio_gpio, and swdio_input.
|
static |
Definition at line 207 of file sysfsgpio.c.
References LOG_WARNING, and swdio_fd.
|
static |
Definition at line 280 of file sysfsgpio.c.
References ERROR_OK, last_tms, LOG_WARNING, tck_fd, tdi_fd, and tms_fd.
|
static |
Definition at line 81 of file sysfsgpio.c.
References is_gpio_valid(), LOG_ERROR, and open_write_close().
Referenced by cleanup_fd(), and setup_sysfs_gpio().
|
static |
Definition at line 188 of file sysfsgpio.c.
Referenced by sysfsgpio_swd_write(), and sysfsgpio_swdio_drive().
|
static |
Definition at line 186 of file sysfsgpio.c.
Referenced by sysfsgpio_swd_write().
|
static |
Definition at line 187 of file sysfsgpio.c.
Referenced by sysfsgpio_swd_write().
|
static |
Definition at line 182 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), sysfsgpio_init(), and sysfsgpio_reset().
|
static |
Definition at line 169 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), COMMAND_HANDLER(), and sysfsgpio_init().
|
static |
Definition at line 183 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), sysfsgpio_init(), and sysfsgpio_swd_write().
|
static |
Definition at line 170 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), COMMAND_HANDLER(), sysfsgpio_init(), and sysfsgpio_swd_mode_possible().
|
static |
Definition at line 184 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), sysfsgpio_init(), sysfsgpio_swd_write(), and sysfsgpio_swdio_read().
|
static |
Definition at line 171 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), COMMAND_HANDLER(), sysfsgpio_init(), sysfsgpio_swd_mode_possible(), and sysfsgpio_swdio_drive().
|
static |
Definition at line 189 of file sysfsgpio.c.
Referenced by sysfsgpio_swd_write(), and sysfsgpio_swdio_drive().
struct adapter_driver sysfsgpio_adapter_driver |
Definition at line 548 of file sysfsgpio.c.
|
static |
Definition at line 548 of file sysfsgpio.c.
Referenced by sysfsgpio_init().
|
static |
Definition at line 451 of file sysfsgpio.c.
|
static |
Definition at line 548 of file sysfsgpio.c.
|
static |
Definition at line 451 of file sysfsgpio.c.
|
static |
Definition at line 548 of file sysfsgpio.c.
|
static |
Definition at line 177 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), sysfsgpio_init(), and sysfsgpio_write().
|
static |
Definition at line 164 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), COMMAND_HANDLER(), sysfsgpio_init(), and sysfsgpio_jtag_mode_possible().
|
static |
Definition at line 179 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), sysfsgpio_init(), and sysfsgpio_write().
|
static |
Definition at line 166 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), COMMAND_HANDLER(), sysfsgpio_init(), and sysfsgpio_jtag_mode_possible().
|
static |
Definition at line 180 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), sysfsgpio_init(), and sysfsgpio_read().
|
static |
Definition at line 167 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), COMMAND_HANDLER(), sysfsgpio_init(), and sysfsgpio_jtag_mode_possible().
|
static |
Definition at line 178 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), sysfsgpio_init(), and sysfsgpio_write().
|
static |
Definition at line 165 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), COMMAND_HANDLER(), sysfsgpio_init(), and sysfsgpio_jtag_mode_possible().
|
static |
Definition at line 181 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), sysfsgpio_init(), and sysfsgpio_reset().
|
static |
Definition at line 168 of file sysfsgpio.c.
Referenced by cleanup_all_fds(), COMMAND_HANDLER(), and sysfsgpio_init().