aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/helper/binarybuffer.c2
-rw-r--r--src/helper/binarybuffer.h3
-rw-r--r--src/helper/interpreter.c2
-rw-r--r--src/helper/interpreter.h3
-rw-r--r--src/jtag/bitq.c2
-rw-r--r--src/jtag/jtag.c57
-rw-r--r--src/jtag/jtag.h15
-rw-r--r--src/pld/virtex2.c2
-rw-r--r--src/target/arm926ejs.c22
-rw-r--r--src/target/arm9tdmi.c9
-rw-r--r--src/target/arm_jtag.c49
-rw-r--r--src/target/arm_jtag.h26
-rw-r--r--src/target/trace.c2
13 files changed, 64 insertions, 130 deletions
diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c
index 7d97891..ddfcced 100644
--- a/src/helper/binarybuffer.c
+++ b/src/helper/binarybuffer.c
@@ -371,7 +371,7 @@ int str_to_buf(char* str, int str_len, u8 *buf, int buf_len, int radix)
return i;
}
-int buf_to_u32_handler(u8 *in_buf, void *priv)
+int buf_to_u32_handler(u8 *in_buf, void *priv, struct scan_field_s *field)
{
u32 *dest = priv;
diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h
index 6f39e7c..feb5724 100644
--- a/src/helper/binarybuffer.h
+++ b/src/helper/binarybuffer.h
@@ -41,7 +41,8 @@ extern u8* buf_set_buf(u8 *src, int src_start, u8 *dst, int dst_start, int len);
extern int str_to_buf(char* str, int len, u8 *bin_buf, int buf_size, int radix);
extern char* buf_to_str(u8 *buf, int size, int radix);
-extern int buf_to_u32_handler(u8 *in_buf, void *priv);
+struct scan_field_s;
+extern int buf_to_u32_handler(u8 *in_buf, void *priv, struct scan_field_s *field);
#define CEIL(m, n) ((m + n - 1) / n)
diff --git a/src/helper/interpreter.c b/src/helper/interpreter.c
index 85cd715..e5ce0f0 100644
--- a/src/helper/interpreter.c
+++ b/src/helper/interpreter.c
@@ -92,7 +92,7 @@ var_t* get_var_by_namenum(char *namenum)
}
-int field_le_to_host(u8 *buffer, void *priv)
+int field_le_to_host(u8 *buffer, void *priv, struct scan_field_s *dummy)
{
var_field_t *field = priv;
field->value = buf_get_u32(buffer, 0, field->num_bits);
diff --git a/src/helper/interpreter.h b/src/helper/interpreter.h
index 93e8d39..c4f8acf 100644
--- a/src/helper/interpreter.h
+++ b/src/helper/interpreter.h
@@ -40,7 +40,8 @@ typedef struct var_s
extern var_t *variables;
-extern int field_le_to_host(u8 *buffer, void *priv);
+struct scan_field_s;
+extern int field_le_to_host(u8 *buffer, void *priv, struct scan_field_s *field);
extern var_t* get_var_by_namenum(char *namenum);
extern int interpreter_register_commands(struct command_context_s *cmd_ctx);
diff --git a/src/jtag/bitq.c b/src/jtag/bitq.c
index a4ec626..dd9acdf 100644
--- a/src/jtag/bitq.c
+++ b/src/jtag/bitq.c
@@ -117,7 +117,7 @@ void bitq_in_proc(void)
if (field->in_handler && bitq_in_state.status==ERROR_OK) {
- bitq_in_state.status=(*field->in_handler)(in_buff, field->in_handler_priv);
+ bitq_in_state.status=(*field->in_handler)(in_buff, field->in_handler_priv, field);
}
}
diff --git a/src/jtag/jtag.c b/src/jtag/jtag.c
index 3ef5735..2d3d8c5 100644
--- a/src/jtag/jtag.c
+++ b/src/jtag/jtag.c
@@ -359,7 +359,8 @@ void* cmd_queue_alloc(size_t size)
offset = (*p_page)->used;
(*p_page)->used += size;
- return ((*p_page)->address) + offset;
+ u8 *t=(u8 *)((*p_page)->address);
+ return t + offset;
}
void cmd_queue_free()
@@ -424,11 +425,15 @@ int jtag_add_ir_scan(int num_fields, scan_field_t *fields, enum tap_state state,
(*last_cmd)->cmd.scan->fields[i].device = i;
(*last_cmd)->cmd.scan->fields[i].num_bits = scan_size;
(*last_cmd)->cmd.scan->fields[i].in_value = NULL;
- (*last_cmd)->cmd.scan->fields[i].in_handler = NULL;
- (*last_cmd)->cmd.scan->fields[i].in_handler_priv = NULL;
- if (jtag_verify_capture_ir)
+ if ((jtag_verify_capture_ir)&&(fields[i].in_handler==NULL))
{
jtag_set_check_value((*last_cmd)->cmd.scan->fields+i, device->expected, device->expected_mask, NULL);
+ } else if (jtag_verify_capture_ir)
+ {
+ (*last_cmd)->cmd.scan->fields[i].in_handler = fields[i].in_handler;
+ (*last_cmd)->cmd.scan->fields[i].in_handler_priv = fields[i].in_handler_priv;
+ (*last_cmd)->cmd.scan->fields[i].in_check_value = device->expected;
+ (*last_cmd)->cmd.scan->fields[i].in_check_mask = device->expected_mask;
}
/* search the list */
@@ -991,8 +996,6 @@ int jtag_build_buffer(scan_command_t *cmd, u8 **buffer)
}
-extern int jtag_check_value(u8 *captured, void *priv);
-
int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
{
int i;
@@ -1020,30 +1023,13 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
free(char_buf);
#endif
- void *priv = cmd->fields[i].in_handler_priv;
- if (cmd->fields[i].in_handler == &jtag_check_value)
- {
- /* Yuk! we want to pass in the pointer to cmd->fields[i] which is not known
- * when jtag_check_value is invoked
- *
- * Not pretty, but this is part of synthesizing check_mask via in_handler
- * with a minimum of code impact.
- *
- * A cleaner change would be to modify the in_handler to always take field
- * as an argument. Perhaps later...
- *
- * Change in_handler to be varargs and have fields+i as the first vararg?
- *
- */
- priv = cmd->fields + i;
- }
if (cmd->fields[i].in_value)
{
buf_cpy(captured, cmd->fields[i].in_value, num_bits);
if (cmd->fields[i].in_handler)
{
- if (cmd->fields[i].in_handler(cmd->fields[i].in_value, priv) != ERROR_OK)
+ if (cmd->fields[i].in_handler(cmd->fields[i].in_value, cmd->fields[i].in_handler_priv, cmd->fields+i) != ERROR_OK)
{
WARNING("in_handler reported a failed check");
retval = ERROR_JTAG_QUEUE_FAILED;
@@ -1054,7 +1040,7 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
/* no in_value specified, but a handler takes care of the scanned data */
if (cmd->fields[i].in_handler && (!cmd->fields[i].in_value))
{
- if (cmd->fields[i].in_handler(captured, priv) != ERROR_OK)
+ if (cmd->fields[i].in_handler(captured, cmd->fields[i].in_handler_priv, cmd->fields+i) != ERROR_OK)
{
/* We're going to call the error:handler later, but if the in_handler
* reported an error we report this failure upstream
@@ -1072,10 +1058,9 @@ int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
return retval;
}
-int jtag_check_value(u8 *captured, void *priv)
+int jtag_check_value(u8 *captured, void *priv, scan_field_t *field)
{
int retval = ERROR_OK;
- scan_field_t *field=(scan_field_t *)priv;
int num_bits = field->num_bits;
int compare_failed = 0;
@@ -1086,21 +1071,7 @@ int jtag_check_value(u8 *captured, void *priv)
compare_failed = buf_cmp(captured, field->in_check_value, num_bits);
if (compare_failed)
- {
- if (field->in_handler_error_handler.error_handler)
{
- /* ask the error handler if once has been specified if this is a real problem */
- if (field->in_handler_error_handler.error_handler(captured, field->in_handler_error_handler.error_handler_priv) != ERROR_OK)
- retval = ERROR_JTAG_QUEUE_FAILED;
- else
- compare_failed = 0;
- }
- else
- {
- /* if there wasn't a handler specified, we report a failure */
- retval = ERROR_JTAG_QUEUE_FAILED;
- }
-
/* An error handler could have caught the failing check
* only report a problem when there wasn't a handler, or if the handler
* acknowledged the error
@@ -1143,10 +1114,6 @@ void jtag_set_check_value(scan_field_t *field, u8 *value, u8 *mask, error_handle
field->in_handler_priv = NULL; /* this will be filled in at the invocation site to point to the field duplicate */
field->in_check_value = value;
field->in_check_mask = mask;
- if (in_error_handler)
- field->in_handler_error_handler = *in_error_handler;
- else
- field->in_handler_error_handler.error_handler = NULL;
}
enum scan_type jtag_scan_type(scan_command_t *cmd)
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index 0ea6f5b..0458e2d 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -64,11 +64,10 @@ extern enum tap_state cmd_queue_cur_state; /* current TAP state */
#define TAP_MOVE(from, to) tap_move[tap_move_map[from]][tap_move_map[to]]
-typedef struct error_handler_s
-{
- int (*error_handler)(u8 *in_value, void *priv); /* handle failed checks */
- void *error_handler_priv; /* additional information for the check_handler */
-} error_handler_t;
+typedef void * error_handler_t; /* Later on we can delete error_handler_t, but keep it for now to make patches more readable */
+
+struct scan_field_s;
+typedef int (*in_handler_t)(u8 *in_value, void *priv, struct scan_field_s *field);
typedef struct scan_field_s
{
@@ -78,10 +77,9 @@ typedef struct scan_field_s
u8 *out_mask; /* only masked bits care */
u8 *in_value; /* pointer to a 32-bit memory location to take data scanned out */
/* in_check_value/mask, in_handler_error_handler, in_handler_priv can be used by the in handler, otherwise they contain garbage */
- error_handler_t in_handler_error_handler;
u8 *in_check_value; /* used to validate scan results */
u8 *in_check_mask; /* check specified bits against check_value */
- int (*in_handler)(u8 *in_value, void *priv); /* process received buffer using this handler */
+ in_handler_t in_handler; /* process received buffer using this handler */
void *in_handler_priv; /* additional information for the in_handler */
} scan_field_t;
@@ -274,6 +272,9 @@ extern void jtag_sleep(u32 us);
extern int jtag_call_event_callbacks(enum jtag_event event);
extern int jtag_register_event_callback(int (*callback)(enum jtag_event event, void *priv), void *priv);
+extern int jtag_verify_capture_ir;
+
+
/* error codes
* JTAG subsystem uses codes between -100 and -199 */
diff --git a/src/pld/virtex2.c b/src/pld/virtex2.c
index ab715d9..a31c37d 100644
--- a/src/pld/virtex2.c
+++ b/src/pld/virtex2.c
@@ -101,7 +101,7 @@ int virtex2_send_32(struct pld_device_s *pld_device, int num_words, u32 *words)
return ERROR_OK;
}
-int virtex2_jtag_buf_to_u32(u8 *in_buf, void *priv)
+int virtex2_jtag_buf_to_u32(u8 *in_buf, void *priv, struct scan_field_s *field)
{
u32 *dest = priv;
*dest = flip_u32(le_to_h_u32(in_buf), 32);
diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c
index ef22514..efead81 100644
--- a/src/target/arm926ejs.c
+++ b/src/target/arm926ejs.c
@@ -94,12 +94,14 @@ target_type_t arm926ejs_target =
.quit = arm926ejs_quit
};
-int arm926ejs_catch_broken_irscan(u8 *in_value, void *priv)
+
+int arm926ejs_catch_broken_irscan(u8 *captured, void *priv, scan_field_t *field)
{
- /* The ARM926EJ-S' instruction register is 4 bits wide */
- *in_value &= 0xf;
+ u8 *in_value=field->in_check_value;
- if ((*in_value == 0x0f) || (*in_value == 0x00))
+ /* The ARM926EJ-S' instruction register is 4 bits wide */
+ u8 t=*in_value & 0xf;
+ if ((t == 0x0f) || (t == 0x00))
{
DEBUG("caught ARM926EJ-S invalid Capture-IR result after CP15 access");
return ERROR_OK;
@@ -119,7 +121,6 @@ int arm926ejs_read_cp15(target_t *target, u32 address, u32 *value)
u8 address_buf[2];
u8 nr_w_buf = 0;
u8 access = 1;
- error_handler_t error_handler;
buf_set_u32(address_buf, 0, 14, address);
@@ -184,11 +185,8 @@ int arm926ejs_read_cp15(target_t *target, u32 address, u32 *value)
#ifdef _DEBUG_INSTRUCTION_EXECUTION_
DEBUG("addr: 0x%x value: %8.8x", address, *value);
#endif
-
- error_handler.error_handler = arm926ejs_catch_broken_irscan;
- error_handler.error_handler_priv = NULL;
- arm_jtag_set_instr(jtag_info, 0xc, &error_handler);
+ arm_jtag_set_instr(jtag_info, 0xc, &arm926ejs_catch_broken_irscan);
return ERROR_OK;
}
@@ -203,7 +201,6 @@ int arm926ejs_write_cp15(target_t *target, u32 address, u32 value)
u8 address_buf[2];
u8 nr_w_buf = 1;
u8 access = 1;
- error_handler_t error_handler;
buf_set_u32(address_buf, 0, 14, address);
buf_set_u32(value_buf, 0, 32, value);
@@ -267,10 +264,7 @@ int arm926ejs_write_cp15(target_t *target, u32 address, u32 value)
DEBUG("addr: 0x%x value: %8.8x", address, value);
#endif
- error_handler.error_handler = arm926ejs_catch_broken_irscan;
- error_handler.error_handler_priv = NULL;
-
- arm_jtag_set_instr(jtag_info, 0xf, &error_handler);
+ arm_jtag_set_instr(jtag_info, 0xf, &arm926ejs_catch_broken_irscan);
return ERROR_OK;
}
diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c
index 5bb7e39..5f808cd 100644
--- a/src/target/arm9tdmi.c
+++ b/src/target/arm9tdmi.c
@@ -101,15 +101,6 @@ arm9tdmi_vector_t arm9tdmi_vectors[] =
{0, 0},
};
-int arm9tdmi_jtag_error_handler(u8 *in_value, void *priv)
-{
- char *caller = priv;
-
- DEBUG("caller: %s", caller);
-
- return ERROR_JTAG_QUEUE_FAILED;
-}
-
int arm9tdmi_examine_debug_reason(target_t *target)
{
/* get pointers to arch-specific information */
diff --git a/src/target/arm_jtag.c b/src/target/arm_jtag.c
index edc1bd8..070af21 100644
--- a/src/target/arm_jtag.c
+++ b/src/target/arm_jtag.c
@@ -33,14 +33,7 @@
#define _ARM_JTAG_SCAN_N_CHECK_
#endif
-int arm_jtag_set_instr_error_handler(u8 *in_value, void *priv)
-{
- ERROR("setting the new JTAG instruction failed, debugging is likely to be broken");
-
- return ERROR_OK;
-}
-
-int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr, error_handler_t *caller_error_handler)
+int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr, in_handler_t handler)
{
jtag_device_t *device = jtag_get_device(jtag_info->chain_pos);
@@ -56,22 +49,8 @@ int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr, error_handler_t *ca
field.in_value = NULL;
field.in_check_value = NULL;
field.in_check_mask = NULL;
- field.in_handler = NULL;
+ field.in_handler = handler;
field.in_handler_priv = NULL;
-
-
-
- if (caller_error_handler)
- {
- jtag_set_check_value(&field, NULL, NULL, caller_error_handler);
- }
- else
- {
- error_handler_t error_handler;
- error_handler.error_handler = arm_jtag_set_instr_error_handler;
- error_handler.error_handler_priv = NULL;
- jtag_set_check_value(&field, NULL, NULL, &error_handler);
- }
jtag_add_ir_scan(1, &field, -1, NULL);
@@ -139,7 +118,7 @@ int arm_jtag_setup_connection(arm_jtag_t *jtag_info)
}
/* read JTAG buffer into host-endian u32, flipping bit-order */
-int arm_jtag_buf_to_u32_flip(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_u32_flip(u8 *in_buf, void *priv, struct scan_field_s *field)
{
u32 *dest = priv;
*dest = flip_u32(le_to_h_u32(in_buf), 32);
@@ -147,35 +126,35 @@ int arm_jtag_buf_to_u32_flip(u8 *in_buf, void *priv)
}
/* read JTAG buffer into little-endian u32, flipping bit-order */
-int arm_jtag_buf_to_le32_flip(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_le32_flip(u8 *in_buf, void *priv, struct scan_field_s *field)
{
h_u32_to_le(((u8*)priv), flip_u32(le_to_h_u32(in_buf), 32));
return ERROR_OK;
}
/* read JTAG buffer into little-endian u16, flipping bit-order */
-int arm_jtag_buf_to_le16_flip(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_le16_flip(u8 *in_buf, void *priv, struct scan_field_s *field)
{
h_u16_to_le(((u8*)priv), flip_u32(le_to_h_u32(in_buf), 32) & 0xffff);
return ERROR_OK;
}
/* read JTAG buffer into big-endian u32, flipping bit-order */
-int arm_jtag_buf_to_be32_flip(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_be32_flip(u8 *in_buf, void *priv, struct scan_field_s *field)
{
h_u32_to_be(((u8*)priv), flip_u32(le_to_h_u32(in_buf), 32));
return ERROR_OK;
}
/* read JTAG buffer into big-endian u16, flipping bit-order */
-int arm_jtag_buf_to_be16_flip(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_be16_flip(u8 *in_buf, void *priv, struct scan_field_s *field)
{
h_u16_to_be(((u8*)priv), flip_u32(le_to_h_u32(in_buf), 32) & 0xffff);
return ERROR_OK;
}
/* read JTAG buffer into u8, flipping bit-order */
-int arm_jtag_buf_to_8_flip(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_8_flip(u8 *in_buf, void *priv, struct scan_field_s *field)
{
u8 *dest = priv;
*dest = flip_u32(le_to_h_u32(in_buf), 32) & 0xff;
@@ -184,7 +163,7 @@ int arm_jtag_buf_to_8_flip(u8 *in_buf, void *priv)
/* not-flipping variants */
/* read JTAG buffer into host-endian u32 */
-int arm_jtag_buf_to_u32(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_u32(u8 *in_buf, void *priv, struct scan_field_s *field)
{
u32 *dest = priv;
*dest = le_to_h_u32(in_buf);
@@ -192,35 +171,35 @@ int arm_jtag_buf_to_u32(u8 *in_buf, void *priv)
}
/* read JTAG buffer into little-endian u32 */
-int arm_jtag_buf_to_le32(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_le32(u8 *in_buf, void *priv, struct scan_field_s *field)
{
h_u32_to_le(((u8*)priv), le_to_h_u32(in_buf));
return ERROR_OK;
}
/* read JTAG buffer into little-endian u16 */
-int arm_jtag_buf_to_le16(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_le16(u8 *in_buf, void *priv, struct scan_field_s *field)
{
h_u16_to_le(((u8*)priv), le_to_h_u32(in_buf) & 0xffff);
return ERROR_OK;
}
/* read JTAG buffer into big-endian u32 */
-int arm_jtag_buf_to_be32(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_be32(u8 *in_buf, void *priv, struct scan_field_s *field)
{
h_u32_to_be(((u8*)priv), le_to_h_u32(in_buf));
return ERROR_OK;
}
/* read JTAG buffer into big-endian u16 */
-int arm_jtag_buf_to_be16(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_be16(u8 *in_buf, void *priv, struct scan_field_s *field)
{
h_u16_to_be(((u8*)priv), le_to_h_u32(in_buf) & 0xffff);
return ERROR_OK;
}
/* read JTAG buffer into u8 */
-int arm_jtag_buf_to_8(u8 *in_buf, void *priv)
+int arm_jtag_buf_to_8(u8 *in_buf, void *priv, struct scan_field_s *field)
{
u8 *dest = priv;
*dest = le_to_h_u32(in_buf) & 0xff;
diff --git a/src/target/arm_jtag.h b/src/target/arm_jtag.h
index f2f5587..227a8d5 100644
--- a/src/target/arm_jtag.h
+++ b/src/target/arm_jtag.h
@@ -34,25 +34,25 @@ typedef struct arm_jtag_s
u32 intest_instr;
} arm_jtag_t;
-extern int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr, error_handler_t *error_handler);
+extern int arm_jtag_set_instr(arm_jtag_t *jtag_info, u32 new_instr, in_handler_t handler);
extern int arm_jtag_scann(arm_jtag_t *jtag_info, u32 new_scan_chain);
extern int arm_jtag_setup_connection(arm_jtag_t *jtag_info);
/* JTAG buffers to host, be and le buffers, flipping variants */
-int arm_jtag_buf_to_u32_flip(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_le32_flip(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_le16_flip(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_be32_flip(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_be16_flip(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_8_flip(u8 *in_buf, void *priv);
+int arm_jtag_buf_to_u32_flip(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_le32_flip(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_le16_flip(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_be32_flip(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_be16_flip(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_8_flip(u8 *in_buf, void *priv, struct scan_field_s *field);
/* JTAG buffers to host, be and le buffers */
-int arm_jtag_buf_to_u32(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_le32(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_le16(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_be32(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_be16(u8 *in_buf, void *priv);
-int arm_jtag_buf_to_8(u8 *in_buf, void *priv);
+int arm_jtag_buf_to_u32(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_le32(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_le16(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_be32(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_be16(u8 *in_buf, void *priv, struct scan_field_s *field);
+int arm_jtag_buf_to_8(u8 *in_buf, void *priv, struct scan_field_s *field);
#endif /* ARM_JTAG */
diff --git a/src/target/trace.c b/src/target/trace.c
index 73f0133..536e34a 100644
--- a/src/target/trace.c
+++ b/src/target/trace.c
@@ -76,7 +76,7 @@ int handle_trace_point_command(struct command_context_s *cmd_ctx, char *cmd, cha
{
if (trace->trace_points)
free(trace->trace_points);
- trace->num_trace_points = NULL;
+ trace->num_trace_points = 0;
trace->trace_points_size = 0;
return ERROR_OK;