summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpancake <pancake@dazo>2007-06-10 00:38:55 +0200
committerpancake <pancake@dazo>2007-06-10 00:38:55 +0200
commitec71146727eb352c57e0ddb5b38858f4a7780c6b (patch)
treef4b1cdbba1786d5c143c9952b7d641fb2df93acd
parent43d8d4591933762cec4e0f72d434aa47311419d3 (diff)
download0xFFFF-ec71146727eb352c57e0ddb5b38858f4a7780c6b.tar.bz2
* Drop the partition limit. It is calculed with ioctl()
* Query the user to strip or not the dumped pieces * Add new flag '-s' for serial port console
-rw-r--r--src/Makefile2
-rw-r--r--src/dump.c34
-rw-r--r--src/main.c41
-rw-r--r--src/main.h1
-rw-r--r--src/serial.c88
5 files changed, 131 insertions, 35 deletions
diff --git a/src/Makefile b/src/Makefile
index c495117..8f44893 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,5 +1,5 @@
VERSION=0.2
-OBJ=main.o fiasco.o hexdump.o dump.o flash.o
+OBJ=main.o fiasco.o hexdump.o dump.o flash.o serial.o
OBJ+=hash.o fpid.o query.o pieces.o utils.o devices.o
BIN=0xFFFF
CFLAGS+=-DVERSION=\"${VERSION}\" -Wall -g -I .
diff --git a/src/dump.c b/src/dump.c
index 5c29c4a..24aa15d 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -393,28 +393,32 @@ int reverse_extract_pieces(char *dir)
char reply;
chdir(dir);
- nanddump("/dev/mtd0", is_n800()?0x200:0, 0x003600, "xloader.bin");
//rf_extract("/dev/mtd0", is_n800()?0x200:0, 0x003600, "xloader.bin");
- nanddump("/dev/mtd0", 0x004000, 0x01ffff, "secondary.bin");
+ nanddump("/dev/mtd0", is_n800()?0x200:0, 0, "xloader.bin");
//rf_extract("/dev/mtd0", 0x004000, 0x01ffff, "secondary.bin");
- nanddump("/dev/mtd2", 0x000800, 0x200000, "zImage");
+ nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin");
//rf_extract("/dev/mtd2", 0x000800, 0x200000, "zImage");
- nanddump("/dev/mtd3", 0x000000, 0x1D00000, "initfs.jffs2");
+ nanddump("/dev/mtd2", 0x000800, 0, "zImage");
//rf_extract("/dev/mtd3", 0x000000, 0x1D00000, "initfs.jffs2");
- printf("\nWARNING: the rootfs extraction on n800 is known to be buggy! feedback is welcome.\n\n");
- printf("Extract rootfs? (y/N): "); fflush(stdout);
+ nanddump("/dev/mtd3", 0x000000, 0, "initfs.jffs2");
+
+ printf("\n\nExtract rootfs? (y/N): "); fflush(stdout);
read(0, &reply, 1);
if (reply=='y'||reply=='Y') {
- nanddump("/dev/mtd4", 0x000000, 0x6000000, "rootfs.jffs2");
//rf_extract("/dev/mtd4", 0x000000, 0x6000000, "rootfs.jffs2");
- }
- else printf("*** Ignoring rootfs\n");
- rf_strip("xloader.bin");
- rf_strip("secondary.bin");
- rf_strip("zImage");
-// rf_strip("initfs.jffs2"); // do not strip initfs, is 2MB long
- //and can be useful for data recovery
- printf("Identifying extracted files...\n");
+ nanddump("/dev/mtd4", 0x000000, 0, "rootfs.jffs2");
+ } else printf("*** Ignoring rootfs\n");
+
+ printf("\n\nStrip dumped files? (y/N): "); fflush(stdout);
+ read(0, &reply, 1);
+ if (reply=='y'||reply=='Y') {
+ rf_strip("xloader.bin");
+ rf_strip("secondary.bin");
+ rf_strip("zImage");
+ rf_strip("initfs.jffs2");
+ } else printf("*** Ignoring strip\n");
+
+ printf("\nIdentifying extracted files...\n");
printf("%s: xloader\n", fpid_file("xloader.bin"));
printf("%s: secondary.bin\n", fpid_file("secondary.bin"));
printf("%s: zImage\n", fpid_file("zImage"));
diff --git a/src/main.c b/src/main.c
index 1e52da7..c90d502 100644
--- a/src/main.c
+++ b/src/main.c
@@ -68,7 +68,7 @@ char *root_devices[] = {
void show_title()
{
- printf("0xFFFF v%s - The Free Fiasco Firmware Flasher\n", VERSION);
+ printf("0xFFFF v%s // The Free Fiasco Firmware Flasher\n", VERSION);
}
void show_usage()
@@ -76,22 +76,23 @@ void show_usage()
int i;
show_title();
- printf(" -b [arg] boots the kernel with arguments\n");
- printf(" -e [path] dump and extract pieces to path\n");
- printf(" -r [0|1] disable/enable R&D mode\n");
- printf(" -f <flags> set the given RD flags (see '-f help' or 'Flasher_tool_usage' in maemo wiki)\n");
- printf(" -p [[p%%]file] piece-of-firmware %% file-where-this-piece-is\n");
- printf(" -u [fiasco] unpack target fiasco image\n");
- printf(" -U [0|1] disable/enable the usb host mode\n");
- printf(" -h show this help message\n");
- printf(" -i show device information (let standby mode)\n");
- printf(" -I [piece] identify a firmware piece\n");
- printf(" -l list supported usb device ids\n");
- printf(" -d [vid:pid] injects a usb device into the supported list\n");
- printf(" -D [0|1|2] sets the root device to flash (0), mmc (1) or usb (2)\n");
- printf(" -R reboot the omap board\n");
- printf(" -v be verbose and noisy\n");
- printf(" -V show 0xFFFF version information\n");
+ printf(" -b [arg] boots the kernel with arguments\n");
+ printf(" -e [path] dump and extract pieces to path\n");
+ printf(" -r [0|1] disable/enable R&D mode\n");
+ printf(" -f <flags> set the given RD flags (see '-f help' or 'Flasher_tool_usage' in maemo wiki)\n");
+ printf(" -p [[p%%]file] piece-of-firmware %% file-where-this-piece-is\n");
+ printf(" -u [fiasco] unpack target fiasco image\n");
+ printf(" -U [0|1] disable/enable the usb host mode\n");
+ printf(" -s [serial] serial port console (minicom like terminal)\n");
+ printf(" -h show this help message\n");
+ printf(" -i show device information (let standby mode)\n");
+ printf(" -I [piece] identify a firmware piece\n");
+ printf(" -l list supported usb device ids\n");
+ printf(" -d [vid:pid] injects a usb device into the supported list\n");
+ printf(" -D [0|1|2] sets the root device to flash (0), mmc (1) or usb (2)\n");
+ printf(" -R reboot the omap board\n");
+ printf(" -v be verbose and noisy\n");
+ printf(" -V show 0xFFFF version information\n");
printf("Pieces are: ");
for(i=0;pieces[i];i++) printf("%s ", pieces[i]); printf("\n");
// serial port support is not yet done (cold flash is for flashing the 8kB nand)
@@ -111,7 +112,7 @@ int main(int argc, char **argv)
struct usb_device_descriptor udd;
int c;
- while((c = getopt(argc, argv, "p:vVhRu:ib:U:r:e:ld:I:D:f:")) != -1) {
+ while((c = getopt(argc, argv, "p:vVhRu:ib:U:r:e:ld:I:D:f:s:")) != -1) {
switch(c) {
case 'd':
sscanf(optarg, "%04hx:%04hx",
@@ -125,6 +126,8 @@ int main(int argc, char **argv)
case 'e':
reverseto = optarg;
break;
+ case 's':
+ return console(optarg);
case 'f':
if (!strcmp(optarg,"help")) {
printf("* Flags are composed of:\n");
@@ -194,7 +197,7 @@ int main(int argc, char **argv)
{
printf("Usage: 0xFFFF [-hvVRi] [-e path] [-U 0|1] [-p [piece%%]file [-p ...]]\n");
printf(" [-b boot-args] [-I piece [-I ...]] [-u fiasco-image]\n");
- printf(" [-D 0|1|2] [-F rd flags]\n");
+ printf(" [-D 0|1|2] [-F rd flags] [-s serial-dev]\n");
return 1;
}
diff --git a/src/main.h b/src/main.h
index 2ad009e..be9926e 100644
--- a/src/main.h
+++ b/src/main.h
@@ -23,6 +23,7 @@ extern struct usb_dev_handle *dev;
int is_valid_device(struct usb_device_descriptor *udd);
void list_valid_devices();
int usb_device_found(struct usb_device_descriptor *udd);
+int console(const char *device);
extern int verbose;
#define D if (verbose)
diff --git a/src/serial.c b/src/serial.c
new file mode 100644
index 0000000..6be2c47
--- /dev/null
+++ b/src/serial.c
@@ -0,0 +1,88 @@
+/*
+ * Copyright (C) 2007
+ * pancake <pancake@youterm.com>
+ *
+ * 0xFFFF is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 0xFFFF is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with 0xFFFF; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#include "main.h"
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <getopt.h>
+#include <termios.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <getopt.h>
+
+int open_serial(const char *file)
+{
+ struct termios tc;
+ int fd = open (file, O_RDWR | O_SYNC);
+ if (fd < 0) {
+ perror (file);
+ return -1;
+ }
+ // 115200 baud, 8n1, no flow control
+ tcgetattr(fd, &tc);
+ tc.c_iflag = IGNPAR;
+ tc.c_oflag = 0;
+ tc.c_cflag = CS8 | CREAD | CLOCAL;
+ tc.c_lflag = 0;
+ cfsetispeed(&tc, B115200);
+ cfsetospeed(&tc, B115200);
+ tcsetattr(fd, TCSANOW, &tc);
+ return fd;
+}
+
+int console(const char *device)
+{
+ char str[513];
+ int fd = open_serial(device);
+ int pid;
+
+ if (fd == -1) {
+ fprintf(stderr, "Cannot open serial device %s\n", device);
+ return 1;
+ }
+
+ pid = fork();
+ if (pid) {
+ while(1) {
+ fgets(str, 512, stdin);
+ if (write(fd, str, strlen(str)-1) == -1) {
+ perror("write");
+ exit (1);
+ }
+ }
+ } else {
+ char buf;
+ while(1) {
+ if (read(fd, &buf,1) == -1) {
+ perror("read");
+ exit (1);
+ }
+ write(1, &buf, 1);
+ }
+ }
+
+ close(fd);
+
+ return 0;
+}