- Import patches from Osvaldo Santana * Fix build on gcc 4 * Fix nanddump call definition (ignore oob added) * Fixed some stupid bugs with -pedantic -std=c99
release 0.3.1
This commit is contained in:
1 parent
fbdac811fc
commit
4115aab13d
11 files changed
+56
-31
No files matched your search
@@ -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
|
||||
|
||||
|
||||
+9
-6
@@ -60,15 +60,18 @@ 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)
|
||||
{
|
||||
|
||||
+1
-1
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+8
-7
@@ -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);
|
||||
|
||||
+5
-5
@@ -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;
|
||||
|
||||
+1
-1
@@ -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");
|
||||
|
||||
+1
-1
@@ -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
|
||||
@@ -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()
|
||||
|
||||
+18
-9
@@ -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
|
||||
+1
-1
@@ -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: ");
|
||||
|
||||
+10
@@ -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?!?!?
|
||||
}
|
||||
Reference in new issue
Block a user