Skip to content

Commit

Permalink
Merge pull request #935 from riscv/from_upstream
Browse files Browse the repository at this point in the history
Merge down up to 0384fe5 from upstream.
  • Loading branch information
timsifive authored Oct 23, 2023
2 parents aad90d8 + d6060b5 commit 3b0561d
Show file tree
Hide file tree
Showing 33 changed files with 857 additions and 1,066 deletions.
37 changes: 31 additions & 6 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Copyright (C) 2020 by Tarek BOUCHKATI <[email protected]>

on: pull_request
on: push

name: OpenOCD Snapshot

Expand Down Expand Up @@ -30,7 +30,7 @@ jobs:
echo "LIBUSB1_SRC=$PWD/libusb-${LIBUSB1_VER}" >> $GITHUB_ENV
- name: Prepare hidapi
env:
HIDAPI_VER: 0.11.2
HIDAPI_VER: 0.13.1
run: |
mkdir -p $DL_DIR && cd $DL_DIR
wget "https://github.com/libusb/hidapi/archive/hidapi-${HIDAPI_VER}.tar.gz"
Expand All @@ -56,6 +56,16 @@ jobs:
wget "https://github.com/aquynh/capstone/archive/${CAPSTONE_VER}.tar.gz"
tar -xzf ${CAPSTONE_VER}.tar.gz
echo "CAPSTONE_SRC=$PWD/capstone-${CAPSTONE_VER}" >> $GITHUB_ENV
- name: Prepare libjaylink
env:
LIBJAYLINK_VER: 0.3.1
run: |
mkdir -p $DL_DIR && cd $DL_DIR
wget https://gitlab.zapb.de/libjaylink/libjaylink/-/archive/${LIBJAYLINK_VER}/libjaylink-${LIBJAYLINK_VER}.tar.gz
tar -xzf libjaylink-${LIBJAYLINK_VER}.tar.gz
cd libjaylink-${LIBJAYLINK_VER}
./autogen.sh
echo "LIBJAYLINK_SRC=$PWD" >> $GITHUB_ENV
- name: Package OpenOCD for windows
env:
MAKE_JOBS: 2
Expand All @@ -64,7 +74,7 @@ jobs:
HIDAPI_CONFIG: --enable-shared --disable-static --disable-testgui
LIBFTDI_CONFIG: -DSTATICLIBS=OFF -DEXAMPLES=OFF -DFTDI_EEPROM=OFF
CAPSTONE_CONFIG: "CAPSTONE_BUILD_CORE_ONLY=yes CAPSTONE_STATIC=yes CAPSTONE_SHARED=no"
CAPSTONE_CFLAGS: -I$(CAPSTONE_SRC)/include/capstone
LIBJAYLINK_CONFIG: --enable-shared --disable-static
run: |
# check if there is tag pointing at HEAD, otherwise take the HEAD SHA-1 as OPENOCD_TAG
OPENOCD_TAG="`git tag --points-at HEAD`"
Expand All @@ -83,16 +93,31 @@ jobs:
# add missing dlls
cd $HOST-root/usr
cp `$HOST-gcc --print-file-name=libwinpthread-1.dll` ./bin/
# required by libftdi1.dll. For the gcc-mingw-10.3.x or later "libgcc_s_dw2-1.dll" will need to be copied.
cp `$HOST-gcc --print-file-name=libgcc_s_sjlj-1.dll` ./bin/
# prepare the artifact
ARTIFACT="openocd-${OPENOCD_TAG}-${HOST}.tar.gz"
tar -czf $ARTIFACT *
echo "RELEASE_NAME=$RELEASE_NAME" >> $GITHUB_ENV
echo "IS_PRE_RELEASE=$IS_PRE_RELEASE" >> $GITHUB_ENV
echo "ARTIFACT_PATH=$PWD/$ARTIFACT" >> $GITHUB_ENV
echo "ARTIFACT_NAME=openocd-windows-${OPENOCD_TAG}" >> $GITHUB_ENV
- name: Publish OpenOCD packaged for windows
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_PATH }}
- name: Delete 'latest' Release
uses: dev-drprasad/[email protected]
with:
delete_release: true
tag_name: ${{ env.RELEASE_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.RELEASE_NAME }}
commit: ${{ github.sha }}
draft: false
artifacts: ${{ env.ARTIFACT_PATH }}
prerelease: ${{ env.IS_PRE_RELEASE }}
token: ${{ secrets.GITHUB_TOKEN }}
13 changes: 13 additions & 0 deletions contrib/cross-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,22 @@ WORK_DIR=$PWD
: ${HIDAPI_SRC:=/path/to/hidapi}
: ${LIBFTDI_SRC:=/path/to/libftdi}
: ${CAPSTONE_SRC:=/path/to/capstone}
: ${LIBJAYLINK_SRC:=/path/to/libjaylink}

OPENOCD_SRC=`readlink -m $OPENOCD_SRC`
LIBUSB1_SRC=`readlink -m $LIBUSB1_SRC`
HIDAPI_SRC=`readlink -m $HIDAPI_SRC`
LIBFTDI_SRC=`readlink -m $LIBFTDI_SRC`
CAPSTONE_SRC=`readlink -m $CAPSTONE_SRC`
LIBJAYLINK_SRC=`readlink -m $LIBJAYLINK_SRC`

HOST_TRIPLET=$1
BUILD_DIR=$WORK_DIR/$HOST_TRIPLET-build
LIBUSB1_BUILD_DIR=$BUILD_DIR/libusb1
HIDAPI_BUILD_DIR=$BUILD_DIR/hidapi
LIBFTDI_BUILD_DIR=$BUILD_DIR/libftdi
CAPSTONE_BUILD_DIR=$BUILD_DIR/capstone
LIBJAYLINK_BUILD_DIR=$BUILD_DIR/libjaylink
OPENOCD_BUILD_DIR=$BUILD_DIR/openocd

## Root of host file tree
Expand Down Expand Up @@ -158,6 +161,16 @@ libdir=${exec_prefix}/lib \
includedir=${prefix}/include/capstone\n\n;' $CAPSTONE_PC_FILE
fi

# libjaylink build & install into sysroot
if [ -d $LIBJAYLINK_SRC ] ; then
mkdir -p $LIBJAYLINK_BUILD_DIR
cd $LIBJAYLINK_BUILD_DIR
$LIBJAYLINK_SRC/configure --build=`$LIBJAYLINK_SRC/config.guess` --host=$HOST_TRIPLET \
--with-sysroot=$SYSROOT --prefix=$PREFIX \
$LIBJAYLINK_CONFIG
make -j $MAKE_JOBS
make install DESTDIR=$SYSROOT
fi

# OpenOCD build & install into sysroot
mkdir -p $OPENOCD_BUILD_DIR
Expand Down
19 changes: 10 additions & 9 deletions doc/openocd.texi
Original file line number Diff line number Diff line change
Expand Up @@ -8811,7 +8811,6 @@ power consumption (because the CPU is needlessly clocked).
@deffn {Command} {resume} [address]
Resume the target at its current code position,
or the optional @var{address} if it is provided.
OpenOCD will wait 5 seconds for the target to resume.
@end deffn

@deffn {Command} {step} [address]
Expand Down Expand Up @@ -9132,8 +9131,10 @@ format. Optional @option{start} and @option{end} parameters allow to
limit the address range.
@end deffn

@deffn {Command} {version}
Displays a string identifying the version of this OpenOCD server.
@deffn {Command} {version} [git]
Returns a string identifying the version of this OpenOCD server.
With option @option{git}, it returns the git version obtained at compile time
through ``git describe''.
@end deffn

@deffn {Command} {virt2phys} virtual_address
Expand Down Expand Up @@ -11665,8 +11666,8 @@ way to represent JTAG test patterns in text files.
In a debug session using JTAG for its transport protocol,
OpenOCD supports running such test files.

@deffn {Command} {svf} @file{filename} [@option{-tap @var{tapname}}] [@option{[-]quiet}] @
[@option{[-]nil}] [@option{[-]progress}] [@option{[-]ignore_error}] @
@deffn {Command} {svf} @file{filename} [@option{-tap @var{tapname}}] [@option{-quiet}] @
[@option{-nil}] [@option{-progress}] [@option{-ignore_error}] @
[@option{-noreset}] [@option{-addcycles @var{cyclecount}}]
This issues a JTAG reset (Test-Logic-Reset) and then
runs the SVF script from @file{filename}.
Expand All @@ -11680,11 +11681,11 @@ Command options:
specified by the SVF file with HIR, TIR, HDR and TDR commands;
instead, calculate them automatically according to the current JTAG
chain configuration, targeting @var{tapname};
@item @option{[-]quiet} do not log every command before execution;
@item @option{[-]nil} ``dry run'', i.e., do not perform any operations
@item @option{-quiet} do not log every command before execution;
@item @option{-nil} ``dry run'', i.e., do not perform any operations
on the real interface;
@item @option{[-]progress} enable progress indication;
@item @option{[-]ignore_error} continue execution despite TDO check
@item @option{-progress} enable progress indication;
@item @option{-ignore_error} continue execution despite TDO check
errors.
@item @option{-noreset} omit JTAG reset (Test-Logic-Reset) before executing
content of the SVF file;
Expand Down
49 changes: 19 additions & 30 deletions src/flash/nor/tcl.c
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,7 @@ COMMAND_HANDLER(handle_flash_write_bank_command)
if (buf_cnt != length) {
LOG_ERROR("Short read");
free(buffer);
fileio_close(fileio);
return ERROR_FAIL;
}

