summaryrefslogtreecommitdiffstats
path: root/rbutil
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 /rbutil
parent39939bb137bea1c149db5ff0edb1dd0dd1d3d596 (diff)
downloadrockbox-dde262b58a8bb908278179e916e0d91068d6987f.tar.gz
rockbox-dde262b58a8bb908278179e916e0d91068d6987f.tar.bz2
rockbox-dde262b58a8bb908278179e916e0d91068d6987f.zip
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')
-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 @@
CXX=$(shell $(PREFIX)wx-config --cxx)
INC =
-CFLAGS = -Wall -Wundef
-OBJS=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
+CFLAGS = -Wall -Wundef -DRBUTIL
+OBJS=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
# Install into /usr/local by default
ifndef 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 =
CXX = g++
CXXFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -Wall -Wundef -Wno-ctor-dtor-privacy -O2 -fno-strict-aliasing -fno-common
CPPFLAGS = -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
-RBUTIL_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
+RBUTIL_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
LDFLAGS = -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -framework QuickTime -framework IOKit -framework Carbon -framework Cocoa -framework System
WX_LIB_FLAVOUR =
TOOLKIT = MAC
@@ -51,6 +51,7 @@ RBUTIL_OBJECTS = \
$(__rbutil_os2_lib_res) \
rbutil.o rbutilApp.o rbutilFrm.o install_dialogs.o bootloaders.o installlog.o \
rbutilCtrls.o ipodpatcher/ipodpatcher.o ipodpatcher/ipodio-posix.o \
+ sansapatcher/sansapatcher.o sansapatcher/sansaio-posix.o \
md5sum.o irivertools.o \
$(__rbutil___win32rc)
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 @@
#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(&sectorbuf,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)
{
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 @@
extern "C" {
// Ipodpatcher
#include "ipodpatcher/ipodpatcher.h"
+ // Sansapatcher
+ #include "sansapatcher/sansapatcher.h"
};
bool initIpodpatcher();
+bool initSansaPatcher();
bool ipodpatcher(int mode,wxString bootloadername);
+bool sansapatcher(int mode,wxString bootloadername);
bool gigabeatf(int mode,wxString bootloadername,wxString deviceDir);
bool iaudiox5(int mode,wxString bootloadername,wxString deviceDir);
bool 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 @@
#define CREDITS_H_INCLUDED
#define RBUTIL_FULLNAME "The Rockbox Utility"
-#define RBUTIL_VERSION "Version 0.3.1.0"
+#define RBUTIL_VERSION "Version 0.3.2.0"
static const wxString rbutil_developers[] = {
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 @@
#define RBUTIL 1
#include <wx/msw/wx.rc>
RBUTIL VERSIONINFO
-FILEVERSION 0,3,1,0
-PRODUCTVERSION 0,3,1,0
+FILEVERSION 0,3,2,0
+PRODUCTVERSION 0,3,2,0
FILEOS 0x00000004
FILETYPE 0x00000001
BEGIN
@@ -10,8 +10,8 @@ BEGIN
BEGIN
BLOCK "FFFF0000"
BEGIN
- VALUE "FileVersion", "0.3.1.0\0"
- VALUE "ProductVersion", "0.3.1.0\0"
+ VALUE "FileVersion", "0.3.2.0\0"
+ VALUE "ProductVersion", "0.3.2.0\0"
VALUE "CompanyName", "Rockbox Team\0"
VALUE "FileDescription", "Rockbox Utility\0"
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 @@
<Add option="-D__GNUWIN32__" />
<Add option="-D__WXMSW__" />
<Add option="-DUSE_PCH" />
+ <Add option="-DRBUTIL" />
<Add directory="$(#WX.include)" />
<Add directory="$(#WX.lib)\gcc_lib$(WX_CFG)\msw" />
<Add directory="$(#WX)\contrib\include" />
@@ -130,9 +131,22 @@
<Unit filename="rbutil.iss" />
<Unit filename="rbutilApp.cpp" />
<Unit filename="rbutilApp.h" />
+ <Unit filename="rbutilCtrls.cpp" />
+ <Unit filename="rbutilCtrls.h" />
<Unit filename="rbutilFrm.cpp" />
<Unit filename="rbutilFrm.h" />
<Unit filename="rbutilFrm_XPM.xpm" />
+ <Unit filename="sansapatcher\parttypes.h" />
+ <Unit filename="sansapatcher\sansaio-win32.c">
+ <Option compilerVar="CC" />
+ <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" />
+ </Unit>
+ <Unit filename="sansapatcher\sansaio.h" />
+ <Unit filename="sansapatcher\sansapatcher.c">
+ <Option compilerVar="CC" />
+ <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" />
+ </Unit>
+ <Unit filename="sansapatcher\sansapatcher.h" />
<Unit filename="themes_3d.xpm" />
<Unit filename="tools2_3d.xpm" />
<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
platform23=iaudiom5
platform24=iaudiox5v
platform25=gigabeatf
+platform26=sansae200
[player]
name=Archos Jukebox Player 6000, Jukebox Studio 5/10/20
@@ -259,3 +260,12 @@ needsbootloader=yes
bootloadermethod=gigabeatf
bootloadername=FWIMG01.DAT
resolution=240x320x16
+
+[sansae200]
+name=Sandisk Sansa E200
+platform=sansae200
+released=no
+needsbootloader=yes
+bootloadermethod=sansapatcher
+bootloadername=PP5022.mi4
+resolution=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()
rbutilFrm *myFrame = new rbutilFrm(NULL);
SetTopWindow(myFrame);
-
+
myFrame->Show(TRUE);
initIpodpatcher(); // reserve mem for ipodpatcher
+ initSansaPatcher(); // reserve mem for sansapatcher
+
wxInitAllImageHandlers(); //init Image handlers
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()
void ThemeCtrl::setDevice(wxString device)
{
-
+
int index = gv->plat_id.Index(device);
if(index == -1) return;
@@ -210,13 +210,13 @@ void ThemeCtrl::setDevice(wxString device)
m_themeList->Append(m_Themes.Last());
}
-
+
this->GetSizer()->Layout();
this->GetSizer()->Fit(this);
this->GetSizer()->SetSizeHints(this);
m_parent->GetSizer()->Layout();
m_parent->GetSizer()->Fit(m_parent);
- m_parent->GetSizer()->SetSizeHints(m_parent);
+ m_parent->GetSizer()->SetSizeHints(m_parent);
}
@@ -265,10 +265,10 @@ void ThemeCtrl::OnThemesLst(wxCommandEvent& event)
this->GetSizer()->Layout();
this->GetSizer()->Fit(this);
this->GetSizer()->SetSizeHints(this);
-
+
m_parent->GetSizer()->Layout();
m_parent->GetSizer()->Fit(m_parent);
- m_parent->GetSizer()->SetSizeHints(m_parent);
+ m_parent->GetSizer()->SetSizeHints(m_parent);
}
@@ -369,7 +369,7 @@ void DeviceSelectorCtrl::CreateControls()
m_deviceCbx = new wxComboBox(this, ID_DEVICE_CBX,wxT(""),
wxDefaultPosition,wxDefaultSize,gv->plat_name,wxCB_READONLY);
-
+
m_deviceCbx->SetToolTip(wxT("Select your Device."));
m_deviceCbx->SetHelpText(wxT("Select your Device."));
@@ -413,24 +413,39 @@ void DeviceSelectorCtrl::OnAutoDetect(wxCommandEvent& event)
int n = ipod_scan(&ipod);
if(n == 1)
{
- wxString temp(ipod.targetname,wxConvUTF8);
- int index = gv->plat_bootloadername.Index(temp);
+ wxString temp(ipod.targetname,wxConvUTF8);
+ int index = gv->plat_bootloadername.Index(temp); // use the bootloader names..
m_deviceCbx->SetValue(gv->plat_name[index]);
gv->curplat=gv->plat_id[index];
+ return;
}
else if (n > 1)
{
- WARN_DIALOG(wxT("More then one device Ipod detected, please connect only One"),
+ WARN_DIALOG(wxT("More then one Ipod device detected, please connect only One"),
wxT("Detecting a Device"));
return;
}
- else
+
+ struct sansa_t sansa;
+ int n2 = sansa_scan(&sansa);
+ if(n2==1)
{
- WARN_DIALOG(wxT("No Device detected. (This function currently only works for Ipods)."),
+ int index = gv->plat_id.Index(wxT("sansae200"));
+ m_deviceCbx->SetValue(gv->plat_name[index]);
+ gv->curplat=gv->plat_id[index];
+ return;
+ }
+ else if (n2 > 1)
+ {
+ WARN_DIALOG(wxT("More then one Sansa device detected, please connect only One"),
wxT("Detecting a Device"));
return;
}
+ WARN_DIALOG(wxT("No Device detected. (This function currently only works for Ipods and Sansas)."),
+ wxT("Detecting a Device"));
+ return;
+
}
/////////////////////////////////////////////
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)
wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxVERTICAL);
this->SetSizer(WxBoxSizer1);
this->SetAutoLayout(TRUE);
-
+
wxPanel* mainPanel = new wxPanel(this,wxID_ANY);
WxBoxSizer1->Add(mainPanel,0,wxALL,0);
wxBoxSizer* WxBoxSizer0 = new wxBoxSizer(wxVERTICAL);
@@ -87,24 +87,24 @@ void rbutilFrm::CreateGUIControls(void)
myDeviceSelector->setDefault();
WxBoxSizer0->Add(myDeviceSelector,0,wxALL,5);
- wxNotebook* tabwindow = new wxNotebook(mainPanel,wxID_ANY);
+ wxNotebook* tabwindow = new wxNotebook(mainPanel,wxID_ANY);
WxBoxSizer0->Add(tabwindow,0,wxALL,5);
-
+
wxPanel* installpage = new wxPanel(tabwindow,wxID_ANY);
wxPanel* themepage = new wxPanel(tabwindow,wxID_ANY);
wxPanel* uninstallpage = new wxPanel(tabwindow,wxID_ANY);
tabwindow->AddPage(installpage,wxT("Installation"),true);
tabwindow->AddPage(themepage,wxT("Themes"));
tabwindow->AddPage(uninstallpage,wxT("Uninstallation"));
-
+
/*********************
Install Page
- ***********************/
-
+ ***********************/
+
wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxVERTICAL);
installpage->SetSizer(WxBoxSizer2);
installpage->SetAutoLayout(TRUE);
-
+
wxStaticBox* WxStaticBoxSizer3_StaticBoxObj = new wxStaticBox(installpage,
wxID_ANY, wxT("Please choose an option"));
wxStaticBoxSizer* WxStaticBoxSizer3 =
@@ -153,13 +153,13 @@ void rbutilFrm::CreateGUIControls(void)
wxBoxSizer* WxBoxSizer3 = new wxBoxSizer(wxVERTICAL);
themepage->SetSizer(WxBoxSizer3);
themepage->SetAutoLayout(TRUE);
-
+
wxStaticBox* WxStaticBoxSizer4_StaticBoxObj = new wxStaticBox(themepage,
wxID_ANY, wxT("Please choose an option"));
wxStaticBoxSizer* WxStaticBoxSizer4 =
new wxStaticBoxSizer(WxStaticBoxSizer4_StaticBoxObj,wxHORIZONTAL);
WxBoxSizer3->Add(WxStaticBoxSizer4,1,wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
-
+
wxFlexGridSizer* WxFlexGridSizer2 = new wxFlexGridSizer(2,2,0,0);
WxStaticBoxSizer4->Add(WxFlexGridSizer2,0,wxGROW | wxALL,0);
@@ -193,24 +193,24 @@ void rbutilFrm::CreateGUIControls(void)
wxT("Install more Themes for Rockbox.\n\n"));
WxFlexGridSizer2->Add(WxStaticText6, 0,
wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL,5);
-
+
/* ********************+
Uninstall Page
***********************/
wxBoxSizer* WxBoxSizer4 = new wxBoxSizer(wxVERTICAL);
uninstallpage->SetSizer(WxBoxSizer4);
- uninstallpage->SetAutoLayout(TRUE);
-
+ uninstallpage->SetAutoLayout(TRUE);
+
wxStaticBox* WxStaticBoxSizer5_StaticBoxObj = new wxStaticBox(uninstallpage,
wxID_ANY, wxT("Please choose an option"));
wxStaticBoxSizer* WxStaticBoxSizer5 =
new wxStaticBoxSizer(WxStaticBoxSizer5_StaticBoxObj,wxHORIZONTAL);
WxBoxSizer4->Add(WxStaticBoxSizer5,1,wxALIGN_CENTER_HORIZONTAL | wxALL, 5);
-
+
wxFlexGridSizer* WxFlexGridSizer3 = new wxFlexGridSizer(2,2,0,0);
WxStaticBoxSizer5->Add(WxFlexGridSizer3,0,wxGROW | wxALL,0);
-
+
wxBitmap WxBitmapButton2_BITMAP (uninstall_3d_xpm);
WxBitmapButton2 = new wxBitmapButton(uninstallpage, ID_REMOVE_BTN,
WxBitmapButton2_BITMAP, wxPoint(0,0), wxSize(64,54),
@@ -270,7 +270,7 @@ void rbutilFrm::CreateGUIControls(void)
wxIcon rbutilFrm_ICON (rbutilFrm_XPM);
this->SetIcon(rbutilFrm_XPM);
this->SetToolTip(wxT("Install Rockbox"));
-
+
wxLogVerbose(wxT("=== end rbutilFrm::CreateGUIControls"));
}
@@ -374,6 +374,17 @@ void rbutilFrm::OnBootloaderRemoveBtn(wxCommandEvent& event)
MESG_DIALOG(wxT("The Uninstallation failed.") );
}
}
+ if(bootloadermethod == wxT("sansapatcher"))
+ {
+ if(sansapatcher(BOOTLOADER_REM,gv->plat_bootloadername[index]))
+ {
+ MESG_DIALOG(wxT("The Bootloader has been uninstalled.") );
+ }
+ else
+ {
+ MESG_DIALOG(wxT("The Uninstallation failed.") );
+ }
+ }
else if(bootloadermethod== wxT("gigabeatf"))
{
@@ -439,6 +450,18 @@ void rbutilFrm::OnBootloaderBtn(wxCommandEvent& event)
MESG_DIALOG(wxT("The installation has failed.") );
}
}
+ if(bootloadermethod == wxT("sansapatcher"))
+ {
+ if(sansapatcher(BOOTLOADER_ADD,gv->plat_bootloadername[index]))
+ {
+ MESG_DIALOG(wxT("The Bootloader has been installed on your device.") );
+ }
+ else
+ {
+ MESG_DIALOG(wxT("The installation has failed.") );
+ }
+
+ }
else if(bootloadermethod== wxT("gigabeatf"))
{
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 @@
#include "sansaio.h"
+#ifndef RBUTIL
void print_error(char* msg)
{
perror(msg);
}
+#endif
int sansa_open(struct sansa_t* sansa, int silent)
{
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 @@
#include "sansaio.h"
-static int lock_volume(HANDLE hDisk)
-{
+static int lock_volume(HANDLE hDisk)
+{
DWORD dummy;
return DeviceIoControl(hDisk, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0,
- &dummy, NULL);
+ &dummy, NULL);
}
-static int unlock_volume(HANDLE hDisk)
-{
+static int unlock_volume(HANDLE hDisk)
+{
DWORD dummy;
return DeviceIoControl(hDisk, FSCTL_UNLOCK_VOLUME, NULL, 0, NULL, 0,
- &dummy, NULL);
-}
+ &dummy, NULL);
+}
+#ifndef RBUTIL
void print_error(char* msg)
{
char* pMsgBuf;
@@ -65,7 +66,7 @@ void print_error(char* msg)
printf(pMsgBuf);
LocalFree(pMsgBuf);
}
-
+#endif
int sansa_open(struct sansa_t* sansa, int silent)
{
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 @@
#endif
-struct partinfo_t {
+struct sansa_partinfo_t {
unsigned long start; /* first sector (LBA) */
unsigned long size; /* number of sectors */
int type;
@@ -57,7 +57,7 @@ struct sansa_t {
HANDLE dh;
char diskname[4096];
int sector_size;
- struct partinfo_t pinfo[4];
+ struct sansa_partinfo_t pinfo[4];
int hasoldbootloader;
loff_t start; /* Offset in bytes of firmware partition from start of disk */
};
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 @@
#include "sansaio.h"
#include "sansapatcher.h"
-#include "bootimg.h"
+#ifndef RBUTIL
+ #include "bootimg.h"
+#endif
/* The offset of the MI4 image header in the firmware partition */
#define PPMI_OFFSET 0x80000
extern int verbose;
-/* Windows requires the buffer for disk I/O to be aligned in memory on a
+/* Windows requires the buffer for disk I/O to be aligned in memory on a
multiple of the disk volume size - so we use a single global variable
and initialise it with sansa_alloc_buf() in main().
*/
@@ -369,8 +371,8 @@ int is_e200(struct sansa_t* sansa)
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,
+ if (sansa_seek_and_read(sansa,
+ sansa->start + PPMI_OFFSET + 0x200 + ppmi_length,
sectorbuf, 512) < 0) {
return -7;
}
@@ -461,14 +463,14 @@ static int load_original_firmware(struct sansa_t* sansa, unsigned char* buf, str
if (get_mi4header(buf,mi4header)==0) {
/* We have a valid MI4 file after a bootloader, so we use this. */
- if ((n = sansa_seek_and_read(sansa,
+ if ((n = sansa_seek_and_read(sansa,
sansa->start + PPMI_OFFSET + 0x200 + ppmi_length,
buf, mi4header->mi4size)) < 0) {
return -1;
}
} else {
/* No valid MI4 file, so read the first image. */
- if ((n = sansa_seek_and_read(sansa,
+ if ((n = sansa_seek_and_read(sansa,
sansa->start + PPMI_OFFSET + 0x200,
buf, ppmi_length)) < 0) {
return -1;
@@ -571,7 +573,9 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type)
bl_length = filesize(infile);
} else {
+ #ifndef RBUTIL
bl_length = LEN_bootimg;
+ #endif
}
/* Create PPMI header */
@@ -595,7 +599,9 @@ int sansa_add_bootloader(struct sansa_t* sansa, char* filename, int type)
return -1;
}
} else {
+ #ifndef RBUTIL
memcpy(sectorbuf+0x200,bootimg,LEN_bootimg);
+ #endif
}
/* Load original firmware from Sansa to the space after the bootloader */