X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=blobdiff_plain;f=src%2Fecosboard.c;h=0805e6fcb93c2c88c5db1d606750cef2dc39021e;hp=e4e5cb9d141e3917b1473f6e21f36ced26c13bf5;hb=91e054a9eaefcfdb2b4e1afa99494f31481bc777;hpb=49675db9723ea6481ea38e9e34351123fc7954a0 diff --git a/src/ecosboard.c b/src/ecosboard.c index e4e5cb9d14..0805e6fcb9 100644 --- a/src/ecosboard.c +++ b/src/ecosboard.c @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2009 by Øyvind Harboe * + * Copyright (C) 2007-2010 by Øyvind Harboe * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -24,18 +24,16 @@ #include #include #include +#include #include -#include "xsvf.h" -#include "svf.h" -#include -#include #include #include #include -#include "openocd.h" +#include + +#include -#include #include #include #include @@ -57,33 +55,15 @@ #include #include #include -#include -#include -#include #include +#include #include -#include "rom.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include -#include +#include "rom.h" #ifdef CYGPKG_HAL_NIOS2 +#include #define ZY1000_SER_DEV "/dev/uart_0" #else #define ZY1000_SER_DEV "/dev/ser0" @@ -120,10 +100,6 @@ static bool writeLog = true; char hwaddr[512]; - -extern struct flash_driver *flash_drivers[]; -extern struct target_type *target_types[]; - #ifdef CYGPKG_PROFILE_GPROF #include @@ -167,7 +143,14 @@ static void zylinjtag_reboot(cyg_addrword_t data) diag_printf("Unmounting /config..\n"); umount("/config"); diag_printf("Rebooting..\n"); +#ifdef CYGPKG_HAL_NIOS2 + /* This will reboot & reconfigure the FPGA from the bootloader + * and on. + */ + IOWR(REMOTE_UPDATE_BASE, 0x20, 0x1); +#else HAL_PLATFORM_RESET(); +#endif } static cyg_thread zylinjtag_thread_object; static cyg_handle_t zylinjtag_thread_handle; @@ -253,11 +236,21 @@ int zy1000_configuration_output_handler_log(struct command_context *context, } #ifdef CYGPKG_PROFILE_GPROF +//extern int64_t totaltime; -int eCosBoard_handle_eCosBoard_profile_command(struct command_context *cmd_ctx, char *cmd, char **args, int argc) +static int zylinjtag_Jim_Command_profile(Jim_Interp *interp, int argc, + Jim_Obj * const *argv) { - command_print(cmd_ctx, "Profiling started"); - start_profile(); + if ((argc == 2) && (strcmp(Jim_GetString(argv[1], NULL), "stats")==0)) + { +// profile_off(); + //LOG_USER("Stats %dms sleeping in select()", (int)totaltime); + } else + { + LOG_USER("Profiling started"); + start_profile(); + //totaltime = 0; + } return ERROR_OK; } @@ -507,6 +500,10 @@ static void zylinjtag_startNetwork(void) cyg_httpd_init_tcl_interpreter(); + // Kludge! Why can't I do this from httpd.c??? I get linker errors... + // some of that --start/end-group stuff? + Jim_InitStaticExtensions(httpstate.jim_interp); + Jim_CreateCommand(httpstate.jim_interp, "log", zylinjtag_Jim_Command_log, NULL, NULL); Jim_CreateCommand(httpstate.jim_interp, "zy1000_reboot", @@ -851,7 +848,7 @@ static int zylinjtag_Jim_Command_uart(Jim_Interp *interp, int argc, static int current_baud = 38400; if (argc == 1) { - command_print(cmd_ctx, "%d", current_baud); + Jim_SetResult(interp, Jim_NewIntObj(interp, current_baud)); return JIM_OK; } else if (argc != 2) @@ -887,8 +884,8 @@ static int zylinjtag_Jim_Command_uart(Jim_Interp *interp, int argc, baud = CYGNUM_SERIAL_BAUD_230400; break; default: - command_print(cmd_ctx, "unsupported baudrate"); - return ERROR_INVALID_ARGUMENTS; + Jim_SetResult(interp, Jim_NewStringObj(interp, "unsupported baudrate", -1)); + return JIM_ERR; } cyg_serial_info_t buf; @@ -901,7 +898,7 @@ static int zylinjtag_Jim_Command_uart(Jim_Interp *interp, int argc, err = cyg_io_lookup(ZY1000_SER_DEV, &serial_handle); if (err != ENOERR) { - LOG_ERROR("Could not open serial port\n"); + Jim_SetResult(interp, Jim_NewStringObj(interp, "Could not open serial port", -1)); return JIM_ERR; } @@ -911,7 +908,7 @@ static int zylinjtag_Jim_Command_uart(Jim_Interp *interp, int argc, &len); if (err != ENOERR) { - LOG_ERROR("Failed to get serial port settings %d", err); + Jim_SetResult(interp, Jim_NewStringObj(interp, "Failed to get serial port settings", -1)); return JIM_ERR; } buf.baud = baud; @@ -920,7 +917,7 @@ static int zylinjtag_Jim_Command_uart(Jim_Interp *interp, int argc, &len); if (err != ENOERR) { - LOG_ERROR("Failed to set serial port settings %d", err); + Jim_SetResult(interp, Jim_NewStringObj(interp, "Failed to set serial port settings", -1)); return JIM_ERR; } @@ -960,7 +957,11 @@ int main(int argc, char *argv[]) diag_init_putc(_zylinjtag_diag_write_char); // We want this in the log. - diag_printf("Zylin ZY1000.\n"); +#ifdef CYGPKG_HAL_NIOS2 + diag_printf("Zylin ZY1000 PCB revc.\n"); +#else + diag_printf("Zylin ZY1000 PCB revb.\n"); +#endif err = mount("", "/ram", "ramfs"); if (err < 0) @@ -999,6 +1000,20 @@ int main(int argc, char *argv[]) copydir("/rom", "/ram/cgi"); +#ifdef CYGPKG_HAL_NIOS2 + cyg_flashaddr_t err_address; +#define UNCACHED_EXT_FLASH_BASE (0x80000000 + EXT_FLASH_BASE) + /* The revc flash is locked upon reset, unlock it */ +#ifdef CYGHWR_IO_FLASH_BLOCK_LOCKING + if ((err = flash_unlock((void *) UNCACHED_EXT_FLASH_BASE, EXT_FLASH_SPAN, + (void **) &err_address)) != 0) + { + diag_printf("Error: could not unlock flash\n"); + } +#endif +#endif + + err = mount("/dev/flash1", "/config", "jffs2"); if (err < 0) { @@ -1079,15 +1094,18 @@ int main(int argc, char *argv[]) command_set_output_handler(cmd_ctx, configuration_output_handler, NULL); command_context_mode(cmd_ctx, COMMAND_CONFIG); + if (util_init(cmd_ctx) != ERROR_OK) + return EXIT_FAILURE; + if (ioutil_init(cmd_ctx) != ERROR_OK) return EXIT_FAILURE; #ifdef CYGPKG_PROFILE_GPROF - COMMAND_REGISTER(cmd_ctx, NULL, "ecosboard_profile", eCosBoard_handle_eCosBoard_profile_command, - COMMAND_ANY, NULL); + Jim_CreateCommand(httpstate.jim_interp, "zy1000_profile", zylinjtag_Jim_Command_profile, + NULL, NULL); #endif - Jim_CreateCommand(httpstate.jim_interp, "uart", zylinjtag_Jim_Command_uart, NULL, NULL); + Jim_CreateCommand(httpstate.jim_interp, "zy1000_uart", zylinjtag_Jim_Command_uart, NULL, NULL); log_init(); @@ -1263,6 +1281,7 @@ struct Tftp cyg_uint8 *mem; int actual; char *server; + int port; char *file; }; @@ -1319,6 +1338,15 @@ static int tftpfs_open(cyg_mtab_entry *mte, cyg_dir dir, const char *name, strncpy(tftp->server, name, server - name); tftp->server[server - name] = 0; + tftp->port = 0; /* default port 69 */ + char *port; + port = strchr(tftp->server, ':'); + if (port != NULL) + { + tftp->port = atoi(port + 1); + *port = 0; + } + tftp->file = strdup(server + 1); if (tftp->file == NULL) { @@ -1336,7 +1364,7 @@ static int fetchTftp(struct Tftp *tftp) if (!tftp->readFile) { int err; - tftp->actual = tftp_client_get(tftp->file, tftp->server, 0, tftp->mem, + tftp->actual = tftp_client_get(tftp->file, tftp->server, tftp->port, tftp->mem, tftpMaxSize, TFTP_OCTET, &err); if (tftp->actual < 0)