From ad785518111eabe4518dca485421e533186f63a5 Mon Sep 17 00:00:00 2001 From: Tomer Shalev Date: Thu, 29 Oct 2009 21:31:50 +0000 Subject: 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 --- rbutil/rbutilqt/base/bootloaderinstalltcc.cpp | 154 ++++++++++++++++++++++++++ rbutil/rbutilqt/base/bootloaderinstalltcc.h | 45 ++++++++ rbutil/rbutilqt/rbutil.ini | 15 ++- rbutil/rbutilqt/rbutilqt.cpp | 4 + rbutil/rbutilqt/rbutilqt.pro | 16 ++- 5 files changed, 228 insertions(+), 6 deletions(-) create mode 100644 rbutil/rbutilqt/base/bootloaderinstalltcc.cpp create mode 100644 rbutil/rbutilqt/base/bootloaderinstalltcc.h (limited to 'rbutil/rbutilqt') diff --git a/rbutil/rbutilqt/base/bootloaderinstalltcc.cpp b/rbutil/rbutilqt/base/bootloaderinstalltcc.cpp new file mode 100644 index 0000000000..1d0a9e606e --- /dev/null +++ b/rbutil/rbutilqt/base/bootloaderinstalltcc.cpp @@ -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 +#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); +} diff --git a/rbutil/rbutilqt/base/bootloaderinstalltcc.h b/rbutil/rbutilqt/base/bootloaderinstalltcc.h new file mode 100644 index 0000000000..b91970034e --- /dev/null +++ b/rbutil/rbutilqt/base/bootloaderinstalltcc.h @@ -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 +#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 diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini index 9face81edf..46559fb3c1 100644 --- a/rbutil/rbutilqt/rbutil.ini +++ b/rbutil/rbutilqt/rbutil.ini @@ -58,7 +58,7 @@ platform60=mrobe100 platform70=smsgyh820 platform71=smsgyh920 platform72=smsgyh925 - +platform73=cowond2 [player] name="Jukebox Player 6000 / Jukebox Studio 5 / 10 / 20" @@ -537,6 +537,19 @@ usbid=0x04e85024 configure_modelname=yh925 encoder=rbspeex +[cowond2] +name="D2 (Unstable)" +buildserver_modelname=cowond2 +bootloadermethod=tcc +bootloadername=/cowon/d2.bin +bootloaderfile=d2n.bin +manualname= +brand=Cowon +usbid=0x0e210800, 0x0e210860, 0x0e210870, 0x0e210880, 0x0e210890 +usberror=0x0e210801, 0x0e210861, 0x0e210871, 0x0e210881, 0x0e210891 +configure_modelname=cowond2 +encoder=rbspeex + [05ac1240] name="Apple Ipod Nano (Second Generation, DFU Mode)" diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp index df8b4d878d..fd5983306d 100644 --- a/rbutil/rbutilqt/rbutilqt.cpp +++ b/rbutil/rbutilqt/rbutilqt.cpp @@ -47,6 +47,7 @@ #include "bootloaderinstallfile.h" #include "bootloaderinstallchinachip.h" #include "bootloaderinstallams.h" +#include "bootloaderinstalltcc.h" #if defined(Q_OS_LINUX) @@ -673,6 +674,9 @@ void RbUtilQt::installBootloader() else if(type == "ams") { bl = new BootloaderInstallAms(this); } + else if(type == "tcc") { + bl = new BootloaderInstallTcc(this); + } else { logger->addItem(tr("No install method known."), LOGERROR); logger->setFinished(); diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro index c1178b8967..b04667028b 100644 --- a/rbutil/rbutilqt/rbutilqt.pro +++ b/rbutil/rbutilqt/rbutilqt.pro @@ -42,14 +42,16 @@ LIBSPEEX = $$system(pkg-config --silence-errors --libs speex) rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex.a libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl.a libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot.a +libmktccboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mktccboot libmktccboot.a } mac { rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex-universal libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl-universal libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot-universal +libmktccboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mktccboot libmktccboot-universal } -QMAKE_EXTRA_TARGETS += rbspeex libucl libmkamsboot -PRE_TARGETDEPS += rbspeex libucl libmkamsboot +QMAKE_EXTRA_TARGETS += rbspeex libucl libmkamsboot libmktccboot +PRE_TARGETDEPS += rbspeex libucl libmkamsboot libmktccboot # rule for creating ctags file tags.commands = ctags -R --c++-kinds=+p --fields=+iaS --extra=+q $(SOURCES) @@ -110,8 +112,10 @@ SOURCES += rbutilqt.cpp \ base/bootloaderinstallfile.cpp \ base/bootloaderinstallchinachip.cpp \ base/bootloaderinstallams.cpp \ + base/bootloaderinstalltcc.cpp \ ../../tools/mkboot.c \ - ../../tools/iriver.c + ../../tools/iriver.c \ + ../../tools/telechips.c \ HEADERS += rbutilqt.h \ install.h \ @@ -170,8 +174,10 @@ HEADERS += rbutilqt.h \ base/bootloaderinstallfile.h \ base/bootloaderinstallchinachip.h \ base/bootloaderinstallams.h \ + base/bootloaderinstalltcc.h \ ../../tools/mkboot.h \ - ../../tools/iriver.h + ../../tools/iriver.h \ + ../../tools/telechips.h \ # Needed by QT on Win INCLUDEPATH = $$_PRO_FILE_PWD_ $$_PRO_FILE_PWD_/irivertools $$_PRO_FILE_PWD_/zip $$_PRO_FILE_PWD_/zlib $$_PRO_FILE_PWD_/base @@ -179,7 +185,7 @@ INCLUDEPATH += $$RBBASE_DIR/rbutil/ipodpatcher $$RBBASE_DIR/rbutil/sansapatcher DEPENDPATH = $$INCLUDEPATH -LIBS += -L$$OUT_PWD -L$$MYBUILDDIR -lrbspeex -lmkamsboot -lucl +LIBS += -L$$OUT_PWD -L$$MYBUILDDIR -lrbspeex -lmkamsboot -lmktccboot -lucl TEMPLATE = app dbg { -- cgit v1.2.3