From 3728cdea3130c62f3d766df040d2cb85f1e6caa4 Mon Sep 17 00:00:00 2001 From: pancake Date: Sat, 16 Jun 2007 05:52:46 +0200 Subject: * Add new command 'nanddump' for the console shell * Avoid dumping non-mtd files because writesize = 0 - Properly close the file when failing * Better doc/pieces documentation --- src/console.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'src/console.c') diff --git a/src/console.c b/src/console.c index f0fbfb4..1f51053 100644 --- a/src/console.c +++ b/src/console.c @@ -33,11 +33,14 @@ void cmd_exit(char *line) void cmd_help(char *line) { printf("connect connects via usb to nolo\n"); + printf("reboot reboots remote host\n"); printf("info shows info of the remote system\n"); printf("linfo shows info of the local system\n"); printf("shell opens a shell (/bin/sh)\n"); printf("badblocks [dev] checks bad blocks on mtd (/dev/mtd1)\n"); printf("dump [dir] dumps the contents of /dev/mtd to dir\n"); + printf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n"); + printf(" f.ex: nanddump /dev/mtd0 0x0 0x4000 xloader.bin 1 1\n"); printf("exit exits the shell\n"); fflush(stdout); } @@ -51,6 +54,24 @@ void cmd_info(char *line) get_rd_flags(); } +void cmd_nanddump(char *line) +{ + char dev[128]; + int from; + int length; + char out[128]; + int ignbb; + int ignoob = -1; + sscanf(line, "%127s 0x%x 0x%x %127s %d %d", &dev, &from, &length, &out, &ignbb, &ignoob); + if (ignoob == -1) { + printf("Invalid arguments.\n"); + printf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n"); + printf(" f.ex: nanddump /dev/mtd0 0x0 0x4000 xloader.bin 1 1\n"); + } else { + nanddump(dev, from, length, out, ignbb, ignoob); + } +} + void cmd_dump(char *line) { if (!line[0]) { @@ -76,12 +97,17 @@ void cmd_connect(char *line) connect_via_usb(); } +void cmd_reboot(char *line) +{ + reboot_board(); +} + void cmd_shell(char *line) { system("/bin/sh"); } -#define CMDS 9 +#define CMDS 11 #define IS_CMD(x) !strcmp(console_commands[i].name, x) #define CALL_CMD(x) console_commands[x].callback((char *)line) #define FOREACH_CMD(x) for(x=0;x ", 8); line[0] = '\0'; fgets(line, 1024, stdin); + if (feof(stdin)) { + write(1, "\n", 1); + break; + } if (line[0]) line[strlen(line)-1] = '\0'; line[1023] = '\0'; } while(console_command(line)); -- cgit v1.2.3