- 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
+71
-46
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
|
OBJ+=hash.o fpid.o query.o pieces.o utils.o devices.o console.o
|
||||||
BIN=0xFFFF
|
BIN=0xFFFF
|
||||||
CFLAGS+=-DVERSION=\"${VERSION}\" -Wall -g -I .
|
CFLAGS+=-DVERSION=\"${VERSION}\" -Wall -g -I .
|
||||||
|
CFLAGS+=-pedantic -std=c99
|
||||||
USBOBJ=../libusb/error.o ../libusb/usb.o ../libusb/descriptors.o
|
USBOBJ=../libusb/error.o ../libusb/usb.o ../libusb/descriptors.o
|
||||||
USBOBJ+=../libusb/linux.o ## XXX not portable
|
USBOBJ+=../libusb/linux.o ## XXX not portable
|
||||||
|
|
||||||
|
|||||||
+9
-6
@@ -60,14 +60,17 @@ void cmd_nanddump(char *line)
|
|||||||
char out[128];
|
char out[128];
|
||||||
int ignbb;
|
int ignbb;
|
||||||
int ignoob = -1;
|
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) {
|
if (ignoob == -1) {
|
||||||
printf("Invalid arguments.\n");
|
eprintf("Invalid arguments.\n");
|
||||||
printf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n");
|
eprintf("nanddump [dev] [start] [len] [out] [ignore-badblocks] [ignore-oob]\n");
|
||||||
printf(" f.ex: nanddump /dev/mtd0 0x0 0x4000 xloader.bin 1 1\n");
|
eprintf(" f.ex: nanddump /dev/mtd0 0x0 0x4000 xloader.bin 1 1\n");
|
||||||
} else {
|
} else
|
||||||
nanddump(dev, from, length, out, ignbb, ignoob);
|
nanddump(dev, from, length, out, ignbb, ignoob);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmd_dump(char *line)
|
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])
|
for(i=1 ; ptr.vendor_id; ptr = supported_devices[++i])
|
||||||
if ((udd->idVendor == ptr.vendor_id)
|
if ((udd->idVendor == ptr.vendor_id)
|
||||||
&& (udd->idProduct == ptr.product_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;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-7
@@ -242,7 +242,8 @@ closeall:
|
|||||||
return 1;
|
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];
|
unsigned char readbuf[2048];
|
||||||
int oobinfochanged = 0 ;
|
int oobinfochanged = 0 ;
|
||||||
@@ -543,20 +544,20 @@ int reverse_extract_pieces(char *dir)
|
|||||||
// TODO: get values from /proc/mtd ???
|
// TODO: get values from /proc/mtd ???
|
||||||
|
|
||||||
//rf_extract("/dev/mtd0", is_n800()?0x200:0, 0x003600, "xloader.bin");
|
//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");
|
//rf_extract("/dev/mtd0", 0x004000, 0x01ffff, "secondary.bin");
|
||||||
nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin", 1);
|
nanddump("/dev/mtd0", 0x004000, 0, "secondary.bin", 1,0);
|
||||||
nanddump("/dev/mtd1", 0, 0, "config.bin", 0);
|
nanddump("/dev/mtd1", 0, 0, "config.bin", 0,0);
|
||||||
//rf_extract("/dev/mtd2", 0x000800, 0x200000, "zImage");
|
//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");
|
//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);
|
printf("\n\nExtract rootfs? (y/N): "); fflush(stdout);
|
||||||
read(0, &reply, 1);
|
read(0, &reply, 1);
|
||||||
if (reply=='y'||reply=='Y') {
|
if (reply=='y'||reply=='Y') {
|
||||||
//rf_extract("/dev/mtd4", 0x000000, 0x6000000, "rootfs.jffs2");
|
//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");
|
} else printf("*** Ignoring rootfs\n");
|
||||||
|
|
||||||
printf("\n\nStrip dumped files? (y/N): "); fflush(stdout);
|
printf("\n\nStrip dumped files? (y/N): "); fflush(stdout);
|
||||||
|
|||||||
+5
-5
@@ -60,8 +60,8 @@ int openfiasco(char *name)
|
|||||||
read(header.fd, buf, namelen);
|
read(header.fd, buf, namelen);
|
||||||
|
|
||||||
printf("Fiasco version: %2d\n", buf[3]);
|
printf("Fiasco version: %2d\n", buf[3]);
|
||||||
strcpy(header.fwname, buf+6);
|
strcpy(header.fwname, (char *)buf+6);
|
||||||
for(i=6;i<namelen;i+=strlen(buf+i)+1)
|
for(i=6;i<namelen;i+=strlen((char *)(buf+i))+1)
|
||||||
printf("Name: %s\n", buf+i);
|
printf("Name: %s\n", buf+i);
|
||||||
|
|
||||||
/* walk the tree */
|
/* walk the tree */
|
||||||
@@ -86,7 +86,7 @@ int openfiasco(char *name)
|
|||||||
printf(" [eof]\n");
|
printf(" [eof]\n");
|
||||||
break;
|
break;
|
||||||
} else printf(" %s\n", data);
|
} else printf(" %s\n", data);
|
||||||
strcpy(header.name, data);
|
strcpy(header.name, (char *)data);
|
||||||
|
|
||||||
if (read(header.fd, buf, 9)<9)
|
if (read(header.fd, buf, 9)<9)
|
||||||
break;
|
break;
|
||||||
@@ -106,7 +106,7 @@ int openfiasco(char *name)
|
|||||||
break;
|
break;
|
||||||
if (data[0])
|
if (data[0])
|
||||||
printf(" version: %s\n", data);
|
printf(" version: %s\n", data);
|
||||||
strcpy(header.version, data);
|
strcpy(header.version, (char *)data);
|
||||||
if (read(header.fd, buf+8, 1)<1)
|
if (read(header.fd, buf+8, 1)<1)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -126,7 +126,7 @@ int openfiasco(char *name)
|
|||||||
|
|
||||||
void fiasco_data_read(struct header_t *header)
|
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) {
|
if (header->data == NULL) {
|
||||||
printf("Cannot alloc %d bytes\n", header->size);
|
printf("Cannot alloc %d bytes\n", header->size);
|
||||||
return;
|
return;
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ usho do_hash(usho *b, int len)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
usho do_hash_file(char *filename)
|
usho do_hash_file(const char *filename)
|
||||||
{
|
{
|
||||||
unsigned char buf[BSIZE];
|
unsigned char buf[BSIZE];
|
||||||
FILE *fd = fopen(filename, "r");
|
FILE *fd = fopen(filename, "r");
|
||||||
|
|||||||
+1
-1
@@ -5,6 +5,6 @@
|
|||||||
#define BSIZE 0x20000
|
#define BSIZE 0x20000
|
||||||
|
|
||||||
usho do_hash(usho *b, int len);
|
usho do_hash(usho *b, int len);
|
||||||
usho do_hash_file(char *filename);
|
usho do_hash_file(const char *filename);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+16
-15
@@ -41,27 +41,27 @@ int info = 0;
|
|||||||
|
|
||||||
/* global structs */
|
/* global structs */
|
||||||
char *pieces[] = {
|
char *pieces[] = {
|
||||||
"xloader", // xloader.bin
|
"xloader", // xloader.bin
|
||||||
"2nd", // 2nd
|
"2nd", // 2nd
|
||||||
"secondary", // secondary.bin
|
"secondary", // secondary.bin
|
||||||
"kernel", // zImage
|
"kernel", // zImage
|
||||||
"initfs", // jffs'd initfs
|
"initfs", // jffs'd initfs
|
||||||
"rootfs", // 80mB of blob
|
"rootfs", // 80mB of blob
|
||||||
"omap-nand", // 8kB of food for the nand
|
"omap-nand", // 8kB of food for the nand
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
char *modes[]={
|
char *modes[]={
|
||||||
"host",
|
"host",
|
||||||
"peripheral",
|
"peripheral",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
char *root_devices[] = {
|
char *root_devices[] = {
|
||||||
"flash",
|
"flash",
|
||||||
"mmc",
|
"mmc",
|
||||||
"usb",
|
"usb",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -132,6 +132,7 @@ int fiasco_flash(char *file)
|
|||||||
openfiasco( file );
|
openfiasco( file );
|
||||||
|
|
||||||
printf("\nTODO: Implement the fiasco flashing here.\n");
|
printf("\nTODO: Implement the fiasco flashing here.\n");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int connect_via_usb()
|
int connect_via_usb()
|
||||||
|
|||||||
+18
-9
@@ -2,6 +2,8 @@
|
|||||||
#ifndef _INCLUDE_MAIN_H_
|
#ifndef _INCLUDE_MAIN_H_
|
||||||
#define _INCLUDE_MAIN_H_
|
#define _INCLUDE_MAIN_H_
|
||||||
|
|
||||||
|
#include "hash.h"
|
||||||
|
|
||||||
#define _FILE_OFFSET_BITS 64
|
#define _FILE_OFFSET_BITS 64
|
||||||
#define _GNU_SOURCE
|
#define _GNU_SOURCE
|
||||||
|
|
||||||
@@ -17,7 +19,12 @@ unsigned long get_file_size(char *file);
|
|||||||
void progressbar(unsigned long long part, unsigned long long total);
|
void progressbar(unsigned long long part, unsigned long long total);
|
||||||
const char *fpid_file(const char *filename);
|
const char *fpid_file(const char *filename);
|
||||||
int add_piece(char *piece);
|
int add_piece(char *piece);
|
||||||
|
void eprintf(const char *format, ...);
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
|
#ifndef PATH_MAX
|
||||||
|
#define PATH_MAX 4096
|
||||||
|
#endif
|
||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
|
|
||||||
extern struct usb_device *device;
|
extern struct usb_device *device;
|
||||||
@@ -74,6 +81,16 @@ enum {
|
|||||||
PIECE_LAST
|
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 *pieces[];
|
||||||
extern char *modes[];
|
extern char *modes[];
|
||||||
extern char *root_devices[];
|
extern char *root_devices[];
|
||||||
@@ -86,15 +103,7 @@ int fiasco_add_eof(int fd);
|
|||||||
extern void (*fiasco_callback)(struct header_t *header);
|
extern void (*fiasco_callback)(struct header_t *header);
|
||||||
int fiasco_add(int fd, const char *name, const char *file, const char *version);
|
int fiasco_add(int fd, const char *name, const char *file, const char *version);
|
||||||
int fiasco_pack(int optind, char *argv[]);
|
int fiasco_pack(int optind, char *argv[]);
|
||||||
struct header_t {
|
int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl, int ioob);
|
||||||
int fd;
|
|
||||||
char fwname[128];
|
|
||||||
char name[128];
|
|
||||||
char version[128];
|
|
||||||
unsigned short hash;
|
|
||||||
unsigned int size;
|
|
||||||
unsigned char *data;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
+1
-1
@@ -55,7 +55,7 @@ int add_piece(char *piece)
|
|||||||
pcs[pcs_n].vers = NULL; // TODO version string not yet supported
|
pcs[pcs_n].vers = NULL; // TODO version string not yet supported
|
||||||
} else {
|
} else {
|
||||||
/*/ autodetect piece type */
|
/*/ autodetect piece type */
|
||||||
pcs[pcs_n].type = fpid_file(piece);
|
pcs[pcs_n].type = (char *)fpid_file(piece);
|
||||||
if (pcs[pcs_n].type == NULL) {
|
if (pcs[pcs_n].type == NULL) {
|
||||||
printf("Use -p [piece]:[file]\n");
|
printf("Use -p [piece]:[file]\n");
|
||||||
printf("Pieces: ");
|
printf("Pieces: ");
|
||||||
|
|||||||
+10
@@ -20,6 +20,7 @@
|
|||||||
#include <usb.h>
|
#include <usb.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
unsigned long get_file_size(char *file)
|
unsigned long get_file_size(char *file)
|
||||||
@@ -53,3 +54,12 @@ void progressbar(unsigned long long part, unsigned long long total)
|
|||||||
printf("]\r");
|
printf("]\r");
|
||||||
fflush(stdout);
|
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