aboutsummaryrefslogtreecommitdiff
path: root/src/ecosboard.c
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-12-01 12:55:07 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-12-01 12:55:07 +0000
commit6e2dbdc3f715a519874860f3efbab7bcbe6d4ef9 (patch)
treea89bf3287be4906c03650b73218470b3d11097a0 /src/ecosboard.c
parenta28eaa85f73759bb189a46308642502c9fa5aa4b (diff)
downloadriscv-openocd-6e2dbdc3f715a519874860f3efbab7bcbe6d4ef9.zip
riscv-openocd-6e2dbdc3f715a519874860f3efbab7bcbe6d4ef9.tar.gz
riscv-openocd-6e2dbdc3f715a519874860f3efbab7bcbe6d4ef9.tar.bz2
wip
git-svn-id: svn://svn.berlios.de/openocd/trunk@1195 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/ecosboard.c')
-rw-r--r--src/ecosboard.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/ecosboard.c b/src/ecosboard.c
index 8195943..b37e169 100644
--- a/src/ecosboard.c
+++ b/src/ecosboard.c
@@ -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[];
@@ -930,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)
+{
+ int del;
+ if (argc != 1)
+ {
+ return JIM_ERR;
+ }
+
+ format();
+}
+
+
static int
zylinjtag_Jim_Command_rm(Jim_Interp *interp,
int argc,
@@ -1310,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();