- fix incorrect svn props from last commit
[openocd.git] / src / ecosboard.c
index 7cab4879b2cd9f78096ff6b5e098b4fc055344fe..349ff6d6570c08e44cbc530a64bec29e350a3be6 100644 (file)
@@ -98,7 +98,7 @@ struct tftpd_fileops fileops =
 
 #endif
 
-#define ZYLIN_VERSION "1.46"
+#define ZYLIN_VERSION "1.47"
 #define ZYLIN_DATE __DATE__
 #define ZYLIN_TIME __TIME__
 /* hmmm....  we can't pick up the right # during build if we've checked this out
@@ -119,6 +119,7 @@ void diag_write(char *buf, int len)
 static bool serialLog = true;
 static bool writeLog = true;
 
+char hwaddr[512];
 
 struct FastLoad
 {
@@ -341,6 +342,9 @@ int handle_zy1000_version_command(struct command_context_s *cmd_ctx, char *cmd,
        return ERROR_OK;
 }
 
+
+
+
 extern flash_driver_t *flash_drivers[];
 extern target_type_t *target_types[];
 
@@ -542,10 +546,10 @@ static void setPower(bool power)
        savePower = power;
        if (power)
        {
-               HAL_WRITE_UINT32(0x08000014, 0x8);
+               HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x14, 0x8);
        } else
        {
-               HAL_WRITE_UINT32(0x08000010, 0x8);
+               HAL_WRITE_UINT32(ZY1000_JTAG_BASE+0x10, 0x8);
        }
 }
 
@@ -796,7 +800,9 @@ void _zylinjtag_diag_write_char(char c, void **param)
                HAL_DIAG_WRITE_CHAR(c);
        }
 
+#ifdef CYGPKG_HAL_ZYLIN_PHI
        printDccChar(c);
+#endif
 }
 
 #define SHOW_RESULT(a, b) diag_printf(#a " failed %d\n", (int)b)
@@ -927,6 +933,72 @@ void openocd_sleep_postlude()
        cyg_mutex_lock(&httpstate.jim_lock);
 }
 
+
+void format(void)
+{
+       diag_printf("Formatting JFFS2...\n");
+
+       cyg_io_handle_t handle;
+
+       Cyg_ErrNo err;
+       err = cyg_io_lookup(CYGDAT_IO_FLASH_BLOCK_DEVICE_NAME_1, &handle);
+       if (err != ENOERR)
+       {
+               diag_printf("Flash Error cyg_io_lookup: %d\n", err);
+               reboot();
+       }
+
+
+       cyg_uint32 len;
+       cyg_io_flash_getconfig_devsize_t ds;
+       len = sizeof (ds);
+       err = cyg_io_get_config(handle,
+                               CYG_IO_GET_CONFIG_FLASH_DEVSIZE, &ds, &len);
+       if (err != ENOERR)
+       {
+               diag_printf("Flash error cyg_io_get_config %d\n", err);
+               reboot();
+       }
+
+       cyg_io_flash_getconfig_erase_t e;
+       void *err_addr;
+       len = sizeof (e);
+
+       e.offset = 0;
+       e.len = ds.dev_size;
+       e.err_address = &err_addr;
+
+       diag_printf("Formatting 0x%08x bytes\n", ds.dev_size);
+       err = cyg_io_get_config(handle, CYG_IO_GET_CONFIG_FLASH_ERASE,
+                               &e, &len);
+       if (err != ENOERR)
+       {
+               diag_printf("Flash erase error %d offset 0x%p\n", err, err_addr);
+               reboot();
+       }
+
+       diag_printf("Flash formatted successfully\n");
+
+       reboot();
+}
+
+
+
+static int
+zylinjtag_Jim_Command_format_jffs2(Jim_Interp *interp,
+                                   int argc,
+               Jim_Obj * const *argv)
+{
+       if (argc != 1)
+       {
+               return JIM_ERR;
+       }
+
+       format();
+       for(;;);
+}
+
+
 static int
 zylinjtag_Jim_Command_rm(Jim_Interp *interp,
                                    int argc,
@@ -1215,33 +1287,9 @@ zylinjtag_Jim_Command_mac(Jim_Interp *interp,
                                    int argc,
                Jim_Obj * const *argv)
 {
-       int s;
-       struct ifreq ifr;
-       s = socket(AF_INET, SOCK_DGRAM, 0);
-       if (s >= 0)
-       {
-               strcpy(ifr.ifr_name, "eth0");
-               int res;
-               res = ioctl(s, SIOCGIFHWADDR, &ifr);
-               close(s);
-
-               if (res < 0)
-               {
-                       return JIM_OK;
-               }
-       }
 
        Jim_Obj *tclOutput = Jim_NewStringObj(interp, "", 0);
 
-       char hwaddr[512];
-       sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[0],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[1],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[2],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[3],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[4],
-                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[5]);
-
        Jim_AppendString(httpstate.jim_interp, tclOutput, hwaddr, strlen(hwaddr));
 
        Jim_SetResult(interp, tclOutput);
@@ -1295,6 +1343,7 @@ zylinjtag_Jim_Command_ip(Jim_Interp *interp,
 
 extern Jim_Interp *interp;
 
+
 static void zylinjtag_startNetwork()
 {
        // Bring TCP/IP up immediately before we're ready to accept commands.
@@ -1330,6 +1379,7 @@ static void zylinjtag_startNetwork()
     Jim_CreateCommand(httpstate.jim_interp, "mac", zylinjtag_Jim_Command_mac, NULL, NULL);
     Jim_CreateCommand(httpstate.jim_interp, "ip", zylinjtag_Jim_Command_ip, NULL, NULL);
     Jim_CreateCommand(httpstate.jim_interp, "rm", zylinjtag_Jim_Command_rm, NULL, NULL);
+    Jim_CreateCommand(httpstate.jim_interp, "format_jffs2", zylinjtag_Jim_Command_format_jffs2, NULL, NULL);
 
        cyg_httpd_start();
 
@@ -1337,6 +1387,34 @@ static void zylinjtag_startNetwork()
 
        diag_printf("Web server running\n");
 
+       int s;
+       struct ifreq ifr;
+       s = socket(AF_INET, SOCK_DGRAM, 0);
+       if (s >= 0)
+       {
+               strcpy(ifr.ifr_name, "eth0");
+               int res;
+               res = ioctl(s, SIOCGIFHWADDR, &ifr);
+               close(s);
+
+               if (res < 0)
+               {
+                       diag_printf("Can't obtain MAC address\n");
+                       reboot();
+               }
+       }
+
+       sprintf(hwaddr, "%02x:%02x:%02x:%02x:%02x:%02x",
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[0],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[1],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[2],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[3],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[4],
+                       (int) ((unsigned char *) &ifr.ifr_hwaddr.sa_data)[5]);
+
+
+       discover_message=alloc_printf("ZY1000 Zylin JTAG debugger MAC %s", hwaddr);
+
        discover_launch();
 }
 
@@ -1352,6 +1430,7 @@ print_exception_handler(cyg_addrword_t data, cyg_code_t exception, cyg_addrword_
        char *infoStr = "unknown";
        switch (exception)
        {
+#ifdef CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION
        case CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION:
                infoStr = "undefined instruction";
                break;
@@ -1364,6 +1443,7 @@ print_exception_handler(cyg_addrword_t data, cyg_code_t exception, cyg_addrword_
        case CYGNUM_HAL_VECTOR_ABORT_DATA:
                infoStr = "abort data";
                break;
+#endif
        default:
                break;
        }
@@ -1403,7 +1483,6 @@ static char uart_stack[4096];
 static char forwardBuffer[1024]; // NB! must be smaller than a TCP/IP packet!!!!!
 static char backwardBuffer[1024];
 
-static cyg_io_handle_t serial_handle;
 
 void setNoDelay(int session, int flag)
 {
@@ -1487,7 +1566,9 @@ zylinjtag_uart(cyg_addrword_t data)
                        continue;
                }
 
+#ifdef CYGPKG_PROFILE_GPROF
                start_profile();
+#endif
                int actual = 0;
                int actual2 = 0;
                int pos, pos2;
@@ -1631,15 +1712,20 @@ void startUart(void)
 
 int handle_uart_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
 {
-       if (argc != 1)
+       static int current_baud = 38400;
+       if (argc == 0)
+       {
+               command_print(cmd_ctx, "%d", current_baud);
+               return ERROR_OK;
+       } else if (argc != 1)
        {
-               command_print(cmd_ctx, "usage: uart <baudrate>");
                return ERROR_INVALID_ARGUMENTS;
        }
 
-       int baud = atol(args[0]);
+       current_baud = atol(args[0]);
 
-       switch (baud)
+       int baud;
+       switch (current_baud)
        {
        case 9600:
                baud = CYGNUM_SERIAL_BAUD_9600;
@@ -1669,6 +1755,16 @@ int handle_uart_command(struct command_context_s *cmd_ctx, char *cmd, char **arg
        //get existing serial configuration
        len = sizeof(cyg_serial_info_t);
        int err;
+       cyg_io_handle_t serial_handle;
+
+       err = cyg_io_lookup("/dev/ser0", &serial_handle);
+       if (err != ENOERR)
+       {
+               LOG_ERROR("/dev/ser0 not found\n");
+               return ERROR_FAIL;
+       }
+
+
        err = cyg_io_get_config(serial_handle, CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN, &buf, &len);
        err = cyg_io_get_config(serial_handle, CYG_IO_GET_CONFIG_SERIAL_INFO, &buf, &len);
        if (err != ENOERR)
@@ -1731,17 +1827,15 @@ int main(int argc, char *argv[])
        ramblockdevice=(cyg_uint8 *)malloc(ramblockdevice_size);
        memset(ramblockdevice, 0xff, ramblockdevice_size);
 
+
+
+#ifdef CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION
        setHandler(CYGNUM_HAL_VECTOR_UNDEF_INSTRUCTION);
        setHandler(CYGNUM_HAL_VECTOR_ABORT_PREFETCH);
        setHandler(CYGNUM_HAL_VECTOR_ABORT_DATA);
+#endif
 
        int err;
-       err = cyg_io_lookup("/dev/ser0", &serial_handle);
-       if (err != ENOERR)
-       {
-               diag_printf("/dev/ser0 not found\n");
-               reboot();
-       }
 
        setPower(true); // on by default
 
@@ -1792,48 +1886,54 @@ int main(int argc, char *argv[])
        err = mount("/dev/flash1", "/config", "jffs2");
        if (err < 0)
        {
-               diag_printf("unable to mount jffs\n");
-               reboot();
-       }
-
-       /* are we using a ram disk instead of a flash disk? This is used
-        * for ZY1000 live demo...
-        *
-        * copy over flash disk to ram block device
-        */
-       if (boolParam("ramdisk"))
-       {
-               diag_printf("Unmounting /config from flash and using ram instead\n");
-               err=umount("/config");
-               if (err < 0)
+               diag_printf("unable to mount jffs2, falling back to ram disk..\n");
+               err = mount("", "/config", "ramfs");
+               if (err<0)
                {
-                       diag_printf("unable to unmount jffs\n");
+                       diag_printf("unable to mount /config as ramdisk.\n");
                        reboot();
                }
-
-               err = mount("/dev/flash1", "/config2", "jffs2");
-               if (err < 0)
+       } else
+       {
+               /* are we using a ram disk instead of a flash disk? This is used
+                * for ZY1000 live demo...
+                *
+                * copy over flash disk to ram block device
+                */
+               if (boolParam("ramdisk"))
                {
-                       diag_printf("unable to mount jffs\n");
-                       reboot();
-               }
+                       diag_printf("Unmounting /config from flash and using ram instead\n");
+                       err=umount("/config");
+                       if (err < 0)
+                       {
+                               diag_printf("unable to unmount jffs\n");
+                               reboot();
+                       }
 
-               err = mount("/dev/ram", "/config", "jffs2");
-               if (err < 0)
-               {
-                       diag_printf("unable to mount ram block device\n");
-                       reboot();
-               }
+                       err = mount("/dev/flash1", "/config2", "jffs2");
+                       if (err < 0)
+                       {
+                               diag_printf("unable to mount jffs\n");
+                               reboot();
+                       }
 
-//             copydir("/config2", "/config");
-               copyfile("/config2/ip", "/config/ip");
-               copydir("/config2/settings", "/config/settings");
+                       err = mount("/dev/ram", "/config", "jffs2");
+                       if (err < 0)
+                       {
+                               diag_printf("unable to mount ram block device\n");
+                               reboot();
+                       }
 
-               umount("/config2");
-       } else
-       {
-               /* we're not going to use a ram block disk */
-               free(ramblockdevice);
+       //              copydir("/config2", "/config");
+                       copyfile("/config2/ip", "/config/ip");
+                       copydir("/config2/settings", "/config/settings");
+
+                       umount("/config2");
+               } else
+               {
+                       /* we're not going to use a ram block disk */
+                       free(ramblockdevice);
+               }
        }
 
 

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)