mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-09 13:15:18 -05:00
FS#10728 - Cowon D2: Add support for D2 in rbutil
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23410 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0f90f0b423
commit
ad78551811
9 changed files with 522 additions and 71 deletions
154
rbutil/rbutilqt/base/bootloaderinstalltcc.cpp
Normal file
154
rbutil/rbutilqt/base/bootloaderinstalltcc.cpp
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2009 by Tomer Shalev
|
||||
* $Id$
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* This file is a modified version of the AMS installer by Dominik Wenger
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore>
|
||||
#include "bootloaderinstallbase.h"
|
||||
#include "bootloaderinstalltcc.h"
|
||||
#include "../mktccboot/mktccboot.h"
|
||||
|
||||
BootloaderInstallTcc::BootloaderInstallTcc(QObject *parent)
|
||||
: BootloaderInstallBase(parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString BootloaderInstallTcc::ofHint()
|
||||
{
|
||||
return tr("Bootloader installation requires you to provide "
|
||||
"a firmware file of the original firmware (bin file). "
|
||||
"You need to download this file yourself due to legal "
|
||||
"reasons."
|
||||
"Press Ok to continue and browse your computer for the firmware "
|
||||
"file.");
|
||||
}
|
||||
|
||||
bool BootloaderInstallTcc::install(void)
|
||||
{
|
||||
if(m_offile.isEmpty())
|
||||
return false;
|
||||
|
||||
// Download firmware from server
|
||||
emit logItem(tr("Downloading bootloader file"), LOGINFO);
|
||||
|
||||
connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2()));
|
||||
downloadBlStart(m_blurl);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void BootloaderInstallTcc::installStage2(void)
|
||||
{
|
||||
unsigned char *of_buf, *boot_buf = NULL, *patched_buf = NULL;
|
||||
int n, of_size, boot_size, patched_size;
|
||||
char errstr[200];
|
||||
bool ret = false;
|
||||
|
||||
m_tempfile.open();
|
||||
QString bootfile = m_tempfile.fileName();
|
||||
m_tempfile.close();
|
||||
|
||||
/* Construct path for write out.
|
||||
* Combine path of m_blfile with filename from OF */
|
||||
QString outfilename = QFileInfo(m_blfile).absolutePath() + "/" +
|
||||
QFileInfo(m_offile).fileName();
|
||||
|
||||
/* Write out file */
|
||||
QFile out(outfilename);
|
||||
|
||||
/* Load original firmware file */
|
||||
of_buf = file_read(m_offile.toLocal8Bit().data(), &of_size);
|
||||
if (of_buf == NULL)
|
||||
{
|
||||
emit logItem(errstr, LOGERROR);
|
||||
emit logItem(tr("Could not load %1").arg(m_offile), LOGERROR);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Load bootloader file */
|
||||
boot_buf = file_read(bootfile.toLocal8Bit().data(), &boot_size);
|
||||
if (boot_buf == NULL)
|
||||
{
|
||||
emit logItem(errstr, LOGERROR);
|
||||
emit logItem(tr("Could not load %1").arg(bootfile), LOGERROR);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* Patch the firmware */
|
||||
emit logItem(tr("Patching Firmware..."), LOGINFO);
|
||||
|
||||
patched_buf = patch_firmware_tcc(of_buf, of_size, boot_buf, boot_size,
|
||||
&patched_size);
|
||||
if (patched_buf == NULL)
|
||||
{
|
||||
emit logItem(errstr, LOGERROR);
|
||||
emit logItem(tr("Could patch firmware"), LOGERROR);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if(!out.open(QIODevice::WriteOnly | QIODevice::Truncate))
|
||||
{
|
||||
emit logItem(tr("Could not open %1 for writing").arg(m_blfile),
|
||||
LOGERROR);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
n = out.write((char*)patched_buf, patched_size);
|
||||
out.close();
|
||||
if (n != patched_size)
|
||||
{
|
||||
emit logItem(tr("Could not write firmware file"), LOGERROR);
|
||||
goto exit;
|
||||
}
|
||||
|
||||
/* End of install */
|
||||
emit logItem(tr("Success: modified firmware file created"), LOGINFO);
|
||||
logInstall(LogAdd);
|
||||
|
||||
ret = true;
|
||||
|
||||
exit:
|
||||
if (of_buf)
|
||||
free(of_buf);
|
||||
|
||||
if (boot_buf)
|
||||
free(boot_buf);
|
||||
|
||||
if (patched_buf)
|
||||
free(patched_buf);
|
||||
|
||||
emit done(ret);
|
||||
}
|
||||
|
||||
bool BootloaderInstallTcc::uninstall(void)
|
||||
{
|
||||
emit logItem("To uninstall, perform a normal upgrade with an unmodified original firmware", LOGINFO);
|
||||
logInstall(LogRemove);
|
||||
return false;
|
||||
}
|
||||
|
||||
BootloaderInstallBase::BootloaderType BootloaderInstallTcc::installed(void)
|
||||
{
|
||||
return BootloaderUnknown;
|
||||
}
|
||||
|
||||
BootloaderInstallBase::Capabilities BootloaderInstallTcc::capabilities(void)
|
||||
{
|
||||
return (Install | NeedsOf);
|
||||
}
|
||||
45
rbutil/rbutilqt/base/bootloaderinstalltcc.h
Normal file
45
rbutil/rbutilqt/base/bootloaderinstalltcc.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2009 by Tomer Shalev
|
||||
* $Id$
|
||||
*
|
||||
* All files in this archive are subject to the GNU General Public License.
|
||||
* See the file COPYING in the source tree root for full license agreement.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* This file is a modified version of the AMS installer by Dominik Wenger
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef BOOTLOADERINSTALLTCC_H
|
||||
#define BOOTLOADERINSTALLTCC_H
|
||||
|
||||
#include <QtCore>
|
||||
#include "bootloaderinstallbase.h"
|
||||
|
||||
//! bootloader installation derivate based on mktccboot
|
||||
class BootloaderInstallTcc : public BootloaderInstallBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BootloaderInstallTcc(QObject *parent);
|
||||
bool install(void);
|
||||
bool uninstall(void);
|
||||
BootloaderInstallBase::BootloaderType installed(void);
|
||||
Capabilities capabilities(void);
|
||||
QString ofHint();
|
||||
|
||||
private:
|
||||
|
||||
private slots:
|
||||
void installStage2(void);
|
||||
};
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue