mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
Rockbox Utility: add support for mkimxboot bootloader.
Reworked version of FS#12402 by Jean-Louis Biasini. Since the mkimxboot process takes quite a while which blocks the UI it has been adjusted to perform the actual firmware patching in a separate process. Various other small changes have been made to make it fit better into Rockbox Utility's dialogs / messages and update the code to latest changes. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31580 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
56e1e859ca
commit
61f999a16e
6 changed files with 264 additions and 3 deletions
|
|
@ -29,6 +29,7 @@
|
|||
#include "bootloaderinstallams.h"
|
||||
#include "bootloaderinstalltcc.h"
|
||||
#include "bootloaderinstallmpio.h"
|
||||
#include "bootloaderinstallimx.h"
|
||||
#include "utils.h"
|
||||
|
||||
#if defined(Q_OS_MACX)
|
||||
|
|
@ -67,6 +68,9 @@ BootloaderInstallBase* BootloaderInstallBase::createBootloaderInstaller(QObject*
|
|||
else if(type == "mpio") {
|
||||
return new BootloaderInstallMpio(parent);
|
||||
}
|
||||
else if(type == "imx") {
|
||||
return new BootloaderInstallImx(parent);
|
||||
}
|
||||
else {
|
||||
return NULL;
|
||||
}
|
||||
|
|
@ -205,6 +209,10 @@ QString BootloaderInstallBase::postinstallHints(QString model)
|
|||
|
||||
msg += "<ol>";
|
||||
msg += tr("<li>Safely remove your player.</li>");
|
||||
if(model == "sansafuzeplus") {
|
||||
msg += tr("<li>Remove any previously inserted microSD card</li>");
|
||||
hint = true;
|
||||
}
|
||||
if(model == "h100" || model == "h120" || model == "h300" ||
|
||||
model == "ondavx747") {
|
||||
hint = true;
|
||||
|
|
@ -217,6 +225,16 @@ QString BootloaderInstallBase::postinstallHints(QString model)
|
|||
"process.</b></li>"
|
||||
"<li>After the firmware has been updated reboot your player.</li>");
|
||||
}
|
||||
if(model == "sansafuzeplus") {
|
||||
hint = true;
|
||||
msg += tr("<li>Disconnect your player. The player will reboot and "
|
||||
"perform an update of the original firmware. "
|
||||
"Please refer to your players manual on details.<br/>"
|
||||
"<b>Important:</b> updating the firmware is a "
|
||||
"critical process that must not be interrupted. <b>Make sure the "
|
||||
"player is charged before disconnecting the player.</b></li>"
|
||||
"<li>After the firmware has been updated reboot your player.</li>");
|
||||
}
|
||||
if(model == "iaudiox5" || model == "iaudiom5"
|
||||
|| model == "iaudiox5v" || model == "iaudiom3" || model == "mpioh200") {
|
||||
hint = true;
|
||||
|
|
|
|||
189
rbutil/rbutilqt/base/bootloaderinstallimx.cpp
Normal file
189
rbutil/rbutilqt/base/bootloaderinstallimx.cpp
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2011 by Jean-Louis Biasini
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore>
|
||||
#include <QtDebug>
|
||||
#include "bootloaderinstallbase.h"
|
||||
#include "bootloaderinstallimx.h"
|
||||
#include "../mkimxboot/mkimxboot.h"
|
||||
|
||||
// class for running mkimxboot() in a separate thread to keep the UI responsive.
|
||||
class BootloaderThreadImx : public QThread
|
||||
{
|
||||
public:
|
||||
void run(void);
|
||||
void setInputFile(QString f)
|
||||
{ m_inputfile = f; }
|
||||
void setOutputFile(QString f)
|
||||
{ m_outputfile = f; }
|
||||
void setBootloaderFile(QString f)
|
||||
{ m_bootfile = f; }
|
||||
enum imx_error_t error(void)
|
||||
{ return m_error; }
|
||||
private:
|
||||
QString m_inputfile;
|
||||
QString m_bootfile;
|
||||
QString m_outputfile;
|
||||
enum imx_error_t m_error;
|
||||
};
|
||||
|
||||
|
||||
void BootloaderThreadImx::run(void)
|
||||
{
|
||||
qDebug() << "[BootloaderThreadImx] Thread started.";
|
||||
struct imx_option_t opt;
|
||||
opt.debug = false;
|
||||
opt.output = IMX_DUALBOOT;
|
||||
|
||||
m_error = mkimxboot(m_inputfile.toLocal8Bit().constData(),
|
||||
m_bootfile.toLocal8Bit().constData(),
|
||||
m_outputfile.toLocal8Bit().constData(), opt);
|
||||
qDebug() << "[BootloaderThreadImx] Thread finished, result:" << m_error;
|
||||
}
|
||||
|
||||
|
||||
BootloaderInstallImx::BootloaderInstallImx(QObject *parent)
|
||||
: BootloaderInstallBase(parent)
|
||||
{
|
||||
m_thread = NULL;
|
||||
}
|
||||
|
||||
|
||||
QString BootloaderInstallImx::ofHint()
|
||||
{
|
||||
return tr("Bootloader installation requires you to provide "
|
||||
"a copy of the original Sandisk firmware (firmware.sb file). "
|
||||
"This file will be patched with the Rockbox bootloader and "
|
||||
"installed to your player. You need to download this file "
|
||||
"yourself due to legal reasons. Please browse the "
|
||||
"<a href='http://forums.sandisk.com/sansa/'>Sansa Forums</a> "
|
||||
"or refer to the "
|
||||
"<a href= 'http://www.rockbox.org/wiki/SansaFuzePlus'>SansaFuzePlus</a> "
|
||||
"wiki page on how to obtain this file.<br/>"
|
||||
"Press Ok to continue and browse your computer for the firmware "
|
||||
"file.");
|
||||
}
|
||||
|
||||
|
||||
/** Start bootloader installation.
|
||||
*/
|
||||
bool BootloaderInstallImx::install(void)
|
||||
{
|
||||
if(!QFileInfo(m_offile).isReadable())
|
||||
{
|
||||
qDebug() << "[BootloaderInstallImx] could not read original firmware file"
|
||||
<< m_offile;
|
||||
emit logItem(tr("Could not read original firmware file"), LOGERROR);
|
||||
return false;
|
||||
}
|
||||
|
||||
qDebug() << "[BootloaderInstallImx] downloading bootloader";
|
||||
// download bootloader from server
|
||||
emit logItem(tr("Downloading bootloader file"), LOGINFO);
|
||||
connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2()));
|
||||
downloadBlStart(m_blurl);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void BootloaderInstallImx::installStage2(void)
|
||||
{
|
||||
qDebug() << "[BootloaderInstallImx] patching file...";
|
||||
emit logItem(tr("Patching file..."), LOGINFO);
|
||||
m_tempfile.open();
|
||||
|
||||
// we have not detailed progress on the patching so just show a busy
|
||||
// indicator instead.
|
||||
emit logProgress(0, 0);
|
||||
m_patchedFile.open();
|
||||
m_thread = new BootloaderThreadImx();
|
||||
m_thread->setInputFile(m_offile);
|
||||
m_thread->setBootloaderFile(m_tempfile.fileName());
|
||||
m_thread->setOutputFile(m_patchedFile.fileName());
|
||||
m_tempfile.close();
|
||||
m_patchedFile.close();
|
||||
connect(m_thread, SIGNAL(finished()), this, SLOT(installStage3()));
|
||||
connect(m_thread, SIGNAL(terminated()), this, SLOT(installStage3()));
|
||||
m_thread->start();
|
||||
}
|
||||
|
||||
|
||||
void BootloaderInstallImx::installStage3(void)
|
||||
{
|
||||
enum imx_error_t err = m_thread->error();
|
||||
emit logProgress(1, 1);
|
||||
// if the patch failed
|
||||
if (err != IMX_SUCCESS)
|
||||
{
|
||||
qDebug() << "[BootloaderInstallImx] Could not patch the original firmware file";
|
||||
emit logItem(tr("Patching the original firmware failed"), LOGERROR);
|
||||
emit done(true);
|
||||
return;
|
||||
}
|
||||
|
||||
qDebug() << "[BootloaderInstallImx] Original Firmware succesfully patched";
|
||||
emit logItem(tr("Succesfully patched firmware file"), LOGINFO);
|
||||
|
||||
// if a bootloader is already present delete it.
|
||||
QString fwfile(m_blfile);
|
||||
if(QFileInfo(fwfile).isFile())
|
||||
{
|
||||
qDebug() << "[BootloaderInstallImx] deleting old target file";
|
||||
QFile::remove(fwfile);
|
||||
}
|
||||
|
||||
// place (new) bootloader. Copy, since the temporary file will be removed
|
||||
// automatically.
|
||||
qDebug() << "[BootloaderInstallImx] moving patched bootloader to" << fwfile;
|
||||
if(m_patchedFile.copy(fwfile))
|
||||
{
|
||||
emit logItem(tr("Bootloader successful installed"), LOGOK);
|
||||
logInstall(LogAdd);
|
||||
emit done(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
emit logItem(tr("Patched bootloader could not be installed"), LOGERROR);
|
||||
emit done(true);
|
||||
}
|
||||
// clean up thread object.
|
||||
delete m_thread;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
bool BootloaderInstallImx::uninstall(void)
|
||||
{
|
||||
emit logItem(tr("To uninstall, perform a normal upgrade with an unmodified "
|
||||
"original firmware."), LOGINFO);
|
||||
logInstall(LogRemove);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
BootloaderInstallBase::BootloaderType BootloaderInstallImx::installed(void)
|
||||
{
|
||||
return BootloaderUnknown;
|
||||
}
|
||||
|
||||
|
||||
BootloaderInstallBase::Capabilities BootloaderInstallImx::capabilities(void)
|
||||
{
|
||||
return (Install | NeedsOf);
|
||||
}
|
||||
|
||||
47
rbutil/rbutilqt/base/bootloaderinstallimx.h
Normal file
47
rbutil/rbutilqt/base/bootloaderinstallimx.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/***************************************************************************
|
||||
* __________ __ ___.
|
||||
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
||||
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
||||
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
||||
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
||||
* \/ \/ \/ \/ \/
|
||||
*
|
||||
* Copyright (C) 2011 by Jean-Louis Biasini
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
#ifndef BOOTLOADERINSTALLIMX_H
|
||||
#define BOOTLOADERINSTALLIMX_H
|
||||
|
||||
#include <QtCore>
|
||||
#include "bootloaderinstallbase.h"
|
||||
|
||||
class BootloaderThreadImx;
|
||||
|
||||
//! bootloader installation class for devices handled by mkimxboot.
|
||||
class BootloaderInstallImx : public BootloaderInstallBase
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
BootloaderInstallImx(QObject *parent);
|
||||
bool install(void);
|
||||
bool uninstall(void);
|
||||
BootloaderInstallBase::BootloaderType installed(void);
|
||||
Capabilities capabilities(void);
|
||||
QString ofHint();
|
||||
|
||||
private slots:
|
||||
void installStage2(void);
|
||||
void installStage3(void);
|
||||
|
||||
private:
|
||||
BootloaderThreadImx *m_thread;
|
||||
QTemporaryFile m_patchedFile;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -501,7 +501,7 @@ encoder=rbspeex
|
|||
[sansafuzeplus]
|
||||
name="Sansa Fuze+"
|
||||
buildserver_modelname=sansafuzeplus
|
||||
bootloadermethod=none ; no bootloader for now
|
||||
bootloadermethod=imx
|
||||
bootloadername=/sandisk-sansa/fuzeplus/bootloader-fuzeplus.sansa
|
||||
bootloaderfile=/firmware.sb
|
||||
manualname=
|
||||
|
|
@ -510,7 +510,6 @@ usbid=0x078174e1
|
|||
usberror=
|
||||
configure_modelname=sansafuzeplus
|
||||
encoder=rbspeex
|
||||
status=disabled
|
||||
|
||||
[sansam200v4]
|
||||
name="Sansa m200v4"
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ SOURCES += \
|
|||
base/bootloaderinstallams.cpp \
|
||||
base/bootloaderinstalltcc.cpp \
|
||||
base/bootloaderinstallmpio.cpp \
|
||||
base/bootloaderinstallimx.cpp \
|
||||
base/rockboxinfo.cpp \
|
||||
../../tools/mkboot.c \
|
||||
../../tools/iriver.c \
|
||||
|
|
@ -121,6 +122,7 @@ HEADERS += \
|
|||
base/bootloaderinstallams.h \
|
||||
base/bootloaderinstalltcc.h \
|
||||
base/bootloaderinstallmpio.h \
|
||||
base/bootloaderinstallimx.h \
|
||||
base/rockboxinfo.h \
|
||||
../../tools/mkboot.h \
|
||||
../../tools/iriver.h \
|
||||
|
|
|
|||
|
|
@ -125,10 +125,16 @@ libchinachippatcher.commands = $$ADDENV \
|
|||
APPVERSION=\"rbutil\" \
|
||||
CC=\"$$QMAKE_CC\" CFLAGS=\"$$MACHINEFLAGS\" AR=\"$$MYAR\" \
|
||||
$(MAKE) -C $$RBBASE_DIR/rbutil/chinachippatcher libchinachippatcher$$RBLIBPOSTFIX
|
||||
libmkimxboot.commands = $$ADDENV \
|
||||
BUILD_DIR=$$MYLIBBUILDDIR/mkimxboot/ \
|
||||
TARGET_DIR=$$MYLIBBUILDDIR \
|
||||
APPVERSION=\"rbutil\" \
|
||||
CC=\"$$QMAKE_CC\" CFLAGS=\"$$MACHINEFLAGS\" AR=\"$$MYAR\" \
|
||||
$(MAKE) -C $$RBBASE_DIR/rbutil/mkimxboot libmkimxboot$$RBLIBPOSTFIX
|
||||
# Note: order is important for RBLIBS! The libs are appended to the linker
|
||||
# flags in this order, put libucl at the end.
|
||||
RBLIBS = librbspeex libipodpatcher libsansapatcher libmkamsboot libmktccboot \
|
||||
libmkmpioboot libchinachippatcher libucl
|
||||
libmkmpioboot libchinachippatcher libmkimxboot libucl
|
||||
QMAKE_EXTRA_TARGETS += $$RBLIBS
|
||||
PRE_TARGETDEPS += $$RBLIBS
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue