mirror of
https://github.com/openocd-org/openocd.git
synced 2025-10-14 02:58:23 +08:00
Compare commits
18 Commits
4fe57a0c19
...
40e6c98dfc
Author | SHA1 | Date | |
---|---|---|---|
![]() |
40e6c98dfc | ||
![]() |
3fbca95ae1 | ||
![]() |
20d7e83576 | ||
![]() |
895dfb5d87 | ||
![]() |
84f6c561f3 | ||
![]() |
1ee7c09d95 | ||
![]() |
fbdb86adbd | ||
![]() |
83c1546e77 | ||
![]() |
152becc460 | ||
![]() |
b06212b5a2 | ||
![]() |
b1c1dd1ec4 | ||
![]() |
25b99ae456 | ||
![]() |
c545b9c4ab | ||
![]() |
330b06b440 | ||
![]() |
6975baa88b | ||
![]() |
7f57e72afe | ||
![]() |
98ed83e278 | ||
![]() |
92287c1a2a |
@@ -5439,7 +5439,8 @@ Displays the current target state:
|
||||
@code{debug-running},
|
||||
@code{halted},
|
||||
@code{reset},
|
||||
@code{running}, or @code{unknown}.
|
||||
@code{running},
|
||||
@code{unavailable} or @code{unknown}.
|
||||
(Also, @pxref{eventpolling,,Event Polling}.)
|
||||
@end deffn
|
||||
|
||||
|
@@ -71,17 +71,18 @@ char *find_file(const char *file)
|
||||
full_path = alloc_printf("%s", file);
|
||||
fp = fopen(full_path, mode);
|
||||
|
||||
while (!fp) {
|
||||
free(full_path);
|
||||
full_path = NULL;
|
||||
dir = *search_dirs++;
|
||||
if (script_search_dirs)
|
||||
while (!fp) {
|
||||
free(full_path);
|
||||
full_path = NULL;
|
||||
dir = *search_dirs++;
|
||||
|
||||
if (!dir)
|
||||
break;
|
||||
if (!dir)
|
||||
break;
|
||||
|
||||
full_path = alloc_printf("%s/%s", dir, file);
|
||||
fp = fopen(full_path, mode);
|
||||
}
|
||||
full_path = alloc_printf("%s/%s", dir, file);
|
||||
fp = fopen(full_path, mode);
|
||||
}
|
||||
|
||||
if (fp) {
|
||||
fclose(fp);
|
||||
|
@@ -7,7 +7,8 @@
|
||||
|
||||
# Try flipping / and \ to find file if the filename does not
|
||||
# match the precise spelling
|
||||
proc find {filename} {
|
||||
# lappend _telnet_autocomplete_skip _find_internal
|
||||
proc _find_internal {filename} {
|
||||
if {[catch {ocd_find $filename} t]==0} {
|
||||
return $t
|
||||
}
|
||||
@@ -20,6 +21,49 @@ proc find {filename} {
|
||||
# make sure error message matches original input string
|
||||
return -code error "Can't find $filename"
|
||||
}
|
||||
|
||||
proc find {filename} {
|
||||
if {[catch {_find_internal $filename} t]==0} {
|
||||
return $t
|
||||
}
|
||||
|
||||
# Check in vendor specific folder:
|
||||
|
||||
# - path/to/a/certain/vendor_config_file
|
||||
# - path/to/a/certain/vendor-config_file
|
||||
# replaced with
|
||||
# - path/to/a/certain/vendor/config_file
|
||||
regsub {([/\\])([^/\\_-]*)[_-]([^/\\]*$)} $filename "\\1\\2\\1\\3" f
|
||||
if {[catch {_find_internal $f} t]==0} {
|
||||
echo "WARNING: '$filename' is deprecated, use '$f' instead"
|
||||
return $t
|
||||
}
|
||||
|
||||
foreach vendor {nordic ti st} {
|
||||
# - path/to/a/certain/config_file
|
||||
# replaced with
|
||||
# - path/to/a/certain/${vendor}/config_file
|
||||
regsub {([/\\])([^/\\]*$)} $filename "\\1$vendor\\1\\2" f
|
||||
if {[catch {_find_internal $f} t]==0} {
|
||||
echo "WARNING: '$filename' is deprecated, use '$f' instead"
|
||||
return $t
|
||||
}
|
||||
}
|
||||
|
||||
# at last, check for explicit renaming
|
||||
if {[catch {
|
||||
source [_find_internal file_renaming.cfg]
|
||||
set unixname [string map {\\ /} $filename]
|
||||
regsub {^(.*/|)((board|chip|cpld|cpu|fpga|interface|target|test|tools)/.*.cfg$)} $unixname {{\1} {\2}} split
|
||||
set newname [lindex $split 0][dict get $_file_renaming [lindex $split 1]]
|
||||
_find_internal $newname
|
||||
} t]==0} {
|
||||
echo "WARNING: '$filename' is deprecated, use '$newname' instead"
|
||||
return $t
|
||||
}
|
||||
|
||||
return -code error "Can't find $filename"
|
||||
}
|
||||
add_usage_text find "<file>"
|
||||
add_help_text find "print full path to file according to OpenOCD search rules"
|
||||
|
||||
|
@@ -105,7 +105,8 @@ static int hwthread_update_threads(struct rtos *rtos)
|
||||
foreach_smp_target(head, target->smp_targets) {
|
||||
struct target *curr = head->target;
|
||||
|
||||
if (!target_was_examined(curr))
|
||||
if (!target_was_examined(curr) ||
|
||||
curr->state == TARGET_UNAVAILABLE)
|
||||
continue;
|
||||
|
||||
++thread_list_size;
|
||||
@@ -130,7 +131,8 @@ static int hwthread_update_threads(struct rtos *rtos)
|
||||
foreach_smp_target(head, target->smp_targets) {
|
||||
struct target *curr = head->target;
|
||||
|
||||
if (!target_was_examined(curr))
|
||||
if (!target_was_examined(curr) ||
|
||||
curr->state == TARGET_UNAVAILABLE)
|
||||
continue;
|
||||
|
||||
threadid_t tid = threadid_from_target(curr);
|
||||
@@ -204,8 +206,8 @@ static int hwthread_update_threads(struct rtos *rtos)
|
||||
else
|
||||
rtos->current_thread = threadid_from_target(target);
|
||||
|
||||
LOG_TARGET_DEBUG(target, "%s current_thread=%i", __func__,
|
||||
(int)rtos->current_thread);
|
||||
LOG_TARGET_DEBUG(target, "current_thread=%" PRId64 ", threads_found=%d",
|
||||
rtos->current_thread, threads_found);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@@ -151,6 +151,29 @@ static bool gdb_use_target_description = true;
|
||||
/* current processing free-run type, used by file-I/O */
|
||||
static char gdb_running_type;
|
||||
|
||||
/* Find an available target in the SMP group that gdb is connected to. For
|
||||
* commands that affect an entire SMP group (like memory access and run control)
|
||||
* this will give better results than returning the unavailable target and having
|
||||
* the command fail. If gdb was aware that targets can be unavailable we
|
||||
* wouldn't need this logic.
|
||||
*/
|
||||
struct target *get_available_target_from_connection(struct connection *connection)
|
||||
{
|
||||
struct gdb_service *gdb_service = connection->service->priv;
|
||||
struct target *target = gdb_service->target;
|
||||
if (target->state == TARGET_UNAVAILABLE && target->smp) {
|
||||
struct target_list *tlist;
|
||||
foreach_smp_target(tlist, target->smp_targets) {
|
||||
struct target *t = tlist->target;
|
||||
if (t->state != TARGET_UNAVAILABLE)
|
||||
return t;
|
||||
}
|
||||
/* If we can't find an available target, just return the
|
||||
* original. */
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
static int gdb_last_signal(struct target *target)
|
||||
{
|
||||
LOG_TARGET_DEBUG(target, "Debug reason is: %s",
|
||||
@@ -961,9 +984,9 @@ static int gdb_target_callback_event_handler(struct target *target,
|
||||
enum target_event event, void *priv)
|
||||
{
|
||||
struct connection *connection = priv;
|
||||
struct gdb_service *gdb_service = connection->service->priv;
|
||||
struct target *gdb_target = get_available_target_from_connection(connection);
|
||||
|
||||
if (gdb_service->target != target)
|
||||
if (gdb_target != target)
|
||||
return ERROR_OK;
|
||||
|
||||
switch (event) {
|
||||
@@ -1504,7 +1527,7 @@ static int gdb_error(struct connection *connection, int retval)
|
||||
static int gdb_read_memory_packet(struct connection *connection,
|
||||
char const *packet, int packet_size)
|
||||
{
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
char *separator;
|
||||
uint64_t addr = 0;
|
||||
uint32_t len = 0;
|
||||
@@ -1579,7 +1602,7 @@ static int gdb_read_memory_packet(struct connection *connection,
|
||||
static int gdb_write_memory_packet(struct connection *connection,
|
||||
char const *packet, int packet_size)
|
||||
{
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
char *separator;
|
||||
uint64_t addr = 0;
|
||||
uint32_t len = 0;
|
||||
@@ -1630,7 +1653,7 @@ static int gdb_write_memory_packet(struct connection *connection,
|
||||
static int gdb_write_memory_binary_packet(struct connection *connection,
|
||||
char const *packet, int packet_size)
|
||||
{
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
char *separator;
|
||||
uint64_t addr = 0;
|
||||
uint32_t len = 0;
|
||||
@@ -1709,7 +1732,7 @@ static int gdb_write_memory_binary_packet(struct connection *connection,
|
||||
static int gdb_step_continue_packet(struct connection *connection,
|
||||
char const *packet, int packet_size)
|
||||
{
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
bool current = false;
|
||||
uint64_t address = 0x0;
|
||||
int retval = ERROR_OK;
|
||||
@@ -1737,7 +1760,7 @@ static int gdb_step_continue_packet(struct connection *connection,
|
||||
static int gdb_breakpoint_watchpoint_packet(struct connection *connection,
|
||||
char const *packet, int packet_size)
|
||||
{
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
int type;
|
||||
enum breakpoint_type bp_type = BKPT_SOFT /* dummy init to avoid warning */;
|
||||
enum watchpoint_rw wp_type = WPT_READ /* dummy init to avoid warning */;
|
||||
@@ -1910,7 +1933,7 @@ static int gdb_memory_map(struct connection *connection,
|
||||
* have to regenerate it a couple of times.
|
||||
*/
|
||||
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
struct flash_bank *p;
|
||||
char *xml = NULL;
|
||||
int size = 0;
|
||||
@@ -2986,7 +3009,7 @@ static bool gdb_handle_vcont_packet(struct connection *connection, const char *p
|
||||
__attribute__((unused)) int packet_size)
|
||||
{
|
||||
struct gdb_connection *gdb_connection = connection->priv;
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
const char *parse = packet;
|
||||
int retval;
|
||||
|
||||
@@ -3208,7 +3231,7 @@ static void gdb_restart_inferior(struct connection *connection, const char *pack
|
||||
|
||||
static bool gdb_handle_vrun_packet(struct connection *connection, const char *packet, int packet_size)
|
||||
{
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
const char *parse = packet;
|
||||
|
||||
/* Skip "vRun" */
|
||||
@@ -3254,7 +3277,7 @@ static int gdb_v_packet(struct connection *connection,
|
||||
struct gdb_connection *gdb_connection = connection->priv;
|
||||
int result;
|
||||
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
|
||||
if (strncmp(packet, "vCont", 5) == 0) {
|
||||
bool handled;
|
||||
@@ -3433,7 +3456,7 @@ static int gdb_detach(struct connection *connection)
|
||||
static int gdb_fileio_response_packet(struct connection *connection,
|
||||
char const *packet, int packet_size)
|
||||
{
|
||||
struct target *target = get_target_from_connection(connection);
|
||||
struct target *target = get_available_target_from_connection(connection);
|
||||
char *separator;
|
||||
char *parsing_point;
|
||||
int fileio_retcode = strtoul(packet + 1, &separator, 16);
|
||||
@@ -3726,10 +3749,11 @@ static int gdb_input_inner(struct connection *connection)
|
||||
}
|
||||
|
||||
if (gdb_con->ctrl_c) {
|
||||
if (target->state == TARGET_RUNNING) {
|
||||
struct target *t = target;
|
||||
if (target->rtos)
|
||||
target->rtos->gdb_target_for_threadid(connection, target->rtos->current_threadid, &t);
|
||||
struct target *available_target = get_available_target_from_connection(connection);
|
||||
if (available_target->state == TARGET_RUNNING) {
|
||||
struct target *t = available_target;
|
||||
if (available_target->rtos)
|
||||
available_target->rtos->gdb_target_for_threadid(connection, target->rtos->current_threadid, &t);
|
||||
retval = target_halt(t);
|
||||
if (retval == ERROR_OK)
|
||||
retval = target_poll(t);
|
||||
|
@@ -1380,6 +1380,19 @@ static int cortex_a_set_breakpoint(struct target *target,
|
||||
buf_set_u32(code, 0, 32, ARMV5_BKPT(0x11));
|
||||
}
|
||||
|
||||
/*
|
||||
* ARMv7-A/R fetches instructions in little-endian on both LE and BE CPUs.
|
||||
* But Cortex-R4 and Cortex-R5 big-endian require BE instructions.
|
||||
* https://developer.arm.com/documentation/den0042/a/Coding-for-Cortex-R-Processors/Endianness
|
||||
* https://developer.arm.com/documentation/den0013/d/Porting/Endianness
|
||||
*/
|
||||
if ((((cortex_a->cpuid & CPUDBG_CPUID_MASK) == CPUDBG_CPUID_CORTEX_R4) ||
|
||||
((cortex_a->cpuid & CPUDBG_CPUID_MASK) == CPUDBG_CPUID_CORTEX_R5)) &&
|
||||
target->endianness == TARGET_BIG_ENDIAN) {
|
||||
// In place swapping is allowed
|
||||
buf_bswap32(code, code, 4);
|
||||
}
|
||||
|
||||
retval = target_read_memory(target,
|
||||
breakpoint->address & 0xFFFFFFFE,
|
||||
breakpoint->length, 1,
|
||||
|
@@ -30,6 +30,9 @@
|
||||
#define CORTEX_A_MIDR_PARTNUM_SHIFT 4
|
||||
|
||||
#define CPUDBG_CPUID 0xD00
|
||||
#define CPUDBG_CPUID_MASK 0xff00fff0
|
||||
#define CPUDBG_CPUID_CORTEX_R4 0x4100c140
|
||||
#define CPUDBG_CPUID_CORTEX_R5 0x4100c150
|
||||
#define CPUDBG_CTYPR 0xD04
|
||||
#define CPUDBG_TTYPR 0xD0C
|
||||
#define CPUDBG_LOCKACCESS 0xFB0
|
||||
|
@@ -220,6 +220,7 @@ static const struct nvp nvp_target_state[] = {
|
||||
{ .name = "halted", .value = TARGET_HALTED },
|
||||
{ .name = "reset", .value = TARGET_RESET },
|
||||
{ .name = "debug-running", .value = TARGET_DEBUG_RUNNING },
|
||||
{ .name = "unavailable", .value = TARGET_UNAVAILABLE },
|
||||
{ .name = NULL, .value = -1 },
|
||||
};
|
||||
|
||||
|
@@ -46,6 +46,8 @@ struct gdb_fileio_info;
|
||||
* not sure how this is used with all the recent changes)
|
||||
* TARGET_DEBUG_RUNNING = 4: the target is running, but it is executing code on
|
||||
* behalf of the debugger (e.g. algorithm for flashing)
|
||||
* TARGET_UNAVAILABLE = 5: The target is unavailable for some reason. It might
|
||||
* be powered down, for instance.
|
||||
*
|
||||
* also see: target_state_name();
|
||||
*/
|
||||
@@ -56,6 +58,7 @@ enum target_state {
|
||||
TARGET_HALTED = 2,
|
||||
TARGET_RESET = 3,
|
||||
TARGET_DEBUG_RUNNING = 4,
|
||||
TARGET_UNAVAILABLE = 5
|
||||
};
|
||||
|
||||
enum target_reset_mode {
|
||||
|
@@ -8,4 +8,4 @@ source [find interface/jlink.cfg]
|
||||
|
||||
transport select swd
|
||||
|
||||
source [find target/nrf51.cfg]
|
||||
source [find target/nordic/nrf51.cfg]
|
@@ -5,4 +5,4 @@
|
||||
#
|
||||
|
||||
source [find interface/cmsis-dap.cfg]
|
||||
source [find target/nrf51.cfg]
|
||||
source [find target/nordic/nrf51.cfg]
|
@@ -8,4 +8,4 @@ source [find interface/jlink.cfg]
|
||||
|
||||
transport select swd
|
||||
|
||||
source [find target/nrf52.cfg]
|
||||
source [find target/nordic/nrf52.cfg]
|
12
tcl/board/nordic/nrf5340-dk.cfg
Normal file
12
tcl/board/nordic/nrf5340-dk.cfg
Normal file
@@ -0,0 +1,12 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#
|
||||
# Nordic Semiconductor nRF5340 Development Kit
|
||||
# https://www.nordicsemi.com/Products/Development-hardware/nRF5340-DK
|
||||
#
|
||||
|
||||
source [find interface/jlink.cfg]
|
||||
|
||||
transport select swd
|
||||
|
||||
source [find target/nordic/nrf53.cfg]
|
12
tcl/board/nordic/nrf9160-dk.cfg
Normal file
12
tcl/board/nordic/nrf9160-dk.cfg
Normal file
@@ -0,0 +1,12 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#
|
||||
# Nordic Semiconductor nRF9160 Development Kit
|
||||
# https://www.nordicsemi.com/Products/Development-hardware/nRF9160-DK
|
||||
#
|
||||
|
||||
source [find interface/jlink.cfg]
|
||||
|
||||
transport select swd
|
||||
|
||||
source [find target/nordic/nrf91.cfg]
|
@@ -5,9 +5,11 @@
|
||||
# or any FT232H/FT2232H/FT4232H based board/module
|
||||
#
|
||||
|
||||
echo "WARNING: 'board/nordic_nrf52_ftx232.cfg' is deprecated, use '-f interface/ftdi/ft232h-module-swd.cfg -f target/nordic/nrf52.cfg' instead"
|
||||
|
||||
source [find interface/ftdi/ft232h-module-swd.cfg]
|
||||
#source [find interface/ftdi/minimodule-swd.cfg]
|
||||
|
||||
transport select swd
|
||||
|
||||
source [find target/nrf52.cfg]
|
||||
source [find target/nordic/nrf52.cfg]
|
||||
|
24
tcl/file_renaming.cfg
Normal file
24
tcl/file_renaming.cfg
Normal file
@@ -0,0 +1,24 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# This file is used to remap configuration files that has been
|
||||
# renamed, except simple renames that are taken care automatically
|
||||
# like:
|
||||
# .../file.cfg ==> .../${vendor}/file.cfg
|
||||
# .../vendor-file.cfg ==> .../vendor/file.cfg
|
||||
# .../vendor_file.cfg ==> .../vendor/file.cfg
|
||||
#
|
||||
# The formatting below is a TCL dict, so pairs of key-value
|
||||
# in a simple TCL list, using for each line
|
||||
# old_name new_name
|
||||
# including in each name one of the prefix folder between
|
||||
# board, chip, cpld, cpu, fpga, interface, target, test, tools
|
||||
|
||||
set _file_renaming {
|
||||
board/nordic_nrf51822_mkit.cfg board/nordic/nrf51822-mkit.cfg
|
||||
board/nordic_nrf51_dk.cfg board/nordic/nrf51-dk.cfg
|
||||
board/nordic_nrf52_dk.cfg board/nordic/nrf52-dk.cfg
|
||||
target/nrf51.cfg target/nordic/nrf51.cfg
|
||||
target/nrf52.cfg target/nordic/nrf52.cfg
|
||||
target/nrf53.cfg target/nordic/nrf53.cfg
|
||||
target/nrf91.cfg target/nordic/nrf91.cfg
|
||||
}
|
@@ -60,7 +60,7 @@ if { ![using_hla] } {
|
||||
# Keep adapter speed less or equal 2000 kHz or flash programming fails!
|
||||
adapter speed 1000
|
||||
|
||||
source [find target/nrf_common.cfg]
|
||||
source [find target/nordic/common.cfg]
|
||||
|
||||
flash bank $_CHIPNAME.app.flash nrf5 0x00000000 0 0 0 $_TARGETNAME_APP
|
||||
flash bank $_CHIPNAME.app.uicr nrf5 0x00FF8000 0 0 0 $_TARGETNAME_APP
|
@@ -45,7 +45,7 @@ adapter speed 1000
|
||||
|
||||
$_TARGETNAME configure -work-area-phys 0x20000000 -work-area-size $_WORKAREASIZE -work-area-backup 0
|
||||
|
||||
source [find target/nrf_common.cfg]
|
||||
source [find target/nordic/common.cfg]
|
||||
|
||||
flash bank $_CHIPNAME.flash nrf5 0x00000000 0 0 0 $_TARGETNAME
|
||||
flash bank $_CHIPNAME.uicr nrf5 0x00FF8000 0 0 0 $_TARGETNAME
|
8
tcl/target/ti_tms570ls1x.cfg
Normal file
8
tcl/target/ti_tms570ls1x.cfg
Normal file
@@ -0,0 +1,8 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
# TMS570LS1114, TMS570LS1115
|
||||
# TMS570LS1224, TMS570LS1225, TMS570LS1227
|
||||
set DAP_TAPID 0x0B95502F
|
||||
set JRC_TAPID 0x0B95502F
|
||||
|
||||
source [find target/ti_tms570.cfg]
|
Reference in New Issue
Block a user