diff options
Diffstat (limited to 'rbutil')
-rw-r--r-- | rbutil/mktccboot/Makefile | 108 | ||||
-rw-r--r-- | rbutil/mktccboot/README | 35 | ||||
-rw-r--r-- | rbutil/mktccboot/mktccboot.c | 174 | ||||
-rw-r--r-- | rbutil/mktccboot/mktccboot.h | 42 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstalltcc.cpp | 154 | ||||
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstalltcc.h | 45 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutil.ini | 15 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.cpp | 4 | ||||
-rw-r--r-- | rbutil/rbutilqt/rbutilqt.pro | 16 |
9 files changed, 522 insertions, 71 deletions
diff --git a/rbutil/mktccboot/Makefile b/rbutil/mktccboot/Makefile index f3c0409b2a..9399a0c09f 100644 --- a/rbutil/mktccboot/Makefile +++ b/rbutil/mktccboot/Makefile | |||
@@ -6,16 +6,112 @@ | |||
6 | # \/ \/ \/ \/ \/ | 6 | # \/ \/ \/ \/ \/ |
7 | # $Id$ | 7 | # $Id$ |
8 | # | 8 | # |
9 | |||
10 | # We use the Telechips code available in the Rockbox tools/ directory | ||
9 | TOOLSDIR=../../tools | 11 | TOOLSDIR=../../tools |
10 | CFLAGS := -O -g -W -Wall -Wshadow -pedantic -I$(TOOLSDIR) | 12 | CFLAGS := -O -g -W -Wall -Wshadow -pedantic -I$(TOOLSDIR) |
11 | 13 | ||
12 | all: mktccboot | 14 | PLAT=tcc |
15 | |||
16 | CC = gcc | ||
17 | MKPLATBOOT=mk$(PLAT)boot | ||
18 | LIB_MKPLATBOOT=lib$(MKPLATBOOT) | ||
19 | |||
20 | #change for releases | ||
21 | ifndef APPVERSION | ||
22 | APPVERSION=`$(TOOLSDIR)/version.sh` | ||
23 | endif | ||
24 | |||
25 | ifndef V | ||
26 | SILENT = @ | ||
27 | endif | ||
28 | |||
29 | ifeq ($(findstring CYGWIN,$(shell uname)),CYGWIN) | ||
30 | OUTPUT=$(MKPLATBOOT).exe | ||
31 | CFLAGS+=-mno-cygwin | ||
32 | else | ||
33 | ifeq ($(findstring MINGW,$(shell uname)),MINGW) | ||
34 | OUTPUT=$(MKPLATBOOT).exe | ||
35 | else | ||
36 | ifeq ($(findstring mingw,$(CC)),mingw) | ||
37 | OUTPUT=$(MKPLATBOOT).exe | ||
38 | else | ||
39 | OUTPUT=$(MKPLATBOOT) | ||
40 | endif | ||
41 | endif | ||
42 | endif | ||
43 | |||
44 | ifdef RBARCH | ||
45 | CFLAGS += -arch $(RBARCH) | ||
46 | endif | ||
47 | |||
48 | OUT = $(TARGET_DIR)build$(RBARCH) | ||
49 | |||
50 | MKPLATBOOT_OBJ=$(OUT)/$(MKPLATBOOT).o | ||
51 | LIBMKPLATBOOT_OBJ=$(OUT)/$(LIB_MKPLATBOOT).o | ||
52 | |||
53 | all: $(OUTPUT) | ||
54 | |||
55 | # Dependant modules | ||
56 | TELECHIPS=$(TOOLSDIR)/telechips | ||
57 | TELECHIPS_OBJ=$(TELECHIPS).o | ||
13 | 58 | ||
14 | telechips.o: $(TOOLSDIR)/telechips.c $(TOOLSDIR)/telechips.h | 59 | $(TELECHIPS_OBJ): $(TELECHIPS).[ch] |
15 | $(SILENT)$(CC) $(CFLAGS) $(TOOLSDIR)/telechips.c -c -o $@ | 60 | make -C $(TOOLSDIR) $(TARGET_DIR)telechips.o |
16 | 61 | ||
17 | mktccboot: mktccboot.c telechips.o | 62 | DEPENDANT_OBJS=$(TELECHIPS_OBJ) |
18 | $(SILENT)$(CC) $(CFLAGS) $+ -o $@ | ||
19 | 63 | ||
64 | $(MKPLATBOOT_OBJ): $(MKPLATBOOT).[ch] $(DEPENDANT_OBJS) | ||
65 | @echo CC $< | ||
66 | $(SILENT)$(CC) $(CFLAGS) -c -o $(MKPLATBOOT_OBJ) -W -Wall $(MKPLATBOOT).c -DVERSION=\"$(APPVERSION)\" | ||
67 | |||
68 | $(OUTPUT): $(OUT) $(MKPLATBOOT_OBJ) | ||
69 | @echo CC $< | ||
70 | $(SILENT)$(CC) $(CFLAGS) -o $(OUTPUT) $(MKPLATBOOT_OBJ) $(DEPENDANT_OBJS) | ||
71 | |||
72 | $(LIBMKPLATBOOT_OBJ): $(MKPLATBOOT_OBJ) | ||
73 | @echo CC $< | ||
74 | $(SILENT)$(CC) $(CFLAGS) -DLIB -c -o $(LIBMKPLATBOOT_OBJ) -W -Wall $(MKPLATBOOT).c | ||
75 | |||
76 | $(LIB_MKPLATBOOT)$(RBARCH).a: $(OUT) $(LIBMKPLATBOOT_OBJ) | ||
77 | @echo AR $@ | ||
78 | $(SILENT)$(AR) ruc $(TARGET_DIR)$(LIB_MKPLATBOOT)$(RBARCH).a $(LIBMKPLATBOOT_OBJ) | ||
79 | |||
80 | # some trickery to build ppc and i386 from a single call | ||
81 | ifeq ($(RBARCH),) | ||
82 | $(LIB_MKPLATBOOT)i386.a: | ||
83 | make RBARCH=i386 TARGET_DIR=$(TARGET_DIR) $(LIB_MKPLATBOOT)i386.a | ||
84 | |||
85 | $(LIB_MKPLATBOOT)ppc.a: | ||
86 | make RBARCH=ppc TARGET_DIR=$(TARGET_DIR) $(LIB_MKPLATBOOT)ppc.a | ||
87 | endif | ||
88 | |||
89 | $(LIB_MKPLATBOOT)-universal: $(LIB_MKPLATBOOT)i386.a $(LIB_MKPLATBOOT)ppc.a | ||
90 | @echo lipo $(TARGET_DIR)$(LIB_MKPLATBOOT).a | ||
91 | $(SILENT) rm -f $(TARGET_DIR)$(LIB_MKPLATBOOT).a | ||
92 | lipo -create $(TARGET_DIR)$(LIB_MKPLATBOOT)ppc.a $(TARGET_DIR)$(LIB_MKPLATBOOT)i386.a -output $(TARGET_DIR)$(LIB_MKPLATBOOT).a | ||
93 | |||
20 | clean: | 94 | clean: |
21 | rm -f telechips.o mktccboot | 95 | rm -f $(OUTPUT) $(LIB_MKPLATBOOT).o $(TARGET_DIR)$(LIB_MKPLATBOOT)*.a $(MKPLATBOOT).dmg |
96 | rm -f $(DEPENDANT_OBJS) | ||
97 | rm -rf build* $(MKPLATBOOT)-* | ||
98 | |||
99 | $(MKPLATBOOT)-i386: | ||
100 | $(MAKE) RBARCH=i386 | ||
101 | mv $(MKPLATBOOT) $(MKPLATBOOT)-i386 | ||
102 | |||
103 | $(MKPLATBOOT)-ppc: | ||
104 | make RBARCH=ppc | ||
105 | mv $(MKPLATBOOT) $(MKPLATBOOT)-ppc | ||
106 | |||
107 | $(MKPLATBOOT)-mac: $(MKPLATBOOT)-i386 $(MKPLATBOOT)-ppc | ||
108 | lipo -create $(MKPLATBOOT)-ppc $(MKPLATBOOT)-i386 -output $(MKPLATBOOT)-mac | ||
109 | |||
110 | $(MKPLATBOOT).dmg: $(MKPLATBOOT)-mac | ||
111 | mkdir -p $(MKPLATBOOT)-dmg | ||
112 | cp -p $(MKPLATBOOT)-mac $(MKPLATBOOT)-dmg | ||
113 | hdiutil create -srcfolder $(MKPLATBOOT)-dmg $(MKPLATBOOT).dmg | ||
114 | |||
115 | $(OUT): | ||
116 | @echo MKDIR $(OUT) | ||
117 | $(SILENT)mkdir $(OUT) | ||
diff --git a/rbutil/mktccboot/README b/rbutil/mktccboot/README new file mode 100644 index 0000000000..719846f2e8 --- /dev/null +++ b/rbutil/mktccboot/README | |||
@@ -0,0 +1,35 @@ | |||
1 | mktccboot | ||
2 | --------- | ||
3 | |||
4 | A tool to inject a bootloader into a Telechips 77X/78X firmware file. | ||
5 | |||
6 | Usage | ||
7 | ----- | ||
8 | |||
9 | mktccboot <firmware file> <boot file> <output file> | ||
10 | |||
11 | <firmware file> is an original Telechips firmware file. | ||
12 | |||
13 | <boot file> is the code you want to execute (a rockbox bootloader), previously | ||
14 | scrambled with tools/scramble utility. | ||
15 | |||
16 | <output file> is the resulting firmware file which you'll have to copy on your | ||
17 | player. See "Firmware filenames". | ||
18 | |||
19 | Dual-Boot | ||
20 | --------- | ||
21 | |||
22 | The purpose of this program is to provide dual-boot between the original | ||
23 | firmware and the new (rockbox) firmware. | ||
24 | |||
25 | By default the player will boot into the new firmware. | ||
26 | |||
27 | To boot into the Original Firmware, you need to press the <???> key. | ||
28 | |||
29 | The player will boot into the Original Firmware as well if it is powered up by | ||
30 | inserting an usb cable. | ||
31 | |||
32 | Hacking | ||
33 | ------- | ||
34 | |||
35 | See comments in mktccboot.c for more information. | ||
diff --git a/rbutil/mktccboot/mktccboot.c b/rbutil/mktccboot/mktccboot.c index e135b7e506..2c6b08890e 100644 --- a/rbutil/mktccboot/mktccboot.c +++ b/rbutil/mktccboot/mktccboot.c | |||
@@ -81,7 +81,7 @@ void usage(void) | |||
81 | exit(1); | 81 | exit(1); |
82 | } | 82 | } |
83 | 83 | ||
84 | off_t filesize(int fd) { | 84 | static off_t filesize(int fd) { |
85 | struct stat buf; | 85 | struct stat buf; |
86 | 86 | ||
87 | if (fstat(fd,&buf) < 0) { | 87 | if (fstat(fd,&buf) < 0) { |
@@ -92,16 +92,97 @@ off_t filesize(int fd) { | |||
92 | } | 92 | } |
93 | } | 93 | } |
94 | 94 | ||
95 | #define DRAMORIG 0x20000000 | ||
96 | /* Injects a bootloader into a Telechips 77X/78X firmware file */ | ||
97 | unsigned char *patch_firmware_tcc(unsigned char *of_buf, int of_size, | ||
98 | unsigned char *boot_buf, int boot_size, int *patched_size) | ||
99 | { | ||
100 | unsigned char *patched_buf; | ||
101 | uint32_t ldr, old_ep_offset, new_ep_offset; | ||
102 | int of_offset; | ||
103 | |||
104 | patched_buf = malloc(of_size + boot_size); | ||
105 | if (!patched_buf) | ||
106 | return NULL; | ||
107 | |||
108 | memcpy(patched_buf, of_buf, of_size); | ||
109 | memcpy(patched_buf + of_size, boot_buf, boot_size); | ||
110 | |||
111 | ldr = get_uint32le(patched_buf); | ||
112 | |||
113 | /* TODO: Verify it's a LDR instruction */ | ||
114 | of_offset = (ldr & 0xfff) + 8; | ||
115 | old_ep_offset = get_uint32le(patched_buf + of_offset); | ||
116 | new_ep_offset = DRAMORIG + of_size; | ||
117 | |||
118 | printf("OF entry point: 0x%08x\n", old_ep_offset); | ||
119 | printf("New entry point: 0x%08x\n", new_ep_offset + 8); | ||
120 | |||
121 | /* Save the OF entry point at the start of the bootloader image */ | ||
122 | put_uint32le(old_ep_offset, patched_buf + of_size); | ||
123 | put_uint32le(new_ep_offset, patched_buf + of_size + 4); | ||
124 | |||
125 | /* Change the OF entry point to the third word in our bootloader */ | ||
126 | put_uint32le(new_ep_offset + 8, patched_buf + of_offset); | ||
127 | |||
128 | telechips_encode_crc(patched_buf, of_size + boot_size); | ||
129 | *patched_size = of_size + boot_size; | ||
130 | |||
131 | return patched_buf; | ||
132 | } | ||
133 | |||
134 | unsigned char *file_read(char *filename, int *size) | ||
135 | { | ||
136 | unsigned char *buf = NULL; | ||
137 | int n, fd = -1; | ||
138 | |||
139 | /* Open file for reading */ | ||
140 | fd = open(filename, O_RDONLY|O_BINARY); | ||
141 | if (fd < 0) | ||
142 | { | ||
143 | printf("[ERR] Could open file for reading, aborting\n"); | ||
144 | perror(filename); | ||
145 | goto error; | ||
146 | } | ||
147 | |||
148 | /* Get file size, and allocate a buffer of that size */ | ||
149 | *size = filesize(fd); | ||
150 | buf = malloc(*size); | ||
151 | if (buf == NULL) | ||
152 | { | ||
153 | printf("[ERR] Could not allocate memory, aborting\n"); | ||
154 | goto error; | ||
155 | } | ||
156 | |||
157 | /* Read the file's content to the buffer */ | ||
158 | n = read(fd, buf, *size); | ||
159 | if (n != *size) | ||
160 | { | ||
161 | printf("[ERR] Could not read from %s\n", filename); | ||
162 | goto error; | ||
163 | } | ||
164 | |||
165 | return buf; | ||
95 | 166 | ||
167 | error: | ||
168 | if (fd >= 0) | ||
169 | close(fd); | ||
170 | |||
171 | if (buf) | ||
172 | free(buf); | ||
173 | |||
174 | return NULL; | ||
175 | } | ||
176 | |||
177 | #ifndef LIB | ||
96 | int main(int argc, char *argv[]) | 178 | int main(int argc, char *argv[]) |
97 | { | 179 | { |
98 | char *infile, *bootfile, *outfile; | 180 | char *infile, *bootfile, *outfile; |
99 | int fdin = -1, fdboot = -1, fdout = -1; | 181 | int fdout = -1; |
100 | int n; | 182 | int n, of_size, boot_size, patched_size; |
101 | int inlength,bootlength; | 183 | unsigned char *of_buf; |
102 | uint32_t ldr; | 184 | unsigned char *boot_buf = NULL; |
103 | unsigned char* image; | 185 | unsigned char* image = NULL; |
104 | int origoffset; | ||
105 | int ret = 0; | 186 | int ret = 0; |
106 | 187 | ||
107 | if(argc < 3) { | 188 | if(argc < 3) { |
@@ -112,79 +193,50 @@ int main(int argc, char *argv[]) | |||
112 | bootfile = argv[2]; | 193 | bootfile = argv[2]; |
113 | outfile = argv[3]; | 194 | outfile = argv[3]; |
114 | 195 | ||
115 | fdin = open(infile, O_RDONLY|O_BINARY); | 196 | /* Read OF and boot files */ |
116 | if (fdin < 0) | 197 | of_buf = file_read(infile, &of_size); |
198 | if (!of_buf) | ||
117 | { | 199 | { |
118 | perror(infile); | ||
119 | ret = 1; | 200 | ret = 1; |
120 | goto error_exit; | 201 | goto error_exit; |
121 | } | 202 | } |
122 | 203 | ||
123 | fdboot = open(bootfile, O_RDONLY|O_BINARY); | 204 | boot_buf = file_read(bootfile, &boot_size); |
124 | if (fdboot < 0) | 205 | if (!boot_buf) |
125 | { | ||
126 | perror(bootfile); | ||
127 | ret = 2; | ||
128 | goto error_exit; | ||
129 | } | ||
130 | |||
131 | inlength = filesize(fdin); | ||
132 | bootlength = filesize(fdboot); | ||
133 | |||
134 | image = malloc(inlength + bootlength); | ||
135 | |||
136 | if (image==NULL) | ||
137 | { | 206 | { |
138 | printf("[ERR] Could not allocate memory, aborting\n"); | ||
139 | ret = 3; | 207 | ret = 3; |
140 | goto error_exit; | 208 | goto error_exit; |
141 | } | 209 | } |
142 | 210 | ||
143 | n = read(fdin, image, inlength); | 211 | /* Allocate buffer for patched firmware */ |
144 | if (n != inlength) | 212 | image = malloc(of_size + boot_size); |
213 | if (image == NULL) | ||
145 | { | 214 | { |
146 | printf("[ERR] Could not read from %s\n",infile); | 215 | printf("[ERR] Could not allocate memory, aborting\n"); |
147 | ret = 4; | 216 | ret = 4; |
148 | goto error_exit; | 217 | goto error_exit; |
149 | } | 218 | } |
150 | 219 | ||
151 | n = read(fdboot, image + inlength, bootlength); | 220 | /* Create the patched firmware */ |
152 | if (n != bootlength) | 221 | image = patch_firmware_tcc(of_buf, of_size, boot_buf, boot_size, |
222 | &patched_size); | ||
223 | if (!image) | ||
153 | { | 224 | { |
154 | printf("[ERR] Could not read from %s\n",bootfile); | 225 | printf("[ERR] Error creating patched firmware, aborting\n"); |
155 | ret = 5; | 226 | ret = 5; |
156 | goto error_exit; | 227 | goto error_exit; |
157 | } | 228 | } |
158 | 229 | ||
159 | ldr = get_uint32le(image); | ||
160 | |||
161 | /* TODO: Verify it's a LDR instruction */ | ||
162 | origoffset = (ldr&0xfff) + 8; | ||
163 | |||
164 | printf("original firmware entry point: 0x%08x\n", | ||
165 | (unsigned int) get_uint32le(image + origoffset)); | ||
166 | printf("New entry point: 0x%08x\n",0x20000000 + inlength + 8); | ||
167 | |||
168 | /* Save the original firmware entry point at the start of the bootloader image */ | ||
169 | put_uint32le(get_uint32le(image + origoffset),image+inlength); | ||
170 | put_uint32le(0x20000000 + inlength,image + inlength + 4); | ||
171 | |||
172 | /* Change the original firmware entry point to the third word in our bootloader */ | ||
173 | put_uint32le(0x20000000 + inlength + 8,image+origoffset); | ||
174 | |||
175 | |||
176 | telechips_encode_crc(image, inlength + bootlength); | ||
177 | |||
178 | fdout = open(outfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644); | 230 | fdout = open(outfile, O_WRONLY|O_CREAT|O_TRUNC|O_BINARY, 0644); |
179 | if (fdout < 0) | 231 | if (fdout < 0) |
180 | { | 232 | { |
181 | perror(bootfile); | 233 | perror(outfile); |
182 | ret = 6; | 234 | ret = 6; |
183 | goto error_exit; | 235 | goto error_exit; |
184 | } | 236 | } |
185 | 237 | ||
186 | n = write(fdout, image, inlength + bootlength); | 238 | n = write(fdout, image, patched_size); |
187 | if (n != inlength + bootlength) | 239 | if (n != patched_size) |
188 | { | 240 | { |
189 | printf("[ERR] Could not write output file %s\n",outfile); | 241 | printf("[ERR] Could not write output file %s\n",outfile); |
190 | ret = 7; | 242 | ret = 7; |
@@ -193,14 +245,18 @@ int main(int argc, char *argv[]) | |||
193 | 245 | ||
194 | error_exit: | 246 | error_exit: |
195 | 247 | ||
196 | if (fdin >= 0) | ||
197 | close(fdin); | ||
198 | |||
199 | if (fdboot >= 0) | ||
200 | close(fdboot); | ||
201 | |||
202 | if (fdout >= 0) | 248 | if (fdout >= 0) |
203 | close(fdout); | 249 | close(fdout); |
204 | 250 | ||
251 | if (of_buf) | ||
252 | free(of_buf); | ||
253 | |||
254 | if (boot_buf) | ||
255 | free(boot_buf); | ||
256 | |||
257 | if (image) | ||
258 | free(image); | ||
259 | |||
205 | return ret; | 260 | return ret; |
206 | } | 261 | } |
262 | #endif | ||
diff --git a/rbutil/mktccboot/mktccboot.h b/rbutil/mktccboot/mktccboot.h new file mode 100644 index 0000000000..6c6410c258 --- /dev/null +++ b/rbutil/mktccboot/mktccboot.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * mktccboot.h - a tool to inject a bootloader into a Telechips 77X/78X firmware | ||
11 | * file. | ||
12 | * | ||
13 | * Copyright (C) 2009 Tomer Shalev | ||
14 | * | ||
15 | * This program is free software; you can redistribute it and/or | ||
16 | * modify it under the terms of the GNU General Public License | ||
17 | * as published by the Free Software Foundation; either version 2 | ||
18 | * of the License, or (at your option) any later version. | ||
19 | * | ||
20 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
21 | * KIND, either express or implied. | ||
22 | * | ||
23 | ****************************************************************************/ | ||
24 | |||
25 | #ifndef _MKTCCBOOT_H_ | ||
26 | #define _MKTCCBOOT_H_ | ||
27 | |||
28 | #ifdef __cplusplus | ||
29 | extern "C" { | ||
30 | #endif | ||
31 | |||
32 | /* Injects a bootloader into a Telechips 77X/78X firmware file */ | ||
33 | unsigned char *patch_firmware_tcc(unsigned char *of_buf, int of_size, | ||
34 | unsigned char *boot_buf, int boot_size, int *patched_size); | ||
35 | |||
36 | unsigned char *file_read(char *filename, int *size); | ||
37 | |||
38 | #ifdef __cplusplus | ||
39 | }; | ||
40 | #endif | ||
41 | |||
42 | #endif | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2009 by Tomer Shalev | ||
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 | * This file is a modified version of the AMS installer by Dominik Wenger | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include <QtCore> | ||
23 | #include "bootloaderinstallbase.h" | ||
24 | #include "bootloaderinstalltcc.h" | ||
25 | #include "../mktccboot/mktccboot.h" | ||
26 | |||
27 | BootloaderInstallTcc::BootloaderInstallTcc(QObject *parent) | ||
28 | : BootloaderInstallBase(parent) | ||
29 | { | ||
30 | } | ||
31 | |||
32 | QString BootloaderInstallTcc::ofHint() | ||
33 | { | ||
34 | return tr("Bootloader installation requires you to provide " | ||
35 | "a firmware file of the original firmware (bin file). " | ||
36 | "You need to download this file yourself due to legal " | ||
37 | "reasons." | ||
38 | "Press Ok to continue and browse your computer for the firmware " | ||
39 | "file."); | ||
40 | } | ||
41 | |||
42 | bool BootloaderInstallTcc::install(void) | ||
43 | { | ||
44 | if(m_offile.isEmpty()) | ||
45 | return false; | ||
46 | |||
47 | // Download firmware from server | ||
48 | emit logItem(tr("Downloading bootloader file"), LOGINFO); | ||
49 | |||
50 | connect(this, SIGNAL(downloadDone()), this, SLOT(installStage2())); | ||
51 | downloadBlStart(m_blurl); | ||
52 | |||
53 | return true; | ||
54 | } | ||
55 | |||
56 | void BootloaderInstallTcc::installStage2(void) | ||
57 | { | ||
58 | unsigned char *of_buf, *boot_buf = NULL, *patched_buf = NULL; | ||
59 | int n, of_size, boot_size, patched_size; | ||
60 | char errstr[200]; | ||
61 | bool ret = false; | ||
62 | |||
63 | m_tempfile.open(); | ||
64 | QString bootfile = m_tempfile.fileName(); | ||
65 | m_tempfile.close(); | ||
66 | |||
67 | /* Construct path for write out. | ||
68 | * Combine path of m_blfile with filename from OF */ | ||
69 | QString outfilename = QFileInfo(m_blfile).absolutePath() + "/" + | ||
70 | QFileInfo(m_offile).fileName(); | ||
71 | |||
72 | /* Write out file */ | ||
73 | QFile out(outfilename); | ||
74 | |||
75 | /* Load original firmware file */ | ||
76 | of_buf = file_read(m_offile.toLocal8Bit().data(), &of_size); | ||
77 | if (of_buf == NULL) | ||
78 | { | ||
79 | emit logItem(errstr, LOGERROR); | ||
80 | emit logItem(tr("Could not load %1").arg(m_offile), LOGERROR); | ||
81 | goto exit; | ||
82 | } | ||
83 | |||
84 | /* Load bootloader file */ | ||
85 | boot_buf = file_read(bootfile.toLocal8Bit().data(), &boot_size); | ||
86 | if (boot_buf == NULL) | ||
87 | { | ||
88 | emit logItem(errstr, LOGERROR); | ||
89 | emit logItem(tr("Could not load %1").arg(bootfile), LOGERROR); | ||
90 | goto exit; | ||
91 | } | ||
92 | |||
93 | /* Patch the firmware */ | ||
94 | emit logItem(tr("Patching Firmware..."), LOGINFO); | ||
95 | |||
96 | patched_buf = patch_firmware_tcc(of_buf, of_size, boot_buf, boot_size, | ||
97 | &patched_size); | ||
98 | if (patched_buf == NULL) | ||
99 | { | ||
100 | emit logItem(errstr, LOGERROR); | ||
101 | emit logItem(tr("Could patch firmware"), LOGERROR); | ||
102 | goto exit; | ||
103 | } | ||
104 | |||
105 | if(!out.open(QIODevice::WriteOnly | QIODevice::Truncate)) | ||
106 | { | ||
107 | emit logItem(tr("Could not open %1 for writing").arg(m_blfile), | ||
108 | LOGERROR); | ||
109 | goto exit; | ||
110 | } | ||
111 | |||
112 | n = out.write((char*)patched_buf, patched_size); | ||
113 | out.close(); | ||
114 | if (n != patched_size) | ||
115 | { | ||
116 | emit logItem(tr("Could not write firmware file"), LOGERROR); | ||
117 | goto exit; | ||
118 | } | ||
119 | |||
120 | /* End of install */ | ||
121 | emit logItem(tr("Success: modified firmware file created"), LOGINFO); | ||
122 | logInstall(LogAdd); | ||
123 | |||
124 | ret = true; | ||
125 | |||
126 | exit: | ||
127 | if (of_buf) | ||
128 | free(of_buf); | ||
129 | |||
130 | if (boot_buf) | ||
131 | free(boot_buf); | ||
132 | |||
133 | if (patched_buf) | ||
134 | free(patched_buf); | ||
135 | |||
136 | emit done(ret); | ||
137 | } | ||
138 | |||
139 | bool BootloaderInstallTcc::uninstall(void) | ||
140 | { | ||
141 | emit logItem("To uninstall, perform a normal upgrade with an unmodified original firmware", LOGINFO); | ||
142 | logInstall(LogRemove); | ||
143 | return false; | ||
144 | } | ||
145 | |||
146 | BootloaderInstallBase::BootloaderType BootloaderInstallTcc::installed(void) | ||
147 | { | ||
148 | return BootloaderUnknown; | ||
149 | } | ||
150 | |||
151 | BootloaderInstallBase::Capabilities BootloaderInstallTcc::capabilities(void) | ||
152 | { | ||
153 | return (Install | NeedsOf); | ||
154 | } | ||
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 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * Copyright (C) 2009 by Tomer Shalev | ||
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 | * This file is a modified version of the AMS installer by Dominik Wenger | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | #ifndef BOOTLOADERINSTALLTCC_H | ||
22 | #define BOOTLOADERINSTALLTCC_H | ||
23 | |||
24 | #include <QtCore> | ||
25 | #include "bootloaderinstallbase.h" | ||
26 | |||
27 | //! bootloader installation derivate based on mktccboot | ||
28 | class BootloaderInstallTcc : public BootloaderInstallBase | ||
29 | { | ||
30 | Q_OBJECT | ||
31 | public: | ||
32 | BootloaderInstallTcc(QObject *parent); | ||
33 | bool install(void); | ||
34 | bool uninstall(void); | ||
35 | BootloaderInstallBase::BootloaderType installed(void); | ||
36 | Capabilities capabilities(void); | ||
37 | QString ofHint(); | ||
38 | |||
39 | private: | ||
40 | |||
41 | private slots: | ||
42 | void installStage2(void); | ||
43 | }; | ||
44 | |||
45 | #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 | |||
58 | platform70=smsgyh820 | 58 | platform70=smsgyh820 |
59 | platform71=smsgyh920 | 59 | platform71=smsgyh920 |
60 | platform72=smsgyh925 | 60 | platform72=smsgyh925 |
61 | 61 | platform73=cowond2 | |
62 | 62 | ||
63 | [player] | 63 | [player] |
64 | name="Jukebox Player 6000 / Jukebox Studio 5 / 10 / 20" | 64 | name="Jukebox Player 6000 / Jukebox Studio 5 / 10 / 20" |
@@ -537,6 +537,19 @@ usbid=0x04e85024 | |||
537 | configure_modelname=yh925 | 537 | configure_modelname=yh925 |
538 | encoder=rbspeex | 538 | encoder=rbspeex |
539 | 539 | ||
540 | [cowond2] | ||
541 | name="D2 (Unstable)" | ||
542 | buildserver_modelname=cowond2 | ||
543 | bootloadermethod=tcc | ||
544 | bootloadername=/cowon/d2.bin | ||
545 | bootloaderfile=d2n.bin | ||
546 | manualname= | ||
547 | brand=Cowon | ||
548 | usbid=0x0e210800, 0x0e210860, 0x0e210870, 0x0e210880, 0x0e210890 | ||
549 | usberror=0x0e210801, 0x0e210861, 0x0e210871, 0x0e210881, 0x0e210891 | ||
550 | configure_modelname=cowond2 | ||
551 | encoder=rbspeex | ||
552 | |||
540 | [05ac1240] | 553 | [05ac1240] |
541 | name="Apple Ipod Nano (Second Generation, DFU Mode)" | 554 | name="Apple Ipod Nano (Second Generation, DFU Mode)" |
542 | 555 | ||
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 @@ | |||
47 | #include "bootloaderinstallfile.h" | 47 | #include "bootloaderinstallfile.h" |
48 | #include "bootloaderinstallchinachip.h" | 48 | #include "bootloaderinstallchinachip.h" |
49 | #include "bootloaderinstallams.h" | 49 | #include "bootloaderinstallams.h" |
50 | #include "bootloaderinstalltcc.h" | ||
50 | 51 | ||
51 | 52 | ||
52 | #if defined(Q_OS_LINUX) | 53 | #if defined(Q_OS_LINUX) |
@@ -673,6 +674,9 @@ void RbUtilQt::installBootloader() | |||
673 | else if(type == "ams") { | 674 | else if(type == "ams") { |
674 | bl = new BootloaderInstallAms(this); | 675 | bl = new BootloaderInstallAms(this); |
675 | } | 676 | } |
677 | else if(type == "tcc") { | ||
678 | bl = new BootloaderInstallTcc(this); | ||
679 | } | ||
676 | else { | 680 | else { |
677 | logger->addItem(tr("No install method known."), LOGERROR); | 681 | logger->addItem(tr("No install method known."), LOGERROR); |
678 | logger->setFinished(); | 682 | 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) | |||
42 | rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex.a | 42 | rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex.a |
43 | libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl.a | 43 | libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl.a |
44 | libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot.a | 44 | libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot.a |
45 | libmktccboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mktccboot libmktccboot.a | ||
45 | } | 46 | } |
46 | mac { | 47 | mac { |
47 | rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex-universal | 48 | rbspeex.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/rbspeex librbspeex-universal |
48 | libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl-universal | 49 | libucl.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/tools/ucl/src libucl-universal |
49 | libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot-universal | 50 | libmkamsboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mkamsboot libmkamsboot-universal |
51 | libmktccboot.commands = @$(MAKE) TARGET_DIR=$$MYBUILDDIR -C $$RBBASE_DIR/rbutil/mktccboot libmktccboot-universal | ||
50 | } | 52 | } |
51 | QMAKE_EXTRA_TARGETS += rbspeex libucl libmkamsboot | 53 | QMAKE_EXTRA_TARGETS += rbspeex libucl libmkamsboot libmktccboot |
52 | PRE_TARGETDEPS += rbspeex libucl libmkamsboot | 54 | PRE_TARGETDEPS += rbspeex libucl libmkamsboot libmktccboot |
53 | 55 | ||
54 | # rule for creating ctags file | 56 | # rule for creating ctags file |
55 | tags.commands = ctags -R --c++-kinds=+p --fields=+iaS --extra=+q $(SOURCES) | 57 | tags.commands = ctags -R --c++-kinds=+p --fields=+iaS --extra=+q $(SOURCES) |
@@ -110,8 +112,10 @@ SOURCES += rbutilqt.cpp \ | |||
110 | base/bootloaderinstallfile.cpp \ | 112 | base/bootloaderinstallfile.cpp \ |
111 | base/bootloaderinstallchinachip.cpp \ | 113 | base/bootloaderinstallchinachip.cpp \ |
112 | base/bootloaderinstallams.cpp \ | 114 | base/bootloaderinstallams.cpp \ |
115 | base/bootloaderinstalltcc.cpp \ | ||
113 | ../../tools/mkboot.c \ | 116 | ../../tools/mkboot.c \ |
114 | ../../tools/iriver.c | 117 | ../../tools/iriver.c \ |
118 | ../../tools/telechips.c \ | ||
115 | 119 | ||
116 | HEADERS += rbutilqt.h \ | 120 | HEADERS += rbutilqt.h \ |
117 | install.h \ | 121 | install.h \ |
@@ -170,8 +174,10 @@ HEADERS += rbutilqt.h \ | |||
170 | base/bootloaderinstallfile.h \ | 174 | base/bootloaderinstallfile.h \ |
171 | base/bootloaderinstallchinachip.h \ | 175 | base/bootloaderinstallchinachip.h \ |
172 | base/bootloaderinstallams.h \ | 176 | base/bootloaderinstallams.h \ |
177 | base/bootloaderinstalltcc.h \ | ||
173 | ../../tools/mkboot.h \ | 178 | ../../tools/mkboot.h \ |
174 | ../../tools/iriver.h | 179 | ../../tools/iriver.h \ |
180 | ../../tools/telechips.h \ | ||
175 | 181 | ||
176 | # Needed by QT on Win | 182 | # Needed by QT on Win |
177 | INCLUDEPATH = $$_PRO_FILE_PWD_ $$_PRO_FILE_PWD_/irivertools $$_PRO_FILE_PWD_/zip $$_PRO_FILE_PWD_/zlib $$_PRO_FILE_PWD_/base | 183 | 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 | |||
179 | 185 | ||
180 | DEPENDPATH = $$INCLUDEPATH | 186 | DEPENDPATH = $$INCLUDEPATH |
181 | 187 | ||
182 | LIBS += -L$$OUT_PWD -L$$MYBUILDDIR -lrbspeex -lmkamsboot -lucl | 188 | LIBS += -L$$OUT_PWD -L$$MYBUILDDIR -lrbspeex -lmkamsboot -lmktccboot -lucl |
183 | 189 | ||
184 | TEMPLATE = app | 190 | TEMPLATE = app |
185 | dbg { | 191 | dbg { |