Expand Down Expand Up @@ -1325,40 +1326,27 @@ COMMAND_HANDLER(handle_flash_banks_command)
return ERROR_OK;
}

static int jim_flash_list(Jim_Interp *interp, int argc, Jim_Obj * const *argv)
COMMAND_HANDLER(handle_flash_list)
{
if (argc != 1) {
Jim_WrongNumArgs(interp, 1, argv,
"no arguments to 'flash list' command");
return JIM_ERR;
}

Jim_Obj *list = Jim_NewListObj(interp, NULL, 0);
if (CMD_ARGC != 0)
return ERROR_COMMAND_SYNTAX_ERROR;

for (struct flash_bank *p = flash_bank_list(); p; p = p->next) {
Jim_Obj *elem = Jim_NewListObj(interp, NULL, 0);

Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "name", -1));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, p->name, -1));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "driver", -1));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, p->driver->name, -1));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "base", -1));
Jim_ListAppendElement(interp, elem, Jim_NewIntObj(interp, p->base));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "size", -1));
Jim_ListAppendElement(interp, elem, Jim_NewIntObj(interp, p->size));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "bus_width", -1));
Jim_ListAppendElement(interp, elem, Jim_NewIntObj(interp, p->bus_width));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "chip_width", -1));
Jim_ListAppendElement(interp, elem, Jim_NewIntObj(interp, p->chip_width));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "target", -1));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, target_name(p->target), -1));

Jim_ListAppendElement(interp, list, elem);
command_print(CMD,
"{\n"
" name %s\n"
" driver %s\n"
" base " TARGET_ADDR_FMT "\n"
" size 0x%" PRIx32 "\n"
" bus_width %u\n"
" chip_width %u\n"
" target %s\n"
"}",
p->name, p->driver->name, p->base, p->size, p->bus_width, p->chip_width,
target_name(p->target));
}

Jim_SetResult(interp, list);

return JIM_OK;
return ERROR_OK;
}

COMMAND_HANDLER(handle_flash_init_command)
Expand Down Expand Up @@ -1405,8 +1393,9 @@ static const struct command_registration flash_config_command_handlers[] = {
{
.name = "list",
.mode = COMMAND_ANY,
.jim_handler = jim_flash_list,
.handler = handle_flash_list,
.help = "Returns a list of details about the flash banks.",
.usage = "",
},
COMMAND_REGISTRATION_DONE
};
Expand Down
20 changes: 10 additions & 10 deletions src/helper/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,19 +662,19 @@ void command_done(struct command_context *cmd_ctx)
}

/* find full path to file */
static int jim_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
COMMAND_HANDLER(handle_find)
{
if (argc != 2)
return JIM_ERR;
const char *file = Jim_GetString(argv[1], NULL);
char *full_path = find_file(file);
if (CMD_ARGC != 1)
return ERROR_COMMAND_SYNTAX_ERROR;

char *full_path = find_file(CMD_ARGV[0]);
if (!full_path)
return JIM_ERR;
Jim_Obj *result = Jim_NewStringObj(interp, full_path, strlen(full_path));
return ERROR_COMMAND_ARGUMENT_INVALID;

command_print(CMD, "%s", full_path);
free(full_path);

Jim_SetResult(interp, result);
return JIM_OK;
return ERROR_OK;
}

COMMAND_HANDLER(handle_echo)
Expand Down Expand Up @@ -1165,7 +1165,7 @@ static const struct command_registration command_builtin_handlers[] = {
{
.name = "ocd_find",
.mode = COMMAND_ANY,
.jim_handler = jim_find,
.handler = handle_find,
.help = "find full path to file",
.usage = "file",
},
Expand Down
6 changes: 4 additions & 2 deletions src/helper/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
* clang for Apple defines
* #define __nonnull _Nonnull
* that is a per argument attribute, incompatible with the gcc per function attribute __nonnull__.
* Undefine it to keep compatibility among compilers.
* gcc for Apple includes sys/cdefs.h from MacOSX.sdk that defines
* #define __nonnull
* In both cases, undefine __nonnull to keep compatibility among compilers and platforms.
*/
#if defined(__clang__) && defined(__APPLE__)
#if defined(__APPLE__)
# undef __nonnull
#endif
#ifndef __nonnull
Expand Down
Loading

0 comments on commit 3b0561d

Please sign in to comment.