Skip to content

Commit

Permalink
Merge up to 26f2df8 from upstream
Browse files Browse the repository at this point in the history
Conflicts:
* `src/target/target.c` due to commit
  4004db5 ("Make polling_interval
  unsigned.")

Change-Id: I0a691dbebe300f3a53fb31bd1097a9aff5551a52
  • Loading branch information
en-sc committed Jan 22, 2025
2 parents 88fe568 + 26f2df8 commit 182092a
Show file tree
Hide file tree
Showing 53 changed files with 679 additions and 422 deletions.
2 changes: 1 addition & 1 deletion config_subdir.m4
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ AC_DEFUN([AX_CONFIG_SUBDIR_OPTION],
AC_CONFIG_SUBDIRS([$1])
m4_ifblank([$2], [rm -f $srcdir/$1/configure.gnu],
[echo -e '#!/bin/sh\nexec "`dirname "'\$'0"`/configure" '"$2"' "'\$'@"' > "$srcdir/$1/configure.gnu"
[printf '#!/bin/sh\nexec "`dirname "'\$'0"`/configure" '"$2"' "'\$'@"\n' > "$srcdir/$1/configure.gnu"
])
])
13 changes: 6 additions & 7 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,11 @@ AC_ARG_ADAPTERS([
LIBFTDI_USB1_ADAPTERS,
LIBGPIOD_ADAPTERS,
SERIAL_PORT_ADAPTERS,
DUMMY_ADAPTER,
PCIE_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 @@ -417,8 +416,8 @@ AS_CASE(["${host_cpu}"],

can_build_buspirate=yes

AS_CASE([$host],
[*-cygwin*], [
AS_CASE([$host_os],
[cygwin*], [
is_win32=yes
parport_use_ppdev=no
Expand All @@ -438,7 +437,7 @@ AS_CASE([$host],
])
])
],
[*-mingw* | *-msys*], [
[mingw* | msys*], [
is_mingw=yes
is_win32=yes
parport_use_ppdev=no
Expand All @@ -457,7 +456,7 @@ AS_CASE([$host],
AC_SUBST([HOST_CPPFLAGS], ["-D__USE_MINGW_ANSI_STDIO -DFD_SETSIZE=128"])
],
[*darwin*], [
[darwin*], [
is_darwin=yes
AS_IF([test "x$parport_use_giveio" = "xyes"], [
Expand Down Expand Up @@ -515,7 +514,7 @@ 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$ADAPTER_VAR([dummy])" = "xyes"], [
AS_IF([test "x$ADAPTER_VAR([dummy])" != "xno"], [
build_bitbang=yes
])

Expand Down
2 changes: 1 addition & 1 deletion contrib/list_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include <assert.h>
#include <helper/list.h>

static LIST_HEAD(threads);
static OOCD_LIST_HEAD(threads);

struct thread {
int id;
Expand Down
15 changes: 15 additions & 0 deletions doc/manual/style.txt
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,21 @@ if (!buf) {
}
@endcode

@section stylelogging Logging

Logging is intended to provide human-readable information to users.
Do not confuse logging with the output of commands.
The latter is intended for the result of a command and should be able to be processed by Tcl scripts.

- Use one of the following functions to generate log messages, never use `printf()` or similar functions.
- Use `LOG_ERROR()` to provide information in case an operation failed in an unrecoverable way. For example, if necessary memory cannot be allocated.
- Use `LOG_WARNING()` to inform the user of about an unexpected behavior that can be handled and the intended operation is still be performed. For example, in case a command is deprecated but is nevertheless executed.
- Use `LOG_INFO()` to provide insightful or necessary information to the user. For example, features or capabilities of a discovered target.
- Use `LOG_DEBUG()` to provide information for troubleshooting. For example, detailed information which makes it easier to debug a specific operation. Try to avoid flooding the log with frequently generated messages. For example, do not use LOG_DEBUG() in operations used for polling the target. Use LOG_DEBUG_IO() for such frequent messages.
- Use `LOG_DEBUG_IO()` to provide I/O related information for troubleshooting. For example, details about the communication between OpenOCD and a debug adapter.
- If the log message is related to a target, use the corresponding `LOG_TARGET_xxx()` functions.
- Do not use a period or exclamation mark at the end of a message.

*/
/** @page styledoxygen Doxygen Style Guide

Expand Down
2 changes: 1 addition & 1 deletion doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -8030,7 +8030,7 @@ The @var{num} parameter is a value shown by @command{flash banks}.
@end deffn

@deffn {Flash Driver} {stm32l4x}
All members of the STM32 G0, G4, L4, L4+, L5, U5, WB and WL
All members of the STM32 C0, G0, G4, L4, L4+, L5, U0, U5, WB and WL
microcontroller families from STMicroelectronics include internal flash
and use ARM Cortex-M0+, M4 and M33 cores.
The driver automatically recognizes a number of these chips using
Expand Down
2 changes: 1 addition & 1 deletion src/flash/nor/sfdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int spi_sfdp(struct flash_bank *bank, struct flash_device *dev,
uint16_t id = (((pheaders[k].ptr) >> 16) & 0xFF00) | (pheaders[k].revision & 0xFF);
uint32_t ptr = pheaders[k].ptr & 0xFFFFFF;

LOG_DEBUG("pheader %d len=0x%02" PRIx8 " id=0x%04" PRIx16
LOG_DEBUG("pheader %d len=0x%02x id=0x%04" PRIx16
" ptr=0x%06" PRIx32, k, words, id, ptr);

/* retrieve parameter table */
Expand Down
55 changes: 54 additions & 1 deletion src/flash/nor/stm32l4x.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@
* http://www.st.com/resource/en/reference_manual/dm00346336.pdf
*/

/* STM32U0xxx series for reference.
*
* RM0503 (STM32U0xx)
* https://www.st.com/resource/en/reference_manual/rm0503-stm32u0-series-advanced-armbased-32bit-mcus-stmicroelectronics.pdf
*/

/* STM32U5xxx series for reference.
*
* RM0456 (STM32U5xx)
Expand Down Expand Up @@ -278,7 +284,7 @@ struct stm32l4_wrp {
};

/* human readable list of families this drivers supports (sorted alphabetically) */
static const char *device_families = "STM32C0/G0/G4/L4/L4+/L5/U5/WB/WL";
static const char *device_families = "STM32C0/G0/G4/L4/L4+/L5/U0/U5/WB/WL";

static const struct stm32l4_rev stm32l47_l48xx_revs[] = {
{ 0x1000, "1" }, { 0x1001, "2" }, { 0x1003, "3" }, { 0x1007, "4" }
Expand All @@ -297,6 +303,10 @@ static const struct stm32l4_rev stm32c03xx_revs[] = {
{ 0x1000, "A" }, { 0x1001, "Z" },
};

static const struct stm32l4_rev stm32c071xx_revs[] = {
{ 0x1001, "Z" },
};

static const struct stm32l4_rev stm32g05_g06xx_revs[] = {
{ 0x1000, "A" },
};
Expand Down Expand Up @@ -325,6 +335,10 @@ static const struct stm32l4_rev stm32g0b_g0cxx_revs[] = {
{ 0x1000, "A" },
};

static const struct stm32l4_rev stm32u0xx_revs[] = {
{ 0x1000, "A" },
};

static const struct stm32l4_rev stm32g43_g44xx_revs[] = {
{ 0x1000, "A" }, { 0x2000, "B" }, { 0x2001, "Z" },
};
Expand Down Expand Up @@ -432,6 +446,18 @@ static const struct stm32l4_part_info stm32l4_parts[] = {
.otp_base = 0x1FFF7000,
.otp_size = 1024,
},
{
.id = DEVID_STM32C071XX,
.revs = stm32c071xx_revs,
.num_revs = ARRAY_SIZE(stm32c071xx_revs),
.device_str = "STM32C071xx",
.max_flash_size_kb = 128,
.flags = F_NONE,
.flash_regs_base = 0x40022000,
.fsize_addr = 0x1FFF75A0,
.otp_base = 0x1FFF7000,
.otp_size = 1024,
},
{
.id = DEVID_STM32U53_U54XX,
.revs = stm32u53_u54xx_revs,
Expand Down Expand Up @@ -600,6 +626,30 @@ static const struct stm32l4_part_info stm32l4_parts[] = {
.otp_base = 0x1FFF7000,
.otp_size = 1024,
},
{
.id = DEVID_STM32U031XX,
.revs = stm32u0xx_revs,
.num_revs = ARRAY_SIZE(stm32u0xx_revs),
.device_str = "STM32U031xx",
.max_flash_size_kb = 64,
.flags = F_NONE,
.flash_regs_base = 0x40022000,
.fsize_addr = 0x1FFF3EA0,
.otp_base = 0x1FFF6800,
.otp_size = 1024,
},
{
.id = DEVID_STM32U073_U083XX,
.revs = stm32u0xx_revs,
.num_revs = ARRAY_SIZE(stm32u0xx_revs),
.device_str = "STM32U073/U083xx",
.max_flash_size_kb = 256,
.flags = F_NONE,
.flash_regs_base = 0x40022000,
.fsize_addr = 0x1FFF6EA0,
.otp_base = 0x1FFF6800,
.otp_size = 1024,
},
{
.id = DEVID_STM32U59_U5AXX,
.revs = stm32u59_u5axx_revs,
Expand Down Expand Up @@ -1955,8 +2005,11 @@ static int stm32l4_probe(struct flash_bank *bank)
case DEVID_STM32L43_L44XX:
case DEVID_STM32C01XX:
case DEVID_STM32C03XX:
case DEVID_STM32C071XX:
case DEVID_STM32G05_G06XX:
case DEVID_STM32G07_G08XX:
case DEVID_STM32U031XX:
case DEVID_STM32U073_U083XX:
case DEVID_STM32L45_L46XX:
case DEVID_STM32L41_L42XX:
case DEVID_STM32G03_G04XX:
Expand Down
3 changes: 3 additions & 0 deletions src/flash/nor/stm32l4x.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#define DEVID_STM32C03XX 0x453
#define DEVID_STM32U53_U54XX 0x455
#define DEVID_STM32G05_G06XX 0x456
#define DEVID_STM32U031XX 0x459
#define DEVID_STM32G07_G08XX 0x460
#define DEVID_STM32L49_L4AXX 0x461
#define DEVID_STM32L45_L46XX 0x462
Expand All @@ -105,7 +106,9 @@
#define DEVID_STM32G49_G4AXX 0x479
#define DEVID_STM32U59_U5AXX 0x481
#define DEVID_STM32U57_U58XX 0x482
#define DEVID_STM32U073_U083XX 0x489
#define DEVID_STM32WBA5X 0x492
#define DEVID_STM32C071XX 0x493
#define DEVID_STM32WB1XX 0x494
#define DEVID_STM32WB5XX 0x495
#define DEVID_STM32WB3XX 0x496
Expand Down
2 changes: 1 addition & 1 deletion src/helper/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct list_head {

#define LIST_HEAD_INIT(name) { &(name), &(name) }

#define LIST_HEAD(name) \
#define OOCD_LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)

static inline void
Expand Down
3 changes: 3 additions & 0 deletions src/helper/log.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ extern int debug_level;
#define LOG_TARGET_INFO(target, fmt_str, ...) \
LOG_INFO("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)

#define LOG_TARGET_USER(target, fmt_str, ...) \
LOG_USER("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)

#define LOG_TARGET_WARNING(target, fmt_str, ...) \
LOG_WARNING("[%s] " fmt_str, target_name(target), ##__VA_ARGS__)

Expand Down
15 changes: 9 additions & 6 deletions src/jtag/drivers/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ noinst_LTLIBRARIES += %D%/libocdjtagdrivers.la
%C%_libocdjtagdrivers_la_CPPFLAGS = $(AM_CPPFLAGS)

ULINK_FIRMWARE = %D%/OpenULINK
ANGIE_FILES = %D%/angie

EXTRA_DIST += $(ULINK_FIRMWARE) \
$(ANGIE_FILES) \
%D%/usb_blaster/README.CheapClone \
%D%/Makefile.rlink \
%D%/rlink_call.m4 \
Expand Down Expand Up @@ -125,12 +123,17 @@ ulinkdir = $(pkgdatadir)/OpenULINK
dist_ulink_DATA = $(ULINK_FIRMWARE)/ulink_firmware.hex
%C%_libocdjtagdrivers_la_LIBADD += -lm
endif

if ANGIE
DRIVERFILES += %D%/angie.c
angiedir = $(pkgdatadir)/angie
dist_angie_DATA = $(ANGIE_FILES)/angie_firmware.bin $(ANGIE_FILES)/angie_bitstream.bit
%C%_libocdjtagdrivers_la_LIBADD += -lm
angiedir = $(pkgdatadir)/angie # This is only for dist_angie_DATA.
DRIVERFILES += %D%/angie.c
DRIVERFILES += %D%/angie/include/msgtypes.h
EXTRA_DIST += %D%/angie/README
dist_angie_DATA = %D%/angie/angie_firmware.bin
dist_angie_DATA += %D%/angie/angie_bitstream.bit
%C%_libocdjtagdrivers_la_LIBADD += -lm
endif

if VSLLINK
DRIVERFILES += %D%/versaloon/usbtoxxx/usbtogpio.c
DRIVERFILES += %D%/versaloon/usbtoxxx/usbtojtagraw.c
Expand Down
2 changes: 1 addition & 1 deletion src/jtag/drivers/am335xgpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ static int am335xgpio_blink(bool on)
return ERROR_OK;
}

static struct bitbang_interface am335xgpio_bitbang = {
static const struct bitbang_interface am335xgpio_bitbang = {
.read = am335xgpio_read,
.write = am335xgpio_write,
.swdio_read = am335xgpio_swdio_read,
Expand Down
2 changes: 1 addition & 1 deletion src/jtag/drivers/at91rm9200.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ static int at91rm9200_write(int tck, int tms, int tdi);
static int at91rm9200_init(void);
static int at91rm9200_quit(void);

static struct bitbang_interface at91rm9200_bitbang = {
static const struct bitbang_interface at91rm9200_bitbang = {
.read = at91rm9200_read,
.write = at91rm9200_write,
.blink = NULL,
Expand Down
2 changes: 1 addition & 1 deletion src/jtag/drivers/bitbang.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static int bitbang_stableclocks(unsigned int num_cycles);

static void bitbang_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk);

struct bitbang_interface *bitbang_interface;
const struct bitbang_interface *bitbang_interface;

/* DANGER!!!! clock absolutely *MUST* be 0 in idle or reset won't work!
*
Expand Down
2 changes: 1 addition & 1 deletion src/jtag/drivers/bitbang.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ extern const struct swd_driver bitbang_swd;

int bitbang_execute_queue(struct jtag_command *cmd_queue);

extern struct bitbang_interface *bitbang_interface;
extern const struct bitbang_interface *bitbang_interface;

#endif /* OPENOCD_JTAG_DRIVERS_BITBANG_H */
20 changes: 5 additions & 15 deletions src/jtag/drivers/cmsis_dap.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,6 @@ struct pending_scan_result {
unsigned int buffer_offset;
};

/* Read mode */
enum cmsis_dap_blocking {
CMSIS_DAP_NON_BLOCKING,
CMSIS_DAP_BLOCKING
};

/* Each block in FIFO can contain up to pending_queue_len transfers */
static unsigned int pending_queue_len;
static unsigned int tfer_max_command_size;
Expand Down Expand Up @@ -321,7 +315,7 @@ static void cmsis_dap_flush_read(struct cmsis_dap *dap)
* USB close/open so we need to flush up to 64 old packets
* to be sure all buffers are empty */
for (i = 0; i < 64; i++) {
int retval = dap->backend->read(dap, 10, NULL);
int retval = dap->backend->read(dap, 10, CMSIS_DAP_BLOCKING);
if (retval == ERROR_TIMEOUT_REACHED)
break;
}
Expand All @@ -338,7 +332,7 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen)
if (dap->pending_fifo_block_count) {
LOG_ERROR("pending %u blocks, flushing", dap->pending_fifo_block_count);
while (dap->pending_fifo_block_count) {
dap->backend->read(dap, 10, NULL);
dap->backend->read(dap, 10, CMSIS_DAP_BLOCKING);
dap->pending_fifo_block_count--;
}
dap->pending_fifo_put_idx = 0;
Expand All @@ -351,7 +345,7 @@ static int cmsis_dap_xfer(struct cmsis_dap *dap, int txlen)
return retval;

/* get reply */
retval = dap->backend->read(dap, LIBUSB_TIMEOUT_MS, NULL);
retval = dap->backend->read(dap, LIBUSB_TIMEOUT_MS, CMSIS_DAP_BLOCKING);
if (retval < 0)
return retval;

Expand Down Expand Up @@ -885,7 +879,7 @@ static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, enum cmsis_dap_blo

if (queued_retval != ERROR_OK) {
/* keep reading blocks until the pipeline is empty */
retval = dap->backend->read(dap, 10, NULL);
retval = dap->backend->read(dap, 10, CMSIS_DAP_BLOCKING);
if (retval == ERROR_TIMEOUT_REACHED || retval == 0) {
/* timeout means that we flushed the pipeline,
* we can safely discard remaining pending requests */
Expand All @@ -896,11 +890,7 @@ static void cmsis_dap_swd_read_process(struct cmsis_dap *dap, enum cmsis_dap_blo
}

/* get reply */
struct timeval tv = {
.tv_sec = 0,
.tv_usec = 0
};
retval = dap->backend->read(dap, LIBUSB_TIMEOUT_MS, blocking ? NULL : &tv);
retval = dap->backend->read(dap, LIBUSB_TIMEOUT_MS, blocking);
bool timeout = (retval == ERROR_TIMEOUT_REACHED || retval == 0);
if (timeout && blocking == CMSIS_DAP_NON_BLOCKING)
return;
Expand Down
Loading

0 comments on commit 182092a

Please sign in to comment.