diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2020-07-19 17:13:55 -0400 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2020-07-20 18:40:24 +0000 |
commit | f6060d62d90c6920bd6edf9ed618f41b9cf7b60f (patch) | |
tree | f0aa84fe8428d2bca0f75a266d3795770cf43aed | |
parent | 561937f2f4bbd38493408a99593c1bccbe36eb48 (diff) | |
download | rockbox-f6060d62d90c6920bd6edf9ed618f41b9cf7b60f.tar.gz rockbox-f6060d62d90c6920bd6edf9ed618f41b9cf7b60f.zip |
rbutil: Add support for the xDuoo X3, X3ii, X20, and AGPTek Rocker.
* All include full bootloader installation!
* X20 lack USB VID/PIDs so cannot be autodetected.
* Benjie T6 (variant/OEM of the Rocker) USB VID/PID unknown.
Change-Id: Ia823de072c83506d36410ec436be15a0caf97151
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallbspatch.cpp | 179 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallbspatch.h | 47 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallhelper.cpp | 6 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutil.ini | 64 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.pri | 2 |
5 files changed, 296 insertions, 2 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallbspatch.cpp b/rbutil/rbutilqt/base/bootloaderinstallbspatch.cpp new file mode 100644 index 0000000000..c9cbd91abe --- /dev/null +++ b/rbutil/rbutilqt/base/bootloaderinstallbspatch.cpp | |||
@@ -0,0 +1,179 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2020 by Solomon Peachy | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | ****************************************************************************/ | ||
18 | |||
19 | #include <QtCore> | ||
20 | #include <QtDebug> | ||
21 | #include "bootloaderinstallbase.h" | ||
22 | #include "bootloaderinstallbspatch.h" | ||
23 | #include "../bspatch/bspatch.h" | ||
24 | #include "Logger.h" | ||
25 | |||
26 | /* class for running bspatch() in a separate thread to keep the UI responsive. */ | ||
27 | class BootloaderThreadBSPatch : public QThread | ||
28 | { | ||
29 | public: | ||
30 | void run(void); | ||
31 | void setInputFile(QString f) | ||
32 | { m_inputfile = f; } | ||
33 | void setOutputFile(QString f) | ||
34 | { m_outputfile = f; } | ||
35 | void setBootloaderFile(QString f) | ||
36 | { m_bootfile = f; } | ||
37 | int error(void) | ||
38 | { return m_error; } | ||
39 | private: | ||
40 | QString m_inputfile; | ||
41 | QString m_bootfile; | ||
42 | QString m_outputfile; | ||
43 | int m_error; | ||
44 | }; | ||
45 | |||
46 | void BootloaderThreadBSPatch::run(void) | ||
47 | { | ||
48 | LOG_INFO() << "Thread started."; | ||
49 | |||
50 | m_error = apply_bspatch(m_inputfile.toLocal8Bit().constData(), | ||
51 | m_outputfile.toLocal8Bit().constData(), | ||
52 | m_bootfile.toLocal8Bit().constData()); | ||
53 | |||
54 | LOG_INFO() << "Thread finished, result:" << m_error; | ||
55 | } | ||
56 | |||
57 | BootloaderInstallBSPatch::BootloaderInstallBSPatch(QObject *parent) | ||
58 | : BootloaderInstallBase(parent) | ||
59 | { | ||
60 | m_thread = NULL; | ||
61 | } | ||
62 | |||
63 | QString BootloaderInstallBSPatch::ofHint() | ||
64 | { | ||
65 | return tr("Bootloader installation requires you to provide " | ||
66 | "the correct verrsion of the original firmware file. " | ||
67 | "This file will be patched with the Rockbox bootloader and " | ||
68 | "installed to your player. You need to download this file " | ||
69 | "yourself due to legal reasons. Please refer to the " | ||
70 | "<a href='http://www.rockbox.org/wiki/'>rockbox wiki</a> " | ||
71 | "pages on how to obtain this file.<br/>" | ||
72 | "Press Ok to continue and browse your computer for the firmware " | ||
73 | "file."); | ||
74 | } | ||
75 | |||
76 | /** Start bootloader installation. | ||
77 | */ | ||
78 | bool BootloaderInstallBSPatch::install(void) | ||
79 | { | ||
80 | if(!QFileInfo(m_offile).isReadable()) | ||
81 | { | ||
82 | LOG_ERROR() << "could not read original firmware file" | ||
83 | << m_offile; | ||
84 | emit logItem(tr("Could not read original firmware file"), LOGERROR); | ||
85 | return false; | ||
86 | } | ||
87 | |||
88 | LOG_INFO() << "downloading bootloader"; | ||
89 | // download bootloader from server | ||
90 | emit logItem(tr("Downloading bootloader file"), LOGINFO); | ||
91 | connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2())); | ||
92 | downloadBlStart(m_blurl); | ||
93 | return true; | ||
94 | } | ||
95 | |||
96 | void BootloaderInstallBSPatch::installStage2(void) | ||
97 | { | ||
98 | LOG_INFO() << "patching file..."; | ||
99 | emit logItem(tr("Patching file..."), LOGINFO); | ||
100 | m_tempfile.open(); | ||
101 | |||
102 | // we have not detailed progress on the patching so just show a busy | ||
103 | // indicator instead. | ||
104 | emit logProgress(0, 0); | ||
105 | m_patchedFile.open(); | ||
106 | m_thread = new BootloaderThreadBSPatch(); | ||
107 | m_thread->setInputFile(m_offile); | ||
108 | m_thread->setBootloaderFile(m_tempfile.fileName()); | ||
109 | m_thread->setOutputFile(m_patchedFile.fileName()); | ||
110 | m_tempfile.close(); | ||
111 | m_patchedFile.close(); | ||
112 | connect(m_thread, SIGNAL(finished()), this, SLOT(installStage3())); | ||
113 | connect(m_thread, SIGNAL(terminated()), this, SLOT(installStage3())); | ||
114 | m_thread->start(); | ||
115 | } | ||
116 | |||
117 | void BootloaderInstallBSPatch::installStage3(void) | ||
118 | { | ||
119 | int err = m_thread->error(); | ||
120 | emit logProgress(1, 1); | ||
121 | // if the patch failed | ||
122 | if (err != 0) | ||
123 | { | ||
124 | LOG_ERROR() << "Could not patch the original firmware file"; | ||
125 | emit logItem(tr("Patching the original firmware failed"), LOGERROR); | ||
126 | emit done(true); | ||
127 | return; | ||
128 | } | ||
129 | |||
130 | LOG_INFO() << "Original Firmware succesfully patched"; | ||
131 | emit logItem(tr("Succesfully patched firmware file"), LOGINFO); | ||
132 | |||
133 | // if a bootloader is already present delete it. | ||
134 | QString fwfile(m_blfile); | ||
135 | if(QFileInfo(fwfile).isFile()) | ||
136 | { | ||
137 | LOG_INFO() << "deleting old target file"; | ||
138 | QFile::remove(fwfile); | ||
139 | } | ||
140 | |||
141 | // place (new) bootloader. Copy, since the temporary file will be removed | ||
142 | // automatically. | ||
143 | LOG_INFO() << "moving patched bootloader to" << fwfile; | ||
144 | if(m_patchedFile.copy(fwfile)) | ||
145 | { | ||
146 | emit logItem(tr("Bootloader successful installed"), LOGOK); | ||
147 | logInstall(LogAdd); | ||
148 | emit done(false); | ||
149 | } | ||
150 | else | ||
151 | { | ||
152 | emit logItem(tr("Patched bootloader could not be installed"), LOGERROR); | ||
153 | emit done(true); | ||
154 | } | ||
155 | // clean up thread object. | ||
156 | delete m_thread; | ||
157 | return; | ||
158 | } | ||
159 | |||
160 | bool BootloaderInstallBSPatch::uninstall(void) | ||
161 | { | ||
162 | emit logItem(tr("To uninstall, perform a normal upgrade with an unmodified " | ||
163 | "original firmware."), LOGINFO); | ||
164 | logInstall(LogRemove); | ||
165 | emit done(true); | ||
166 | return false; | ||
167 | } | ||
168 | |||
169 | |||
170 | BootloaderInstallBase::BootloaderType BootloaderInstallBSPatch::installed(void) | ||
171 | { | ||
172 | return BootloaderUnknown; | ||
173 | } | ||
174 | |||
175 | |||
176 | BootloaderInstallBase::Capabilities BootloaderInstallBSPatch::capabilities(void) | ||
177 | { | ||
178 | return (Install | NeedsOf); | ||
179 | } | ||
diff --git a/rbutil/rbutilqt/base/bootloaderinstallbspatch.h b/rbutil/rbutilqt/base/bootloaderinstallbspatch.h new file mode 100644 index 0000000000..7108820fda --- /dev/null +++ b/rbutil/rbutilqt/base/bootloaderinstallbspatch.h | |||
@@ -0,0 +1,47 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2020 Solomon Peachy | ||
10 | * | ||
11 | * All files in this archive are subject to the GNU General Public License. | ||
12 | * See the file COPYING in the source tree root for full license agreement. | ||
13 | * | ||
14 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
15 | * KIND, either express or implied. | ||
16 | * | ||
17 | ****************************************************************************/ | ||
18 | #ifndef BOOTLOADERINSTALLBSPATCH_H | ||
19 | #define BOOTLOADERINSTALLBSPATCH_H | ||
20 | |||
21 | #include <QtCore> | ||
22 | #include "bootloaderinstallbase.h" | ||
23 | |||
24 | class BootloaderThreadBSPatch; | ||
25 | |||
26 | //! bootloader installation class for devices handled by mkimxboot. | ||
27 | class BootloaderInstallBSPatch : public BootloaderInstallBase | ||
28 | { | ||
29 | Q_OBJECT | ||
30 | public: | ||
31 | BootloaderInstallBSPatch(QObject *parent); | ||
32 | bool install(void); | ||
33 | bool uninstall(void); | ||
34 | BootloaderInstallBase::BootloaderType installed(void); | ||
35 | Capabilities capabilities(void); | ||
36 | QString ofHint(); | ||
37 | |||
38 | private slots: | ||
39 | void installStage2(void); | ||
40 | void installStage3(void); | ||
41 | |||
42 | private: | ||
43 | BootloaderThreadBSPatch *m_thread; | ||
44 | QTemporaryFile m_patchedFile; | ||
45 | }; | ||
46 | |||
47 | #endif | ||
diff --git a/rbutil/rbutilqt/base/bootloaderinstallhelper.cpp b/rbutil/rbutilqt/base/bootloaderinstallhelper.cpp index d6d2dbc7a1..d7d7ace5e9 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallhelper.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallhelper.cpp | |||
@@ -32,6 +32,7 @@ | |||
32 | #include "bootloaderinstallmpio.h" | 32 | #include "bootloaderinstallmpio.h" |
33 | #include "bootloaderinstallimx.h" | 33 | #include "bootloaderinstallimx.h" |
34 | #include "bootloaderinstalls5l.h" | 34 | #include "bootloaderinstalls5l.h" |
35 | #include "bootloaderinstallbspatch.h" | ||
35 | 36 | ||
36 | BootloaderInstallBase* BootloaderInstallHelper::createBootloaderInstaller(QObject* parent, QString type) | 37 | BootloaderInstallBase* BootloaderInstallHelper::createBootloaderInstaller(QObject* parent, QString type) |
37 | { | 38 | { |
@@ -68,10 +69,12 @@ BootloaderInstallBase* BootloaderInstallHelper::createBootloaderInstaller(QObjec | |||
68 | else if(type == "s5l") { | 69 | else if(type == "s5l") { |
69 | return new BootloaderInstallS5l(parent); | 70 | return new BootloaderInstallS5l(parent); |
70 | } | 71 | } |
72 | else if(type == "bspatch") { | ||
73 | return new BootloaderInstallBSPatch(parent); | ||
74 | } | ||
71 | else { | 75 | else { |
72 | return NULL; | 76 | return NULL; |
73 | } | 77 | } |
74 | |||
75 | } | 78 | } |
76 | 79 | ||
77 | 80 | ||
@@ -134,4 +137,3 @@ QString BootloaderInstallHelper::postinstallHints(QString model) | |||
134 | else | 137 | else |
135 | return QString(); | 138 | return QString(); |
136 | } | 139 | } |
137 | |||
diff --git a/rbutil/rbutilqt/rbutil.ini b/rbutil/rbutilqt/rbutil.ini index 7034e46f42..2c113c89ce 100644 --- a/rbutil/rbutilqt/rbutil.ini +++ b/rbutil/rbutilqt/rbutil.ini | |||
@@ -91,6 +91,10 @@ platform101=gogearhdd1630 | |||
91 | platform102=gogearhdd6330 | 91 | platform102=gogearhdd6330 |
92 | platform103=gogearsa9200 | 92 | platform103=gogearsa9200 |
93 | platform110=creativezenxfi3 | 93 | platform110=creativezenxfi3 |
94 | platform120=xduoox3 | ||
95 | platform130=xduoox3ii | ||
96 | platform131=xduoox20 | ||
97 | platform132=agptekrocker | ||
94 | 98 | ||
95 | ; devices sections | 99 | ; devices sections |
96 | ; | 100 | ; |
@@ -873,6 +877,66 @@ configure_modelname=creativezenxfi3 | |||
873 | playerpic=creativezenxfi3 | 877 | playerpic=creativezenxfi3 |
874 | encoder=rbspeex | 878 | encoder=rbspeex |
875 | 879 | ||
880 | [xduoox3] | ||
881 | name="xDuoo X3" | ||
882 | buildserver_modelname=xduoox3 | ||
883 | bootloadermethod=bspatch | ||
884 | bootloadername=/xduoo/X3-v11.bsdiff | ||
885 | bootloaderfile=update.zip | ||
886 | bootloaderfilter=*.zip | ||
887 | manualname= | ||
888 | brand=xDuoo | ||
889 | usbid=0x0525a4a5 | ||
890 | usberror= | ||
891 | configure_modelname=xduoox3 | ||
892 | playerpic=xduoox3 | ||
893 | encoder=rbspeex | ||
894 | |||
895 | [xduoox3ii] | ||
896 | name="xDuoo X3 II" | ||
897 | buildserver_modelname=xduoox3ii | ||
898 | bootloadermethod=bspatch | ||
899 | bootloadername=/xduoo/X3II-v13.bsdiff | ||
900 | bootloaderfile=/update.upt | ||
901 | bootloaderfilter=*.upt *.zip | ||
902 | manualname= | ||
903 | brand=xDuoo | ||
904 | usbid=0x003cc502 | ||
905 | usberror= | ||
906 | configure_modelname=xduoox3ii | ||
907 | playerpic=xduoox3ii | ||
908 | encoder=rbspeex | ||
909 | |||
910 | [xduoox20] | ||
911 | name="xDuoo X20" | ||
912 | buildserver_modelname=xduoox20 | ||
913 | bootloadermethod=bspatch | ||
914 | bootloadername=/xduoo/X20-v18.bsdiff | ||
915 | bootloaderfile=/update.upt | ||
916 | bootloaderfilter=*.upt *.zip | ||
917 | manualname= | ||
918 | brand=xDuoo | ||
919 | ;usbid=0x0525a4a5 | ||
920 | usberror= | ||
921 | configure_modelname=xduoox20 | ||
922 | playerpic=xduoox20 | ||
923 | encoder=rbspeex | ||
924 | |||
925 | [agptekrocker] | ||
926 | name="AGPTek Rocker" | ||
927 | buildserver_modelname=agptekrocker | ||
928 | bootloadermethod=bspatch | ||
929 | bootloadername=/agptek/ROCKER-20171101.bsdiff | ||
930 | bootloaderfile=/update.upt | ||
931 | bootloaderfilter=*.upt *.zip | ||
932 | manualname= | ||
933 | brand=AGPTek | ||
934 | usbid=0xc5020029 | ||
935 | usberror= | ||
936 | configure_modelname=agptekrocker | ||
937 | playerpic=agptekrocker | ||
938 | encoder=rbspeex | ||
939 | |||
876 | ; incompatible devices sections | 940 | ; incompatible devices sections |
877 | ; each section uses a USB VID / PID string as section name. | 941 | ; each section uses a USB VID / PID string as section name. |
878 | ; name: human readable string to show the user when this device is detected. | 942 | ; name: human readable string to show the user when this device is detected. |
diff --git a/rbutil/rbutilqt/rbutilqt.pri b/rbutil/rbutilqt/rbutilqt.pri index d88ecac8cf..f622d1a0de 100644 --- a/rbutil/rbutilqt/rbutilqt.pri +++ b/rbutil/rbutilqt/rbutilqt.pri | |||
@@ -55,6 +55,7 @@ SOURCES += \ | |||
55 | sysinfo.cpp \ | 55 | sysinfo.cpp \ |
56 | systrace.cpp \ | 56 | systrace.cpp \ |
57 | base/bootloaderinstallbase.cpp \ | 57 | base/bootloaderinstallbase.cpp \ |
58 | base/bootloaderinstallbspatch.cpp \ | ||
58 | base/bootloaderinstallhelper.cpp \ | 59 | base/bootloaderinstallhelper.cpp \ |
59 | base/bootloaderinstallmi4.cpp \ | 60 | base/bootloaderinstallmi4.cpp \ |
60 | base/bootloaderinstallhex.cpp \ | 61 | base/bootloaderinstallhex.cpp \ |
@@ -134,6 +135,7 @@ HEADERS += \ | |||
134 | base/system.h \ | 135 | base/system.h \ |
135 | systrace.h \ | 136 | systrace.h \ |
136 | base/bootloaderinstallbase.h \ | 137 | base/bootloaderinstallbase.h \ |
138 | base/bootloaderinstallbspatch.h \ | ||
137 | base/bootloaderinstallhelper.h \ | 139 | base/bootloaderinstallhelper.h \ |
138 | base/bootloaderinstallmi4.h \ | 140 | base/bootloaderinstallmi4.h \ |
139 | base/bootloaderinstallhex.h \ | 141 | base/bootloaderinstallhex.h \ |