* 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:
pancake@localhost.localdomain committed 2009-10-17 15:43:39 +02:00
1 parent 3a1053b29e
commit 034b17cef4
4 files changed
+70 -22

No files matched your search

+8 -14
View File
@@ -1,6 +1,6 @@
/*
* 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
* it under the terms of the GNU General Public License as published by
@@ -32,13 +32,16 @@
* boot os
* n770 0421:0105 0421:0431
* n800 0421:0431
* n900 0421:0105 0421:01c7
*
*/
struct devices supported_devices[SUPPORTED_DEVICES] = {
{ "FFFF", 0x000, 0x0000, 0x0000 }, // dummy
{ "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
// { "n900", 0x421, 0x01c7, 0x0001 }, // a pre-production n900
// { "n900", 0x421, 0x0105, 0x0001 }, // a pre-production n900
{ 0 },
{ 0 }
};
@@ -82,21 +85,14 @@ void list_valid_devices()
* structures for the specified device.
* Otherwise returns false (0)
*/
int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_device)
{
struct usb_bus *bus;
int dev_index = 0;
if (usb_find_busses() < 0) {
fprintf(stderr, "\nerror: no usb busses found.\n");
struct usb_bus *bus;
if ((usb_find_busses()<0) || (usb_find_devices()==-1)) {
fprintf(stderr, "\nerror: no usb bus or device found.\n");
exit(1);
} 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) {
struct usb_device *dev = bus->devices;
D printf("bus: \n");
@@ -113,8 +109,6 @@ int usb_device_found(struct usb_device_descriptor *udd, struct devices *it_devic
}
}
}
}
return 0;
}
#endif
+60 -5
View File
@@ -1,6 +1,6 @@
/*
* 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
* 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];
struct nand_oobinfo old_oobinfo;
struct mtd_oob_buf oob = {0, 16, oobbuf};
/* XXX stat1 is never initialized !!! */
struct mtd_ecc_stats stat1, stat2;
mtd_info_t meminfo;
@@ -176,7 +177,6 @@ int check_badblocks(char *mtddev)
fprintf(stderr, "Size %u, flags %u, type 0x%x\n",
meminfo.size, meminfo.flags, (int)meminfo.type);
oob.length = meminfo.oobsize;
for(i = 0; i < meminfo.size; i+= meminfo.writesize) {
@@ -245,6 +245,7 @@ closeall:
}
// 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)
{
unsigned char readbuf[2048];
@@ -453,12 +454,11 @@ __done:
return 1;
}
int is_n800()
static int is_n900()
{
int n800 = 0;
unsigned char buf[4];
FILE *fd = fopen("/dev/mtd0", "rb");
if (!fd) {
fprintf(stderr, "Cannot open /dev/mtd0.\n");
exit(1);
@@ -466,9 +466,23 @@ int is_n800()
fread(buf, 4, 1, fd);
if (!memcmp("\xff\xff\xff\xff", buf, 4))
n800 = 1;
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;
}
@@ -539,9 +553,50 @@ int dump_config()
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)
{
char reply;
if (n900)
return reverse_extract_pieces_n900(dir);
printf("Device detected: n770/n800/n900\n");
chdir(dir);
// TODO: get values from /proc/mtd ???
+1 -1
View File
@@ -29,7 +29,7 @@
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;
unsigned char buf[128];
+1 -2
View File
@@ -56,7 +56,6 @@ extern int verbose;
#define CMD_WRITE 64
#define CMD_QUERY 192
struct piece_t {
char *name;
char *type;
@@ -103,7 +102,7 @@ extern char *modes[];
extern char *root_devices[];
// 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);
void fiasco_data_read(struct header_t *header);
int fiasco_add_eof(int fd);