From 564d249e66f56e962903659e71d4b5be17112388 Mon Sep 17 00:00:00 2001 From: Dave Chapman Date: Fri, 3 Aug 2007 02:12:32 +0000 Subject: Detect and reject 2nd Gen Nanos when scanning for ipods, instead of failing quietly. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14152 a1c6a512-1295-4272-9138-f99709370657 --- rbutil/ipodpatcher/ipodpatcher.c | 24 ++++++++++++++++++++++-- rbutil/ipodpatcher/main.c | 9 +++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) (limited to 'rbutil/ipodpatcher') diff --git a/rbutil/ipodpatcher/ipodpatcher.c b/rbutil/ipodpatcher/ipodpatcher.c index 7459b5da87..40285aaaa5 100644 --- a/rbutil/ipodpatcher/ipodpatcher.c +++ b/rbutil/ipodpatcher/ipodpatcher.c @@ -1038,9 +1038,20 @@ int read_directory(struct ipod_t* ipod) } p = sectorbuf + x; - + + /* A hack to detect 2nd gen Nanos - maybe there is a better way? */ + if (p[0] == 0) + { + n=ipod_read(ipod, sectorbuf, ipod->sector_size); + if (n < 0) { + fprintf(stderr,"[ERR] Read of directory failed.\n"); + return -1; + } + p = sectorbuf; + } + while ((ipod->nimages < MAX_IMAGES) && (p < (sectorbuf + x + 400)) && - (memcmp(p,"!ATA",4)==0)) { + ((memcmp(p,"!ATA",4)==0) || (memcmp(p,"DNAN",4)==0))) { p+=4; if (memcmp(p,"soso",4)==0) { ipod->ipod_directory[ipod->nimages].ftype=FTYPE_OSOS; @@ -1220,6 +1231,15 @@ int getmodel(struct ipod_t* ipod, int ipod_version) #ifdef WITH_BOOTOBJS ipod->bootloader = ipodvideo; ipod->bootloader_len = LEN_ipodvideo; +#endif + break; + case 0x100: + ipod->modelstr="2nd Generation Nano"; + ipod->modelnum = 0; + ipod->targetname = NULL; +#ifdef WITH_BOOTOBJS + ipod->bootloader = NULL; + ipod->bootloader_len = 0; #endif break; default: diff --git a/rbutil/ipodpatcher/main.c b/rbutil/ipodpatcher/main.c index 24938931d6..c47063cba8 100644 --- a/rbutil/ipodpatcher/main.c +++ b/rbutil/ipodpatcher/main.c @@ -348,6 +348,15 @@ int main(int argc, char* argv[]) printf("[INFO] Ipod model: %s (\"%s\")\n",ipod.modelstr, ipod.macpod ? "macpod" : "winpod"); + if (ipod.ipod_directory[0].vers == 0x10000) { + fprintf(stderr,"[ERR] *** ipodpatcher does not support the 2nd Generation Nano! ***\n"); +#ifdef WITH_BOOTOBJS + printf("Press ENTER to exit ipodpatcher :"); + fgets(yesno,4,stdin); +#endif + return 0; + } + if (ipod.macpod) { print_macpod_warning(); } -- cgit v1.2.3