summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpancake <pancake@dazo>2007-11-20 04:14:13 +0100
committerpancake <pancake@dazo>2007-11-20 04:14:13 +0100
commit4115aab13d70bbe8300562bcd789cc5bc27c8ded (patch)
tree8bd7531d26dd35a45d5a52a5574bc1693261c168
parentfbdac811fc7694ca936607590cb19fd930528f5e (diff)
download0xFFFF-0.3.1.tar.bz2
- Import patches from Osvaldo Santana * Fix build on gcc 4 * Fix nanddump call definition (ignore oob added) * Fixed some stupid bugs with -pedantic -std=c990.3.1
release 0.3.1
-rw-r--r--src/Makefile1
-rw-r--r--src/console.c15
-rw-r--r--src/devices.c2
-rw-r--r--src/dump.c15
-rw-r--r--src/fiasco.c10
-rw-r--r--src/hash.c2
-rw-r--r--src/hash.h2
-rw-r--r--src/main.c31
-rw-r--r--src/main.h27
-rw-r--r--src/pieces.c2
-rw-r--r--src/utils.c10
11 files changed, 71 insertions, 46 deletions
diff --git a/src/Makefile b/src/Makefile
index d8547ae..1ac4058 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,6 +3,7 @@ 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 console.o
BIN=0xFFFF
CFLAGS+=-DVERSION=\"${VERSION}\" -Wall -g -I .
+CFLAGS+=-pedantic -std=c99
USBOBJ=../libusb/error.o ../libusb/usb.o ../libusb/descriptors.o
USBOBJ+=../libusb/linux.o ## XXX not portable
diff --git a/src/console.c b/src/console.c
index 28bbc2d..3aa406c 100644
--- a/src/console.c
+++ b/src/console.c
@@ -60,14 +60,17 @@ void cmd_nanddump(char *line)
char out[128];
int ignbb;
int ignoob = -1;
- sscanf(line, "%127s 0x%x 0x%x %127s %d %d", &dev, &from, &length, &out, &ignbb, &ignoob);
+
+ sscanf(line, "%127s 0x%x 0x%x %127s %d %d",
+ (char *)&dev, (unsigned int*)&from, (unsigned int *)&length,
+ (char *)&out, (int*)&ignbb, (int *)&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 {
+ eprintf("Invalid arguments.\n");
+ eprintf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n");
+ eprintf(" 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)
diff --git a/src/devices.c b/src/devices.c
index 66fddee..6bfe624 100644
--- a/src/devices.c
+++ b/src/devices.c
@@ -56,7 +56,7 @@ int is_valid_device(struct usb_device_descriptor *udd)
for(i=1 ; ptr.vendor_id; ptr = supported_devices[++i])
if ((udd->idVendor == ptr.vendor_id)
&& (udd->idProduct == ptr.product_id)) {
- D printf("found %s\n", supported_devices[i]);
+ D printf("found %s\n", supported_devices[i].name);
return i;
}
diff --git a/src/dump.c b/src/dump.c
index f0705ea..83a1ce5 100644
--- a/src/dump.c
+++ b/src/dump.c
@@ -242,7 +242,8 @@ closeall:
return 1;
}
-int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl)
+// XXX warning ioob is not used
+int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl, int ioob)
{
unsigned char readbuf[2048];
int oobinfochanged = 0 ;
@@ -543,20 +544,20 @@ int reverse_extract_pieces(char *dir)
// TODO: get values from /proc/mtd ???
//rf_extract("/dev/mtd0", is_n800()?0x200:0, 0x003600, "xloader.bin");
- nanddump("/dev/mtd0", is_n800()?0x200:0, 0x4000, "xloader.bin", 1); // 0x3600 size?
+ nanddump("/dev/mtd0", is_n800()?0x200:0, 0x4000, "xloader.bin", 1,0); // 0x3600 size?
//rf_extract("/dev/mtd0", 0x004000, 0x01ffff, "secondary.bin");
- nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin", 1);
- nanddump("/dev/mtd1", 0, 0, "config.bin", 0);
+ nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin", 1,0);
+ nanddump("/dev/mtd1", 0, 0, "config.bin", 0,0);
//rf_extract("/dev/mtd2", 0x000800, 0x200000, "zImage");
- nanddump("/dev/mtd2", 0x000800, 0, "zImage", 0);
+ nanddump("/dev/mtd2", 0x000800, 0, "zImage", 0,0);
//rf_extract("/dev/mtd3", 0x000000, 0x1D00000, "initfs.jffs2");
- nanddump("/dev/mtd3", 0x000000, 0, "initfs.jffs2", 0);
+ nanddump("/dev/mtd3", 0x000000, 0, "initfs.jffs2", 0,0);
printf("\n\nExtract rootfs? (y/N): "); fflush(stdout);
read(0, &reply, 1);
if (reply=='y'||reply=='Y') {
//rf_extract("/dev/mtd4", 0x000000, 0x6000000, "rootfs.jffs2");
- nanddump("/dev/mtd4", 0x000000, 0, "rootfs.jffs2", 0);
+ nanddump("/dev/mtd4", 0x000000, 0, "rootfs.jffs2", 0,0);
} else printf("*** Ignoring rootfs\n");
printf("\n\nStrip dumped files? (y/N): "); fflush(stdout);
diff --git a/src/fiasco.c b/src/fiasco.c
index f993a11..91b7481 100644
--- a/src/fiasco.c
+++ b/src/fiasco.c
@@ -60,8 +60,8 @@ int openfiasco(char *name)
read(header.fd, buf, namelen);
printf("Fiasco version: %2d\n", buf[3]);
- strcpy(header.fwname, buf+6);
- for(i=6;i<namelen;i+=strlen(buf+i)+1)
+ strcpy(header.fwname, (char *)buf+6);
+ for(i=6;i<namelen;i+=strlen((char *)(buf+i))+1)
printf("Name: %s\n", buf+i);
/* walk the tree */
@@ -86,7 +86,7 @@ int openfiasco(char *name)
printf(" [eof]\n");
break;
} else printf(" %s\n", data);
- strcpy(header.name, data);
+ strcpy(header.name, (char *)data);
if (read(header.fd, buf, 9)<9)
break;
@@ -106,7 +106,7 @@ int openfiasco(char *name)
break;
if (data[0])
printf(" version: %s\n", data);
- strcpy(header.version, data);
+ strcpy(header.version, (char *)data);
if (read(header.fd, buf+8, 1)<1)
break;
}
@@ -126,7 +126,7 @@ int openfiasco(char *name)
void fiasco_data_read(struct header_t *header)
{
- header->data = (char *)malloc(header->size);
+ header->data = (unsigned char *)malloc(header->size);
if (header->data == NULL) {
printf("Cannot alloc %d bytes\n", header->size);
return;
diff --git a/src/hash.c b/src/hash.c
index 066eacc..77b4159 100644
--- a/src/hash.c
+++ b/src/hash.c
@@ -27,7 +27,7 @@ usho do_hash(usho *b, int len)
return result;
}
-usho do_hash_file(char *filename)
+usho do_hash_file(const char *filename)
{
unsigned char buf[BSIZE];
FILE *fd = fopen(filename, "r");
diff --git a/src/hash.h b/src/hash.h
index b7de788..363d5d4 100644
--- a/src/hash.h
+++ b/src/hash.h
@@ -5,6 +5,6 @@
#define BSIZE 0x20000
usho do_hash(usho *b, int len);
-usho do_hash_file(char *filename);
+usho do_hash_file(const char *filename);
#endif
diff --git a/src/main.c b/src/main.c
index a029e40..999eaf7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,27 +41,27 @@ int info = 0;
/* global structs */
char *pieces[] = {
- "xloader", // xloader.bin
- "2nd", // 2nd
- "secondary", // secondary.bin
- "kernel", // zImage
- "initfs", // jffs'd initfs
- "rootfs", // 80mB of blob
- "omap-nand", // 8kB of food for the nand
- NULL
+ "xloader", // xloader.bin
+ "2nd", // 2nd
+ "secondary", // secondary.bin
+ "kernel", // zImage
+ "initfs", // jffs'd initfs
+ "rootfs", // 80mB of blob
+ "omap-nand", // 8kB of food for the nand
+ NULL
};
char *modes[]={
- "host",
- "peripheral",
- NULL
+ "host",
+ "peripheral",
+ NULL
};
char *root_devices[] = {
- "flash",
- "mmc",
- "usb",
- NULL
+ "flash",
+ "mmc",
+ "usb",
+ NULL
};
@@ -132,6 +132,7 @@ int fiasco_flash(char *file)
openfiasco( file );
printf("\nTODO: Implement the fiasco flashing here.\n");
+ return -1;
}
int connect_via_usb()
diff --git a/src/main.h b/src/main.h
index 7da0e31..2fbd15a 100644
--- a/src/main.h
+++ b/src/main.h
@@ -2,6 +2,8 @@
#ifndef _INCLUDE_MAIN_H_
#define _INCLUDE_MAIN_H_
+#include "hash.h"
+
#define _FILE_OFFSET_BITS 64
#define _GNU_SOURCE
@@ -17,7 +19,12 @@ unsigned long get_file_size(char *file);
void progressbar(unsigned long long part, unsigned long long total);
const char *fpid_file(const char *filename);
int add_piece(char *piece);
+void eprintf(const char *format, ...);
+#include <limits.h>
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
#include <usb.h>
extern struct usb_device *device;
@@ -74,6 +81,16 @@ enum {
PIECE_LAST
};
+struct header_t {
+ int fd;
+ char fwname[128];
+ char name[128];
+ char version[128];
+ unsigned short hash;
+ unsigned int size;
+ unsigned char *data;
+};
+
extern char *pieces[];
extern char *modes[];
extern char *root_devices[];
@@ -86,15 +103,7 @@ int fiasco_add_eof(int fd);
extern void (*fiasco_callback)(struct header_t *header);
int fiasco_add(int fd, const char *name, const char *file, const char *version);
int fiasco_pack(int optind, char *argv[]);
-struct header_t {
- int fd;
- char fwname[128];
- char name[128];
- char version[128];
- unsigned short hash;
- unsigned int size;
- unsigned char *data;
-};
+int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl, int ioob);
#endif
diff --git a/src/pieces.c b/src/pieces.c
index cfa217d..16cacce 100644
--- a/src/pieces.c
+++ b/src/pieces.c
@@ -55,7 +55,7 @@ int add_piece(char *piece)
pcs[pcs_n].vers = NULL; // TODO version string not yet supported
} else {
/*/ autodetect piece type */
- pcs[pcs_n].type = fpid_file(piece);
+ pcs[pcs_n].type = (char *)fpid_file(piece);
if (pcs[pcs_n].type == NULL) {
printf("Use -p [piece]:[file]\n");
printf("Pieces: ");
diff --git a/src/utils.c b/src/utils.c
index fe74e16..e694a0f 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -20,6 +20,7 @@
#include <usb.h>
#include <stdio.h>
#include <string.h>
+#include <stdarg.h>
#include <stdlib.h>
unsigned long get_file_size(char *file)
@@ -53,3 +54,12 @@ void progressbar(unsigned long long part, unsigned long long total)
printf("]\r");
fflush(stdout);
}
+
+void eprintf(const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ vfprintf(stderr, format, ap);
+ va_end(ap);
+ //fflush(stderr); // XXX CRASH?!? stdin here?!?!?
+}