summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile3
-rwxr-xr-xtools/configure30
-rw-r--r--tools/gigabeats.c171
-rw-r--r--tools/gigabeats.h20
-rw-r--r--tools/scramble.c12
5 files changed, 231 insertions, 5 deletions
diff --git a/tools/Makefile b/tools/Makefile
index b7f445ebf6..74d82affab 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -16,13 +16,14 @@ CLEANALL := scramble descramble iriver sh2d bmp2rb rdf2binary convbdf \
16all: 16all:
17 @echo "Run make in your build directory!" 17 @echo "Run make in your build directory!"
18 18
19scramble: scramble.o iriver.o mi4.o gigabeat.o 19scramble: scramble.o iriver.o mi4.o gigabeat.o gigabeats.o
20descramble: descramble.o iriver.o gigabeat.o 20descramble: descramble.o iriver.o gigabeat.o
21 21
22scramble.o: scramble.c iriver.h mi4.h gigabeat.h 22scramble.o: scramble.c iriver.h mi4.h gigabeat.h
23descramble.o: descramble.c iriver.h gigabeat.h 23descramble.o: descramble.c iriver.h gigabeat.h
24iriver.o: iriver.c iriver.h 24iriver.o: iriver.c iriver.h
25gigabeat.o: gigabeat.c gigabeat.h 25gigabeat.o: gigabeat.c gigabeat.h
26gigabeats.o: gigabeats.c gigabeats.h
26mi4.o: mi4.c mi4.h 27mi4.o: mi4.c mi4.h
27 28
28sh2d: sh2d.c 29sh2d: sh2d.c
diff --git a/tools/configure b/tools/configure
index 63e5512c01..73e6a50e79 100755
--- a/tools/configure
+++ b/tools/configure
@@ -615,7 +615,7 @@ cat <<EOF
615 615
616 ==iAudio== ==Toshiba== ==SanDisk== 616 ==iAudio== ==Toshiba== ==SanDisk==
617 30) X5/X5V/X5L 40) Gigabeat F 50) Sansa e200 617 30) X5/X5V/X5L 40) Gigabeat F 50) Sansa e200
618 31) M5/M5L 51) Sansa e200R 618 31) M5/M5L 41) Gigabeat S 51) Sansa e200R
619 52) Sansa c200 619 52) Sansa c200
620 620
621 ==Tatung== ==Olympus== 621 ==Tatung== ==Olympus==
@@ -1257,6 +1257,30 @@ EOF
1257 t_model="gigabeat-fx" 1257 t_model="gigabeat-fx"
1258 ;; 1258 ;;
1259 1259
1260 41|gigabeats)
1261 target_id=26
1262 archos="gigabeats"
1263 target="-DGIGABEAT_S"
1264 memory=32 # always
1265 arm9tdmicc
1266 tool="$rootdir/tools/scramble -add=gigs"
1267 bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
1268 bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
1269 output="rockbox.gigabeat"
1270 appextra="recorder:gui"
1271 archosrom=""
1272 flash=""
1273 plugins="yes"
1274 codecs="libmad liba52 libffmpegFLAC libwma libTremor libwavpack libmusepack libalac libfaad libm4a libspeex libdemac"
1275 toolset=$gigabeatbitmaptools
1276 boottool="$rootdir/tools/scramble -gigabeats"
1277 bootoutput="nk.bin"
1278 # architecture, manufacturer and model for the target-tree build
1279 t_cpu="arm"
1280 t_manufacturer="imx31"
1281 t_model="gigabeat-s"
1282 ;;
1283
1260 70|mrobe500) 1284 70|mrobe500)
1261 target_id=20 1285 target_id=20
1262 archos="mrobe500" 1286 archos="mrobe500"
@@ -1349,7 +1373,7 @@ EOF
1349 appextra="recorder:gui" 1373 appextra="recorder:gui"
1350 archosrom="" 1374 archosrom=""
1351 flash="" 1375 flash=""
1352 plugins="yes" 1376 plugins=""
1353 swcodec="yes" 1377 swcodec="yes"
1354 boottool="$rootdir/tools/scramble -mi4v3 -model=c200 -type=RBBL" 1378 boottool="$rootdir/tools/scramble -mi4v3 -model=c200 -type=RBBL"
1355 bootoutput="firmware.mi4" 1379 bootoutput="firmware.mi4"
@@ -1387,7 +1411,7 @@ EOF
1387 t_manufacturer="tatung" 1411 t_manufacturer="tatung"
1388 t_model="tpj1022" 1412 t_model="tpj1022"
1389 ;; 1413 ;;
1390 1414
1391 *) 1415 *)
1392 echo "Please select a supported target platform!" 1416 echo "Please select a supported target platform!"
1393 exit 1417 exit
diff --git a/tools/gigabeats.c b/tools/gigabeats.c
new file mode 100644
index 0000000000..0d60eae781
--- /dev/null
+++ b/tools/gigabeats.c
@@ -0,0 +1,171 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2007 by Will Robertson
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 <stdio.h>
21#include <stdlib.h>
22
23static FILE * openinfile( const char * filename )
24{
25 FILE * F = fopen( filename, "rb" );
26 if( F == NULL )
27 {
28 fprintf( stderr, "Couldn't open input file %s\n", filename );
29 perror( "Error was " );
30 exit( -1 );
31 };
32 return F;
33};
34
35static FILE * openoutfile( const char * filename )
36{
37 FILE * F = fopen( filename, "wb" );
38 if( F == NULL )
39 {
40 fprintf( stderr, "Couldn't open output file %s\n", filename );
41 perror( "Error was " );
42 exit( -1 );
43 };
44 return F;
45};
46
47unsigned long calc_csum(const unsigned char* pb, int cb)
48{
49 unsigned long l = 0;
50 while (cb--)
51 l += *pb++;
52 return l;
53}
54
55int gigabeat_s_code(char *infile, char *outfile)
56{
57 FILE *in, *out;
58 unsigned long size = 0;
59 unsigned long data;
60 int imagelength;
61
62 in = openinfile(infile);
63 out = openoutfile(outfile);
64
65 fseek(in, 0, SEEK_END);
66 size = ftell(in);
67 fseek(in, 0, SEEK_SET);
68 unsigned long *binptr = malloc(size);
69 if(binptr == NULL) {
70 fprintf(stderr, "Not enough memory to perform the requested operation. Aborting.\n" );
71 return 0;
72 }
73 fread(binptr, size/4, 4, in);
74 /* 15 bytes for header, three 12 byte headers, the data for the first three
75 * records, 12 byte header for code, code and the 12 byte footer
76 * However, the original nk.bin's length doesn't correspond with
77 * the length of the file, so I don't know what's up...
78 */
79
80 unsigned long header[2];
81 header[0] = 0x88200000;
82 /* header[1] = 15 + 12 + 4 + 12 + 8 + 12 + 4 + 12 + size + 12; */
83 header[1] = 0xCC0CD8; /* The bootloader checks this value and compares */
84 fwrite("B000FF\n", 7, 1, out);
85 fwrite(header, sizeof(header), 1, out);
86
87 unsigned long record[4];
88 unsigned long extra;
89
90 /*First record*/
91 record[0] = 0x88200000;
92 record[1] = 4;
93 record[2] = 0x1eb;
94 record[3] = 0xEA0003FE;
95 fwrite(record, sizeof(record), 1, out);
96
97 /*Second record*/
98 record[0] = 0x88200040;
99 record[1] = 8;
100 record[2] = 0x3e9;
101 record[3] = 0x43454345;
102 extra = 0x88EBF274;
103 fwrite(record, sizeof(record), 1, out);
104 fwrite(&extra, sizeof(extra), 1, out);
105
106 /*Third record*/
107 record[0] = 0x88200048;
108 record[1] = 4;
109 record[2] = 0x231;
110 record[3] = 0x00CBF274;
111 fwrite(record, sizeof(record), 1, out);
112
113 /*Signature bypass record*/
114 unsigned long magic = 0xE3A00001;
115 record[0] = 0x88065A10;
116 record[1] = 4;
117 record[2] = calc_csum((unsigned char*)&magic,4);
118 record[3] = magic;
119 fwrite(record, sizeof(record), 1, out);
120
121 /*The actual code*/
122 header[0] = 0x88201000;
123 header[1] = size;
124 extra = calc_csum((unsigned char*)binptr, size);
125 fwrite(header, sizeof(header), 1, out);
126 fwrite(&extra, sizeof(extra), 1, out);
127 fwrite(binptr, size, 1, out);
128
129 /* Table of contents. It's a start, but it still won't boot.
130 * Looks like it needs the file/module info as well... */
131 binptr[0] = 0x02000000;
132 binptr[1] = 0x02000000;
133 binptr[2] = 0x88040000;
134 binptr[3] = 0x88076338;
135 binptr[4] = 0x1;
136 binptr[5] = 0x88080000;
137 binptr[6] = 0x8809C000;
138 binptr[7] = 0x88100000;
139 binptr[8] = 0x0;
140 binptr[9] = 0x0;
141 binptr[10] = 0x0;
142 binptr[11] = 0x0;
143 binptr[12] = 0x0;
144 binptr[13] = 0x0;
145 binptr[14] = 0x80808080;
146 binptr[15] = 0x0;
147 binptr[16] = 0x0;
148 binptr[17] = 0x201C2;
149 binptr[18] = 0x88050940;
150 binptr[19] = 0x0;
151 binptr[20] = 0x0;
152 header[0] = 0x88EBF274;
153 header[1] = 0x54;
154 extra = calc_csum((unsigned char*)binptr, 84);
155 fwrite(header, sizeof(header), 1, out);
156 fwrite(&extra, sizeof(extra), 1, out);
157 fwrite(binptr, 84, 1, out);
158
159 /*The footer*/
160 header[0] = 0;
161 header[1] = 0x88201000;
162 extra = 0;
163 fwrite(header, sizeof(header), 1, out);
164 fwrite(&extra, sizeof(extra), 1, out);
165
166 fprintf(stderr, "File processed successfully\n" );
167
168 fclose(in);
169 fclose(out);
170 return(0);
171}
diff --git a/tools/gigabeats.h b/tools/gigabeats.h
new file mode 100644
index 0000000000..f682a9d887
--- /dev/null
+++ b/tools/gigabeats.h
@@ -0,0 +1,20 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2006 by Marcoen Hirschberg
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
20int gigabeat_s_code(char *infile, char *outfile);
diff --git a/tools/scramble.c b/tools/scramble.c
index 9f18e96e85..8534d41832 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -23,6 +23,7 @@
23#include <string.h> 23#include <string.h>
24#include "iriver.h" 24#include "iriver.h"
25#include "gigabeat.h" 25#include "gigabeat.h"
26#include "gigabeats.h"
26#include "mi4.h" 27#include "mi4.h"
27 28
28int iaudio_encode(char *iname, char *oname, char *idstring); 29int iaudio_encode(char *iname, char *oname, char *idstring);
@@ -92,7 +93,8 @@ void usage(void)
92 "\t-ipod3g ipod firmware partition format (3rd Gen)\n" 93 "\t-ipod3g ipod firmware partition format (3rd Gen)\n"
93 "\t-ipod4g ipod firmware partition format (4th Gen, Mini, Nano, Photo/Color)\n" 94 "\t-ipod4g ipod firmware partition format (4th Gen, Mini, Nano, Photo/Color)\n"
94 "\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n" 95 "\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n"
95 "\t-gigabeat Toshiba Gigabeat format\n" 96 "\t-gigabeat Toshiba Gigabeat F/X format\n"
97 "\t-gigabeats Toshiba Gigabeat S format\n"
96 "\t-mi4v2 PortalPlayer .mi4 format (revision 010201)\n" 98 "\t-mi4v2 PortalPlayer .mi4 format (revision 010201)\n"
97 "\t-mi4v3 PortalPlayer .mi4 format (revision 010301)\n" 99 "\t-mi4v3 PortalPlayer .mi4 format (revision 010301)\n"
98 "\t-mi4r Sandisk Rhapsody .mi4 format\n" 100 "\t-mi4r Sandisk Rhapsody .mi4 format\n"
@@ -231,6 +233,8 @@ int main (int argc, char** argv)
231 modelnum = 19; 233 modelnum = 19;
232 else if(!strcmp(&argv[1][5], "c200")) 234 else if(!strcmp(&argv[1][5], "c200"))
233 modelnum = 20; 235 modelnum = 20;
236 else if(!strcmp(&argv[1][5], "gigs"))
237 modelnum = 21;
234 else { 238 else {
235 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]); 239 fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
236 return 2; 240 return 2;
@@ -254,6 +258,12 @@ int main (int argc, char** argv)
254 gigabeat_code(iname, oname); 258 gigabeat_code(iname, oname);
255 return 0; 259 return 0;
256 } 260 }
261 else if(!strcmp(argv[1], "-gigabeats")) {
262 iname = argv[2];
263 oname = argv[3];
264 gigabeat_s_code(iname, oname);
265 return 0;
266 }
257 else if(!strcmp(argv[1], "-iaudiox5")) { 267 else if(!strcmp(argv[1], "-iaudiox5")) {
258 iname = argv[2]; 268 iname = argv[2];
259 oname = argv[3]; 269 oname = argv[3];