Karl Beldan <karl.beldan@gmail.com> - fix vector_catch command
[openocd.git] / src / ecosboard.c
index 8195943e0267de06172cacad8f58d9459ad8b106..b6fbc495bd4b95558c91b77890ebd778ca9d8997 100644 (file)
@@ -342,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[];
 
@@ -350,6 +353,9 @@ extern target_type_t *target_types[];
 
 extern char _stext, _etext; // Defined by the linker
 
+static char *start_of_code=&_stext;
+static char *end_of_code=&_etext;
+
 void start_profile(void)
 {
        // This starts up the system-wide profiling, gathering
@@ -367,9 +373,9 @@ void start_profile(void)
        //       too large, the usefulness of the profile is reduced.
 
        // no more interrupts than 1/10ms.
-       //    profile_on(&_stext, &_etext, 16, 10000); // DRAM
        //profile_on((void *)0, (void *)0x40000, 16, 10000); // SRAM
-       profile_on(0, &_etext, 16, 10000); // SRAM & DRAM
+//     profile_on(0, &_etext, 16, 10000); // SRAM & DRAM
+       profile_on(start_of_code, end_of_code, 16, 10000); // Nios DRAM
 }
 #endif
 
@@ -930,6 +936,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,
@@ -1310,6 +1382,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();
 
@@ -1847,7 +1920,7 @@ int main(int argc, char *argv[])
                                reboot();
                        }
 
-                       err = mount("/dev/ram", "/config", "jffs2");
+                       err = mount("", "/config", "ramfs");
                        if (err < 0)
                        {
                                diag_printf("unable to mount ram block device\n");
@@ -2483,122 +2556,3 @@ static int logfs_fo_close(struct CYG_FILE_TAG *fp)
        return ENOERR;
 }
 
-static bool
-ramiodev_init( struct cyg_devtab_entry *tab )
-{
-       return true;
-}
-
-static Cyg_ErrNo
-ramiodev_bread( cyg_io_handle_t handle, void *buf, cyg_uint32 *len,
-                  cyg_uint32 pos)
-{
-       if (*len+pos>ramblockdevice_size)
-       {
-               *len=ramblockdevice_size-pos;
-       }
-       memcpy(buf, ramblockdevice+pos, *len);
-       return ENOERR;
-}
-
-static Cyg_ErrNo
-ramiodev_bwrite( cyg_io_handle_t handle, const void *buf, cyg_uint32 *len,
-                   cyg_uint32 pos )
-{
-       if (((pos%4)!=0)||(((*len)%4)!=0))
-       {
-               diag_printf("Unaligned write %d %d!", pos, *len);
-       }
-
-       memcpy(ramblockdevice+pos, buf, *len);
-       return ENOERR;
-}
-
-static Cyg_ErrNo
-ramiodev_get_config( cyg_io_handle_t handle,
-                       cyg_uint32 key,
-                       void* buf,
-                       cyg_uint32* len)
-{
-    switch (key) {
-    case CYG_IO_GET_CONFIG_FLASH_ERASE:
-    {
-        if ( *len != sizeof( cyg_io_flash_getconfig_erase_t ) )
-             return -EINVAL;
-        {
-            cyg_io_flash_getconfig_erase_t *e = (cyg_io_flash_getconfig_erase_t *)buf;
-            char *startpos = ramblockdevice + e->offset;
-
-            if (((e->offset%(64*1024))!=0)||((e->len%(64*1024))!=0))
-            {
-               diag_printf("Erease is not aligned %d %d\n", e->offset, e->len);
-            }
-
-            memset(startpos, 0xff, e->len);
-
-            e->flasherr = 0;
-        }
-        return ENOERR;
-    }
-    case CYG_IO_GET_CONFIG_FLASH_DEVSIZE:
-    {
-        if ( *len != sizeof( cyg_io_flash_getconfig_devsize_t ) )
-             return -EINVAL;
-        {
-            cyg_io_flash_getconfig_devsize_t *d =
-                (cyg_io_flash_getconfig_devsize_t *)buf;
-
-                       d->dev_size = ramblockdevice_size;
-        }
-        return ENOERR;
-    }
-
-    case CYG_IO_GET_CONFIG_FLASH_BLOCKSIZE:
-    {
-        cyg_io_flash_getconfig_blocksize_t *b =
-            (cyg_io_flash_getconfig_blocksize_t *)buf;
-        if ( *len != sizeof( cyg_io_flash_getconfig_blocksize_t ) )
-             return -EINVAL;
-
-        // offset unused for now
-               b->block_size = 64*1024;
-        return ENOERR;
-    }
-
-    default:
-        return -EINVAL;
-    }
-}
-
-static Cyg_ErrNo
-ramiodev_set_config( cyg_io_handle_t handle,
-                       cyg_uint32 key,
-                       const void* buf,
-                       cyg_uint32* len)
-{
-
-    switch (key) {
-    default:
-        return -EINVAL;
-    }
-} // ramiodev_set_config()
-
-// get_config/set_config should be added later to provide the other flash
-// operations possible, like erase etc.
-
-BLOCK_DEVIO_TABLE( cyg_io_ramdev1_ops,
-                   &ramiodev_bwrite,
-                   &ramiodev_bread,
-                   0, // no select
-                   &ramiodev_get_config,
-                   &ramiodev_set_config
-    );
-
-
-BLOCK_DEVTAB_ENTRY( cyg_io_ramdev1,
-                    "/dev/ram",
-                    0,
-                    &cyg_io_ramdev1_ops,
-                    &ramiodev_init,
-                    0, // No lookup required
-                    NULL );

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)