summaryrefslogtreecommitdiff
path: root/rbutil/bootloaders.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/bootloaders.cpp')
-rwxr-xr-xrbutil/bootloaders.cpp105
1 files changed, 103 insertions, 2 deletions
diff --git a/rbutil/bootloaders.cpp b/rbutil/bootloaders.cpp
index 274264cadf..039451f247 100755
--- a/rbutil/bootloaders.cpp
+++ b/rbutil/bootloaders.cpp
@@ -26,8 +26,7 @@
26#include "installlog.h" 26#include "installlog.h"
27 27
28 28
29// for ipodpatcher 29int verbose =0;
30int verbose = 0;
31// reserves memory for ipodpatcher 30// reserves memory for ipodpatcher
32bool initIpodpatcher() 31bool initIpodpatcher()
33{ 32{
@@ -162,6 +161,108 @@ bool ipodpatcher(int mode,wxString bootloadername)
162 return true; 161 return true;
163} 162}
164 163
164// reserves memory for sansapatcher
165bool initSansaPatcher()
166{
167 if (sansa_alloc_buffer(&sectorbuf,BUFFER_SIZE) < 0) return true;
168 else return false;
169}
170
171
172// sansainstallation
173bool sansapatcher(int mode,wxString bootloadername)
174{
175 wxString src,dest,buf;
176
177 struct sansa_t sansa;
178
179 int n = sansa_scan(&sansa);
180 if (n == 0)
181 {
182 ERR_DIALOG(wxT("[ERR] No Sansa found."), wxT("Scanning for Sansa"));
183 return false;
184 }
185 if (n > 1)
186 {
187 ERR_DIALOG(wxT("[ERR] to many Sansa found."), wxT("Scanning for Sansa"));
188 return false;
189 }
190
191 // downloading files
192 if(mode == BOOTLOADER_ADD)
193 {
194 src.Printf(wxT("%s/sandisk-sansa/e200/%s"),gv->bootloader_url.c_str(),bootloadername.c_str());
195 dest.Printf(wxT("%s" PATH_SEP "download" PATH_SEP "%s"),
196 gv->stdpaths->GetUserDataDir().c_str(),bootloadername.c_str());
197 if ( DownloadURL(src, dest) )
198 {
199 wxRemoveFile(dest);
200 buf.Printf(wxT("Unable to download %s"), src.c_str() );
201 ERR_DIALOG(buf, wxT("Download"));
202 return false;
203 }
204 }
205
206 if (sansa_open(&sansa, 0) < 0)
207 {
208 ERR_DIALOG(wxT("[ERR] could not open sansa"), wxT("open Sansa"));
209 return false;
210 }
211
212 if (sansa_read_partinfo(&sansa,0) < 0)
213 {
214 ERR_DIALOG(wxT("[ERR] could not read partitiontable"), wxT("reading partitiontable"));
215 return false;
216 }
217
218 int i = is_e200(&sansa);
219 if (i < 0) {
220 ERR_DIALOG(wxT("[ERR] Disk is not an E200 (%d), aborting.\n"), wxT("Checking Disk"));
221 return false;
222 }
223
224 if (sansa.hasoldbootloader)
225 {
226 ERR_DIALOG(wxT("[ERR] ************************************************************************\n"
227 "[ERR] *** OLD ROCKBOX INSTALLATION DETECTED, ABORTING.\n"
228 "[ERR] *** You must reinstall the original Sansa firmware before running\n"
229 "[ERR] *** sansapatcher for the first time.\n"
230 "[ERR] *** See http://www.rockbox.org/twiki/bin/view/Main/SansaE200Install\n"
231 "[ERR] ************************************************************************\n"),wxT("Checking Disk"));
232 return false;
233 }
234
235 if(mode == BOOTLOADER_ADD)
236 {
237 if (sansa_reopen_rw(&sansa) < 0) {
238 ERR_DIALOG(wxT("[ERR] Could not open Sansa in RW mode"), wxT("Bootloader add"));
239 return false;
240 }
241
242 if (sansa_add_bootloader(&sansa, (char*)dest.c_str(), FILETYPE_MI4)==0) {
243
244 } else {
245 ERR_DIALOG(wxT("[ERR] failed to add Bootloader"), wxT("Bootloader add"));
246 }
247
248 }
249 else if(mode == BOOTLOADER_REM)
250 {
251 if (sansa_reopen_rw(&sansa) < 0) {
252 ERR_DIALOG(wxT("[ERR] Could not open Sansa in RW mode"), wxT("Bootloader Remove"));
253 }
254
255 if (sansa_delete_bootloader(&sansa)==0) {
256
257 } else {
258 ERR_DIALOG(wxT("[ERR] failed to remove Bootloader"), wxT("Bootloader remove"));
259 }
260 }
261
262 sansa_close(&sansa);
263 return true;
264}
265
165// gigabeatinstallation 266// gigabeatinstallation
166bool gigabeatf(int mode,wxString bootloadername,wxString deviceDir) 267bool gigabeatf(int mode,wxString bootloadername,wxString deviceDir)
167{ 268{