From 91e47f3ab8875176b6f6ac9244562f42f140467d Mon Sep 17 00:00:00 2001 From: Andreas Fritiofson Date: Wed, 18 Jun 2014 23:10:45 +0200 Subject: Fix some problems with the bin2char utility Don't hardcode the type for the array, just output the array initializer so the includer can choose the type and storage class, zero-terminate at will and so on. Change-Id: I6d5e0710eaaba0a218b3eb32f6569177356f4462 Signed-off-by: Andreas Fritiofson Reviewed-on: http://openocd.zylin.com/2176 Tested-by: jenkins Reviewed-by: Paul Fertser --- src/target/Makefile.am | 6 +++--- src/target/xscale.c | 14 +++++--------- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'src/target') diff --git a/src/target/Makefile.am b/src/target/Makefile.am index efbeb33a..bf80c64c 100644 --- a/src/target/Makefile.am +++ b/src/target/Makefile.am @@ -16,12 +16,12 @@ EXTRA_DIST = \ startup.tcl \ $(wildcard $(srcdir)/xscale/*) -DEBUG_HEADER = xscale_debug.h +DEBUG_HEADER = xscale_debug.inc BUILT_SOURCES = $(DEBUG_HEADER) CLEANFILES = $(DEBUG_HEADER) -$(DEBUG_HEADER): $(BIN2C) $(DEBUG_HANDLER) - $(BIN2C) < $(DEBUG_HANDLER) xscale_debug_handler > xscale_debug.h +$(DEBUG_HEADER): $(DEBUG_HANDLER) $(BIN2C) + $(BIN2C) < $< > $@ || { rm -f $@; false; } METASOURCES = AUTO noinst_LTLIBRARIES = libtarget.la diff --git a/src/target/xscale.c b/src/target/xscale.c index e88a2311..04189a14 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -73,14 +73,10 @@ static int xscale_read_trace(struct target *); /* This XScale "debug handler" is loaded into the processor's * mini-ICache, which is 2K of code writable only via JTAG. - * - * FIXME the OpenOCD "bin2char" utility currently doesn't handle - * binary files cleanly. It's string oriented, and terminates them - * with a NUL character. Better would be to generate the constants - * and let other code decide names, scoping, and other housekeeping. */ -static /* unsigned const char xscale_debug_handler[] = ... */ -#include "xscale_debug.h" +static const uint8_t xscale_debug_handler[] = { +#include "xscale_debug.inc" +}; static char *const xscale_reg_list[] = { "XSCALE_MAINID", /* 0 */ @@ -1549,7 +1545,7 @@ static int xscale_deassert_reset(struct target *target) * coprocessors, trace data, etc. */ address = xscale->handler_address; - for (unsigned binary_size = sizeof xscale_debug_handler - 1; + for (unsigned binary_size = sizeof xscale_debug_handler; binary_size > 0; binary_size -= buf_cnt, buffer += buf_cnt) { uint32_t cache_line[8]; @@ -3028,7 +3024,7 @@ static int xscale_target_create(struct target *target, Jim_Interp *interp) { struct xscale_common *xscale; - if (sizeof xscale_debug_handler - 1 > 0x800) { + if (sizeof xscale_debug_handler > 0x800) { LOG_ERROR("debug_handler.bin: larger than 2kb"); return ERROR_FAIL; } -- cgit v1.2.3-18-g5258