Commit 60ba4476 authored by ntfreak's avatar ntfreak
Browse files

- fix incorrectly registered function openocd_array2mem

- removed unused variables
- reformatted lpc288x.[ch]
- fixed helper/Makefile.am dependencies
- add correct svn props to added files

git-svn-id: svn://svn.berlios.de/openocd/trunk@829 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent 722fcb8d
......@@ -141,12 +141,12 @@ int flash_register_commands(struct command_context_s *cmd_ctx)
static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
flash_bank_t *p;
if (argc != 1) {
Jim_WrongNumArgs(interp, 1, argv, "no arguments to flash_banks command");
return JIM_ERR;
}
flash_bank_t *p;
int i = 0;
if (!flash_banks)
{
......@@ -158,7 +158,6 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
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->driver->name, -1));
Jim_ListAppendElement(interp, elem, Jim_NewStringObj(interp, "base", -1));
......@@ -178,7 +177,6 @@ static int jim_flash_banks(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK;
}
int flash_init_drivers(struct command_context_s *cmd_ctx)
{
if (flash_banks)
......
......@@ -94,8 +94,6 @@
/* F_CLK_TIME */
#define FCT_CLK_DIV_MASK 0x0FFF
int lpc288x_register_commands(struct command_context_s *cmd_ctx);
int lpc288x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank);
int lpc288x_erase(struct flash_bank_s *bank, int first, int last);
......@@ -134,8 +132,6 @@ int lpc288x_register_commands(struct command_context_s *cmd_ctx)
return ERROR_OK;
}
u32 lpc288x_wait_status_busy(flash_bank_t *bank, int timeout)
{
u32 status;
......@@ -160,8 +156,7 @@ int lpc288x_read_part_info(struct flash_bank_s *bank)
{
lpc288x_flash_bank_t *lpc288x_info = bank->driver_priv;
target_t *target = bank->target;
u32 cidr, status;
int sectornum;
u32 cidr;
int i = 0;
u32 offset;
......@@ -212,12 +207,10 @@ int lpc288x_protect_check(struct flash_bank_s *bank)
return ERROR_OK;
}
/* flash_bank LPC288x 0 0 0 0 <target#> <cclk>
*/
/* flash_bank LPC288x 0 0 0 0 <target#> <cclk> */
int lpc288x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc, struct flash_bank_s *bank)
{
lpc288x_flash_bank_t *lpc288x_info;
int i;
if (argc < 6)
{
......@@ -235,36 +228,29 @@ int lpc288x_flash_bank_command(struct command_context_s *cmd_ctx, char *cmd, cha
return ERROR_OK;
}
/*
The frequency is the AHB clock frequency divided by (CLK_DIV
3) + 1. This must be programmed such that the Flash
Programming clock frequency is 66 kHz 20%.
AHB = 12 MHz ?
12000000/66000 = 182
CLK_DIV = 60 ?
*/
/* The frequency is the AHB clock frequency divided by (CLK_DIV 3) + 1.
* This must be programmed such that the Flash Programming clock frequency is 66 kHz 20%.
* AHB = 12 MHz ?
* 12000000/66000 = 182
* CLK_DIV = 60 ? */
void lpc288x_set_flash_clk(struct flash_bank_s *bank)
{
u32 clk_time;
lpc288x_flash_bank_t *lpc288x_info = bank->driver_priv;
clk_time = (lpc288x_info->cclk / 66000) / 3;
target_write_u32(bank->target, F_CTRL, FC_CS | FC_WEN );
target_write_u32(bank->target, F_CTRL, FC_CS | FC_WEN);
target_write_u32(bank->target, F_CLK_TIME, clk_time);
}
/*
AHB tcyc (in ns) 83 ns
LOAD_TIMER_ERASE FPT_TIME = ((400,000,000 / AHB tcyc (in ns)) - 2) / 512
= 9412 (9500) (AN10548 9375)
LOAD_TIMER_WRITE FPT_TIME = ((1,000,000 / AHB tcyc (in ns)) - 2) / 512
= 23 (75) (AN10548 72 - is this wrong?)
TODO: Sort out timing calcs ;)
*/
/* AHB tcyc (in ns) 83 ns
* LOAD_TIMER_ERASE FPT_TIME = ((400,000,000 / AHB tcyc (in ns)) - 2) / 512
* = 9412 (9500) (AN10548 9375)
* LOAD_TIMER_WRITE FPT_TIME = ((1,000,000 / AHB tcyc (in ns)) - 2) / 512
* = 23 (75) (AN10548 72 - is this wrong?)
* TODO: Sort out timing calcs ;) */
void lpc288x_load_timer(int erase, struct target_s *target)
{
if(erase == LOAD_TIMER_ERASE)
if (erase == LOAD_TIMER_ERASE)
{
target_write_u32(target, F_PROG_TIME, FPT_ENABLE | 9500);
}
......@@ -274,8 +260,6 @@ void lpc288x_load_timer(int erase, struct target_s *target)
}
}
u32 lpc288x_system_ready(struct flash_bank_s *bank)
{
lpc288x_flash_bank_t *lpc288x_info = bank->driver_priv;
......@@ -293,9 +277,8 @@ u32 lpc288x_system_ready(struct flash_bank_s *bank)
int lpc288x_erase_check(struct flash_bank_s *bank)
{
u32 buffer, test_bytes;
u32 addr, sector, i, status = lpc288x_system_ready(bank); /* probed? halted? */
if(status != ERROR_OK)
u32 status = lpc288x_system_ready(bank); /* probed? halted? */
if (status != ERROR_OK)
{
LOG_INFO("Processor not halted/not probed");
return status;
......@@ -311,7 +294,7 @@ int lpc288x_erase(struct flash_bank_s *bank, int first, int last)
target_t *target = bank->target;
status = lpc288x_system_ready(bank); /* probed? halted? */
if(status != ERROR_OK)
if (status != ERROR_OK)
{
return status;
}
......@@ -334,25 +317,17 @@ int lpc288x_erase(struct flash_bank_s *bank, int first, int last)
lpc288x_load_timer(LOAD_TIMER_ERASE,target);
target_write_u32( target,
bank->sectors[sector].offset,
0x00);
target_write_u32(target, bank->sectors[sector].offset, 0x00);
target_write_u32( target,
F_CTRL,
FC_PROG_REQ |
FC_PROTECT |
FC_CS);
target_write_u32(target, F_CTRL, FC_PROG_REQ | FC_PROTECT | FC_CS);
}
if (lpc288x_wait_status_busy(bank, 1000) != ERROR_OK)
{
return ERROR_FLASH_OPERATION_FAILED;
}
return ERROR_OK;
}
int lpc288x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
{
u8 page_buffer[FLASH_PAGE_SIZE];
......@@ -363,7 +338,7 @@ int lpc288x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
/* probed? halted? */
status = lpc288x_system_ready(bank);
if(status != ERROR_OK)
if (status != ERROR_OK)
{
return status;
}
......@@ -372,9 +347,9 @@ int lpc288x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
first_sector = last_sector = 0xffffffff;
/* validate the write range... */
for(i = 0; i < bank->num_sectors; i++)
for (i = 0; i < bank->num_sectors; i++)
{
if((offset >= bank->sectors[i].offset) &&
if ((offset >= bank->sectors[i].offset) &&
(offset < (bank->sectors[i].offset + bank->sectors[i].size)) &&
(first_sector == 0xffffffff))
{
......@@ -386,7 +361,7 @@ int lpc288x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
return ERROR_FLASH_DST_BREAKS_ALIGNMENT;
}
}
if(((offset + count) > bank->sectors[i].offset) &&
if (((offset + count) > bank->sectors[i].offset) &&
((offset + count) <= (bank->sectors[i].offset + bank->sectors[i].size)) &&
(last_sector == 0xffffffff))
{
......@@ -408,11 +383,11 @@ int lpc288x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
source_offset = 0;
dest_offset = 0;
for (sector=first_sector; sector<=last_sector; sector++)
for (sector = first_sector; sector <= last_sector; sector++)
{
for(page = 0; page < bank->sectors[sector].size / FLASH_PAGE_SIZE; page++)
for (page = 0; page < bank->sectors[sector].size / FLASH_PAGE_SIZE; page++)
{
if(bytes_remaining == 0)
if (bytes_remaining == 0)
{
count = 0;
memset(page_buffer, 0xFF, FLASH_PAGE_SIZE);
......@@ -436,19 +411,12 @@ int lpc288x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
}
/* fill flash data latches with 1's */
target_write_u32(target, F_CTRL,
FC_CS |
FC_SET_DATA |
FC_WEN |
FC_FUNC );
target_write_u32(target, F_CTRL,
FC_CS |
FC_WEN |
FC_FUNC );
target_write_u32(target, F_CTRL, FC_CS | FC_SET_DATA | FC_WEN | FC_FUNC);
target_write_u32(target, F_CTRL, FC_CS | FC_WEN | FC_FUNC);
/*would be better to use the clean target_write_buffer() interface but
it seems not to be a LOT slower....
bulk_write_memory() is no quicker :(*/
* it seems not to be a LOT slower....
* bulk_write_memory() is no quicker :(*/
#if 1
if (target->type->write_memory(target, offset + dest_offset, 4, 128, page_buffer) != ERROR_OK)
{
......@@ -456,7 +424,7 @@ int lpc288x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
return ERROR_FLASH_OPERATION_FAILED;
}
#else
if(target_write_buffer(target, offset + dest_offset, FLASH_PAGE_SIZE, page_buffer) != ERROR_OK)
if (target_write_buffer(target, offset + dest_offset, FLASH_PAGE_SIZE, page_buffer) != ERROR_OK)
{
LOG_INFO("Write to flash buffer failed");
return ERROR_FLASH_OPERATION_FAILED;
......@@ -468,25 +436,16 @@ int lpc288x_write(struct flash_bank_s *bank, u8 *buffer, u32 offset, u32 count)
lpc288x_load_timer(LOAD_TIMER_WRITE, target);
target_write_u32( target,
F_CTRL,
FC_PROG_REQ |
FC_PROTECT |
FC_FUNC |
FC_CS);
target_write_u32(target, F_CTRL, FC_PROG_REQ | FC_PROTECT | FC_FUNC | FC_CS);
}
}
return ERROR_OK;
}
int lpc288x_probe(struct flash_bank_s *bank)
{
/* we only deal with LPC2888 so flash config is fixed
*/
/* we only deal with LPC2888 so flash config is fixed */
lpc288x_flash_bank_t *lpc288x_info = bank->driver_priv;
int retval;
......@@ -503,11 +462,9 @@ int lpc288x_probe(struct flash_bank_s *bank)
retval = lpc288x_read_part_info(bank);
if (retval != ERROR_OK)
return retval;
return ERROR_OK;
}
int lpc288x_info(struct flash_bank_s *bank, char *buf, int buf_size)
{
snprintf(buf, buf_size, "lpc288x flash driver");
......@@ -522,7 +479,7 @@ int lpc288x_protect(struct flash_bank_s *bank, int set, int first, int last)
/* probed? halted? */
status = lpc288x_system_ready(bank);
if(status != ERROR_OK)
if (status != ERROR_OK)
{
return status;
}
......@@ -537,7 +494,7 @@ int lpc288x_protect(struct flash_bank_s *bank, int set, int first, int last)
for (lockregion = first; lockregion <= last; lockregion++)
{
if(set)
if (set)
{
/* write an odd value to base addy to protect... */
value = 0x01;
......@@ -547,19 +504,9 @@ int lpc288x_protect(struct flash_bank_s *bank, int set, int first, int last)
/* write an even value to base addy to unprotect... */
value = 0x00;
}
target_write_u32( target,
bank->sectors[lockregion].offset,
value);
target_write_u32( target,
F_CTRL,
FC_LOAD_REQ |
FC_PROTECT |
FC_WEN |
FC_FUNC |
FC_CS);
target_write_u32(target, bank->sectors[lockregion].offset, value);
target_write_u32(target, F_CTRL, FC_LOAD_REQ | FC_PROTECT | FC_WEN | FC_FUNC | FC_CS);
}
return ERROR_OK;
}
......@@ -38,4 +38,3 @@ typedef struct lpc288x_flash_bank_s
} lpc288x_flash_bank_t;
#endif /* lpc288x_H */
INCLUDES = -I$(top_srcdir)/src $(all_includes)
INCLUDES = -I$(top_srcdir)/src $(all_includes) -I$(top_srcdir)/src/target
METASOURCES = AUTO
AM_CPPFLAGS = -DPKGDATADIR=\"$(pkgdatadir)\" -DPKGLIBDIR=\"$(pkglibdir)\" @CPPFLAGS@
noinst_LIBRARIES = libhelper.a
......@@ -10,20 +10,18 @@ CONFIGFILES = options.c jim.c
endif
libhelper_a_SOURCES = binarybuffer.c $(CONFIGFILES) configuration.c log.c command.c time_support.c \
replacements.c fileio.c
noinst_HEADERS = binarybuffer.h configuration.h types.h log.h command.h \
time_support.h replacements.h fileio.h \
jim.h
replacements.c fileio.c startup_tcl.c
libhelper_a_SOURCES += startup_tcl.c
noinst_HEADERS = binarybuffer.h configuration.h types.h log.h command.h \
time_support.h replacements.h fileio.h jim.h
noinst_PROGRAMS = bin2char
bin2char_SOURCES = bin2char.c
# Convert .tcl to cfile
startup_tcl.c: bin2char startup.tcl
./bin2char startup_tcl < $(srcdir)/startup.tcl > startup_tcl.c
startup_tcl.c: startup.tcl bin2char$(EXEEXT)
./bin2char$(EXEEXT) startup_tcl < $(srcdir)/$< > $@
# add startup_tcl.c to make clean list
CLEANFILES = startup_tcl.c
......@@ -25,8 +25,9 @@
#endif
#include "replacements.h"
#include "target.h"
#include "command.h"
#include "configuration.h"
#include "log.h"
#include "time_support.h"
......@@ -44,6 +45,9 @@ Jim_Interp *interp = NULL;
int handle_sleep_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int handle_fast_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc);
int run_command(command_context_t *context, command_t *c, char *words[], int num_words);
static void tcl_output(void *privData, const char *file, int line, const char *function, const char *string)
{
Jim_Obj *tclOutput=(Jim_Obj *)privData;
......@@ -178,7 +182,6 @@ command_t* register_command(command_context_t *context, command_t *parent, char
Jim_CreateCommand(interp, full_name, script_command, c, NULL);
free((void *)full_name);
/* accumulate help text in Tcl helptext list. */
Jim_Obj *helptext=Jim_GetGlobalVariableStr(interp, "ocd_helptext", JIM_ERRMSG);
if (Jim_IsShared(helptext))
......@@ -207,7 +210,6 @@ int unregister_all_commands(command_context_t *context)
if (context == NULL)
return ERROR_OK;
while(NULL != context->commands)
{
c = context->commands;
......@@ -277,7 +279,6 @@ int unregister_command(command_context_t *context, char *name)
return ERROR_OK;
}
void command_output_text(command_context_t *context, const char *data)
{
if( context && context->output_handler && data ){
......@@ -435,7 +436,6 @@ int command_run_line(command_context_t *context, char *line)
return retval;
}
int command_run_linef(command_context_t *context, char *format, ...)
{
int retval=ERROR_FAIL;
......@@ -451,8 +451,6 @@ int command_run_linef(command_context_t *context, char *format, ...)
return retval;
}
void command_set_output_handler(command_context_t* context, int (*output_handler)(struct command_context_s *context, const char* line), void *priv)
{
context->output_handler = output_handler;
......@@ -476,7 +474,6 @@ int command_done(command_context_t *context)
return ERROR_OK;
}
/* find full path to file */
static int jim_find(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
......@@ -502,8 +499,6 @@ static int jim_echo(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
return JIM_OK;
}
static size_t openocd_jim_fwrite(const void *_ptr, size_t size, size_t n, void *cookie)
{
size_t nbytes;
......
......@@ -76,14 +76,12 @@ extern int command_run_line(command_context_t *context, char *line);
extern int command_run_linef(command_context_t *context, char *format, ...);
extern void command_output_text(command_context_t *context, const char *data);
#define ERROR_COMMAND_CLOSE_CONNECTION (-600)
#define ERROR_COMMAND_SYNTAX_ERROR (-601)
#define ERROR_COMMAND_NOTFOUND (-602)
extern int fast_and_dangerous;
/* Integrate the JIM TCL interpretor into the command processing. */
#include <stdarg.h>
#ifdef __ECOS
......
......@@ -970,7 +970,7 @@ static void Jim_InitExtension(Jim_Interp *interp)
#ifdef JIM_EMBEDDED
Jim_Interp *ExportedJimCreateInterp(void);
static void Jim_InitEmbedded(void) {
static inline void Jim_InitEmbedded(void) {
Jim_Interp *i = ExportedJimCreateInterp();
Jim_InitExtension(i);
Jim_FreeInterp(i);
......
......@@ -761,9 +761,6 @@ void MINIDRIVER(interface_jtag_add_dr_out)(int device_num,
}
}
void jtag_add_plain_dr_scan(int num_fields, scan_field_t *fields, enum tap_state state)
{
int retval;
......@@ -872,7 +869,6 @@ void jtag_add_pathmove(int num_states, enum tap_state *path)
jtag_error=retval;
}
int MINIDRIVER(interface_jtag_add_pathmove)(int num_states, enum tap_state *path)
{
jtag_command_t **last_cmd = jtag_get_last_command_p();
......@@ -1040,7 +1036,6 @@ int MINIDRIVER(interface_jtag_add_reset)(int req_trst, int req_srst)
(*last_cmd)->cmd.reset->trst = req_trst;
(*last_cmd)->cmd.reset->srst = req_srst;
return ERROR_OK;
}
......@@ -1120,7 +1115,6 @@ int jtag_build_buffer(scan_command_t *cmd, u8 **buffer)
}
return bit_count;
}
int jtag_read_buffer(u8 *buffer, scan_command_t *cmd)
......@@ -1631,7 +1625,6 @@ int jtag_init(struct command_context_s *cmd_ctx)
return jtag_init_reset(cmd_ctx);
}
static int default_khz(int khz, int *jtag_speed)
{
LOG_ERROR("Translation from khz to jtag_speed not implemented");
......@@ -1931,7 +1924,6 @@ int handle_jtag_khz_command(struct command_context_s *cmd_ctx, char *cmd, char *
return ERROR_OK;
}
int handle_endstate_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
enum tap_state state;
......@@ -2007,7 +1999,6 @@ int handle_runtest_command(struct command_context_s *cmd_ctx, char *cmd, char **
}
int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
{
int i;
......@@ -2051,7 +2042,7 @@ int Jim_Command_drscan(Jim_Interp *interp, int argc, Jim_Obj *const *args)
scan_field_t *fields;
int num_fields;
int field_count = 0;
int i, j, e;
int i, e;
long device;
/* args[1] = device
......
......@@ -24,7 +24,6 @@
#include <stdarg.h>
#include "tcl_server.h"
#include "jim.h"
#include "log.h"
#include "command.h"
......@@ -41,7 +40,6 @@ typedef struct tcl_connection_s {
int tc_linedrop;
int tc_lineoffset;
char tc_line[TCL_MAX_LINE];
int tc_outerror; /* flag an output error */
} tcl_connection_t;
......@@ -80,7 +78,6 @@ int tcl_output(connection_t *connection, const void *data, ssize_t len)
return ERROR_SERVER_REMOTE_CLOSED;
}
/* connections */
static int tcl_new_connection(connection_t *connection)
{
......@@ -143,7 +140,8 @@ static int tcl_input(connection_t *connection)
if (retval != ERROR_OK)
return retval;
#undef ESTR
} else {
}
else {
tclc->tc_line[tclc->tc_lineoffset-1] = '\0';
retval = Jim_Eval(interp, tclc->tc_line);
result = Jim_GetString(Jim_GetResult(interp), &reslen);
......@@ -153,6 +151,7 @@ static int tcl_input(connection_t *connection)
if (memchr(result, '\n', reslen) == NULL)
tcl_output(connection, "\n", 1);
}
tclc->tc_lineoffset = 0;
tclc->tc_linedrop = 0;
}
......@@ -184,7 +183,6 @@ int tcl_init(void)
return retval;
}
int tcl_register_commands(command_context_t *cmd_ctx)
{
register_command(cmd_ctx, NULL, "tcl_port", handle_tcl_port_command, COMMAND_CONFIG, "");
......
......@@ -949,10 +949,9 @@ int target_register_commands(struct command_context_s *cmd_ctx)
register_command(cmd_ctx, NULL, "virt2phys", handle_virt2phys_command, COMMAND_ANY, "virt2phys <virtual address>");
register_command(cmd_ctx, NULL, "profile", handle_profile_command, COMMAND_EXEC, "PRELIMINARY! - profile <seconds> <gmon.out>");
/* script procedures */
register_jim(cmd_ctx, "openocd_mem2array", jim_mem2array, "read memory and return as a TCL array for script processing");
register_jim(cmd_ctx, "openocd_array2mem", jim_mem2array, "convert a TCL array to memory locations and write the values");
register_jim(cmd_ctx, "openocd_array2mem", jim_array2mem, "convert a TCL array to memory locations and write the values");
return ERROR_OK;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment