From: OpenOCD-Gerrit <ope...@us...> - 2021-07-31 09:10:25
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "Main OpenOCD repository". The branch, master has been updated via db16b3dc5b061c152f2478a5b9b7b3a3b0908911 (commit) via beff3de2ce7e275bf8c0051641dfc1acb0ecee9a (commit) via d94e1ffef0c352af1a291819907f398f060a462e (commit) from dbb10a57d128073cece9ccfc7edc7bb45b220406 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit db16b3dc5b061c152f2478a5b9b7b3a3b0908911 Author: Tim Newsome <ti...@si...> Date: Fri Jul 9 12:58:07 2021 -0700 Call poll at a fixed interval. The existing implementation blocks in select() for a fixed amount of time. This change tracks when the next event (likely poll()) wants to be run, and uses a shorter timeout in select() if necessary. Also track all these timeouts using milliseconds as returned by timeval_ms() instead of `struct timeval` to simplify the code. This feature is helpful if poll() wants to do something like sample PCs or memory values for basically the entire time that otherwise OpenOCD would be hung in select(). See https://github.com/riscv/riscv-openocd/pull/541 for an example of that. The RISC-V code using this change will be upstreamed some day, too. Signed-off-by: Tim Newsome <ti...@si...> Change-Id: I67104a7cf69ed07c8399c14aa55963fc5116a67d Reviewed-on: http://openocd.zylin.com/6363 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/server/server.c b/src/server/server.c index 6f0b23caa..64acd3689 100644 --- a/src/server/server.c +++ b/src/server/server.c @@ -437,6 +437,8 @@ int server_loop(struct command_context *command_context) /* used in accept() */ int retval; + int64_t next_event = timeval_ms() + polling_period; + #ifndef _WIN32 if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) LOG_ERROR("couldn't set SIGPIPE to SIG_IGN"); @@ -478,7 +480,12 @@ int server_loop(struct command_context *command_context) retval = socket_select(fd_max + 1, &read_fds, NULL, NULL, &tv); } else { /* Every 100ms, can be changed with "poll_period" command */ - tv.tv_usec = polling_period * 1000; + int timeout_ms = next_event - timeval_ms(); + if (timeout_ms < 0) + timeout_ms = 0; + else if (timeout_ms > polling_period) + timeout_ms = polling_period; + tv.tv_usec = timeout_ms * 1000; /* Only while we're sleeping we'll let others run */ openocd_sleep_prelude(); kept_alive(); @@ -511,7 +518,8 @@ int server_loop(struct command_context *command_context) if (retval == 0) { /* We only execute these callbacks when there was nothing to do or we timed *out */ - target_call_timer_callbacks(); + target_call_timer_callbacks_now(); + next_event = target_timer_next_event(); process_jim_events(command_context); FD_ZERO(&read_fds); /* eCos leaves read_fds unchanged in this case! */ diff --git a/src/target/target.c b/src/target/target.c index cf1873c5e..a67712009 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -154,9 +154,10 @@ static struct target_type *target_types[] = { struct target *all_targets; static struct target_event_callback *target_event_callbacks; static struct target_timer_callback *target_timer_callbacks; +static int64_t target_timer_next_event_value; static LIST_HEAD(target_reset_callback_list); static LIST_HEAD(target_trace_callback_list); -static const int polling_interval = 100; +static const int polling_interval = TARGET_DEFAULT_POLLING_INTERVAL; static const struct jim_nvp nvp_assert[] = { { .name = "assert", NVP_ASSERT }, @@ -1733,8 +1734,8 @@ int target_register_timer_callback(int (*callback)(void *priv), (*callbacks_p)->time_ms = time_ms; (*callbacks_p)->removed = false; - gettimeofday(&(*callbacks_p)->when, NULL); - timeval_add_time(&(*callbacks_p)->when, 0, time_ms * 1000); + (*callbacks_p)->when = timeval_ms() + time_ms; + target_timer_next_event_value = MIN(target_timer_next_event_value, (*callbacks_p)->when); (*callbacks_p)->priv = priv; (*callbacks_p)->next = NULL; @@ -1868,15 +1869,14 @@ int target_call_trace_callbacks(struct target *target, size_t len, uint8_t *data } static int target_timer_callback_periodic_restart( - struct target_timer_callback *cb, struct timeval *now) + struct target_timer_callback *cb, int64_t *now) { - cb->when = *now; - timeval_add_time(&cb->when, 0, cb->time_ms * 1000L); + cb->when = *now + cb->time_ms; return ERROR_OK; } static int target_call_timer_callback(struct target_timer_callback *cb, - struct timeval *now) + int64_t *now) { cb->callback(cb->priv); @@ -1898,8 +1898,12 @@ static int target_call_timer_callbacks_check_time(int checktime) keep_alive(); - struct timeval now; - gettimeofday(&now, NULL); + int64_t now = timeval_ms(); + + /* Initialize to a default value that's a ways into the future. + * The loop below will make it closer to now if there are + * callbacks that want to be called sooner. */ + target_timer_next_event_value = now + 1000; /* Store an address of the place containing a pointer to the * next item; initially, that's a standalone "root of the @@ -1915,11 +1919,14 @@ static int target_call_timer_callbacks_check_time(int checktime) bool call_it = (*callback)->callback && ((!checktime && (*callback)->type == TARGET_TIMER_TYPE_PERIODIC) || - timeval_compare(&now, &(*callback)->when) >= 0); + now >= (*callback)->when); if (call_it) target_call_timer_callback(*callback, &now); + if (!(*callback)->removed && (*callback)->when < target_timer_next_event_value) + target_timer_next_event_value = (*callback)->when; + callback = &(*callback)->next; } @@ -1927,17 +1934,22 @@ static int target_call_timer_callbacks_check_time(int checktime) return ERROR_OK; } -int target_call_timer_callbacks(void) +int target_call_timer_callbacks() { return target_call_timer_callbacks_check_time(1); } /* invoke periodic callbacks immediately */ -int target_call_timer_callbacks_now(void) +int target_call_timer_callbacks_now() { return target_call_timer_callbacks_check_time(0); } +int64_t target_timer_next_event(void) +{ + return target_timer_next_event_value; +} + /* Prints the working area layout for debug purposes */ static void print_wa_layout(struct target *target) { diff --git a/src/target/target.h b/src/target/target.h index 18a9516f5..1e19434e4 100644 --- a/src/target/target.h +++ b/src/target/target.h @@ -333,7 +333,7 @@ struct target_timer_callback { unsigned int time_ms; enum target_timer_type type; bool removed; - struct timeval when; + int64_t when; /* output of timeval_ms() */ void *priv; struct target_timer_callback *next; }; @@ -407,6 +407,11 @@ int target_call_timer_callbacks(void); * a synchronous command completes. */ int target_call_timer_callbacks_now(void); +/** + * Returns when the next registered event will take place. Callers can use this + * to go to sleep until that time occurs. + */ +int64_t target_timer_next_event(void); struct target *get_target_by_num(int num); struct target *get_current_target(struct command_context *cmd_ctx); @@ -790,4 +795,6 @@ int target_profiling_default(struct target *target, uint32_t *samples, uint32_t extern bool get_target_reset_nag(void); +#define TARGET_DEFAULT_POLLING_INTERVAL 100 + #endif /* OPENOCD_TARGET_TARGET_H */ commit beff3de2ce7e275bf8c0051641dfc1acb0ecee9a Author: PoroCYon <por...@ti...> Date: Wed Jul 21 04:17:08 2021 +0200 drivers/cmsis-dap: update for newest protocol version The capabilities INFO command can now return two bytes, without this patch, the capabilities would simply not be read and left as 0 (i.e. no capabilities). cf. https://arm-software.github.io/CMSIS_5/DAP/html/group__DAP__Info.html ; https://github.com/ARM-software/CMSIS_5/blob/116866fd74756c88096e37cbd0066fadad583cad/CMSIS/DAP/Firmware/Source/DAP.c#L100-L111 Change-Id: Ibd894971edf1c120cae08089e5515ce5e9972323 Signed-off-by: PoroCYon <por...@ti...> Reviewed-on: http://openocd.zylin.com/6373 Tested-by: jenkins Reviewed-by: Andrzej SierżÄga <as...@gm...> Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/src/jtag/drivers/cmsis_dap.c b/src/jtag/drivers/cmsis_dap.c index be8881d9b..06d5c6962 100644 --- a/src/jtag/drivers/cmsis_dap.c +++ b/src/jtag/drivers/cmsis_dap.c @@ -102,10 +102,16 @@ static bool swd_mode; #define INFO_ID_PKT_SZ 0xff /* short */ #define INFO_ID_SWO_BUF_SZ 0xfd /* word */ -#define INFO_CAPS_SWD BIT(0) -#define INFO_CAPS_JTAG BIT(1) -#define INFO_CAPS_SWO_UART BIT(2) -#define INFO_CAPS_SWO_MANCHESTER BIT(3) +#define INFO_CAPS_SWD BIT(0) +#define INFO_CAPS_JTAG BIT(1) +#define INFO_CAPS_SWO_UART BIT(2) +#define INFO_CAPS_SWO_MANCHESTER BIT(3) +#define INFO_CAPS_ATOMIC_CMDS BIT(4) +#define INFO_CAPS_TEST_DOMAIN_TIMER BIT(5) +#define INFO_CAPS_SWO_STREAMING_TRACE BIT(6) +#define INFO_CAPS_UART_PORT BIT(7) +#define INFO_CAPS_USB_COM_PORT BIT(8) +#define INFO_CAPS__NUM_CAPS 9 /* CMD_LED */ #define LED_ID_CONNECT 0x00 @@ -203,11 +209,16 @@ static bool swd_mode; /* CMSIS-DAP Vendor Commands * None as yet... */ -static const char * const info_caps_str[] = { - "SWD Supported", - "JTAG Supported", - "SWO-UART Supported", - "SWO-MANCHESTER Supported" +static const char * const info_caps_str[INFO_CAPS__NUM_CAPS] = { + "SWD supported", + "JTAG supported", + "SWO-UART supported", + "SWO-MANCHESTER supported", + "Atomic commands supported", + "Test domain timer supported", + "SWO streaming trace supported", + "UART communication port supported", + "UART via USB COM port supported", }; struct pending_transfer_result { @@ -1016,19 +1027,17 @@ static int cmsis_dap_get_caps_info(void) if (retval != ERROR_OK) return retval; - if (data[0] == 1) { - uint8_t caps = data[1]; + if (data[0] == 1 || data[0] == 2) { + uint16_t caps = data[1]; + if (data[0] == 2) + caps |= (uint16_t)data[2] << 8; cmsis_dap_handle->caps = caps; - if (caps & INFO_CAPS_SWD) - LOG_INFO("CMSIS-DAP: %s", info_caps_str[0]); - if (caps & INFO_CAPS_JTAG) - LOG_INFO("CMSIS-DAP: %s", info_caps_str[1]); - if (caps & INFO_CAPS_SWO_UART) - LOG_INFO("CMSIS-DAP: %s", info_caps_str[2]); - if (caps & INFO_CAPS_SWO_MANCHESTER) - LOG_INFO("CMSIS-DAP: %s", info_caps_str[3]); + for (int i = 0; i < INFO_CAPS__NUM_CAPS; ++i) { + if (caps & BIT(i)) + LOG_INFO("CMSIS-DAP: %s", info_caps_str[i]); + } } return ERROR_OK; diff --git a/src/jtag/drivers/cmsis_dap.h b/src/jtag/drivers/cmsis_dap.h index 634a62c8f..f6d9df21b 100644 --- a/src/jtag/drivers/cmsis_dap.h +++ b/src/jtag/drivers/cmsis_dap.h @@ -16,7 +16,7 @@ struct cmsis_dap { uint16_t packet_buffer_size; uint8_t *command; uint8_t *response; - uint8_t caps; + uint16_t caps; uint8_t mode; uint32_t swo_buf_sz; bool trace_enabled; commit d94e1ffef0c352af1a291819907f398f060a462e Author: Matthew Mets <ma...@bl...> Date: Thu Jul 22 01:25:15 2021 +0200 doc/openocd.texi: Add documentation for bcm2835 interface This adds documentation for the bcm2835 interface configuration parameters to the user manual. Documentation format is based on the FTDI interface section, and was taken from the descriptions in the driver source code. Change-Id: I77b09b8bd44d8e8fe9cc5fb9de3c3a30550d943c Signed-off-by: Matthew Mets <ma...@bl...> Reviewed-on: http://openocd.zylin.com/6376 Tested-by: jenkins Reviewed-by: Antonio Borneo <bor...@gm...> diff --git a/doc/openocd.texi b/doc/openocd.texi index 8f372a1a2..3aee034a4 100644 --- a/doc/openocd.texi +++ b/doc/openocd.texi @@ -3197,6 +3197,73 @@ configuration on exit. See @file{interface/raspberrypi-native.cfg} for a sample config and pinout. +@deffn {Config Command} {bcm2835gpio_jtag_nums} @var{tck} @var{tms} @var{tdi} @var{tdo} +Set JTAG transport GPIO numbers for TCK, TMS, TDI, and TDO (in that order). +Must be specified to enable JTAG transport. These pins can also be specified +individually. +@end deffn + +@deffn {Config Command} {bcm2835gpio_tck_num} @var{tck} +Set TCK GPIO number. Must be specified to enable JTAG transport. Can also be +specified using the configuration command bcm2835gpio_jtag_nums. +@end deffn + +@deffn {Config Command} {bcm2835gpio_tms_num} @var{tms} +Set TMS GPIO number. Must be specified to enable JTAG transport. Can also be +specified using the configuration command bcm2835gpio_jtag_nums. +@end deffn + +@deffn {Config Command} {bcm2835gpio_tdo_num} @var{tdo} +Set TDO GPIO number. Must be specified to enable JTAG transport. Can also be +specified using the configuration command bcm2835gpio_jtag_nums. +@end deffn + +@deffn {Config Command} {bcm2835gpio_tdi_num} @var{tdi} +Set TDI GPIO number. Must be specified to enable JTAG transport. Can also be +specified using the configuration command bcm2835gpio_jtag_nums. +@end deffn + +@deffn {Config Command} {bcm2835gpio_swd_nums} @var{swclk} @var{swdio} +Set SWD transport GPIO numbers for SWCLK and SWDIO (in that order). Must be +specified to enable SWD transport. These pins can also be specified individually. +@end deffn + +@deffn {Config Command} {bcm2835gpio_swclk_num} @var{swclk} +Set SWCLK GPIO number. Must be specified to enable SWD transport. Can also be +specified using the configuration command bcm2835gpio_swd_nums. +@end deffn + +@deffn {Config Command} {bcm2835gpio_swdio_num} @var{swdio} +Set SWDIO GPIO number. Must be specified to enable SWD transport. Can also be +specified using the configuration command bcm2835gpio_swd_nums. +@end deffn + +@deffn {Config Command} {bcm2835gpio_swdio_dir_num} @var{swdio} @var{dir} +Set SWDIO direction control pin GPIO number. If specified, this pin can be used +to control the direction of an external buffer on the SWDIO pin (set=output +mode, clear=input mode). If not specified, this feature is disabled. +@end deffn + +@deffn {Config Command} {bcm2835gpio_srst_num} @var{srst} +Set SRST GPIO number. Must be specified to enable SRST. +@end deffn + +@deffn {Config Command} {bcm2835gpio_trst_num} @var{trst} +Set TRST GPIO number. Must be specified to enable TRST. +@end deffn + +@deffn {Config Command} {bcm2835gpio_speed_coeffs} @var{speed_coeff} @var{speed_offset} +Set SPEED_COEFF and SPEED_OFFSET for delay calculations. If unspecified, +speed_coeff defaults to 113714, and speed_offset defaults to 28. +@end deffn + +@deffn {Config Command} {bcm2835gpio_peripheral_base} @var{base} +Set the peripheral base register address to access GPIOs. For the RPi1, use +0x20000000. For RPi2 and RPi3, use 0x3F000000. For RPi4, use 0xFE000000. A full +list can be found in the +@uref{https://www.raspberrypi.org/documentation/hardware/raspberrypi/peripheral_addresses.md, official guide}. +@end deffn + @end deffn @deffn {Interface Driver} {imx_gpio} ----------------------------------------------------------------------- Summary of changes: doc/openocd.texi | 67 ++++++++++++++++++++++++++++++++++++++++++++ src/jtag/drivers/cmsis_dap.c | 47 ++++++++++++++++++------------- src/jtag/drivers/cmsis_dap.h | 2 +- src/server/server.c | 12 ++++++-- src/target/target.c | 36 ++++++++++++++++-------- src/target/target.h | 9 +++++- 6 files changed, 138 insertions(+), 35 deletions(-) hooks/post-receive -- Main OpenOCD repository |