summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-03-21 13:01:22 +0000
committerDave Chapman <dave@dchapman.com>2007-03-21 13:01:22 +0000
commitb2b79d57d89e67891663c6a1584d9dfb96dcd36e (patch)
treec4857408052ca1aef73d1347c41df07887c74f1c
parent5efce18257f05a930345c8146b66fd88295855c4 (diff)
downloadrockbox-b2b79d57d89e67891663c6a1584d9dfb96dcd36e.tar.gz
rockbox-b2b79d57d89e67891663c6a1584d9dfb96dcd36e.tar.bz2
rockbox-b2b79d57d89e67891663c6a1584d9dfb96dcd36e.zip
Some more sanity checks - don't recognise the new bootloader installed via the old method as a valid E200
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12878 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/sansapatcher/sansapatcher.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c
index e96b202fed..8f50459f36 100644
--- a/rbutil/sansapatcher/sansapatcher.c
+++ b/rbutil/sansapatcher/sansapatcher.c
@@ -353,6 +353,7 @@ static int sansa_seek_and_read(struct sansa_t* sansa, loff_t pos, unsigned char*
int is_e200(struct sansa_t* sansa)
{
struct mi4header_t mi4header;
+ int ppmi_length;
/* Check partition layout */
@@ -381,6 +382,7 @@ int is_e200(struct sansa_t* sansa)
/* No bootloader header, abort */
return -7;
}
+ ppmi_length = le2int(sectorbuf+4);
/* Check main mi4 file header */
if (sansa_seek_and_read(sansa, sansa->start+PPMI_OFFSET+0x200, sectorbuf, 0x200) < 0) {
@@ -394,11 +396,28 @@ int is_e200(struct sansa_t* sansa)
return -6;
}
- if ((mi4header.mi4size < 100000) &&
- (memcmp(sectorbuf+0x1f8,"RBBL",4)!=0)) {
+ /* Some sanity checks:
+
+ 1) Main MI4 image without RBBL and < 100000 bytes -> old install
+ 2) Main MI4 image with RBBL but no second image -> old install
+ */
+
+ sansa->hasoldbootloader = 0;
+ if (memcmp(sectorbuf+0x1f8,"RBBL",4)==0) {
+ /* Look for an original firmware after the first image */
+ if (sansa_seek_and_read(sansa,
+ sansa->start + PPMI_OFFSET + 0x200 + ppmi_length,
+ sectorbuf, 512) < 0) {
+ return -7;
+ }
+
+ if (get_mi4header(sectorbuf,&mi4header)!=0) {
+ fprintf(stderr,"[ERR] No original firmware found\n");
+ sansa->hasoldbootloader = 1;
+ }
+ } else if (mi4header.mi4size < 100000) {
+ fprintf(stderr,"[ERR] Old bootloader found\n");
sansa->hasoldbootloader = 1;
- } else {
- sansa->hasoldbootloader = 0;
}
return 0;