diff options
| author | Dominik Wenger <domonoky@googlemail.com> | 2007-05-03 20:07:57 +0000 |
|---|---|---|
| committer | Dominik Wenger <domonoky@googlemail.com> | 2007-05-03 20:07:57 +0000 |
| commit | dde262b58a8bb908278179e916e0d91068d6987f (patch) | |
| tree | 659519211ddb52e4dfd40d71187fbeb171313aa7 /rbutil/bootloaders.cpp | |
| parent | 39939bb137bea1c149db5ff0edb1dd0dd1d3d596 (diff) | |
| download | rockbox-dde262b58a8bb908278179e916e0d91068d6987f.zip rockbox-dde262b58a8bb908278179e916e0d91068d6987f.tar.gz rockbox-dde262b58a8bb908278179e916e0d91068d6987f.tar.bz2 rockbox-dde262b58a8bb908278179e916e0d91068d6987f.tar.xz | |
Support for Sansa E200 in rbutil
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13315 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'rbutil/bootloaders.cpp')
| -rwxr-xr-x | rbutil/bootloaders.cpp | 105 |
1 files changed, 103 insertions, 2 deletions
diff --git a/rbutil/bootloaders.cpp b/rbutil/bootloaders.cpp index 274264c..039451f 100755 --- a/rbutil/bootloaders.cpp +++ b/rbutil/bootloaders.cpp @@ -26,8 +26,7 @@ #include "installlog.h" -// for ipodpatcher -int verbose = 0; +int verbose =0; // reserves memory for ipodpatcher bool initIpodpatcher() { @@ -162,6 +161,108 @@ bool ipodpatcher(int mode,wxString bootloadername) return true; } +// reserves memory for sansapatcher +bool initSansaPatcher() +{ + if (sansa_alloc_buffer(§orbuf,BUFFER_SIZE) < 0) return true; + else return false; +} + + +// sansainstallation +bool sansapatcher(int mode,wxString bootloadername) +{ + wxString src,dest,buf; + + struct sansa_t sansa; + + int n = sansa_scan(&sansa); + if (n == 0) + { + ERR_DIALOG(wxT("[ERR] No Sansa found."), wxT("Scanning for Sansa")); + return false; + } + if (n > 1) + { + ERR_DIALOG(wxT("[ERR] to many Sansa found."), wxT("Scanning for Sansa")); + return false; + } + + // downloading files + if(mode == BOOTLOADER_ADD) + { + src.Printf(wxT("%s/sandisk-sansa/e200/%s"),gv->bootloader_url.c_str(),bootloadername.c_str()); + dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s"), + gv->stdpaths->GetUserDataDir().c_str(),bootloadername.c_str()); + if ( DownloadURL(src, dest) ) + { + wxRemoveFile(dest); + buf.Printf(wxT("Unable to download %s"), src.c_str() ); + ERR_DIALOG(buf, wxT("Download")); + return false; + } + } + + if (sansa_open(&sansa, 0) < 0) + { + ERR_DIALOG(wxT("[ERR] could not open sansa"), wxT("open Sansa")); + return false; + } + + if (sansa_read_partinfo(&sansa,0) < 0) + { + ERR_DIALOG(wxT("[ERR] could not read partitiontable"), wxT("reading partitiontable")); + return false; + } + + int i = is_e200(&sansa); + if (i < 0) { + ERR_DIALOG(wxT("[ERR] Disk is not an E200 (%d), aborting.\n"), wxT("Checking Disk")); + return false; + } + + if (sansa.hasoldbootloader) + { + ERR_DIALOG(wxT("[ERR] ************************************************************************\n" + "[ERR] *** OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n" + "[ERR] *** You must reinstall the original Sansa firmware before running\n" + "[ERR] *** sansapatcher for the first time.\n" + "[ERR] *** See http://www.rockbox.org/twiki/bin/view/Main/SansaE200Install\n" + "[ERR] ************************************************************************\n"),wxT("Checking Disk")); + return false; + } + + if(mode == BOOTLOADER_ADD) + { + if (sansa_reopen_rw(&sansa) < 0) { + ERR_DIALOG(wxT("[ERR] Could not open Sansa in RW mode"), wxT("Bootloader add")); + return false; + } + + if (sansa_add_bootloader(&sansa, (char*)dest.c_str(), FILETYPE_MI4)==0) { + + } else { + ERR_DIALOG(wxT("[ERR] failed to add Bootloader"), wxT("Bootloader add")); + } + + } + else if(mode == BOOTLOADER_REM) + { + if (sansa_reopen_rw(&sansa) < 0) { + ERR_DIALOG(wxT("[ERR] Could not open Sansa in RW mode"), wxT("Bootloader Remove")); + } + + if (sansa_delete_bootloader(&sansa)==0) { + + } else { + ERR_DIALOG(wxT("[ERR] failed to remove Bootloader"), wxT("Bootloader remove")); + } + } + + sansa_close(&sansa); + return true; +} + // gigabeatinstallation bool gigabeatf(int mode,wxString bootloadername,wxString deviceDir) { |