Skip to content

Commit

Permalink
Merge pull request #1163 from en-sc/en-sc/from_upstream
Browse files Browse the repository at this point in the history
Merge up to fd62626 from  upstream
  • Loading branch information
en-sc authored Nov 18, 2024
2 parents a2f5da3 + cabb600 commit c53f931
Show file tree
Hide file tree
Showing 220 changed files with 1,428 additions and 1,159 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ patches
.cproject
.settings

# VSCode stuff
.vscode

# Emacs temp files
*~

Expand Down
7 changes: 7 additions & 0 deletions HACKING
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,13 @@ Only for <em>exceptional cases</em>, it is allowed to submit patches
to Gerrit with the special field 'Checkpatch-ignore:' in the commit
message. This field will cause checkpatch to ignore the error types
listed in the field, only for the patch itself.
For errors in the commit message, the special field has to be put in
the commit message before the line that produces the error.
The special field must be added <em>before</em> the 'Signed-off-by:'
line, otherwise it is ignored.
To ignore multiple errors, either add multiple lines with the special
field or add multiple error types, separated by space or commas, in a
single line.
The error type is printed by checkpatch on failure.
For example the names of Windows APIs mix lower and upper case chars,
in violation of OpenOCD coding style, triggering a 'CAMELCASE' error:
Expand Down
44 changes: 19 additions & 25 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,18 @@ AS_IF([test -x "$srcdir/guess-rev.sh"], [
AC_MSG_RESULT([$build_release])

# Adapter drivers
# 1st column -- configure option
# 2nd column -- description
# 3rd column -- symbol used for both config.h and automake
# 1st column -- Basename for the configure option generated with AC_ARG_ENABLE.
# For example, "buspirate" generates options "--enable-buspirate[=yes/no]"
# and "--disable-buspirate".
# 2nd column -- Description for the configure option. For example, "Bus Pirate"
# generates "Enable building support for the Bus Pirate (default is auto)".
# 3rd column -- Basename for the config.h and Automake symbols.
# For example, basename "BUS_PIRATE" generates "BUILD_BUS_PIRATE" with AC_DEFINE
# for config.h and "BUS_PIRATE" with AM_CONDITIONAL for Automake.
m4_define([ADAPTER_ARG], [m4_argn([1], $1)])
m4_define([ADAPTER_DESC], [m4_argn([2], $1)])
m4_define([ADAPTER_SYM], [m4_argn([3], $1)])
# AC_ARG_ENABLE uses prefix "enable_" to name the corresponding option variable.
m4_define([ADAPTER_VAR], [enable_[]ADAPTER_ARG($1)])
m4_define([ADAPTER_OPT], [m4_translit(ADAPTER_ARG($1), [_], [-])])

Expand Down Expand Up @@ -265,6 +271,7 @@ AC_ARG_ADAPTERS([
LIBFTDI_USB1_ADAPTERS
LIBGPIOD_ADAPTERS,
SERIAL_PORT_ADAPTERS,
PCIE_ADAPTERS,
LIBJAYLINK_ADAPTERS
],[auto])

Expand Down Expand Up @@ -341,12 +348,10 @@ AC_ARG_ENABLE([sysfsgpio],
AS_HELP_STRING([--enable-sysfsgpio], [Enable building support for programming driven via sysfs gpios.]),
[build_sysfsgpio=$enableval], [build_sysfsgpio=no])

AC_ARG_ENABLE([xlnx_pcie_xvc],
AS_HELP_STRING([--enable-xlnx-pcie-xvc], [Enable building support for Xilinx XVC/PCIe.]),
[build_xlnx_pcie_xvc=$enableval], [build_xlnx_pcie_xvc=no])

AS_CASE([$host_os],
[linux*], [],
[linux*], [
is_linux=yes
],
[
AS_IF([test "x$build_sysfsgpio" = "xyes"], [
AC_MSG_ERROR([sysfsgpio is only available on linux])
Expand All @@ -356,10 +361,6 @@ AS_CASE([$host_os],
AC_MSG_ERROR([linuxgpiod is only available on linux])
])
AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
AC_MSG_ERROR([xlnx_pcie_xvc is only available on linux])
])
AS_CASE([$host_os], [freebsd*], [],
[
AS_IF([test "x$build_rshim" = "xyes"], [
Expand Down Expand Up @@ -620,13 +621,6 @@ AS_IF([test "x$build_sysfsgpio" = "xyes"], [
AC_DEFINE([BUILD_SYSFSGPIO], [0], [0 if you don't want SysfsGPIO driver.])
])

AS_IF([test "x$build_xlnx_pcie_xvc" = "xyes"], [
build_xlnx_pcie_xvc=yes
AC_DEFINE([BUILD_XLNX_PCIE_XVC], [1], [1 if you want the Xilinx XVC/PCIe driver.])
], [
AC_DEFINE([BUILD_XLNX_PCIE_XVC], [0], [0 if you don't want Xilinx XVC/PCIe driver.])
])

PKG_CHECK_MODULES([LIBUSB1], [libusb-1.0], [
use_libusb1=yes
AC_DEFINE([HAVE_LIBUSB1], [1], [Define if you have libusb-1.x])
Expand Down Expand Up @@ -688,11 +682,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 $1: An array of adapter triplets, used to derive option and variable names for each adapter.
# Arg $2: Whether the adapters can be enabled, for example, because
# their 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.
# if an adapter was requested but cannot be enabled.
m4_define([PROCESS_ADAPTERS], [
m4_foreach([adapter], [$1], [
AS_IF([test $2], [
Expand All @@ -703,7 +697,7 @@ m4_define([PROCESS_ADAPTERS], [
])
], [
AS_IF([test "x$ADAPTER_VAR([adapter])" = "xyes"], [
AC_MSG_ERROR([$3 is required for the ADAPTER_DESC([adapter])])
AC_MSG_ERROR([$3 is required for [adapter] ADAPTER_DESC([adapter]).])
])
ADAPTER_VAR([adapter])=no
AC_DEFINE([BUILD_]ADAPTER_SYM([adapter]), [0], [0 if you do not want the ]ADAPTER_DESC([adapter]).)
Expand All @@ -719,6 +713,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([PCIE_ADAPTERS], ["x$is_linux" = "xyes"], [Linux build])
PROCESS_ADAPTERS([DUMMY_ADAPTER], [true], [unused])

AS_IF([test "x$enable_linuxgpiod" != "xno"], [
Expand Down Expand Up @@ -775,7 +770,6 @@ AM_CONDITIONAL([GW16012], [test "x$build_gw16012" = "xyes"])
AM_CONDITIONAL([REMOTE_BITBANG], [test "x$build_remote_bitbang" = "xyes"])
AM_CONDITIONAL([BUSPIRATE], [test "x$enable_buspirate" != "xno"])
AM_CONDITIONAL([SYSFSGPIO], [test "x$build_sysfsgpio" = "xyes"])
AM_CONDITIONAL([XLNX_PCIE_XVC], [test "x$build_xlnx_pcie_xvc" = "xyes"])
AM_CONDITIONAL([USE_LIBUSB1], [test "x$use_libusb1" = "xyes"])
AM_CONDITIONAL([IS_CYGWIN], [test "x$is_cygwin" = "xyes"])
AM_CONDITIONAL([IS_MINGW], [test "x$is_mingw" = "xyes"])
Expand Down
24 changes: 12 additions & 12 deletions contrib/itmdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ unsigned int dump_swit;
* NOTE that this specific encoding could be space-optimized; and that
* trace data streams could also be history-sensitive.
*/
static void show_task(int port, unsigned data)
static void show_task(int port, unsigned int data)
{
unsigned code = data >> 16;
unsigned int code = data >> 16;
char buf[16];

if (dump_swit)
Expand Down Expand Up @@ -77,7 +77,7 @@ static void show_task(int port, unsigned data)

static void show_reserved(FILE *f, char *label, int c)
{
unsigned i;
unsigned int i;

if (dump_swit)
return;
Expand All @@ -96,9 +96,9 @@ static void show_reserved(FILE *f, char *label, int c)
printf("\n");
}

static bool read_varlen(FILE *f, int c, unsigned *value)
static bool read_varlen(FILE *f, int c, unsigned int *value)
{
unsigned size;
unsigned int size;
unsigned char buf[4];

*value = 0;
Expand Down Expand Up @@ -135,8 +135,8 @@ static bool read_varlen(FILE *f, int c, unsigned *value)

static void show_hard(FILE *f, int c)
{
unsigned type = c >> 3;
unsigned value;
unsigned int type = c >> 3;
unsigned int value;
char *label;

if (dump_swit)
Expand Down Expand Up @@ -230,16 +230,16 @@ static void show_hard(FILE *f, int c)
*/
struct {
int port;
void (*show)(int port, unsigned data);
void (*show)(int port, unsigned int data);
} format[] = {
{ .port = 31, .show = show_task, },
};

static void show_swit(FILE *f, int c)
{
unsigned port = c >> 3;
unsigned value = 0;
unsigned i;
unsigned int port = c >> 3;
unsigned int value = 0;
unsigned int i;

if (port + 1 == dump_swit) {
if (!read_varlen(f, c, &value))
Expand Down Expand Up @@ -272,7 +272,7 @@ static void show_swit(FILE *f, int c)

static void show_timestamp(FILE *f, int c)
{
unsigned counter = 0;
unsigned int counter = 0;
char *label = "";
bool delayed = false;

Expand Down
20 changes: 10 additions & 10 deletions contrib/loaders/flash/fespi/riscv_fespi.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void fespi_disable_hw_mode(volatile uint32_t *ctrl_base);
static void fespi_enable_hw_mode(volatile uint32_t *ctrl_base);
static int fespi_wip(volatile uint32_t *ctrl_base);
static int fespi_write_buffer(volatile uint32_t *ctrl_base,
const uint8_t *buffer, unsigned offset, unsigned len,
const uint8_t *buffer, unsigned int offset, unsigned int len,
uint32_t flash_info);

/* Can set bits 3:0 in result. */
Expand All @@ -113,7 +113,7 @@ static int fespi_write_buffer(volatile uint32_t *ctrl_base,
* after pprog_cmd
*/
int flash_fespi(volatile uint32_t *ctrl_base, uint32_t page_size,
const uint8_t *buffer, unsigned offset, uint32_t count,
const uint8_t *buffer, unsigned int offset, uint32_t count,
uint32_t flash_info)
{
int result;
Expand Down Expand Up @@ -163,12 +163,12 @@ int flash_fespi(volatile uint32_t *ctrl_base, uint32_t page_size,
return result;
}

static uint32_t fespi_read_reg(volatile uint32_t *ctrl_base, unsigned address)
static uint32_t fespi_read_reg(volatile uint32_t *ctrl_base, unsigned int address)
{
return ctrl_base[address / 4];
}

static void fespi_write_reg(volatile uint32_t *ctrl_base, unsigned address, uint32_t value)
static void fespi_write_reg(volatile uint32_t *ctrl_base, unsigned int address, uint32_t value)
{
ctrl_base[address / 4] = value;
}
Expand All @@ -188,7 +188,7 @@ static void fespi_enable_hw_mode(volatile uint32_t *ctrl_base)
/* Can set bits 7:4 in result. */
static int fespi_txwm_wait(volatile uint32_t *ctrl_base)
{
unsigned timeout = TIMEOUT;
unsigned int timeout = TIMEOUT;

while (timeout--) {
uint32_t ip = fespi_read_reg(ctrl_base, FESPI_REG_IP);
Expand All @@ -209,7 +209,7 @@ static void fespi_set_dir(volatile uint32_t *ctrl_base, bool dir)
/* Can set bits 11:8 in result. */
static int fespi_tx(volatile uint32_t *ctrl_base, uint8_t in)
{
unsigned timeout = TIMEOUT;
unsigned int timeout = TIMEOUT;

while (timeout--) {
uint32_t txfifo = fespi_read_reg(ctrl_base, FESPI_REG_TXFIFO);
Expand All @@ -224,7 +224,7 @@ static int fespi_tx(volatile uint32_t *ctrl_base, uint8_t in)
/* Can set bits 15:12 in result. */
static int fespi_rx(volatile uint32_t *ctrl_base, uint8_t *out)
{
unsigned timeout = TIMEOUT;
unsigned int timeout = TIMEOUT;

while (timeout--) {
uint32_t value = fespi_read_reg(ctrl_base, FESPI_REG_RXFIFO);
Expand Down Expand Up @@ -252,7 +252,7 @@ static int fespi_wip(volatile uint32_t *ctrl_base)
if (result != ERROR_OK)
return result | ERROR_STACK(0x20000);

unsigned timeout = TIMEOUT;
unsigned int timeout = TIMEOUT;
while (timeout--) {
result = fespi_tx(ctrl_base, 0);
if (result != ERROR_OK)
Expand All @@ -273,7 +273,7 @@ static int fespi_wip(volatile uint32_t *ctrl_base)

/* Can set bits 23:20 in result. */
static int fespi_write_buffer(volatile uint32_t *ctrl_base,
const uint8_t *buffer, unsigned offset, unsigned len,
const uint8_t *buffer, unsigned int offset, unsigned int len,
uint32_t flash_info)
{
int result = fespi_tx(ctrl_base, SPIFLASH_WRITE_ENABLE);
Expand Down Expand Up @@ -304,7 +304,7 @@ static int fespi_write_buffer(volatile uint32_t *ctrl_base,
if (result != ERROR_OK)
return result | ERROR_STACK(0x600000);

for (unsigned i = 0; i < len; i++) {
for (unsigned int i = 0; i < len; i++) {
result = fespi_tx(ctrl_base, buffer[i]);
if (result != ERROR_OK)
return result | ERROR_STACK(0x700000);
Expand Down
20 changes: 7 additions & 13 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ This command is only available if your libusb1 is at least version 1.0.16.
Specifies the @var{serial_string} of the adapter to use.
If this command is not specified, serial strings are not checked.
Only the following adapter drivers use the serial string from this command:
arm-jtag-ew, cmsis_dap, esp_usb_jtag, ft232r, ftdi, hla (stlink, ti-icdi), jlink, kitprog, opendus,
arm-jtag-ew, cmsis_dap, esp_usb_jtag, ft232r, ftdi, hla (ti-icdi), jlink, kitprog, opendus,
openjtag, osbdm, presto, rlink, st-link, usb_blaster (ublast2), usbprog, vsllink, xds110.
@end deffn

Expand Down Expand Up @@ -3235,23 +3235,14 @@ version reported is V2.J21.S4.
Currently Not Supported.
@end deffn

@deffn {Config Command} {hla layout} (@option{stlink}|@option{icdi}|@option{nulink})
@deffn {Config Command} {hla layout} (@option{icdi}|@option{nulink})
Specifies the adapter layout to use.
@end deffn

@deffn {Config Command} {hla vid_pid} [vid pid]+
Pairs of vendor IDs and product IDs of the device.
@end deffn

@deffn {Config Command} {hla stlink_backend} (usb | tcp [port])
@emph{ST-Link only:} Choose between 'exclusive' USB communication (the default backend) or
'shared' mode using ST-Link TCP server (the default port is 7184).

@emph{Note:} ST-Link TCP server is a binary application provided by ST
available from @url{https://www.st.com/en/development-tools/st-link-server.html,
ST-LINK server software module}.
@end deffn

@deffn {Command} {hla command} command
Execute a custom adapter-specific command. The @var{command} string is
passed as is to the underlying adapter layout handler.
Expand All @@ -3261,9 +3252,12 @@ passed as is to the underlying adapter layout handler.
@anchor{st_link_dap_interface}
@deffn {Interface Driver} {st-link}
This is a driver that supports STMicroelectronics adapters ST-LINK/V2
(from firmware V2J24), STLINK-V3 and STLINK-V3PWR, thanks to a new API that provides
(from 2015 firmware V2J24), STLINK-V3 and STLINK-V3PWR, thanks to a new API that provides
directly access the arm ADIv5 DAP.

The older API that requires HLA transport is deprecated and will be dropped
from OpenOCD. In mean time it's still available by using @file{interface/stlink-hla.cfg}.

The new API provide access to multiple AP on the same DAP, but the
maximum number of the AP port is limited by the specific firmware version
(e.g. firmware V2J29 has 3 as maximum AP number, while V2J32 has 8).
Expand Down Expand Up @@ -10706,7 +10700,7 @@ baud with our custom divisor to get 12MHz)
@item OpenOCD invocation line:
@example
openocd -f interface/stlink.cfg \
-c "transport select hla_swd" \
-c "transport select dapdirect_swd" \
-f target/stm32l1.cfg \
-c "stm32l1.tpiu configure -protocol uart" \
-c "stm32l1.tpiu configure -traceclk 24000000 -pin-freq 12000000" \
Expand Down
2 changes: 1 addition & 1 deletion jimtcl
Submodule jimtcl updated 110 files
6 changes: 3 additions & 3 deletions src/flash/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@
#include "common.h"
#include <helper/log.h>

unsigned get_flash_name_index(const char *name)
unsigned int get_flash_name_index(const char *name)
{
const char *name_index = strrchr(name, '.');
if (!name_index)
return 0;
if (name_index[1] < '0' || name_index[1] > '9')
return ~0U;
unsigned requested;
unsigned int requested;
int retval = parse_uint(name_index + 1, &requested);
/* detect parsing error by forcing past end of bank list */
return (retval == ERROR_OK) ? requested : ~0U;
}

bool flash_driver_name_matches(const char *name, const char *expected)
{
unsigned blen = strlen(name);
unsigned int blen = strlen(name);
/* only match up to the length of the driver name... */
if (strncmp(name, expected, blen) != 0)
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/flash/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* name provides a suffix but it does not parse as an unsigned integer,
* the routine returns ~0U. This will prevent further matching.
*/
unsigned get_flash_name_index(const char *name);
unsigned int get_flash_name_index(const char *name);
/**
* Attempt to match the @c expected name with the @c name of a driver.
* @param name The name of the driver (from the bank's device structure).
Expand Down
Loading

0 comments on commit c53f931

Please sign in to comment.