diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-07-01 12:29:47 +0200 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-07-01 12:34:59 +0200 |
commit | bf1c491c2b510648a3c1efc2c381e30635248d18 (patch) | |
tree | 039f50a8c5eaae0270e5ae295de4ee23a9ded9ed /rbutil | |
parent | d8f5a00fc1cd8beff431bd236377b3fccece29fd (diff) | |
download | rockbox-bf1c491c2b510648a3c1efc2c381e30635248d18.tar.gz rockbox-bf1c491c2b510648a3c1efc2c381e30635248d18.zip |
Move check for existing bootloader to ipodpatcher.
Bootloader handling is different on nano2g compared to the other supported Ipod
models. Since ipodpatcher handles this internally make ipodpatcher also provide
a way to check this when using from Rockbox Utility to avoid duplicating the
(already existing) checks in the latter.
Fixes wrong "bootloader already installed" message on nano2g.
Change-Id: Ibc658d775fbac7cf9a7e329d445fe97828a455d8
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/ipodpatcher/ipodpatcher.c | 44 | ||||
-rw-r--r-- | rbutil/ipodpatcher/ipodpatcher.h | 1 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallipod.cpp | 6 |
3 files changed, 27 insertions, 24 deletions
diff --git a/rbutil/ipodpatcher/ipodpatcher.c b/rbutil/ipodpatcher/ipodpatcher.c index 9f446d4ea4..542e078605 100644 --- a/rbutil/ipodpatcher/ipodpatcher.c +++ b/rbutil/ipodpatcher/ipodpatcher.c | |||
@@ -796,6 +796,26 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type | |||
796 | } | 796 | } |
797 | 797 | ||
798 | 798 | ||
799 | int ipod_has_bootloader(struct ipod_t* ipod) | ||
800 | { | ||
801 | /* The 2nd gen Nano is installed differently */ | ||
802 | if (ipod->modelnum == 62) { | ||
803 | int i; | ||
804 | int has_osbk = 0; | ||
805 | /* Check if we have an OSBK image */ | ||
806 | for (i = 0; i < ipod->nimages; i++) { | ||
807 | if (ipod->ipod_directory[i].ftype==FTYPE_OSBK) { | ||
808 | has_osbk = 1; | ||
809 | } | ||
810 | } | ||
811 | return has_osbk; | ||
812 | } | ||
813 | else { | ||
814 | return (ipod->ipod_directory[0].entryOffset != 0); | ||
815 | } | ||
816 | } | ||
817 | |||
818 | |||
799 | /* | 819 | /* |
800 | Bootloader installation on the Nano2G consists of renaming the | 820 | Bootloader installation on the Nano2G consists of renaming the |
801 | OSOS image to OSBK and then writing the Rockbox bootloader as a | 821 | OSOS image to OSBK and then writing the Rockbox bootloader as a |
@@ -810,17 +830,8 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type | |||
810 | 830 | ||
811 | static int add_bootloader_nano2g(struct ipod_t* ipod, char* filename, int type) | 831 | static int add_bootloader_nano2g(struct ipod_t* ipod, char* filename, int type) |
812 | { | 832 | { |
813 | int i; | ||
814 | int has_osbk = 0; | ||
815 | |||
816 | /* Check if we already have an OSBK image */ | 833 | /* Check if we already have an OSBK image */ |
817 | for (i = 0; i < ipod->nimages; i++) { | 834 | if (ipod_has_bootloader(ipod) == 0) { |
818 | if (ipod->ipod_directory[i].ftype==FTYPE_OSBK) { | ||
819 | has_osbk = 1; | ||
820 | } | ||
821 | } | ||
822 | |||
823 | if (has_osbk == 0) { | ||
824 | /* First-time install - rename OSOS to OSBK and create new OSOS for bootloader */ | 835 | /* First-time install - rename OSOS to OSBK and create new OSOS for bootloader */ |
825 | fprintf(stderr,"[INFO] Creating OSBK backup image of original firmware\n"); | 836 | fprintf(stderr,"[INFO] Creating OSBK backup image of original firmware\n"); |
826 | 837 | ||
@@ -841,17 +852,8 @@ static int add_bootloader_nano2g(struct ipod_t* ipod, char* filename, int type) | |||
841 | 852 | ||
842 | static int delete_bootloader_nano2g(struct ipod_t* ipod) | 853 | static int delete_bootloader_nano2g(struct ipod_t* ipod) |
843 | { | 854 | { |
844 | int i; | ||
845 | int has_osbk = 0; | ||
846 | |||
847 | /* Check if we have an OSBK image */ | 855 | /* Check if we have an OSBK image */ |
848 | for (i = 0; i < ipod->nimages; i++) { | 856 | if (ipod_has_bootloader(ipod) == 0) { |
849 | if (ipod->ipod_directory[i].ftype==FTYPE_OSBK) { | ||
850 | has_osbk = 1; | ||
851 | } | ||
852 | } | ||
853 | |||
854 | if (has_osbk == 0) { | ||
855 | fprintf(stderr,"[ERR] No OSBK image found - nothing to uninstall\n"); | 857 | fprintf(stderr,"[ERR] No OSBK image found - nothing to uninstall\n"); |
856 | return -1; | 858 | return -1; |
857 | } else { | 859 | } else { |
@@ -1118,7 +1120,7 @@ int delete_bootloader(struct ipod_t* ipod) | |||
1118 | 1120 | ||
1119 | /* Firstly check we have a bootloader... */ | 1121 | /* Firstly check we have a bootloader... */ |
1120 | 1122 | ||
1121 | if (ipod->ipod_directory[0].entryOffset == 0) { | 1123 | if (ipod_has_bootloader(ipod) == 0) { |
1122 | fprintf(stderr,"[ERR] No bootloader found.\n"); | 1124 | fprintf(stderr,"[ERR] No bootloader found.\n"); |
1123 | return -1; | 1125 | return -1; |
1124 | } | 1126 | } |
diff --git a/rbutil/ipodpatcher/ipodpatcher.h b/rbutil/ipodpatcher/ipodpatcher.h index 30a1b1e9fd..dc3f100520 100644 --- a/rbutil/ipodpatcher/ipodpatcher.h +++ b/rbutil/ipodpatcher/ipodpatcher.h | |||
@@ -69,6 +69,7 @@ void ipod_get_ramsize(struct ipod_t* ipod); | |||
69 | int read_aupd(struct ipod_t* ipod, char* filename); | 69 | int read_aupd(struct ipod_t* ipod, char* filename); |
70 | int write_aupd(struct ipod_t* ipod, char* filename); | 70 | int write_aupd(struct ipod_t* ipod, char* filename); |
71 | off_t filesize(int fd); | 71 | off_t filesize(int fd); |
72 | int ipod_has_bootloader(struct ipod_t* ipod); | ||
72 | 73 | ||
73 | #ifdef __cplusplus | 74 | #ifdef __cplusplus |
74 | } | 75 | } |
diff --git a/rbutil/rbutilqt/base/bootloaderinstallipod.cpp b/rbutil/rbutilqt/base/bootloaderinstallipod.cpp index cb69faa35b..249da13735 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallipod.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallipod.cpp | |||
@@ -166,7 +166,7 @@ bool BootloaderInstallIpod::uninstall(void) | |||
166 | return false; | 166 | return false; |
167 | } | 167 | } |
168 | 168 | ||
169 | if (ipod.ipod_directory[0].entryOffset == 0) { | 169 | if (ipod_has_bootloader(&ipod) == 0) { |
170 | emit logItem(tr("No bootloader detected."), LOGERROR); | 170 | emit logItem(tr("No bootloader detected."), LOGERROR); |
171 | emit done(true); | 171 | emit done(true); |
172 | return false; | 172 | return false; |
@@ -199,8 +199,8 @@ BootloaderInstallBase::BootloaderType BootloaderInstallIpod::installed(void) | |||
199 | } | 199 | } |
200 | else { | 200 | else { |
201 | read_directory(&ipod); | 201 | read_directory(&ipod); |
202 | if(ipod.ipod_directory[0].entryOffset == 0 || ipod.macpod) { | 202 | getmodel(&ipod,(ipod.ipod_directory[ipod.ososimage].vers>>8)); |
203 | qDebug() << "[BootloaderInstallIpod] installed: BootloaderOther"; | 203 | if(!ipod_has_bootloader(&ipod)) { |
204 | result = BootloaderOther; | 204 | result = BootloaderOther; |
205 | } | 205 | } |
206 | else { | 206 | else { |