Skip to content

Commit

Permalink
Merge pull request #1075 from en-sc/en-sc/from_upstream
Browse files Browse the repository at this point in the history
Merge up to 437dde7 from upstream
  • Loading branch information
en-sc authored Jun 5, 2024
2 parents b548653 + 9c4a5d6 commit 40cda81
Show file tree
Hide file tree
Showing 38 changed files with 470 additions and 244 deletions.
7 changes: 6 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,14 @@ TCL_PATH = tcl
TCL_FILES = find $(srcdir)/$(TCL_PATH) -name '*.cfg' -o -name '*.tcl' -o -name '*.txt' | \
sed -e 's,^$(srcdir)/$(TCL_PATH),,'

# Without the PERL_UNICODE="IO" workaround below when running git2cl, you get several
# "Wide character" warnings and you also risk an invalid character encoding in
# the generated ChangeLog file. For more information, see this bug report:
# Warning "Wide character in print"
# https://savannah.nongnu.org/bugs/?65689
dist-hook:
if test -d $(srcdir)/.git -a \( ! -e $(distdir)/ChangeLog -o -w $(distdir)/ChangeLog \) ; then \
git --git-dir $(srcdir)/.git log | $(srcdir)/tools/git2cl/git2cl > $(distdir)/ChangeLog ; \
git --git-dir $(srcdir)/.git log | PERL_UNICODE="IO" $(srcdir)/tools/git2cl/git2cl > $(distdir)/ChangeLog ; \
fi
for i in $$($(TCL_FILES)); do \
j="$(distdir)/$(TCL_PATH)/$$i" && \
Expand Down
24 changes: 15 additions & 9 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ m4_define([PCIE_ADAPTERS],
m4_define([SERIAL_PORT_ADAPTERS],
[[[buspirate], [Bus Pirate], [BUS_PIRATE]]])

# The word 'Adapter' in "Dummy Adapter" below must begin with a capital letter
# because there is an M4 macro called 'adapter'.
m4_define([DUMMY_ADAPTER],
[[[dummy], [Dummy Adapter], [DUMMY]]])

m4_define([OPTIONAL_LIBRARIES],
[[[capstone], [Use Capstone disassembly framework], []]])

Expand Down Expand Up @@ -235,10 +240,6 @@ AS_IF([test "x$debug_malloc" = "xyes"], [
AC_DEFINE([_DEBUG_FREE_SPACE_],[1], [Include malloc free space in logging])
])

AC_ARG_ENABLE([dummy],
AS_HELP_STRING([--enable-dummy], [Enable building the dummy port driver]),
[build_dummy=$enableval], [build_dummy=no])

AC_ARG_ENABLE([rshim],
AS_HELP_STRING([--enable-rshim], [Enable building the rshim driver]),
[build_rshim=$enableval], [build_rshim=no])
Expand Down Expand Up @@ -267,6 +268,8 @@ AC_ARG_ADAPTERS([
LIBJAYLINK_ADAPTERS
],[auto])

AC_ARG_ADAPTERS([DUMMY_ADAPTER],[no])

AC_ARG_ENABLE([parport],
AS_HELP_STRING([--enable-parport], [Enable building the pc parallel port driver]),
[build_parport=$enableval], [build_parport=no])
Expand Down Expand Up @@ -493,11 +496,8 @@ AS_IF([test "x$build_dmem" = "xyes"], [
AC_DEFINE([BUILD_DMEM], [0], [0 if you don't want to debug via Direct Mem.])
])

AS_IF([test "x$build_dummy" = "xyes"], [
AS_IF([test "x$ADAPTER_VAR([dummy])" = "xyes"], [
build_bitbang=yes
AC_DEFINE([BUILD_DUMMY], [1], [1 if you want dummy driver.])
], [
AC_DEFINE([BUILD_DUMMY], [0], [0 if you don't want dummy driver.])
])

AS_IF([test "x$build_ep93xx" = "xyes"], [
Expand Down Expand Up @@ -679,6 +679,11 @@ PKG_CHECK_MODULES([LIBGPIOD], [libgpiod < 2.0], [
PKG_CHECK_MODULES([LIBJAYLINK], [libjaylink >= 0.2],
[use_libjaylink=yes], [use_libjaylink=no])

# Arg $1: The adapter name, used to derive option and variable names for the adapter.
# Arg $2: Whether the adapter can be enabled, for example, because
# its prerequisites are installed in the system.
# Arg $3: What prerequisites are missing, to be shown in an error message
# if the adapter was requested but cannot be enabled.
m4_define([PROCESS_ADAPTERS], [
m4_foreach([adapter], [$1], [
AS_IF([test $2], [
Expand All @@ -705,6 +710,7 @@ PROCESS_ADAPTERS([LIBFTDI_ADAPTERS], ["x$use_libftdi" = "xyes"], [libftdi])
PROCESS_ADAPTERS([LIBFTDI_USB1_ADAPTERS], ["x$use_libftdi" = "xyes" -a "x$use_libusb1" = "xyes"], [libftdi and libusb-1.x])
PROCESS_ADAPTERS([LIBGPIOD_ADAPTERS], ["x$use_libgpiod" = "xyes"], [libgpiod])
PROCESS_ADAPTERS([LIBJAYLINK_ADAPTERS], ["x$use_internal_libjaylink" = "xyes" -o "x$use_libjaylink" = "xyes"], [libjaylink-0.2])
PROCESS_ADAPTERS([DUMMY_ADAPTER], [true], [unused])

AS_IF([test "x$enable_linuxgpiod" != "xno"], [
build_bitbang=yes
Expand Down Expand Up @@ -744,7 +750,6 @@ AS_IF([test "x$enable_esp_usb_jtag" != "xno"], [

AM_CONDITIONAL([RELEASE], [test "x$build_release" = "xyes"])
AM_CONDITIONAL([PARPORT], [test "x$build_parport" = "xyes"])
AM_CONDITIONAL([DUMMY], [test "x$build_dummy" = "xyes"])
AM_CONDITIONAL([GIVEIO], [test "x$parport_use_giveio" = "xyes"])
AM_CONDITIONAL([EP93XX], [test "x$build_ep93xx" = "xyes"])
AM_CONDITIONAL([AT91RM9200], [test "x$build_at91rm9200" = "xyes"])
Expand Down Expand Up @@ -853,6 +858,7 @@ m4_foreach([adapter], [USB1_ADAPTERS,
LIBFTDI_USB1_ADAPTERS,
LIBGPIOD_ADAPTERS,
LIBJAYLINK_ADAPTERS, PCIE_ADAPTERS, SERIAL_PORT_ADAPTERS,
DUMMY_ADAPTER,
OPTIONAL_LIBRARIES],
[s=m4_format(["%-40s"], ADAPTER_DESC([adapter]))
AS_CASE([$ADAPTER_VAR([adapter])],
Expand Down
15 changes: 15 additions & 0 deletions doc/manual/style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,21 @@ OpenOCD project.
x = 0;
}
@endcode
- on <tt> if </tt> statements where the condition is split among multiple
lines, increase the indentation of the condition to prevent it to match
to the indentation of the <tt> then </tt> block due to length of 'if ('
being same of the TAB width of 4 characters. Use:
@code
if (CMD_ARGC < 3
|| CMD_ARGC > 8)
return ERROR_COMMAND_SYNTAX_ERROR;
@endcode
instead of:
@code
if (CMD_ARGC < 3 ||
CMD_ARGC > 8)
return ERROR_COMMAND_SYNTAX_ERROR;
@endcode

Finally, try to avoid lines of code that are longer than 72-80 columns:

Expand Down
19 changes: 15 additions & 4 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,7 @@ to be available anymore as of April 2012.
@* Link @url{http://www.distortec.com/jtag-lock-pick-tiny-2} FT232H-based

@item @b{GW16042}
@* Link: @url{http://shop.gateworks.com/index.php?route=product/product&path=70_80&product_id=64}
FT2232H-based
@* Link: @url{https://www.gateworks.com/} FT2232H-based

@end itemize
@section USB-JTAG / Altera USB-Blaster compatibles
Expand Down Expand Up @@ -442,7 +441,7 @@ SWD and not JTAG, thus not supported.

@itemize @bullet
@item @b{Raisonance RLink}
@* Link: @url{http://www.mcu-raisonance.com/~rlink-debugger-programmer__@/microcontrollers__tool~tool__T018:4cn9ziz4bnx6.html}
@* Link: @url{https://www.raisonance.com/rlink.html}
@item @b{STM32 Primer}
@* Link: @url{http://www.stm32circle.com/resources/stm32primer.php}
@item @b{STM32 Primer2}
Expand Down Expand Up @@ -9220,6 +9219,18 @@ read_memory 0x20000000 32 2
@end example
@end deffn

@deffn {Command} {debug_reason}
Displays the current debug reason:
@code{debug-request},
@code{breakpoint},
@code{watchpoint},
@code{watchpoint-and-breakpoint},
@code{single-step},
@code{target-not-halted},
@code{program-exit},
@code{exception-catch} or @code{undefined}.
@end deffn

@deffn {Command} {halt} [ms]
@deffnx {Command} {wait_halt} [ms]
The @command{halt} command first sends a halt request to the target,
Expand Down Expand Up @@ -9389,7 +9400,7 @@ Loads an image stored in memory by @command{fast_load_image} to the
current target. Must be preceded by fast_load_image.
@end deffn

@deffn {Command} {fast_load_image} filename [address [@option{bin}|@option{ihex}|@option{elf}|@option{s19} [@option{min_addr} [@option{max_length}]]]]]]
@deffn {Command} {fast_load_image} filename [address [@option{bin}|@option{ihex}|@option{elf}|@option{s19} [@option{min_addr} [@option{max_length}]]]]
Normally you should be using @command{load_image} or GDB load. However, for
testing purposes or when I/O overhead is significant(OpenOCD running on an embedded
host), storing the image in memory and uploading the image to the target
Expand Down
1 change: 0 additions & 1 deletion src/flash/nor/psoc6.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#include "target/target.h"
#include "target/cortex_m.h"
#include "target/breakpoints.h"
#include "target/target_type.h"
#include "target/algorithm.h"

/**************************************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/helper/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/* To achieve C99 printf compatibility in MinGW, gnu_printf should be
* used for __attribute__((format( ... ))), with GCC v4.4 or later
*/
#if (defined(IS_MINGW) && (((__GNUC__ << 16) + __GNUC_MINOR__) >= 0x00040004))
#if (defined(IS_MINGW) && (((__GNUC__ << 16) + __GNUC_MINOR__) >= 0x00040004)) && !defined(__clang__)
#define PRINTF_ATTRIBUTE_FORMAT gnu_printf
#else
#define PRINTF_ATTRIBUTE_FORMAT printf
Expand Down
2 changes: 1 addition & 1 deletion src/helper/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
/* To achieve C99 printf compatibility in MinGW, gnu_printf should be
* used for __attribute__((format( ... ))), with GCC v4.4 or later
*/
#if (defined(IS_MINGW) && (((__GNUC__ << 16) + __GNUC_MINOR__) >= 0x00040004))
#if (defined(IS_MINGW) && (((__GNUC__ << 16) + __GNUC_MINOR__) >= 0x00040004)) && !defined(__clang__)
#define PRINTF_ATTRIBUTE_FORMAT gnu_printf
#else
#define PRINTF_ATTRIBUTE_FORMAT printf
Expand Down
18 changes: 9 additions & 9 deletions src/jtag/drivers/linuxgpiod.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,12 +378,12 @@ static int linuxgpiod_init(void)
goto out_error;
}

if (helper_get_line(ADAPTER_GPIO_IDX_TDO) != ERROR_OK ||
helper_get_line(ADAPTER_GPIO_IDX_TDI) != ERROR_OK ||
helper_get_line(ADAPTER_GPIO_IDX_TCK) != ERROR_OK ||
helper_get_line(ADAPTER_GPIO_IDX_TMS) != ERROR_OK ||
helper_get_line(ADAPTER_GPIO_IDX_TRST) != ERROR_OK)
goto out_error;
if (helper_get_line(ADAPTER_GPIO_IDX_TDO) != ERROR_OK
|| helper_get_line(ADAPTER_GPIO_IDX_TDI) != ERROR_OK
|| helper_get_line(ADAPTER_GPIO_IDX_TCK) != ERROR_OK
|| helper_get_line(ADAPTER_GPIO_IDX_TMS) != ERROR_OK
|| helper_get_line(ADAPTER_GPIO_IDX_TRST) != ERROR_OK)
goto out_error;
}

if (transport_is_swd()) {
Expand Down Expand Up @@ -413,9 +413,9 @@ static int linuxgpiod_init(void)
goto out_error;
}

if (helper_get_line(ADAPTER_GPIO_IDX_SRST) != ERROR_OK ||
helper_get_line(ADAPTER_GPIO_IDX_LED) != ERROR_OK)
goto out_error;
if (helper_get_line(ADAPTER_GPIO_IDX_SRST) != ERROR_OK
|| helper_get_line(ADAPTER_GPIO_IDX_LED) != ERROR_OK)
goto out_error;

return ERROR_OK;

Expand Down
3 changes: 1 addition & 2 deletions src/rtos/FreeRTOS.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "rtos.h"
#include "helper/log.h"
#include "helper/types.h"
Expand Down Expand Up @@ -931,7 +930,7 @@ static int freertos_create(struct target *target)
{
unsigned int i = 0;
while (i < ARRAY_SIZE(freertos_params_list) &&
strcmp(freertos_params_list[i].target_name, target->type->name) != 0) {
strcmp(freertos_params_list[i].target_name, target_type_name(target)) != 0) {
i++;
}
if (i >= ARRAY_SIZE(freertos_params_list)) {
Expand Down
3 changes: 1 addition & 2 deletions src/rtos/ThreadX.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "rtos.h"
#include "helper/log.h"
#include "helper/types.h"
Expand Down Expand Up @@ -608,7 +607,7 @@ static int threadx_get_thread_detail(struct rtos *rtos,
static int threadx_create(struct target *target)
{
for (unsigned int i = 0; i < ARRAY_SIZE(threadx_params_list); i++)
if (strcmp(threadx_params_list[i].target_name, target->type->name) == 0) {
if (strcmp(threadx_params_list[i].target_name, target_type_name(target)) == 0) {
target->rtos->rtos_specific_params = (void *)&threadx_params_list[i];
target->rtos->current_thread = 0;
target->rtos->thread_details = NULL;
Expand Down
7 changes: 3 additions & 4 deletions src/rtos/chibios.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "target/armv7m.h"
#include "target/cortex_m.h"
#include "rtos.h"
Expand Down Expand Up @@ -470,7 +469,7 @@ static int chibios_get_thread_reg_list(struct rtos *rtos, int64_t thread_id,
/* Update stacking if it can only be determined from runtime information */
if (!param->stacking_info &&
(chibios_update_stacking(rtos) != ERROR_OK)) {
LOG_ERROR("Failed to determine exact stacking for the target type %s", rtos->target->type->name);
LOG_ERROR("Failed to determine exact stacking for the target type %s", target_type_name(rtos->target));
return -1;
}

Expand Down Expand Up @@ -518,12 +517,12 @@ static bool chibios_detect_rtos(struct target *target)
static int chibios_create(struct target *target)
{
for (unsigned int i = 0; i < ARRAY_SIZE(chibios_params_list); i++)
if (strcmp(chibios_params_list[i].target_name, target->type->name) == 0) {
if (strcmp(chibios_params_list[i].target_name, target_type_name(target)) == 0) {
target->rtos->rtos_specific_params = (void *)&chibios_params_list[i];
return 0;
}

LOG_WARNING("Could not find target \"%s\" in ChibiOS compatibility "
"list", target->type->name);
"list", target_type_name(target));
return -1;
}
7 changes: 3 additions & 4 deletions src/rtos/chromium-ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <helper/bits.h>
#include <rtos/rtos.h>
#include <target/target.h>
#include <target/target_type.h>

#include "rtos_standard_stackings.h"

Expand Down Expand Up @@ -120,7 +119,7 @@ static int chromium_ec_create(struct target *target)
size_t t;

for (t = 0; t < ARRAY_SIZE(chromium_ec_params_list); t++)
if (!strcmp(chromium_ec_params_list[t].target_name, target->type->name)) {
if (!strcmp(chromium_ec_params_list[t].target_name, target_type_name(target))) {
params = malloc(sizeof(*params));
if (!params) {
LOG_ERROR("Chromium-EC: out of memory");
Expand All @@ -133,11 +132,11 @@ static int chromium_ec_create(struct target *target)
target->rtos->thread_details = NULL;
target->rtos->thread_count = 0;

LOG_INFO("Chromium-EC: Using target: %s", target->type->name);
LOG_INFO("Chromium-EC: Using target: %s", target_type_name(target));
return ERROR_OK;
}

LOG_ERROR("Chromium-EC: target not supported: %s", target->type->name);
LOG_ERROR("Chromium-EC: target not supported: %s", target_type_name(target));
return ERROR_FAIL;
}

Expand Down
7 changes: 3 additions & 4 deletions src/rtos/eCos.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "target/armv7m.h"
#include "rtos.h"
#include "helper/log.h"
Expand Down Expand Up @@ -1137,7 +1136,7 @@ static int ecos_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[
ARRAY_SIZE(ecos_symbol_list), sizeof(struct symbol_table_elem));

/* If the target reference was passed into this function we could limit
* the symbols we need to lookup to the target->type->name based
* the symbols we need to lookup to the target_type_name(target) based
* range. For the moment we need to provide a single vector with all of
* the symbols across all of the supported architectures. */
for (i = 0; i < ARRAY_SIZE(ecos_symbol_list); i++) {
Expand Down Expand Up @@ -1189,8 +1188,8 @@ static int ecos_create(struct target *target)
for (unsigned int i = 0; i < ARRAY_SIZE(ecos_params_list); i++) {
const char * const *tnames = ecos_params_list[i].target_names;
while (*tnames) {
if (strcmp(*tnames, target->type->name) == 0) {
/* LOG_DEBUG("eCos: matched target \"%s\"", target->type->name); */
if (strcmp(*tnames, target_type_name(target)) == 0) {
/* LOG_DEBUG("eCos: matched target \"%s\"", target_type_name(target)); */
target->rtos->rtos_specific_params = (void *)&ecos_params_list[i];
ecos_params_list[i].flush_common = true;
ecos_params_list[i].stacking_info = NULL;
Expand Down
5 changes: 2 additions & 3 deletions src/rtos/embKernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "rtos.h"
#include "helper/log.h"
#include "helper/types.h"
Expand Down Expand Up @@ -110,12 +109,12 @@ static int embkernel_create(struct target *target)
{
size_t i = 0;
while ((i < ARRAY_SIZE(embkernel_params_list)) &&
(strcmp(embkernel_params_list[i].target_name, target->type->name) != 0))
(strcmp(embkernel_params_list[i].target_name, target_type_name(target)) != 0))
i++;

if (i >= ARRAY_SIZE(embkernel_params_list)) {
LOG_WARNING("Could not find target \"%s\" in embKernel compatibility "
"list", target->type->name);
"list", target_type_name(target));
return -1;
}

Expand Down
1 change: 0 additions & 1 deletion src/rtos/hwthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <helper/time_support.h>
#include <jtag/jtag.h>
#include "target/target.h"
#include "target/target_type.h"
#include "target/register.h"
#include <target/smp.h>
#include "rtos.h"
Expand Down
Loading

0 comments on commit 40cda81

Please sign in to comment.