* Apply Pali Rohár patch - Add support for device and hw revisions specified in hw pieces - Updated documentation - Fixed problems when unpacking - Ready for mmc and cold flashing
This commit is contained in:
1 parent
04f9369ace
commit
34c8fb057d
5 files changed
+131
-31
No files matched your search
+16
-3
@@ -16,13 +16,26 @@ FILE HEADER
|
|||||||
PIECE HEADER
|
PIECE HEADER
|
||||||
|
|
||||||
1 byte = 0x54 -- piece signature
|
1 byte = 0x54 -- piece signature
|
||||||
6 bytes -- unknown
|
1 byte -- unknown:
|
||||||
|
N800/N810:
|
||||||
|
0x02 - initfs, rootfs, kernel (2007)
|
||||||
|
0x03 - xloader, 2nd, secondary, kernel (DIABLO)
|
||||||
|
N900:
|
||||||
|
0x03 - kernel, rootfs, cmt-2nd, cmt-algo, cmt-mcusw
|
||||||
|
0x04 - xloader, 2nd, secondary
|
||||||
|
0x05 - mmc
|
||||||
|
5 bytes -- unknown (always 0x2e 0x19 0x01 0x01 0x00)
|
||||||
2 bytes -- checksum for the piece contents (xorpair)
|
2 bytes -- checksum for the piece contents (xorpair)
|
||||||
12 bytes -- piece name (first byte is FF if is the last)
|
12 bytes -- piece name (first byte is FF if is the last)
|
||||||
4 bytes -- piece size (big endian)
|
4 bytes -- piece size (big endian)
|
||||||
4 bytes -- unknown
|
4 bytes -- unknown (always 0x00 0x00 0x00 0x00)
|
||||||
block {
|
block {
|
||||||
1 byte -- if (value '1'-'9') { ..there's a comment.. }
|
1 byte -- if (value '1'-'4' or '/') { ..there's a comment.. }
|
||||||
|
'1' - version
|
||||||
|
'2' - device & hw revisions
|
||||||
|
'3' - layout
|
||||||
|
'4' - unknown
|
||||||
|
'/' - unknown
|
||||||
1 byte -- length of comment
|
1 byte -- length of comment
|
||||||
N bytes -- comment
|
N bytes -- comment
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-9
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
* Copyright (C) 2007-2009 pancake <pancake@nopcode.org>
|
* Copyright (C) 2007-2009 pancake <pancake@nopcode.org>
|
||||||
|
* Copyright (C) 2012 Pali Rohár <pali.rohar@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -29,19 +30,20 @@
|
|||||||
*
|
*
|
||||||
* The following table shows this info:
|
* The following table shows this info:
|
||||||
*
|
*
|
||||||
* boot os
|
* cold-flash flash emmc-flash mass-stor pc-suite
|
||||||
* n770 0421:0105 0421:0431
|
* n770 0421:0105 0421:0431
|
||||||
* n800 0421:0431
|
* n800 0421:04c3 0421:0431
|
||||||
* n900 0421:0105 0421:01c7
|
* n810 0421:0105
|
||||||
|
* n900 0421:0106 0421:0105 0421:???? 0421:01c7 0421:01c8
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
struct devices supported_devices[SUPPORTED_DEVICES] = {
|
||||||
{ "FFFF", 0x000, 0x0000, 0x0000 }, // dummy
|
{ "FFFF", 0x0000, 0x0000, FLASH_NORMAL }, // dummy
|
||||||
{ "unkn", 0x421, 0x3f00, 0x0000 }, // probably a development board
|
{ "unkn", 0x0421, 0x3f00, FLASH_NORMAL }, // probably a development board
|
||||||
{ "n770/n810/n900", 0x421, 0x0105, 0x0001 },
|
{ "n800", 0x0421, 0x04c3, FLASH_NORMAL }, // a n800
|
||||||
{ "n800", 0x421, 0x04c3, 0x0001 }, // a n800
|
{ "n770/n810/n900", 0x0421, 0x0105, FLASH_NORMAL },
|
||||||
// { "n900", 0x421, 0x01c7, 0x0001 }, // a pre-production n900
|
{ "n900", 0x0421, 0x0106, FLASH_COLD },
|
||||||
// { "n900", 0x421, 0x0105, 0x0001 }, // a pre-production n900
|
// { "n900", 0x0421, 0x????, FLASH_EMMC },
|
||||||
{ 0 },
|
{ 0 },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|||||||
+79
-14
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
* Copyright (C) 2007-2011 pancake <pancake@youterm.com>
|
* Copyright (C) 2007-2011 pancake <pancake@youterm.com>
|
||||||
|
* Copyright (C) 2011-2012 Pali Rohár <pali.rohar@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -39,6 +40,7 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
off_t off, here;
|
off_t off, here;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
memset(&header, 0, sizeof(header));
|
||||||
header.fd = open(name, O_RDONLY);
|
header.fd = open(name, O_RDONLY);
|
||||||
|
|
||||||
if (header.fd == -1) {
|
if (header.fd == -1) {
|
||||||
@@ -77,9 +79,11 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while(1) {
|
while(1) {
|
||||||
if (read(header.fd, buf, 7)<7)
|
if (read(header.fd, buf, 7)<7) {
|
||||||
|
printf("Next valid header not found\n");
|
||||||
return close(header.fd);
|
return close(header.fd);
|
||||||
if (buf[0] == 0x54 /*&& buf[1] == 0x04*/ && buf[2] == 0x2E && buf[3] == 0x19 && buf[4] == 0x01 && buf[5] == 0x01 && buf[6] == 0x00)
|
}
|
||||||
|
if (buf[0] == 0x54 && buf[2] == 0x2E && buf[3] == 0x19 && buf[4] == 0x01 && buf[5] == 0x01 && buf[6] == 0x00)
|
||||||
break;
|
break;
|
||||||
lseek(header.fd, -6, SEEK_CUR);
|
lseek(header.fd, -6, SEEK_CUR);
|
||||||
++i;
|
++i;
|
||||||
@@ -99,7 +103,7 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
printf(" [eof]\n");
|
printf(" [eof]\n");
|
||||||
break;
|
break;
|
||||||
} else if (v) printf(" %s\n", data);
|
} else if (v) printf(" %s\n", data);
|
||||||
strcpy(header.name, (char *)data);
|
strcpy(header.type, (char *)data);
|
||||||
|
|
||||||
if (v) {
|
if (v) {
|
||||||
printf(" header: ");
|
printf(" header: ");
|
||||||
@@ -108,7 +112,7 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (read(header.fd, buf, 9)<9)
|
if (read(header.fd, buf, 9)<9)
|
||||||
break;
|
return close(header.fd);
|
||||||
memcpy(&header.size, buf,4);
|
memcpy(&header.size, buf,4);
|
||||||
header.size = ntohl(header.size);
|
header.size = ntohl(header.size);
|
||||||
if (v) {
|
if (v) {
|
||||||
@@ -120,23 +124,61 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
// buf[4], buf[5], buf[6], buf[7], buf[8]);
|
// buf[4], buf[5], buf[6], buf[7], buf[8]);
|
||||||
/* XXX this is not ok */
|
/* XXX this is not ok */
|
||||||
//printf("BUF8: %02x\n", buf[8]);
|
//printf("BUF8: %02x\n", buf[8]);
|
||||||
while (buf[8] && buf[8]>'0' && buf[8] < '9') {
|
memset(header.device, 0, sizeof(header.device));
|
||||||
|
memset(header.hwrev, 0, sizeof(header.hwrev));
|
||||||
|
memset(header.version, 0, sizeof(header.version));
|
||||||
|
if (header.layout) {
|
||||||
|
free(header.layout);
|
||||||
|
header.layout = NULL;
|
||||||
|
}
|
||||||
|
while ((buf[8] >= '1' && buf[8] <= '4') || buf[8] == '/') {
|
||||||
if (read(header.fd, data, 1)<1)
|
if (read(header.fd, data, 1)<1)
|
||||||
break;
|
return close(header.fd);
|
||||||
i = data[0];
|
i = data[0];
|
||||||
if (read(header.fd, data, i)<i)
|
if (read(header.fd, data, i)<i)
|
||||||
break;
|
return close(header.fd);
|
||||||
if (data[0]) {
|
if (data[0]) {
|
||||||
if (v) {
|
if (v) {
|
||||||
printf(" version-length: %d\n", i);
|
printf(" subinfo\n");
|
||||||
printf(" version: %s\n", data);
|
printf(" type: ");
|
||||||
|
if (buf[8] == '1') printf("version string");
|
||||||
|
else if (buf[8] == '2') printf("hw revision");
|
||||||
|
else if (buf[8] == '3') printf("layout");
|
||||||
|
else printf("unknown (%c)", buf[8]);
|
||||||
|
printf("\n");
|
||||||
|
printf(" length: %d\n", i);
|
||||||
}
|
}
|
||||||
pdata = data;
|
pdata = data;
|
||||||
pdataend = data+i;
|
pdataend = data+i;
|
||||||
while(pdata<pdataend) {
|
while(pdata<pdataend) {
|
||||||
strcat(header.name, pdata==data?"-":",");
|
if (v) {
|
||||||
strcat(header.name, (char*)pdata);
|
printf(" ");
|
||||||
if (v) printf(" sub-version: %s\n", pdata);
|
if (buf[8] == '1') printf("version");
|
||||||
|
else if (buf[8] == '2' && pdata == data) printf("device");
|
||||||
|
else if (buf[8] == '2' && pdata != data) printf("hw revision");
|
||||||
|
else if (buf[8] == '3') printf("layout");
|
||||||
|
else printf("data");
|
||||||
|
if (buf[8] != '3' && buf[8] != '/')
|
||||||
|
printf(": %s\n", pdata);
|
||||||
|
else
|
||||||
|
printf(": (not printing)\n");
|
||||||
|
}
|
||||||
|
if (buf[8] == '1') {
|
||||||
|
strcpy(header.version, (char *)pdata);
|
||||||
|
} else if (buf[8] == '2' && pdata == data) {
|
||||||
|
strcpy(header.device, (char *)pdata);
|
||||||
|
} else if (buf[8] == '2' && pdata != data) {
|
||||||
|
if (header.hwrev[0] == 0)
|
||||||
|
strcpy(header.hwrev, (char *)pdata);
|
||||||
|
else {
|
||||||
|
strcat(header.hwrev, ",");
|
||||||
|
strcat(header.hwrev, (char *)pdata);
|
||||||
|
}
|
||||||
|
} else if (buf[8] == '3') {
|
||||||
|
if (header.layout) free(header.layout);
|
||||||
|
header.layout = malloc(strlen((char*)pdata)+1);
|
||||||
|
if (header.layout) strcpy(header.layout, (char *)pdata);
|
||||||
|
}
|
||||||
pdata = pdata+strlen((char*)pdata)+1;
|
pdata = pdata+strlen((char*)pdata)+1;
|
||||||
for(;*pdata=='\0' && pdata<pdataend; pdata++);
|
for(;*pdata=='\0' && pdata<pdataend; pdata++);
|
||||||
}
|
}
|
||||||
@@ -145,13 +187,28 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
lseek(header.fd, 1, SEEK_CUR);
|
lseek(header.fd, 1, SEEK_CUR);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
strcpy(header.version, (char *)data);
|
|
||||||
if (read(header.fd, buf+8, 1)<1)
|
if (read(header.fd, buf+8, 1)<1)
|
||||||
break;
|
return close(header.fd);
|
||||||
|
}
|
||||||
|
strcpy(header.name, header.type);
|
||||||
|
if (header.device[0]) {
|
||||||
|
strcat(header.name, "-");
|
||||||
|
strcat(header.name, header.device);
|
||||||
|
}
|
||||||
|
if (header.hwrev[0]) {
|
||||||
|
strcat(header.name, "-");
|
||||||
|
strcat(header.name, header.hwrev);
|
||||||
|
}
|
||||||
|
if (header.version[0]) {
|
||||||
|
strcat(header.name, "-");
|
||||||
|
strcat(header.name, header.version);
|
||||||
}
|
}
|
||||||
/* callback */
|
/* callback */
|
||||||
off = lseek(header.fd, 0, SEEK_CUR);
|
off = lseek(header.fd, 0, SEEK_CUR);
|
||||||
if (v) {
|
if (v) {
|
||||||
|
printf(" version: %s\n", header.version);
|
||||||
|
printf(" device: %s\n", header.device);
|
||||||
|
printf(" hwrev: %s\n", header.hwrev);
|
||||||
printf(" name: %s\n", header.name);
|
printf(" name: %s\n", header.name);
|
||||||
printf(" body-at: 0x%08x\n", (unsigned int)off);
|
printf(" body-at: 0x%08x\n", (unsigned int)off);
|
||||||
}
|
}
|
||||||
@@ -162,6 +219,10 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
printf("==> %s\n", header.name);
|
printf("==> %s\n", header.name);
|
||||||
if (fiasco_callback != NULL) {
|
if (fiasco_callback != NULL) {
|
||||||
fiasco_callback(&header);
|
fiasco_callback(&header);
|
||||||
|
if (header.layout) {
|
||||||
|
free(header.layout);
|
||||||
|
header.layout = NULL;
|
||||||
|
}
|
||||||
free(header.data);
|
free(header.data);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
@@ -171,6 +232,10 @@ int openfiasco(const char *name, const char *piece_grep, int v)
|
|||||||
// XXX dup
|
// XXX dup
|
||||||
lseek(header.fd, off, SEEK_SET);
|
lseek(header.fd, off, SEEK_SET);
|
||||||
lseek(header.fd, header.size, SEEK_CUR);
|
lseek(header.fd, header.size, SEEK_CUR);
|
||||||
|
if (header.layout) {
|
||||||
|
free(header.layout);
|
||||||
|
header.layout = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return close(header.fd);
|
return close(header.fd);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-3
@@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
* 0xFFFF - Open Free Fiasco Firmware Flasher
|
||||||
* Copyright (C) 2007 pancake <pancake@youterm.com>
|
* Copyright (C) 2007 pancake <pancake@youterm.com>
|
||||||
|
* Copyright (C) 2012 Pali Rohár <pali.rohar@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@@ -23,12 +24,16 @@
|
|||||||
/* global structs */
|
/* global structs */
|
||||||
char *pieces[] = {
|
char *pieces[] = {
|
||||||
"xloader", // xloader.bin
|
"xloader", // xloader.bin
|
||||||
"2nd", // 2nd
|
"2nd", // 2nd.bin
|
||||||
"secondary", // secondary.bin
|
"secondary", // secondary.bin
|
||||||
"kernel", // zImage
|
"kernel", // zImage
|
||||||
"initfs", // jffs'd initfs
|
"initfs", // initfs
|
||||||
"rootfs", // 80mB of blob
|
"rootfs", // rootfs
|
||||||
"omap-nand", // 8kB of food for the nand
|
"omap-nand", // 8kB of food for the nand
|
||||||
|
"mmc", // raw eMMC image
|
||||||
|
"cmt-2nd", // cmt-2nd
|
||||||
|
"cmt-algo", // cmt-algo
|
||||||
|
"cmt-mcusw", // cmt-mcusw
|
||||||
"fiasco", // FIASCO IMAGE
|
"fiasco", // FIASCO IMAGE
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|||||||
+17
-2
@@ -62,11 +62,18 @@ struct piece_t {
|
|||||||
char *vers;
|
char *vers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum flash_mode {
|
||||||
|
FLASH_COLD,
|
||||||
|
FLASH_NORMAL,
|
||||||
|
FLASH_EMMC,
|
||||||
|
FLASH_ANY
|
||||||
|
};
|
||||||
|
|
||||||
struct devices {
|
struct devices {
|
||||||
char *name;
|
char *name;
|
||||||
unsigned short vendor_id;
|
unsigned short vendor_id;
|
||||||
unsigned short product_id;
|
unsigned short product_id;
|
||||||
unsigned short flags;
|
enum flash_mode mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define SUPPORTED_DEVICES 6
|
#define SUPPORTED_DEVICES 6
|
||||||
@@ -83,6 +90,10 @@ enum {
|
|||||||
PIECE_INITFS,
|
PIECE_INITFS,
|
||||||
PIECE_ROOTFS,
|
PIECE_ROOTFS,
|
||||||
PIECE_OMAPNAND,
|
PIECE_OMAPNAND,
|
||||||
|
PIECE_MMC,
|
||||||
|
PIECE_CMT_2ND,
|
||||||
|
PIECE_CMT_ALGO,
|
||||||
|
PIECE_CMT_MCUSW,
|
||||||
PIECE_FIASCO,
|
PIECE_FIASCO,
|
||||||
PIECE_LAST
|
PIECE_LAST
|
||||||
};
|
};
|
||||||
@@ -90,11 +101,15 @@ enum {
|
|||||||
struct header_t {
|
struct header_t {
|
||||||
int fd;
|
int fd;
|
||||||
char fwname[128];
|
char fwname[128];
|
||||||
char name[128];
|
|
||||||
char version[128];
|
char version[128];
|
||||||
|
char type[128];
|
||||||
|
char device[16];
|
||||||
|
char hwrev[128];
|
||||||
|
char name[128];
|
||||||
unsigned short hash;
|
unsigned short hash;
|
||||||
unsigned int size;
|
unsigned int size;
|
||||||
unsigned char *data;
|
unsigned char *data;
|
||||||
|
char *layout;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern char *pieces[];
|
extern char *pieces[];
|
||||||
|
|||||||
Reference in new issue
Block a user