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
This commit is contained in:
parent
d8f5a00fc1
commit
bf1c491c2b
3 changed files with 27 additions and 24 deletions
|
@ -796,6 +796,26 @@ int add_new_image(struct ipod_t* ipod, char* imagename, char* filename, int type
|
|||
}
|
||||
|
||||
|
||||
int ipod_has_bootloader(struct ipod_t* ipod)
|
||||
{
|
||||
/* The 2nd gen Nano is installed differently */
|
||||
if (ipod->modelnum == 62) {
|
||||
int i;
|
||||
int has_osbk = 0;
|
||||
/* Check if we have an OSBK image */
|
||||
for (i = 0; i < ipod->nimages; i++) {
|
||||
if (ipod->ipod_directory[i].ftype==FTYPE_OSBK) {
|
||||
has_osbk = 1;
|
||||
}
|
||||
}
|
||||
return has_osbk;
|
||||
}
|
||||
else {
|
||||
return (ipod->ipod_directory[0].entryOffset != 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Bootloader installation on the Nano2G consists of renaming the
|
||||
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
|
|||
|
||||
static int add_bootloader_nano2g(struct ipod_t* ipod, char* filename, int type)
|
||||
{
|
||||
int i;
|
||||
int has_osbk = 0;
|
||||
|
||||
/* Check if we already have an OSBK image */
|
||||
for (i = 0; i < ipod->nimages; i++) {
|
||||
if (ipod->ipod_directory[i].ftype==FTYPE_OSBK) {
|
||||
has_osbk = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_osbk == 0) {
|
||||
if (ipod_has_bootloader(ipod) == 0) {
|
||||
/* First-time install - rename OSOS to OSBK and create new OSOS for bootloader */
|
||||
fprintf(stderr,"[INFO] Creating OSBK backup image of original firmware\n");
|
||||
|
||||
|
@ -841,17 +852,8 @@ static int add_bootloader_nano2g(struct ipod_t* ipod, char* filename, int type)
|
|||
|
||||
static int delete_bootloader_nano2g(struct ipod_t* ipod)
|
||||
{
|
||||
int i;
|
||||
int has_osbk = 0;
|
||||
|
||||
/* Check if we have an OSBK image */
|
||||
for (i = 0; i < ipod->nimages; i++) {
|
||||
if (ipod->ipod_directory[i].ftype==FTYPE_OSBK) {
|
||||
has_osbk = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (has_osbk == 0) {
|
||||
if (ipod_has_bootloader(ipod) == 0) {
|
||||
fprintf(stderr,"[ERR] No OSBK image found - nothing to uninstall\n");
|
||||
return -1;
|
||||
} else {
|
||||
|
@ -1118,7 +1120,7 @@ int delete_bootloader(struct ipod_t* ipod)
|
|||
|
||||
/* Firstly check we have a bootloader... */
|
||||
|
||||
if (ipod->ipod_directory[0].entryOffset == 0) {
|
||||
if (ipod_has_bootloader(ipod) == 0) {
|
||||
fprintf(stderr,"[ERR] No bootloader found.\n");
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -69,6 +69,7 @@ void ipod_get_ramsize(struct ipod_t* ipod);
|
|||
int read_aupd(struct ipod_t* ipod, char* filename);
|
||||
int write_aupd(struct ipod_t* ipod, char* filename);
|
||||
off_t filesize(int fd);
|
||||
int ipod_has_bootloader(struct ipod_t* ipod);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ bool BootloaderInstallIpod::uninstall(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (ipod.ipod_directory[0].entryOffset == 0) {
|
||||
if (ipod_has_bootloader(&ipod) == 0) {
|
||||
emit logItem(tr("No bootloader detected."), LOGERROR);
|
||||
emit done(true);
|
||||
return false;
|
||||
|
@ -199,8 +199,8 @@ BootloaderInstallBase::BootloaderType BootloaderInstallIpod::installed(void)
|
|||
}
|
||||
else {
|
||||
read_directory(&ipod);
|
||||
if(ipod.ipod_directory[0].entryOffset == 0 || ipod.macpod) {
|
||||
qDebug() << "[BootloaderInstallIpod] installed: BootloaderOther";
|
||||
getmodel(&ipod,(ipod.ipod_directory[ipod.ososimage].vers>>8));
|
||||
if(!ipod_has_bootloader(&ipod)) {
|
||||
result = BootloaderOther;
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Reference in a new issue