summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDominik Wenger <domonoky@googlemail.com>2009-08-15 13:04:21 +0000
committerDominik Wenger <domonoky@googlemail.com>2009-08-15 13:04:21 +0000
commita66dfa4ab7d09e0826dcf11cd366ea4200fb9c28 (patch)
tree45e4a3321d2d0ecf83e7b2f2fab10feca42069fa
parent2ae585273ef025f597f5aaffa5e9ea193db49f0d (diff)
downloadrockbox-a66dfa4ab7d09e0826dcf11cd366ea4200fb9c28.tar.gz
rockbox-a66dfa4ab7d09e0826dcf11cd366ea4200fb9c28.zip
rbutil: add ams sansa targets. (FS#10185)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@22317 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--rbutil/mkamsboot/mkamsboot.c5
-rw-r--r--rbutil/mkamsboot/mkamsboot.h13
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallams.cpp176
-rw-r--r--rbutil/rbutilqt/base/bootloaderinstallams.h43
-rw-r--r--rbutil/rbutilqt/rbutil.ini72
-rw-r--r--rbutil/rbutilqt/rbutilqt.cpp5
-rw-r--r--rbutil/rbutilqt/rbutilqt.pro18
7 files changed, 324 insertions, 8 deletions
diff --git a/rbutil/mkamsboot/mkamsboot.c b/rbutil/mkamsboot/mkamsboot.c
index fb0e3cb034..71bc4868ad 100644
--- a/rbutil/mkamsboot/mkamsboot.c
+++ b/rbutil/mkamsboot/mkamsboot.c
@@ -216,6 +216,11 @@ static struct md5sums sansasums[] = {
216 216
217#define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0])) 217#define NUM_MD5S (sizeof(sansasums)/sizeof(sansasums[0]))
218 218
219int firmware_revision(int model)
220{
221 return fw_revisions[model];
222}
223
219static off_t filesize(int fd) 224static off_t filesize(int fd)
220{ 225{
221 struct stat buf; 226 struct stat buf;
diff --git a/rbutil/mkamsboot/mkamsboot.h b/rbutil/mkamsboot/mkamsboot.h
index a14b320685..3e58341884 100644
--- a/rbutil/mkamsboot/mkamsboot.h
+++ b/rbutil/mkamsboot/mkamsboot.h
@@ -139,4 +139,17 @@ void patch_firmware(
139 139
140int total_size(int model, int rb_packedsize, int of_packedsize); 140int total_size(int model, int rb_packedsize, int of_packedsize);
141 141
142/* firmware_revision()
143 *
144 * returns the firmware revision for a particular model
145 *
146 * ARGUMENTS
147 *
148 * model : firmware model (MODEL_XXX)
149 *
150 * RETURN VALUE
151 * firmware version
152*/
153int firmware_revision(int model);
154
142#endif 155#endif
diff --git a/rbutil/rbutilqt/base/bootloaderinstallams.cpp b/rbutil/rbutilqt/base/bootloaderinstallams.cpp
new file mode 100644
index 0000000000..9b357aedb6
--- /dev/null
+++ b/rbutil/rbutilqt/base/bootloaderinstallams.cpp
@@ -0,0 +1,176 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2008 by Dominik Wenger
10 * $Id$
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19
20#include <QtCore>
21#include "bootloaderinstallbase.h"
22#include "bootloaderinstallams.h"
23
24extern "C"
25{
26 #include "../mkamsboot/mkamsboot.h"
27};
28
29BootloaderInstallAms::BootloaderInstallAms(QObject *parent)
30 : BootloaderInstallBase(parent)
31{
32}
33
34QString BootloaderInstallAms::ofHint()
35{
36 return tr("Bootloader installation requires you to provide "
37 "a firmware file of the original firmware (bin file). "
38 "You need to download this file yourself due to legal "
39 "reasons."
40 "Press Ok to continue and browse your computer for the firmware "
41 "file.");
42}
43
44bool BootloaderInstallAms::install(void)
45{
46 if(m_offile.isEmpty())
47 return false;
48
49 // download firmware from server
50 emit logItem(tr("Downloading bootloader file"), LOGINFO);
51
52 connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2()));
53 downloadBlStart(m_blurl);
54
55 return true;
56}
57
58void BootloaderInstallAms::installStage2(void)
59{
60 unsigned char* buf;
61 unsigned char* of_packed;
62 int of_packedsize;
63 unsigned char* rb_packed;
64 int rb_packedsize;
65 off_t len;
66 struct md5sums sum;
67 char md5sum[33]; /* 32 hex digits, plus terminating zero */
68 int n;
69 int firmware_size;
70 int bootloader_size;
71 int totalsize;
72 char errstr[200];
73
74 sum.md5 = md5sum;
75
76 m_tempfile.open();
77 QString bootfile = m_tempfile.fileName();
78 m_tempfile.close();
79
80 /* Load original firmware file */
81 buf = load_of_file(m_offile.toLocal8Bit().data(), &len,&sum,&firmware_size,
82 &of_packed,&of_packedsize,errstr,sizeof(errstr));
83 if (buf == NULL)
84 {
85 emit logItem(errstr, LOGERROR);
86 emit logItem(tr("Could not load %1").arg(m_offile), LOGERROR);
87 emit done(true);
88 return;
89 }
90
91 /* Load bootloader file */
92 rb_packed = load_rockbox_file(bootfile.toLocal8Bit().data(), sum.model, &bootloader_size,&rb_packedsize,
93 errstr,sizeof(errstr));
94 if (rb_packed == NULL)
95 {
96 emit logItem(errstr, LOGERROR);
97 emit logItem(tr("Could not load %1").arg(bootfile), LOGERROR);
98 free(buf);
99 free(of_packed);
100 emit done(true);
101 return;
102 }
103
104 /* check total size */
105 totalsize = total_size(sum.model,rb_packedsize,of_packedsize);
106 if (totalsize > firmware_size)
107 {
108 emit logItem("No room to insert bootloader, try another firmware version",LOGERROR);
109 free(buf);
110 free(of_packed);
111 free(rb_packed);
112 emit done(true);
113 return;
114 }
115
116 /* patch the firmware */
117 emit logItem(tr("Patching Firmware..."), LOGINFO);
118
119 patch_firmware(sum.model,firmware_revision(sum.model),firmware_size,buf,len,of_packed,of_packedsize,rb_packed,rb_packedsize);
120
121 /* construct path for write out. combine path of m_blfile with filename from of */
122 QString outfilename = QFileInfo(m_blfile).absolutePath() + "/" +QFileInfo(m_offile).fileName();
123 /* write out file*/
124 QFile out(outfilename);
125
126 if(!out.open(QIODevice::WriteOnly | QIODevice::Truncate))
127 {
128 emit logItem(tr("Could not open %1 for writing").arg(m_blfile),LOGERROR);
129 free(buf);
130 free(of_packed);
131 free(rb_packed);
132 emit done(true);
133 return;
134 }
135
136 n = out.write((char*)buf, len);
137
138 if (n != len)
139 {
140 emit logItem(tr("Could not write firmware file"),LOGERROR);
141 free(buf);
142 free(of_packed);
143 free(rb_packed);
144 emit done(true);
145 return;
146 }
147
148 out.close();
149
150 free(buf);
151 free(of_packed);
152 free(rb_packed);
153
154 //end of install
155 emit logItem(tr("Success: modified firmware file created"), LOGINFO);
156 logInstall(LogAdd);
157 emit done(false);
158 return;
159}
160
161bool BootloaderInstallAms::uninstall(void)
162{
163 emit logItem("To uninstall, perform a normal upgrade with an unmodified original firmware", LOGINFO);
164 logInstall(LogRemove);
165 return false;
166}
167
168BootloaderInstallBase::BootloaderType BootloaderInstallAms::installed(void)
169{
170 return BootloaderUnknown;
171}
172
173BootloaderInstallBase::Capabilities BootloaderInstallAms::capabilities(void)
174{
175 return (Install | NeedsOf);
176}
diff --git a/rbutil/rbutilqt/base/bootloaderinstallams.h b/rbutil/rbutilqt/base/bootloaderinstallams.h
new file mode 100644
index 0000000000..05ae576afe
--- /dev/null
+++ b/rbutil/rbutilqt/base/bootloaderinstallams.h
@@ -0,0 +1,43 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 *
9 * Copyright (C) 2008 by Dominik Wenger
10 * $Id$
11 *
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
14 *
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
17 *
18 ****************************************************************************/
19#ifndef BOOTLOADERINSTALLAMS_H
20#define BOOTLOADERINSTALLAMS_H
21
22#include <QtCore>
23#include "bootloaderinstallbase.h"
24
25//! bootloader installation derivate based on mkamsboot
26class BootloaderInstallAms : public BootloaderInstallBase
27{
28 Q_OBJECT
29 public:
30 BootloaderInstallAms(QObject *parent);
31 bool install(void);
32 bool uninstall(void);
33 BootloaderInstallBase::BootloaderType installed(void);
34 Capabilities capabilities(void);
35 QString ofHint();
36
37 private:
38
39 private slots:
40 void installStage2(void);
41};
42
43#endif
diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini
index f82b36d78a..3148bc78d2 100644
--- a/rbutil/rbutilqt/rbutil.ini
+++ b/rbutil/rbutilqt/rbutil.ini
@@ -45,11 +45,14 @@ platform33=iaudiom3
45platform40=gigabeatf 45platform40=gigabeatf
46platform50=sansae200 46platform50=sansae200
47platform51=sansac200 47platform51=sansac200
48platform57=smsgyh820 48platform52=sansae200v2
49platform58=smsgyh920 49platform53=sansafuze
50platform59=smsgyh925 50platform54=sansam200v4
51platform55=sansaclip
51platform60=mrobe100 52platform60=mrobe100
52 53platform70=smsgyh820
54platform71=smsgyh920
55platform72=smsgyh925
53 56
54 57
55[player] 58[player]
@@ -441,6 +444,67 @@ configure_modelname=c200
441targetid=30 444targetid=30
442encoder=rbspeex 445encoder=rbspeex
443 446
447[sansae200v2]
448name="Sansa e200v2 series"
449buildserver_modelname=sansae200v2
450bootloadermethod=ams
451bootloadername=/sandisk-sansa/e200v2/bootloader-e200v2.sansa
452bootloaderfile=/e200pa.bin
453resolution=176x220x16
454manualname=
455brand=Sandisk
456usbid=0x078174c1
457usberror=0x07810722
458configure_modelname=e200v2
459targetid=51
460encoder=rbspeex
461
462[sansafuze]
463name="Sansa Fuze"
464buildserver_modelname=sansafuze
465bootloadermethod=ams
466bootloadername=/sandisk-sansa/fuze/bootloader-fuze.sansa
467bootloaderfile=/fuzea.bin
468resolution=220x176x16
469manualname=
470brand=Sandisk
471usbid=0x07817423
472usberror=0x078174c0
473configure_modelname=fuze
474targetid=53
475encoder=rbspeex
476
477[sansam200v4]
478name="Sansa m200v4"
479buildserver_modelname=sansam200v4
480bootloadermethod=ams
481bootloadername=/sandisk-sansa/m200v4/bootloader-m200v4.sansa
482bootloaderfile=/m200a.bin
483resolution=128x64x1
484manualname=
485brand=Sandisk
486usbid=
487usberror=
488configure_modelname=m200v4
489targetid=52
490encoder=rbspeex
491
492[sansaclip]
493name="Sansa Clip"
494buildserver_modelname=sansaclip
495bootloadermethod=ams
496bootloadername=/sandisk-sansa/clip/bootloader-clip.sansa
497bootloaderfile=/m300a.bin
498resolution=128x64x1
499manualname=
500brand=Sandisk
501usbid=0x07817433
502usberror=0x07817432
503configure_modelname=clip
504targetid=50
505encoder=rbspeex
506
507
444[mrobe100] 508[mrobe100]
445name="m:robe100" 509name="m:robe100"
446buildserver_modelname=mrobe100 510buildserver_modelname=mrobe100
diff --git a/rbutil/rbutilqt/rbutilqt.cpp b/rbutil/rbutilqt/rbutilqt.cpp
index dff0395bc1..af79f2edef 100644
--- a/rbutil/rbutilqt/rbutilqt.cpp
+++ b/rbutil/rbutilqt/rbutilqt.cpp
@@ -44,6 +44,8 @@
44#include "bootloaderinstallipod.h" 44#include "bootloaderinstallipod.h"
45#include "bootloaderinstallsansa.h" 45#include "bootloaderinstallsansa.h"
46#include "bootloaderinstallfile.h" 46#include "bootloaderinstallfile.h"
47#include "bootloaderinstallams.h"
48
47 49
48#if defined(Q_OS_LINUX) 50#if defined(Q_OS_LINUX)
49#include <stdio.h> 51#include <stdio.h>
@@ -650,6 +652,9 @@ void RbUtilQt::installBootloader()
650 else if(type == "file") { 652 else if(type == "file") {
651 bl = new BootloaderInstallFile(this); 653 bl = new BootloaderInstallFile(this);
652 } 654 }
655 else if(type == "ams") {
656 bl = new BootloaderInstallAms(this);
657 }
653 else { 658 else {
654 logger->addItem(tr("No install method known."), LOGERROR); 659 logger->addItem(tr("No install method known."), LOGERROR);
655 logger->setFinished(); 660 logger->setFinished();
diff --git a/rbutil/rbutilqt/rbutilqt.pro b/rbutil/rbutilqt/rbutilqt.pro
index 31b07bf068..07f05669e2 100644
--- a/rbutil/rbutilqt/rbutilqt.pro
+++ b/rbutil/rbutilqt/rbutilqt.pro
@@ -42,9 +42,17 @@ QMAKE_EXTRA_TARGETS += lrelease
42 PRE_TARGETDEPS += lrelease 42 PRE_TARGETDEPS += lrelease
43} 43}
44 44
45#custum rules for libmkamsboot.a
46libucl.commands = @$(MAKE) -C ../../tools/ucl/src libucl.a
47QMAKE_EXTRA_TARGETS += libucl
48PRE_TARGETDEPS += libucl
49
50libmkamsboot.commands = @$(MAKE) -C ../mkamsboot libmkamsboot.a
51QMAKE_EXTRA_TARGETS += libmkamsboot
52PRE_TARGETDEPS += libmkamsboot
45 53
46SOURCES += rbutilqt.cpp \ 54SOURCES += rbutilqt.cpp \
47 main.cpp \ 55 main.cpp \
48 install.cpp \ 56 install.cpp \
49 base/httpget.cpp \ 57 base/httpget.cpp \
50 configure.cpp \ 58 configure.cpp \
@@ -83,6 +91,7 @@ SOURCES += rbutilqt.cpp \
83 base/bootloaderinstallipod.cpp \ 91 base/bootloaderinstallipod.cpp \
84 base/bootloaderinstallsansa.cpp \ 92 base/bootloaderinstallsansa.cpp \
85 base/bootloaderinstallfile.cpp \ 93 base/bootloaderinstallfile.cpp \
94 base/bootloaderinstallams.cpp \
86 ../../tools/mkboot.c \ 95 ../../tools/mkboot.c \
87 ../../tools/iriver.c 96 ../../tools/iriver.c
88 97
@@ -136,14 +145,15 @@ HEADERS += rbutilqt.h \
136 base/bootloaderinstallipod.h \ 145 base/bootloaderinstallipod.h \
137 base/bootloaderinstallsansa.h \ 146 base/bootloaderinstallsansa.h \
138 base/bootloaderinstallfile.h \ 147 base/bootloaderinstallfile.h \
148 base/bootloaderinstallams.h \
139 ../../tools/mkboot.h \ 149 ../../tools/mkboot.h \
140 ../../tools/iriver.h 150 ../../tools/iriver.h
141 151
142# Needed by QT on Win 152# Needed by QT on Win
143INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex ../../tools 153INCLUDEPATH = . irivertools zip zlib ../ipodpatcher ../sansapatcher ../../tools/rbspeex ../../tools
144INCLUDEPATH += base 154INCLUDEPATH += base
145 155
146LIBS += -L../../tools/rbspeex -lrbspeex 156LIBS += -L../../tools/rbspeex -lrbspeex -L../mkamsboot -lmkamsboot -L../../tools/ucl/src/ -lucl
147 157
148TEMPLATE = app 158TEMPLATE = app
149dbg { 159dbg {