* Added support for local n900 nand dump * Do some code cleanup, update headers from 2007 to 2009 :) - Fix warning messages
This commit is contained in:
1 parent
3a1053b29e
commit
034b17cef4
4 files changed
+70
-22
No files matched your search
+8
-14
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
* Copyright (C) 2007 pancake <pancake@youterm.com>
|
* Copyright (C) 2007-2009 pancake <pancake@nopcode.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -32,13 +32,16 @@
|
|||||||
* boot os
|
* boot os
|
||||||
* n770 0421:0105 0421:0431
|
* n770 0421:0105 0421:0431
|
||||||
* n800 0421:0431
|
* n800 0421:0431
|
||||||
|
* n900 0421:0105 0421:01c7
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
||||||
{ "FFFF", 0x000, 0x0000, 0x0000 }, // dummy
|
{ "FFFF", 0x000, 0x0000, 0x0000 }, // dummy
|
||||||
{ "unkn", 0x421, 0x3f00, 0x0000 }, // probably a development board
|
{ "unkn", 0x421, 0x3f00, 0x0000 }, // probably a development board
|
||||||
{ "n770/n810", 0x421, 0x0105, 0x0001 }, // my n770
|
{ "n770/n810/n900", 0x421, 0x0105, 0x0001 },
|
||||||
{ "n800", 0x421, 0x04c3, 0x0001 }, // a n800
|
{ "n800", 0x421, 0x04c3, 0x0001 }, // a n800
|
||||||
|
// { "n900", 0x421, 0x01c7, 0x0001 }, // a pre-production n900
|
||||||
|
// { "n900", 0x421, 0x0105, 0x0001 }, // a pre-production n900
|
||||||
{ 0 },
|
{ 0 },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
@@ -82,21 +85,14 @@ void list_valid_devices()
|
|||||||
* structures for the specified device.
|
* structures for the specified device.
|
||||||
* Otherwise returns false (0)
|
* Otherwise returns false (0)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device)
|
int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device)
|
||||||
{
|
{
|
||||||
struct usb_bus *bus;
|
|
||||||
int dev_index = 0;
|
int dev_index = 0;
|
||||||
|
struct usb_bus *bus;
|
||||||
if (usb_find_busses() < 0) {
|
if ((usb_find_busses()<0) || (usb_find_devices()==-1)) {
|
||||||
fprintf(stderr, "\nerror: no usb busses found.\n");
|
fprintf(stderr, "\nerror: no usb bus or device found.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
} else {
|
} else {
|
||||||
switch(usb_find_devices()) {
|
|
||||||
case -1:
|
|
||||||
fprintf(stderr, "\nerror: no devices found.\n");
|
|
||||||
exit(1);
|
|
||||||
default:
|
|
||||||
for (bus = usb_busses; bus; bus = bus->next) {
|
for (bus = usb_busses; bus; bus = bus->next) {
|
||||||
struct usb_device *dev = bus->devices;
|
struct usb_device *dev = bus->devices;
|
||||||
D printf("bus: \n");
|
D printf("bus: \n");
|
||||||
@@ -113,8 +109,6 @@ int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_devic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
+60
-5
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
* Copyright (C) 2007 pancake <pancake@youterm.com>
|
* Copyright (C) 2007-2009 pancake <pancake@nopcode.org>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@@ -161,6 +161,7 @@ int check_badblocks(char *mtddev)
|
|||||||
unsigned char oobbuf[64];
|
unsigned char oobbuf[64];
|
||||||
struct nand_oobinfo old_oobinfo;
|
struct nand_oobinfo old_oobinfo;
|
||||||
struct mtd_oob_buf oob = {0, 16, oobbuf};
|
struct mtd_oob_buf oob = {0, 16, oobbuf};
|
||||||
|
/* XXX stat1 is never initialized !!! */
|
||||||
struct mtd_ecc_stats stat1, stat2;
|
struct mtd_ecc_stats stat1, stat2;
|
||||||
mtd_info_t meminfo;
|
mtd_info_t meminfo;
|
||||||
|
|
||||||
@@ -176,7 +177,6 @@ int check_badblocks(char *mtddev)
|
|||||||
fprintf(stderr, "Size %u, flags %u, type 0x%x\n",
|
fprintf(stderr, "Size %u, flags %u, type 0x%x\n",
|
||||||
meminfo.size, meminfo.flags, (int)meminfo.type);
|
meminfo.size, meminfo.flags, (int)meminfo.type);
|
||||||
|
|
||||||
|
|
||||||
oob.length = meminfo.oobsize;
|
oob.length = meminfo.oobsize;
|
||||||
for(i = 0; i < meminfo.size; i+= meminfo.writesize) {
|
for(i = 0; i < meminfo.size; i+= meminfo.writesize) {
|
||||||
|
|
||||||
@@ -245,6 +245,7 @@ closeall:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX warning ioob is not used
|
// XXX warning ioob is not used
|
||||||
|
// isbl is used to skip bad blocks ?
|
||||||
int nanddump(char *mtddev, unsigned long start_addr, unsigned long length, char *dumpfile, int isbl, int ioob)
|
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];
|
||||||
@@ -453,12 +454,11 @@ __done:
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_n800()
|
static int is_n900()
|
||||||
{
|
{
|
||||||
int n800 = 0;
|
int n800 = 0;
|
||||||
unsigned char buf[4];
|
unsigned char buf[4];
|
||||||
FILE *fd = fopen("/dev/mtd0", "rb");
|
FILE *fd = fopen("/dev/mtd0", "rb");
|
||||||
|
|
||||||
if (!fd) {
|
if (!fd) {
|
||||||
fprintf(stderr, "Cannot open /dev/mtd0.\n");
|
fprintf(stderr, "Cannot open /dev/mtd0.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -466,9 +466,23 @@ int is_n800()
|
|||||||
fread(buf, 4, 1, fd);
|
fread(buf, 4, 1, fd);
|
||||||
if (!memcmp("\xff\xff\xff\xff", buf, 4))
|
if (!memcmp("\xff\xff\xff\xff", buf, 4))
|
||||||
n800 = 1;
|
n800 = 1;
|
||||||
|
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
return n800;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int is_n800()
|
||||||
|
{
|
||||||
|
int n800 = 0;
|
||||||
|
unsigned char buf[4];
|
||||||
|
FILE *fd = fopen("/dev/mtd2", "rb");
|
||||||
|
if (!fd) {
|
||||||
|
fprintf(stderr, "Cannot open /dev/mtd2.\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
fread(buf, 4, 1, fd);
|
||||||
|
if (!memcmp("\xff\xff\xff\xff", buf, 4))
|
||||||
|
n800 = 1;
|
||||||
|
fclose(fd);
|
||||||
return n800;
|
return n800;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,9 +553,50 @@ int dump_config()
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int reverse_extract_pieces_n900(char *dir)
|
||||||
|
{
|
||||||
|
char reply;
|
||||||
|
chdir(dir);
|
||||||
|
printf("Device detected: n900\n");
|
||||||
|
// Some of the values here are probably not correct
|
||||||
|
// I need a firmware to identify if the sizes of the pieces are ok
|
||||||
|
|
||||||
|
nanddump("/dev/mtd0", 0, 0, "xloader.bin", 1, 0); // fix size?
|
||||||
|
nanddump("/dev/mtd1", 0, 0, "config.bin", 1, 0);
|
||||||
|
nanddump("/dev/mtd3", 0, 0, "nolo.bin", 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/mtd5", 0x000000, 0, "rootfs.jffs2", 0,0);
|
||||||
|
} 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("config.bin");
|
||||||
|
rf_strip("nolo.bin");
|
||||||
|
} else printf("*** Ignoring strip\n");
|
||||||
|
|
||||||
|
printf("\nIdentifying extracted files...\n");
|
||||||
|
printf("%s: xloader\n", fpid_file("xloader.bin"));
|
||||||
|
printf("%s: config.bin\n", fpid_file("config.bin"));
|
||||||
|
printf("%s: nolo.bin\n", fpid_file("nolo.bin"));
|
||||||
|
printf("%s: rootfs.jffs2\n", fpid_file("rootfs.jffs2"));
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int reverse_extract_pieces(char *dir)
|
int reverse_extract_pieces(char *dir)
|
||||||
{
|
{
|
||||||
char reply;
|
char reply;
|
||||||
|
|
||||||
|
if (n900)
|
||||||
|
return reverse_extract_pieces_n900(dir);
|
||||||
|
|
||||||
|
printf("Device detected: n770/n800/n900\n");
|
||||||
chdir(dir);
|
chdir(dir);
|
||||||
|
|
||||||
// TODO: get values from /proc/mtd ???
|
// TODO: get values from /proc/mtd ???
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
int (*fiasco_callback)(struct header_t *header) = NULL;
|
int (*fiasco_callback)(struct header_t *header) = NULL;
|
||||||
|
|
||||||
int openfiasco(char *name, char *piece_grep, int v)
|
int openfiasco(char *name, const char *piece_grep, int v)
|
||||||
{
|
{
|
||||||
struct header_t header;
|
struct header_t header;
|
||||||
unsigned char buf[128];
|
unsigned char buf[128];
|
||||||
|
|||||||
+1
-2
@@ -56,7 +56,6 @@ extern int verbose;
|
|||||||
#define CMD_WRITE 64
|
#define CMD_WRITE 64
|
||||||
#define CMD_QUERY 192
|
#define CMD_QUERY 192
|
||||||
|
|
||||||
|
|
||||||
struct piece_t {
|
struct piece_t {
|
||||||
char *name;
|
char *name;
|
||||||
char *type;
|
char *type;
|
||||||
@@ -103,7 +102,7 @@ extern char *modes[];
|
|||||||
extern char *root_devices[];
|
extern char *root_devices[];
|
||||||
|
|
||||||
// fiasco
|
// fiasco
|
||||||
int openfiasco(char *name, char *grep, int v);
|
int openfiasco(char *name, const char *grep, int v);
|
||||||
int fiasco_new(const char *filename, const char *name);
|
int fiasco_new(const char *filename, const char *name);
|
||||||
void fiasco_data_read(struct header_t *header);
|
void fiasco_data_read(struct header_t *header);
|
||||||
int fiasco_add_eof(int fd);
|
int fiasco_add_eof(int fd);
|
||||||
|
|||||||
Reference in new issue
Block a user