Allow transports to override the selected target (hla configs unification)

This should allow to share common configs for both regular access and
high-level adapters.

Use the newly-added functionality in stlink and icdi drivers, amend
the configs accordingly.

Runtime-tested with a TI tm4c123g board.

Change-Id: Ibb88266a4ca25f06f6c073e916c963f017447bad
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
[gus@projectgus.com: context-specific deprecation warnings]
Signed-off-by: Angus Gratton <gus@projectgus.com>
[andrew.smirnov@gmail.com: additional nrf51.cfg mods]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Tested-by: Andrey Skvortsov <andrej.skvortzov@gmail.com>
Reviewed-on: http://openocd.zylin.com/1664
Tested-by: jenkins
Reviewed-by: Andreas Fritiofson <andreas.fritiofson@gmail.com>
This commit is contained in:
Paul Fertser
2013-09-28 14:23:15 +04:00
committed by Andreas Fritiofson
parent f701c0cbeb
commit c7384117c6
67 changed files with 489 additions and 596 deletions

View File

@@ -1570,6 +1570,12 @@ static int stlink_usb_write_mem(void *handle, uint32_t addr, uint32_t size,
return retval;
}
/** */
static int stlink_usb_override_target(const char *targetname)
{
return !strcmp(targetname, "cortex_m");
}
/** */
static int stlink_usb_close(void *fd)
{
@@ -1798,5 +1804,7 @@ struct hl_layout_api_s stlink_usb_layout_api = {
/** */
.write_mem = stlink_usb_write_mem,
/** */
.write_debug_reg = stlink_usb_write_debug_reg
.write_debug_reg = stlink_usb_write_debug_reg,
/** */
.override_target = stlink_usb_override_target,
};

View File

@@ -645,6 +645,11 @@ static int icdi_usb_write_mem(void *handle, uint32_t addr, uint32_t size,
return retval;
}
static int icdi_usb_override_target(const char *targetname)
{
return !strcmp(targetname, "cortex_m");
}
static int icdi_usb_close(void *handle)
{
struct icdi_usb_handle_s *h = handle;
@@ -770,5 +775,6 @@ struct hl_layout_api_s icdi_usb_layout_api = {
.write_reg = icdi_usb_write_reg,
.read_mem = icdi_usb_read_mem,
.write_mem = icdi_usb_write_mem,
.write_debug_reg = icdi_usb_write_debug_reg
.write_debug_reg = icdi_usb_write_debug_reg,
.override_target = icdi_usb_override_target,
};

View File

@@ -145,6 +145,35 @@ int hl_interface_init_reset(void)
return ERROR_OK;
}
static int dummy_khz(int khz, int *jtag_speed)
{
*jtag_speed = khz;
return ERROR_OK;
}
static int dummy_speed_div(int speed, int *khz)
{
*khz = speed;
return ERROR_OK;
}
static int dummy_speed(int speed)
{
return ERROR_OK;
}
int hl_interface_override_target(const char **targetname)
{
if (hl_if.layout->api->override_target) {
if (hl_if.layout->api->override_target(*targetname)) {
*targetname = "hla_target";
return ERROR_OK;
} else
return ERROR_FAIL;
}
return ERROR_FAIL;
}
COMMAND_HANDLER(hl_interface_handle_device_desc_command)
{
LOG_DEBUG("hl_interface_handle_device_desc_command");
@@ -286,4 +315,7 @@ struct jtag_interface hl_interface = {
.init = hl_interface_init,
.quit = hl_interface_quit,
.execute_queue = hl_interface_execute_queue,
.speed = &dummy_speed,
.khz = &dummy_khz,
.speed_div = &dummy_speed_div,
};

View File

@@ -67,5 +67,6 @@ int hl_interface_open(enum hl_transports tr);
int hl_interface_init_target(struct target *t);
int hl_interface_init_reset(void);
int hl_interface_override_target(const char **targetname);
#endif /* _HL_INTERFACE */

View File

@@ -74,7 +74,9 @@ struct hl_layout_api_s {
*/
int (*idcode) (void *handle, uint32_t *idcode);
/** */
enum target_state (*state) (void *handle);
int (*override_target) (const char *targetname);
/** */
enum target_state (*state) (void *fd);
};
/** */

View File

@@ -59,7 +59,13 @@ static int jim_newtap_expected_id(Jim_Nvp *n, Jim_GetOptInfo *goi,
return JIM_OK;
}
#define NTAP_OPT_EXPECTED_ID 0
#define NTAP_OPT_IRLEN 0
#define NTAP_OPT_IRMASK 1
#define NTAP_OPT_IRCAPTURE 2
#define NTAP_OPT_ENABLED 3
#define NTAP_OPT_DISABLED 4
#define NTAP_OPT_EXPECTED_ID 5
#define NTAP_OPT_VERSION 6
static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi)
{
@@ -69,8 +75,14 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi)
Jim_Nvp *n;
char *cp;
const Jim_Nvp opts[] = {
{.name = "-expected-id", .value = NTAP_OPT_EXPECTED_ID},
{.name = NULL, .value = -1},
{ .name = "-irlen", .value = NTAP_OPT_IRLEN },
{ .name = "-irmask", .value = NTAP_OPT_IRMASK },
{ .name = "-ircapture", .value = NTAP_OPT_IRCAPTURE },
{ .name = "-enable", .value = NTAP_OPT_ENABLED },
{ .name = "-disable", .value = NTAP_OPT_DISABLED },
{ .name = "-expected-id", .value = NTAP_OPT_EXPECTED_ID },
{ .name = "-ignore-version", .value = NTAP_OPT_VERSION },
{ .name = NULL, .value = -1},
};
pTap = calloc(1, sizeof(struct jtag_tap));
@@ -121,6 +133,12 @@ static int jim_hl_newtap_cmd(Jim_GetOptInfo *goi)
return e;
}
break;
case NTAP_OPT_IRLEN:
case NTAP_OPT_IRMASK:
case NTAP_OPT_IRCAPTURE:
/* dummy read to ignore the next argument */
Jim_GetOpt_Wide(goi, NULL);
break;
} /* switch (n->value) */
} /* while (goi->argc) */

