summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2007-05-03 20:07:57 +0000
committerDominik Wenger <domonoky@googlemail.com>2007-05-03 20:07:57 +0000
commitdde262b58a8bb908278179e916e0d91068d6987f (patch)
tree659519211ddb52e4dfd40d71187fbeb171313aa7
parent39939bb137bea1c149db5ff0edb1dd0dd1d3d596 (diff)
downloadrockbox-dde262b58a8bb908278179e916e0d91068d6987f.tar.gz
rockbox-dde262b58a8bb908278179e916e0d91068d6987f.zip
Support for Sansa E200 in rbutil
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13315 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/Makefile4
-rwxr-xr-xrbutil/Makefile.macosx3
-rwxr-xr-xrbutil/bootloaders.cpp105
-rwxr-xr-xrbutil/bootloaders.h4
-rw-r--r--rbutil/credits.h2
-rw-r--r--rbutil/rbutil-rc.rc8
-rw-r--r--rbutil/rbutil.cbp14
-rw-r--r--rbutil/rbutil.ini10
-rw-r--r--rbutil/rbutilApp.cpp4
-rw-r--r--rbutil/rbutilCtrls.cpp37
-rw-r--r--rbutil/rbutilFrm.cpp53
-rw-r--r--rbutil/sansapatcher/sansaio-posix.c2
-rw-r--r--rbutil/sansapatcher/sansaio-win32.c17
-rw-r--r--rbutil/sansapatcher/sansaio.h4
-rw-r--r--rbutil/sansapatcher/sansapatcher.c18
15 files changed, 232 insertions, 53 deletions
diff --git a/rbutil/Makefile b/rbutil/Makefile
index fdb29f30a3..208a149e83 100644
--- a/rbutil/Makefile
+++ b/rbutil/Makefile
@@ -11,8 +11,8 @@
11 11
12CXX=$(shell $(PREFIX)wx-config --cxx) 12CXX=$(shell $(PREFIX)wx-config --cxx)
13INC = 13INC =
14CFLAGS = -Wall -Wundef 14CFLAGS = -Wall -Wundef -DRBUTIL
15OBJS=rbutil.o rbutilApp.o rbutilFrm.o rbutilCtrls.o install_dialogs.o bootloaders.o installlog.o ipodpatcher/ipodpatcher.o ipodpatcher/ipodio-posix.o irivertools.o md5sum.o 15OBJS=rbutil.o rbutilApp.o rbutilFrm.o rbutilCtrls.o install_dialogs.o bootloaders.o installlog.o ipodpatcher/ipodpatcher.o ipodpatcher/ipodio-posix.o sansapatcher/sansapatcher.o sansapatcher/sansaio-posix.o irivertools.o md5sum.o
16 16
17# Install into /usr/local by default 17# Install into /usr/local by default
18ifndef DESTDIR 18ifndef DESTDIR
diff --git a/rbutil/Makefile.macosx b/rbutil/Makefile.macosx
index 1c6c900507..caf383f7f4 100755
--- a/rbutil/Makefile.macosx
+++ b/rbutil/Makefile.macosx
@@ -25,7 +25,7 @@ LDFLAGS_GUI =
25CXX = g++ 25CXX = g++
26CXXFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -Wall -Wundef -Wno-ctor-dtor-privacy -O2 -fno-strict-aliasing -fno-common 26CXXFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -Wall -Wundef -Wno-ctor-dtor-privacy -O2 -fno-strict-aliasing -fno-common
27CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -I${wx_top_builddir}/lib/wx/include/mac-ansi-release-static-2.8 -I${top_srcdir}/include -fpascal-strings -I${top_srcdir}/src/mac/carbon/morefilex -I/Developer/Headers/FlatCarbon 27CPPFLAGS = -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -I${wx_top_builddir}/lib/wx/include/mac-ansi-release-static-2.8 -I${top_srcdir}/include -fpascal-strings -I${top_srcdir}/src/mac/carbon/morefilex -I/Developer/Headers/FlatCarbon
28RBUTIL_CFLAGS = $(CXXFLAGS) -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -I${wx_top_builddir}/lib/wx/include/mac-ansi-release-static-2.8 -I${top_srcdir}/include -fpascal-strings -I${top_srcdir}/src/mac/carbon/morefilex -I/Developer/Headers/FlatCarbon 28RBUTIL_CFLAGS = $(CXXFLAGS) -DRBUTIL -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -I${wx_top_builddir}/lib/wx/include/mac-ansi-release-static-2.8 -I${top_srcdir}/include -fpascal-strings -I${top_srcdir}/src/mac/carbon/morefilex -I/Developer/Headers/FlatCarbon
29LDFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -framework QuickTime -framework IOKit -framework Carbon -framework Cocoa -framework System 29LDFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -framework QuickTime -framework IOKit -framework Carbon -framework Cocoa -framework System
30WX_LIB_FLAVOUR = 30WX_LIB_FLAVOUR =
31TOOLKIT = MAC 31TOOLKIT = MAC
@@ -51,6 +51,7 @@ RBUTIL_OBJECTS = \
51 $(__rbutil_os2_lib_res) \ 51 $(__rbutil_os2_lib_res) \
52 rbutil.o rbutilApp.o rbutilFrm.o install_dialogs.o bootloaders.o installlog.o \ 52 rbutil.o rbutilApp.o rbutilFrm.o install_dialogs.o bootloaders.o installlog.o \
53 rbutilCtrls.o ipodpatcher/ipodpatcher.o ipodpatcher/ipodio-posix.o \ 53 rbutilCtrls.o ipodpatcher/ipodpatcher.o ipodpatcher/ipodio-posix.o \
54 sansapatcher/sansapatcher.o sansapatcher/sansaio-posix.o \
54 md5sum.o irivertools.o \ 55 md5sum.o irivertools.o \
55 $(__rbutil___win32rc) 56 $(__rbutil___win32rc)
56 57
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{
diff --git a/rbutil/bootloaders.h b/rbutil/bootloaders.h
index 015f095b76..ba751bd715 100755
--- a/rbutil/bootloaders.h
+++ b/rbutil/bootloaders.h
@@ -28,11 +28,15 @@
28extern "C" { 28extern "C" {
29 // Ipodpatcher 29 // Ipodpatcher
30 #include "ipodpatcher/ipodpatcher.h" 30 #include "ipodpatcher/ipodpatcher.h"
31 // Sansapatcher
32 #include "sansapatcher/sansapatcher.h"
31}; 33};
32 34
33 35
34bool initIpodpatcher(); 36bool initIpodpatcher();
37bool initSansaPatcher();
35bool ipodpatcher(int mode,wxString bootloadername); 38bool ipodpatcher(int mode,wxString bootloadername);
39bool sansapatcher(int mode,wxString bootloadername);
36bool gigabeatf(int mode,wxString bootloadername,wxString deviceDir); 40bool gigabeatf(int mode,wxString bootloadername,wxString deviceDir);
37bool iaudiox5(int mode,wxString bootloadername,wxString deviceDir); 41bool iaudiox5(int mode,wxString bootloadername,wxString deviceDir);
38bool fwpatcher(int mode,wxString bootloadername,wxString deviceDir,wxString firmware); 42bool fwpatcher(int mode,wxString bootloadername,wxString deviceDir,wxString firmware);
diff --git a/rbutil/credits.h b/rbutil/credits.h
index 2fc14c6efd..84f38f8fcb 100644
--- a/rbutil/credits.h
+++ b/rbutil/credits.h
@@ -22,7 +22,7 @@
22#define CREDITS_H_INCLUDED 22#define CREDITS_H_INCLUDED
23 23
24#define RBUTIL_FULLNAME "The Rockbox Utility" 24#define RBUTIL_FULLNAME "The Rockbox Utility"
25#define RBUTIL_VERSION "Version 0.3.1.0" 25#define RBUTIL_VERSION "Version 0.3.2.0"
26 26
27static const wxString rbutil_developers[] = { 27static const wxString rbutil_developers[] = {
28 wxT("Christi Alice Scarborough"), 28 wxT("Christi Alice Scarborough"),
diff --git a/rbutil/rbutil-rc.rc b/rbutil/rbutil-rc.rc
index abede2a54f..51f33468f7 100644
--- a/rbutil/rbutil-rc.rc
+++ b/rbutil/rbutil-rc.rc
@@ -1,8 +1,8 @@
1#define RBUTIL 1 1#define RBUTIL 1
2#include <wx/msw/wx.rc> 2#include <wx/msw/wx.rc>
3RBUTIL VERSIONINFO 3RBUTIL VERSIONINFO
4FILEVERSION 0,3,1,0 4FILEVERSION 0,3,2,0
5PRODUCTVERSION 0,3,1,0 5PRODUCTVERSION 0,3,2,0
6FILEOS 0x00000004 6FILEOS 0x00000004
7FILETYPE 0x00000001 7FILETYPE 0x00000001
8BEGIN 8BEGIN
@@ -10,8 +10,8 @@ BEGIN
10 BEGIN 10 BEGIN
11 BLOCK "FFFF0000" 11 BLOCK "FFFF0000"
12 BEGIN 12 BEGIN
13 VALUE "FileVersion", "0.3.1.0\0" 13 VALUE "FileVersion", "0.3.2.0\0"
14 VALUE "ProductVersion", "0.3.1.0\0" 14 VALUE "ProductVersion", "0.3.2.0\0"
15 VALUE "CompanyName", "Rockbox Team\0" 15 VALUE "CompanyName", "Rockbox Team\0"
16 VALUE "FileDescription", "Rockbox Utility\0" 16 VALUE "FileDescription", "Rockbox Utility\0"
17 VALUE "InternalName", "rbutil\0" 17 VALUE "InternalName", "rbutil\0"
diff --git a/rbutil/rbutil.cbp b/rbutil/rbutil.cbp
index 9b31e924a5..aebf2173b1 100644
--- a/rbutil/rbutil.cbp
+++ b/rbutil/rbutil.cbp
@@ -58,6 +58,7 @@
58 <Add option="-D__GNUWIN32__" /> 58 <Add option="-D__GNUWIN32__" />
59 <Add option="-D__WXMSW__" /> 59 <Add option="-D__WXMSW__" />
60 <Add option="-DUSE_PCH" /> 60 <Add option="-DUSE_PCH" />
61 <Add option="-DRBUTIL" />
61 <Add directory="$(#WX.include)" /> 62 <Add directory="$(#WX.include)" />
62 <Add directory="$(#WX.lib)\gcc_lib$(WX_CFG)\msw" /> 63 <Add directory="$(#WX.lib)\gcc_lib$(WX_CFG)\msw" />
63 <Add directory="$(#WX)\contrib\include" /> 64 <Add directory="$(#WX)\contrib\include" />
@@ -130,9 +131,22 @@
130 <Unit filename="rbutil.iss" /> 131 <Unit filename="rbutil.iss" />
131 <Unit filename="rbutilApp.cpp" /> 132 <Unit filename="rbutilApp.cpp" />
132 <Unit filename="rbutilApp.h" /> 133 <Unit filename="rbutilApp.h" />
134 <Unit filename="rbutilCtrls.cpp" />
135 <Unit filename="rbutilCtrls.h" />
133 <Unit filename="rbutilFrm.cpp" /> 136 <Unit filename="rbutilFrm.cpp" />
134 <Unit filename="rbutilFrm.h" /> 137 <Unit filename="rbutilFrm.h" />
135 <Unit filename="rbutilFrm_XPM.xpm" /> 138 <Unit filename="rbutilFrm_XPM.xpm" />
139 <Unit filename="sansapatcher\parttypes.h" />
140 <Unit filename="sansapatcher\sansaio-win32.c">
141 <Option compilerVar="CC" />
142 <Option compiler="gcc" use="1" buildCommand="mingw32-gcc.exe -W -g -pipe -mthreads -Winvalid-pch -D__GNUWIN32__ -D__WXMSW__ -DUSE_PCH -g -I.\ -IC:\Dev-Cpp\include -c $file -o .objs\sansapatcher\sansaio-win32.o" />
143 </Unit>
144 <Unit filename="sansapatcher\sansaio.h" />
145 <Unit filename="sansapatcher\sansapatcher.c">
146 <Option compilerVar="CC" />
147 <Option compiler="gcc" use="1" buildCommand="mingw32-gcc.exe -W -g -pipe -mthreads -Winvalid-pch -D__GNUWIN32__ -D__WXMSW__ -DUSE_PCH -g -I.\ -IC:\Dev-Cpp\include -c $file -o .objs\sansapatcher\sansapatcher.o" />
148 </Unit>
149 <Unit filename="sansapatcher\sansapatcher.h" />
136 <Unit filename="themes_3d.xpm" /> 150 <Unit filename="themes_3d.xpm" />
137 <Unit filename="tools2_3d.xpm" /> 151 <Unit filename="tools2_3d.xpm" />
138 <Unit filename="uninstall_3d.xpm" /> 152 <Unit filename="uninstall_3d.xpm" />
diff --git a/rbutil/rbutil.ini b/rbutil/rbutil.ini
index 01e86c1506..42b74dea49 100644
--- a/rbutil/rbutil.ini
+++ b/rbutil/rbutil.ini
@@ -35,6 +35,7 @@ platform22=iaudiox5
35platform23=iaudiom5 35platform23=iaudiom5
36platform24=iaudiox5v 36platform24=iaudiox5v
37platform25=gigabeatf 37platform25=gigabeatf
38platform26=sansae200
38 39
39[player] 40[player]
40name=Archos Jukebox Player 6000, Jukebox Studio 5/10/20 41name=Archos Jukebox Player 6000, Jukebox Studio 5/10/20
@@ -259,3 +260,12 @@ needsbootloader=yes
259bootloadermethod=gigabeatf 260bootloadermethod=gigabeatf
260bootloadername=FWIMG01.DAT 261bootloadername=FWIMG01.DAT
261resolution=240x320x16 262resolution=240x320x16
263
264[sansae200]
265name=Sandisk Sansa E200
266platform=sansae200
267released=no
268needsbootloader=yes
269bootloadermethod=sansapatcher
270bootloadername=PP5022.mi4
271resolution=176x220x16
diff --git a/rbutil/rbutilApp.cpp b/rbutil/rbutilApp.cpp
index 1b183a1e49..2005e6c6f0 100644
--- a/rbutil/rbutilApp.cpp
+++ b/rbutil/rbutilApp.cpp
@@ -80,10 +80,12 @@ bool rbutilFrmApp::OnInit()
80 80
81 rbutilFrm *myFrame = new rbutilFrm(NULL); 81 rbutilFrm *myFrame = new rbutilFrm(NULL);
82 SetTopWindow(myFrame); 82 SetTopWindow(myFrame);
83 83
84 myFrame->Show(TRUE); 84 myFrame->Show(TRUE);
85 85
86 initIpodpatcher(); // reserve mem for ipodpatcher 86 initIpodpatcher(); // reserve mem for ipodpatcher
87 initSansaPatcher(); // reserve mem for sansapatcher
88
87 wxInitAllImageHandlers(); //init Image handlers 89 wxInitAllImageHandlers(); //init Image handlers
88 90
89 wxLogVerbose(wxT("=== end rbUtilFrmApp::OnInit()")); 91 wxLogVerbose(wxT("=== end rbUtilFrmApp::OnInit()"));
diff --git a/rbutil/rbutilCtrls.cpp b/rbutil/rbutilCtrls.cpp
index 36caeeaac0..fe89ca84f4 100644
--- a/rbutil/rbutilCtrls.cpp
+++ b/rbutil/rbutilCtrls.cpp
@@ -144,7 +144,7 @@ void ThemeCtrl::Init()
144 144
145void ThemeCtrl::setDevice(wxString device) 145void ThemeCtrl::setDevice(wxString device)
146{ 146{
147 147
148 int index = gv->plat_id.Index(device); 148 int index = gv->plat_id.Index(device);
149 if(index == -1) return; 149 if(index == -1) return;
150 150
@@ -210,13 +210,13 @@ void ThemeCtrl::setDevice(wxString device)
210 210
211 m_themeList->Append(m_Themes.Last()); 211 m_themeList->Append(m_Themes.Last());
212 } 212 }
213 213
214 this->GetSizer()->Layout(); 214 this->GetSizer()->Layout();
215 this->GetSizer()->Fit(this); 215 this->GetSizer()->Fit(this);
216 this->GetSizer()->SetSizeHints(this); 216 this->GetSizer()->SetSizeHints(this);
217 m_parent->GetSizer()->Layout(); 217 m_parent->GetSizer()->Layout();
218 m_parent->GetSizer()->Fit(m_parent); 218 m_parent->GetSizer()->Fit(m_parent);
219 m_parent->GetSizer()->SetSizeHints(m_parent); 219 m_parent->GetSizer()->SetSizeHints(m_parent);
220} 220}
221 221
222 222
@@ -265,10 +265,10 @@ void ThemeCtrl::OnThemesLst(wxCommandEvent& event)
265 this->GetSizer()->Layout(); 265 this->GetSizer()->Layout();
266 this->GetSizer()->Fit(this); 266 this->GetSizer()->Fit(this);
267 this->GetSizer()->SetSizeHints(this); 267 this->GetSizer()->SetSizeHints(this);
268 268
269 m_parent->GetSizer()->Layout(); 269 m_parent->GetSizer()->Layout();
270 m_parent->GetSizer()->Fit(m_parent); 270 m_parent->GetSizer()->Fit(m_parent);
271 m_parent->GetSizer()->SetSizeHints(m_parent); 271 m_parent->GetSizer()->SetSizeHints(m_parent);
272 272
273} 273}
274 274
@@ -369,7 +369,7 @@ void DeviceSelectorCtrl::CreateControls()
369 369
370 m_deviceCbx = new wxComboBox(this, ID_DEVICE_CBX,wxT(""), 370 m_deviceCbx = new wxComboBox(this, ID_DEVICE_CBX,wxT(""),
371 wxDefaultPosition,wxDefaultSize,gv->plat_name,wxCB_READONLY); 371 wxDefaultPosition,wxDefaultSize,gv->plat_name,wxCB_READONLY);
372 372
373 m_deviceCbx->SetToolTip(wxT("Select your Device.")); 373 m_deviceCbx->SetToolTip(wxT("Select your Device."));
374 m_deviceCbx->SetHelpText(wxT("Select your Device.")); 374 m_deviceCbx->SetHelpText(wxT("Select your Device."));
375 375
@@ -413,24 +413,39 @@ void DeviceSelectorCtrl::OnAutoDetect(wxCommandEvent& event)
413 int n = ipod_scan(&ipod); 413 int n = ipod_scan(&ipod);
414 if(n == 1) 414 if(n == 1)
415 { 415 {
416 wxString temp(ipod.targetname,wxConvUTF8); 416 wxString temp(ipod.targetname,wxConvUTF8);
417 int index = gv->plat_bootloadername.Index(temp); 417 int index = gv->plat_bootloadername.Index(temp); // use the bootloader names..
418 m_deviceCbx->SetValue(gv->plat_name[index]); 418 m_deviceCbx->SetValue(gv->plat_name[index]);
419 gv->curplat=gv->plat_id[index]; 419 gv->curplat=gv->plat_id[index];
420 return;
420 } 421 }
421 else if (n > 1) 422 else if (n > 1)
422 { 423 {
423 WARN_DIALOG(wxT("More then one device Ipod detected, please connect only One"), 424 WARN_DIALOG(wxT("More then one Ipod device detected, please connect only One"),
424 wxT("Detecting a Device")); 425 wxT("Detecting a Device"));
425 return; 426 return;
426 } 427 }
427 else 428
429 struct sansa_t sansa;
430 int n2 = sansa_scan(&sansa);
431 if(n2==1)
428 { 432 {
429 WARN_DIALOG(wxT("No Device detected. (This function currently only works for Ipods)."), 433 int index = gv->plat_id.Index(wxT("sansae200"));
434 m_deviceCbx->SetValue(gv->plat_name[index]);
435 gv->curplat=gv->plat_id[index];
436 return;
437 }
438 else if (n2 > 1)
439 {
440 WARN_DIALOG(wxT("More then one Sansa device detected, please connect only One"),
430 wxT("Detecting a Device")); 441 wxT("Detecting a Device"));
431 return; 442 return;
432 } 443 }
433 444
445 WARN_DIALOG(wxT("No Device detected. (This function currently only works for Ipods and Sansas)."),
446 wxT("Detecting a Device"));
447 return;
448
434} 449}
435 450
436///////////////////////////////////////////// 451/////////////////////////////////////////////
diff --git a/rbutil/rbutilFrm.cpp b/rbutil/rbutilFrm.cpp
index 4c57e08353..78408d184d 100644
--- a/rbutil/rbutilFrm.cpp
+++ b/rbutil/rbutilFrm.cpp
@@ -71,7 +71,7 @@ void rbutilFrm::CreateGUIControls(void)
71 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL); 71 wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
72 this->SetSizer(WxBoxSizer1); 72 this->SetSizer(WxBoxSizer1);
73 this->SetAutoLayout(TRUE); 73 this->SetAutoLayout(TRUE);
74 74
75 wxPanel* mainPanel = new wxPanel(this,wxID_ANY); 75 wxPanel* mainPanel = new wxPanel(this,wxID_ANY);
76 WxBoxSizer1->Add(mainPanel,0,wxALL,0); 76 WxBoxSizer1->Add(mainPanel,0,wxALL,0);
77 wxBoxSizer* WxBoxSizer0 = new wxBoxSizer(wxVERTICAL); 77 wxBoxSizer* WxBoxSizer0 = new wxBoxSizer(wxVERTICAL);
@@ -87,24 +87,24 @@ void rbutilFrm::CreateGUIControls(void)
87 myDeviceSelector->setDefault(); 87 myDeviceSelector->setDefault();
88 WxBoxSizer0->Add(myDeviceSelector,0,wxALL,5); 88 WxBoxSizer0->Add(myDeviceSelector,0,wxALL,5);
89 89
90 wxNotebook* tabwindow = new wxNotebook(mainPanel,wxID_ANY); 90 wxNotebook* tabwindow = new wxNotebook(mainPanel,wxID_ANY);
91 WxBoxSizer0->Add(tabwindow,0,wxALL,5); 91 WxBoxSizer0->Add(tabwindow,0,wxALL,5);
92 92
93 wxPanel* installpage = new wxPanel(tabwindow,wxID_ANY); 93 wxPanel* installpage = new wxPanel(tabwindow,wxID_ANY);
94 wxPanel* themepage = new wxPanel(tabwindow,wxID_ANY); 94 wxPanel* themepage = new wxPanel(tabwindow,wxID_ANY);
95 wxPanel* uninstallpage = new wxPanel(tabwindow,wxID_ANY); 95 wxPanel* uninstallpage = new wxPanel(tabwindow,wxID_ANY);
96 tabwindow->AddPage(installpage,wxT("Installation"),true); 96 tabwindow->AddPage(installpage,wxT("Installation"),true);
97 tabwindow->AddPage(themepage,wxT("Themes")); 97 tabwindow->AddPage(themepage,wxT("Themes"));
98 tabwindow->AddPage(uninstallpage,wxT("Uninstallation")); 98 tabwindow->AddPage(uninstallpage,wxT("Uninstallation"));
99 99
100 /********************* 100 /*********************
101 Install Page 101 Install Page
102 ***********************/ 102 ***********************/
103 103
104 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL); 104 wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL);
105 installpage->SetSizer(WxBoxSizer2); 105 installpage->SetSizer(WxBoxSizer2);
106 installpage->SetAutoLayout(TRUE); 106 installpage->SetAutoLayout(TRUE);
107 107
108 wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(installpage, 108 wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(installpage,
109 wxID_ANY, wxT("Please choose an option")); 109 wxID_ANY, wxT("Please choose an option"));
110 wxStaticBoxSizer* WxStaticBoxSizer3 = 110 wxStaticBoxSizer* WxStaticBoxSizer3 =
@@ -153,13 +153,13 @@ void rbutilFrm::CreateGUIControls(void)
153 wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxVERTICAL); 153 wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxVERTICAL);
154 themepage->SetSizer(WxBoxSizer3); 154 themepage->SetSizer(WxBoxSizer3);
155 themepage->SetAutoLayout(TRUE); 155 themepage->SetAutoLayout(TRUE);
156 156
157 wxStaticBox* WxStaticBoxSizer4_StaticBoxObj = new wxStaticBox(themepage, 157 wxStaticBox* WxStaticBoxSizer4_StaticBoxObj = new wxStaticBox(themepage,
158 wxID_ANY, wxT("Please choose an option")); 158 wxID_ANY, wxT("Please choose an option"));
159 wxStaticBoxSizer* WxStaticBoxSizer4 = 159 wxStaticBoxSizer* WxStaticBoxSizer4 =
160 new wxStaticBoxSizer(WxStaticBoxSizer4_StaticBoxObj,wxHORIZONTAL); 160 new wxStaticBoxSizer(WxStaticBoxSizer4_StaticBoxObj,wxHORIZONTAL);
161 WxBoxSizer3->Add(WxStaticBoxSizer4,1,wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 161 WxBoxSizer3->Add(WxStaticBoxSizer4,1,wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
162 162
163 wxFlexGridSizer* WxFlexGridSizer2 = new wxFlexGridSizer(2,2,0,0); 163 wxFlexGridSizer* WxFlexGridSizer2 = new wxFlexGridSizer(2,2,0,0);
164 WxStaticBoxSizer4->Add(WxFlexGridSizer2,0,wxGROW | wxALL,0); 164 WxStaticBoxSizer4->Add(WxFlexGridSizer2,0,wxGROW | wxALL,0);
165 165
@@ -193,24 +193,24 @@ void rbutilFrm::CreateGUIControls(void)
193 wxT("Install more Themes for Rockbox.\n\n")); 193 wxT("Install more Themes for Rockbox.\n\n"));
194 WxFlexGridSizer2->Add(WxStaticText6, 0, 194 WxFlexGridSizer2->Add(WxStaticText6, 0,
195 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5); 195 wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
196 196
197 /* ********************+ 197 /* ********************+
198 Uninstall Page 198 Uninstall Page
199 ***********************/ 199 ***********************/
200 200
201 wxBoxSizer* WxBoxSizer4 = new wxBoxSizer(wxVERTICAL); 201 wxBoxSizer* WxBoxSizer4 = new wxBoxSizer(wxVERTICAL);
202 uninstallpage->SetSizer(WxBoxSizer4); 202 uninstallpage->SetSizer(WxBoxSizer4);
203 uninstallpage->SetAutoLayout(TRUE); 203 uninstallpage->SetAutoLayout(TRUE);
204 204
205 wxStaticBox* WxStaticBoxSizer5_StaticBoxObj = new wxStaticBox(uninstallpage, 205 wxStaticBox* WxStaticBoxSizer5_StaticBoxObj = new wxStaticBox(uninstallpage,
206 wxID_ANY, wxT("Please choose an option")); 206 wxID_ANY, wxT("Please choose an option"));
207 wxStaticBoxSizer* WxStaticBoxSizer5 = 207 wxStaticBoxSizer* WxStaticBoxSizer5 =
208 new wxStaticBoxSizer(WxStaticBoxSizer5_StaticBoxObj,wxHORIZONTAL); 208 new wxStaticBoxSizer(WxStaticBoxSizer5_StaticBoxObj,wxHORIZONTAL);
209 WxBoxSizer4->Add(WxStaticBoxSizer5,1,wxALIGN_CENTER_HORIZONTAL | wxALL, 5); 209 WxBoxSizer4->Add(WxStaticBoxSizer5,1,wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
210 210
211 wxFlexGridSizer* WxFlexGridSizer3 = new wxFlexGridSizer(2,2,0,0); 211 wxFlexGridSizer* WxFlexGridSizer3 = new wxFlexGridSizer(2,2,0,0);
212 WxStaticBoxSizer5->Add(WxFlexGridSizer3,0,wxGROW | wxALL,0); 212 WxStaticBoxSizer5->Add(WxFlexGridSizer3,0,wxGROW | wxALL,0);
213 213
214 wxBitmap WxBitmapButton2_BITMAP (uninstall_3d_xpm); 214 wxBitmap WxBitmapButton2_BITMAP (uninstall_3d_xpm);
215 WxBitmapButton2 = new wxBitmapButton(uninstallpage, ID_REMOVE_BTN, 215 WxBitmapButton2 = new wxBitmapButton(uninstallpage, ID_REMOVE_BTN,
216 WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54), 216 WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
@@ -270,7 +270,7 @@ void rbutilFrm::CreateGUIControls(void)
270 wxIcon rbutilFrm_ICON (rbutilFrm_XPM); 270 wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
271 this->SetIcon(rbutilFrm_XPM); 271 this->SetIcon(rbutilFrm_XPM);
272 this->SetToolTip(wxT("Install Rockbox")); 272 this->SetToolTip(wxT("Install Rockbox"));
273 273
274 wxLogVerbose(wxT("=== end rbutilFrm::CreateGUIControls")); 274 wxLogVerbose(wxT("=== end rbutilFrm::CreateGUIControls"));
275} 275}
276 276
@@ -374,6 +374,17 @@ void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event)
374 MESG_DIALOG(wxT("The Uninstallation failed.") ); 374 MESG_DIALOG(wxT("The Uninstallation failed.") );
375 } 375 }
376 } 376 }
377 if(bootloadermethod == wxT("sansapatcher"))
378 {
379 if(sansapatcher(BOOTLOADER_REM,gv->plat_bootloadername[index]))
380 {
381 MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
382 }
383 else
384 {
385 MESG_DIALOG(wxT("The Uninstallation failed.") );
386 }
387 }
377 else if(bootloadermethod== wxT("gigabeatf")) 388 else if(bootloadermethod== wxT("gigabeatf"))
378 { 389 {
379 390
@@ -439,6 +450,18 @@ void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event)
439 MESG_DIALOG(wxT("The installation has failed.") ); 450 MESG_DIALOG(wxT("The installation has failed.") );
440 } 451 }
441 } 452 }
453 if(bootloadermethod == wxT("sansapatcher"))
454 {
455 if(sansapatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index]))
456 {
457 MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
458 }
459 else
460 {
461 MESG_DIALOG(wxT("The installation has failed.") );
462 }
463
464 }
442 else if(bootloadermethod== wxT("gigabeatf")) 465 else if(bootloadermethod== wxT("gigabeatf"))
443 { 466 {
444 467
diff --git a/rbutil/sansapatcher/sansaio-posix.c b/rbutil/sansapatcher/sansaio-posix.c
index e2b5496b32..bf72718d64 100644
--- a/rbutil/sansapatcher/sansaio-posix.c
+++ b/rbutil/sansapatcher/sansaio-posix.c
@@ -42,10 +42,12 @@
42 42
43#include "sansaio.h" 43#include "sansaio.h"
44 44
45#ifndef RBUTIL
45void print_error(char* msg) 46void print_error(char* msg)
46{ 47{
47 perror(msg); 48 perror(msg);
48} 49}
50#endif
49 51
50int sansa_open(struct sansa_t* sansa, int silent) 52int sansa_open(struct sansa_t* sansa, int silent)
51{ 53{
diff --git a/rbutil/sansapatcher/sansaio-win32.c b/rbutil/sansapatcher/sansaio-win32.c
index 7335ab614c..e9b8819f19 100644
--- a/rbutil/sansapatcher/sansaio-win32.c
+++ b/rbutil/sansapatcher/sansaio-win32.c
@@ -37,22 +37,23 @@
37 37
38#include "sansaio.h" 38#include "sansaio.h"
39 39
40static int lock_volume(HANDLE hDisk) 40static int lock_volume(HANDLE hDisk)
41{ 41{
42 DWORD dummy; 42 DWORD dummy;
43 43
44 return DeviceIoControl(hDisk, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, 44 return DeviceIoControl(hDisk, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0,
45 &dummy, NULL); 45 &dummy, NULL);
46} 46}
47 47
48static int unlock_volume(HANDLE hDisk) 48static int unlock_volume(HANDLE hDisk)
49{ 49{
50 DWORD dummy; 50 DWORD dummy;
51 51
52 return DeviceIoControl(hDisk, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0, 52 return DeviceIoControl(hDisk, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0,
53 &dummy, NULL); 53 &dummy, NULL);
54} 54}
55 55
56#ifndef RBUTIL
56void print_error(char* msg) 57void print_error(char* msg)
57{ 58{
58 char* pMsgBuf; 59 char* pMsgBuf;
@@ -65,7 +66,7 @@ void print_error(char* msg)
65 printf(pMsgBuf); 66 printf(pMsgBuf);
66 LocalFree(pMsgBuf); 67 LocalFree(pMsgBuf);
67} 68}
68 69#endif
69int sansa_open(struct sansa_t* sansa, int silent) 70int sansa_open(struct sansa_t* sansa, int silent)
70{ 71{
71 DISK_GEOMETRY_EX diskgeometry_ex; 72 DISK_GEOMETRY_EX diskgeometry_ex;
diff --git a/rbutil/sansapatcher/sansaio.h b/rbutil/sansapatcher/sansaio.h
index f30884887c..2ef88fd384 100644
--- a/rbutil/sansapatcher/sansaio.h
+++ b/rbutil/sansapatcher/sansaio.h
@@ -38,7 +38,7 @@
38 38
39#endif 39#endif
40 40
41struct partinfo_t { 41struct sansa_partinfo_t {
42 unsigned long start; /* first sector (LBA) */ 42 unsigned long start; /* first sector (LBA) */
43 unsigned long size; /* number of sectors */ 43 unsigned long size; /* number of sectors */
44 int type; 44 int type;
@@ -57,7 +57,7 @@ struct sansa_t {
57 HANDLE dh; 57 HANDLE dh;
58 char diskname[4096]; 58 char diskname[4096];
59 int sector_size; 59 int sector_size;
60 struct partinfo_t pinfo[4]; 60 struct sansa_partinfo_t pinfo[4];
61 int hasoldbootloader; 61 int hasoldbootloader;
62 loff_t start; /* Offset in bytes of firmware partition from start of disk */ 62 loff_t start; /* Offset in bytes of firmware partition from start of disk */
63}; 63};
diff --git a/rbutil/sansapatcher/sansapatcher.c b/rbutil/sansapatcher/sansapatcher.c
index 2081e396c2..310f312052 100644
--- a/rbutil/sansapatcher/sansapatcher.c
+++ b/rbutil/sansapatcher/sansapatcher.c
@@ -28,14 +28,16 @@
28 28
29#include "sansaio.h" 29#include "sansaio.h"
30#include "sansapatcher.h" 30#include "sansapatcher.h"
31#include "bootimg.h"
32 31
32#ifndef RBUTIL
33 #include "bootimg.h"
34#endif
33/* The offset of the MI4 image header in the firmware partition */ 35/* The offset of the MI4 image header in the firmware partition */
34#define PPMI_OFFSET 0x80000 36#define PPMI_OFFSET 0x80000
35 37
36extern int verbose; 38extern int verbose;
37 39
38/* Windows requires the buffer for disk I/O to be aligned in memory on a 40/* Windows requires the buffer for disk I/O to be aligned in memory on a
39 multiple of the disk volume size - so we use a single global variable 41 multiple of the disk volume size - so we use a single global variable
40 and initialise it with sansa_alloc_buf() in main(). 42 and initialise it with sansa_alloc_buf() in main().
41*/ 43*/
@@ -369,8 +371,8 @@ int is_e200(struct sansa_t* sansa)
369 sansa->hasoldbootloader = 0; 371 sansa->hasoldbootloader = 0;
370 if (memcmp(sectorbuf+0x1f8,"RBBL",4)==0) { 372 if (memcmp(sectorbuf+0x1f8,"RBBL",4)==0) {
371 /* Look for an original firmware after the first image */ 373 /* Look for an original firmware after the first image */
372 if (sansa_seek_and_read(sansa, 374 if (sansa_seek_and_read(sansa,
373 sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, 375 sansa->start + PPMI_OFFSET + 0x200 + ppmi_length,
374 sectorbuf, 512) < 0) { 376 sectorbuf, 512) < 0) {
375 return -7; 377 return -7;
376 } 378 }
@@ -461,14 +463,14 @@ static int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, str
461 463
462 if (get_mi4header(buf,mi4header)==0) { 464 if (get_mi4header(buf,mi4header)==0) {
463 /* We have a valid MI4 file after a bootloader, so we use this. */ 465 /* We have a valid MI4 file after a bootloader, so we use this. */
464 if ((n = sansa_seek_and_read(sansa, 466 if ((n = sansa_seek_and_read(sansa,
465 sansa->start + PPMI_OFFSET + 0x200 + ppmi_length, 467 sansa->start + PPMI_OFFSET + 0x200 + ppmi_length,
466 buf, mi4header->mi4size)) < 0) { 468 buf, mi4header->mi4size)) < 0) {
467 return -1; 469 return -1;
468 } 470 }
469 } else { 471 } else {
470 /* No valid MI4 file, so read the first image. */ 472 /* No valid MI4 file, so read the first image. */
471 if ((n = sansa_seek_and_read(sansa, 473 if ((n = sansa_seek_and_read(sansa,
472 sansa->start + PPMI_OFFSET + 0x200, 474 sansa->start + PPMI_OFFSET + 0x200,
473 buf, ppmi_length)) < 0) { 475 buf, ppmi_length)) < 0) {
474 return -1; 476 return -1;
@@ -571,7 +573,9 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type)
571 573
572 bl_length = filesize(infile); 574 bl_length = filesize(infile);
573 } else { 575 } else {
576 #ifndef RBUTIL
574 bl_length = LEN_bootimg; 577 bl_length = LEN_bootimg;
578 #endif
575 } 579 }
576 580
577 /* Create PPMI header */ 581 /* Create PPMI header */
@@ -595,7 +599,9 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type)
595 return -1; 599 return -1;
596 } 600 }
597 } else { 601 } else {
602 #ifndef RBUTIL
598 memcpy(sectorbuf+0x200,bootimg,LEN_bootimg); 603 memcpy(sectorbuf+0x200,bootimg,LEN_bootimg);
604 #endif
599 } 605 }
600 606
601 /* Load original firmware from Sansa to the space after the bootloader */ 607 /* Load original firmware from Sansa to the space after the bootloader */