View File

@@ -134,6 +134,12 @@ static const struct command_registration stlink_transport_command_handlers[] = {
.usage = "",
.chain = hl_transport_jtag_subcommand_handlers,
},
{
.name = "jtag_ntrst_delay",
.mode = COMMAND_ANY,
.handler = hl_transport_jtag_command,
.usage = "",
},
COMMAND_REGISTRATION_DONE
};
@@ -204,12 +210,14 @@ static struct transport hl_swd_transport = {
.name = "hla_swd",
.select = hl_transport_select,
.init = hl_transport_init,
.override_target = hl_interface_override_target,
};
static struct transport hl_jtag_transport = {
.name = "hla_jtag",
.select = hl_transport_select,
.init = hl_transport_init,
.override_target = hl_interface_override_target,
};
static struct transport stlink_swim_transport = {

View File

@@ -55,6 +55,7 @@
#include "trace.h"
#include "image.h"
#include "rtos/rtos.h"
#include "transport/transport.h"
/* default halt wait timeout (ms) */
#define DEFAULT_HALT_TIMEOUT 5000
@@ -5066,6 +5067,15 @@ static int target_create(Jim_GetOptInfo *goi)
if (e != JIM_OK)
return e;
cp = cp2;
struct transport *tr = get_current_transport();
if (tr->override_target) {
e = tr->override_target(&cp);
if (e != ERROR_OK) {
LOG_ERROR("The selected transport doesn't support this target");
return JIM_ERR;
}
LOG_INFO("The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD");
}
/* now does target type exist */
for (x = 0 ; target_types[x] ; x++) {
if (0 == strcmp(cp, target_types[x]->name)) {

View File

@@ -65,6 +65,14 @@ struct transport {
*/
int (*init)(struct command_context *ctx);
/**
* Optional. If defined, allows transport to override target
* name prior to initialisation.
*
* @returns ERROR_OK on success, or an error code on failure.
*/
int (*override_target)(const char **targetname);
/**
* Transports are stored in a singly linked list.
*/

View File

@@ -10,6 +10,8 @@
#
source [find interface/ti-icdi.cfg]
transport select hla_jtag
set WORKAREASIZE 0x8000
set CHIPNAME lm4f120h5qr
source [find target/stellaris_icdi.cfg]
source [find target/stellaris.cfg]

View File

@@ -10,6 +10,8 @@
#
source [find interface/ti-icdi.cfg]
transport select hla_jtag
set WORKAREASIZE 0x8000
set CHIPNAME lm4f23x
source [find target/stellaris_icdi.cfg]
source [find target/stellaris.cfg]

View File

@@ -6,6 +6,8 @@
source [find interface/ti-icdi.cfg]
transport select hla_jtag
set WORKAREASIZE 0x8000
set CHIPNAME tm4c123gh6pm
source [find target/stellaris_icdi.cfg]
source [find target/stellaris.cfg]

View File

@@ -3,7 +3,9 @@
source [find interface/stlink-v2-1.cfg]
source [find target/stm32f0x_stlink.cfg]
transport select hla_swd
source [find target/stm32f0x.cfg]
# use hardware reset, connect under reset
reset_config srst_only srst_nogate

View File

@@ -3,7 +3,9 @@
source [find interface/stlink-v2-1.cfg]
source [find target/stm32f1x_stlink.cfg]
transport select hla_swd
source [find target/stm32f1x.cfg]
# use hardware reset, connect under reset
reset_config srst_only srst_nogate

View File

@@ -3,7 +3,9 @@
source [find interface/stlink-v2-1.cfg]
source [find target/stm32f3x_stlink.cfg]
transport select hla_swd
source [find target/stm32f3x.cfg]
# use hardware reset, connect under reset
reset_config srst_only srst_nogate

View File

@@ -3,7 +3,9 @@
source [find interface/stlink-v2-1.cfg]
source [find target/stm32f4x_stlink.cfg]
transport select hla_swd
source [find target/stm32f4x.cfg]
# use hardware reset, connect under reset
reset_config srst_only srst_nogate

View File

@@ -6,13 +6,15 @@
source [find interface/stlink-v2.cfg]
transport select hla_swd
# increase working area to 8KB
set WORKAREASIZE 0x2000
# chip name
set CHIPNAME STM32F051R8T6
source [find target/stm32f0x_stlink.cfg]
source [find target/stm32f0x.cfg]
# use hardware reset, connect under reset
reset_config srst_only srst_nogate

View File

@@ -6,13 +6,15 @@
source [find interface/stlink-v2.cfg]
transport select hla_swd
# increase working area to 128KB
set WORKAREASIZE 0x20000
# chip name
set CHIPNAME STM32F207IGH6
source [find target/stm32f2x_stlink.cfg]
source [find target/stm32f2x.cfg]
# use hardware reset, connect under reset
reset_config srst_only srst_nogate

View File

@@ -6,13 +6,15 @@
source [find interface/stlink-v2.cfg]
transport select hla_swd
# increase working area to 128KB
set WORKAREASIZE 0x20000
# chip name
set CHIPNAME STM32F417IGH6
source [find target/stm32f4x_stlink.cfg]
source [find target/stm32f4x.cfg]
# use hardware reset, connect under reset
reset_config srst_only srst_nogate

View File

@@ -6,13 +6,15 @@
source [find interface/stlink-v2.cfg]
transport select hla_swd
# increase working area to 128KB
set WORKAREASIZE 0x20000
# chip name
set CHIPNAME STM32F429NIH6
source [find target/stm32f4x_stlink.cfg]
source [find target/stm32f4x.cfg]
# use hardware reset, connect under reset
reset_config srst_only srst_nogate

Some files were not shown because too many files have changed in this diff Show More