summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorWill Robertson <aliask@rockbox.org>2007-09-21 15:51:53 +0000
committerWill Robertson <aliask@rockbox.org>2007-09-21 15:51:53 +0000
commit590501cfe404b5463adecc70628e5bc7c8f142a2 (patch)
tree3b038f90c9c3bbef8cf0b84f5a4ea338f9599851 /tools
parenta26110c52dff9bc15d20146462d52d07f61bd238 (diff)
downloadrockbox-590501cfe404b5463adecc70628e5bc7c8f142a2.tar.gz
rockbox-590501cfe404b5463adecc70628e5bc7c8f142a2.tar.bz2
rockbox-590501cfe404b5463adecc70628e5bc7c8f142a2.zip
Merge the Gigabeat S branch back into trunk. Fingers crossed nothing breaks.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14805 a1c6a512-1295-4272-9138-f99709370657
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 \
all:
@echo "Run make in your build directory!"
-scramble: scramble.o iriver.o mi4.o gigabeat.o
+scramble: scramble.o iriver.o mi4.o gigabeat.o gigabeats.o
descramble: descramble.o iriver.o gigabeat.o
scramble.o: scramble.c iriver.h mi4.h gigabeat.h
descramble.o: descramble.c iriver.h gigabeat.h
iriver.o: iriver.c iriver.h
gigabeat.o: gigabeat.c gigabeat.h
+gigabeats.o: gigabeats.c gigabeats.h
mi4.o: mi4.c mi4.h
sh2d: 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
==iAudio== ==Toshiba== ==SanDisk==
30) X5/X5V/X5L 40) Gigabeat F 50) Sansa e200
- 31) M5/M5L 51) Sansa e200R
+ 31) M5/M5L 41) Gigabeat S 51) Sansa e200R
52) Sansa c200
==Tatung== ==Olympus==
@@ -1257,6 +1257,30 @@ EOF
t_model="gigabeat-fx"
;;
+ 41|gigabeats)
+ target_id=26
+ archos="gigabeats"
+ target="-DGIGABEAT_S"
+ memory=32 # always
+ arm9tdmicc
+ tool="$rootdir/tools/scramble -add=gigs"
+ bmp2rb_mono="$rootdir/tools/bmp2rb -f 0"
+ bmp2rb_native="$rootdir/tools/bmp2rb -f 4"
+ output="rockbox.gigabeat"
+ appextra="recorder:gui"
+ archosrom=""
+ flash=""
+ plugins="yes"
+ codecs="libmad liba52 libffmpegFLAC libwma libTremor libwavpack libmusepack libalac libfaad libm4a libspeex libdemac"
+ toolset=$gigabeatbitmaptools
+ boottool="$rootdir/tools/scramble -gigabeats"
+ bootoutput="nk.bin"
+ # architecture, manufacturer and model for the target-tree build
+ t_cpu="arm"
+ t_manufacturer="imx31"
+ t_model="gigabeat-s"
+ ;;
+
70|mrobe500)
target_id=20
archos="mrobe500"
@@ -1349,7 +1373,7 @@ EOF
appextra="recorder:gui"
archosrom=""
flash=""
- plugins="yes"
+ plugins=""
swcodec="yes"
boottool="$rootdir/tools/scramble -mi4v3 -model=c200 -type=RBBL"
bootoutput="firmware.mi4"
@@ -1387,7 +1411,7 @@ EOF
t_manufacturer="tatung"
t_model="tpj1022"
;;
-
+
*)
echo "Please select a supported target platform!"
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2007 by Will Robertson
+ *
+ * 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 <stdio.h>
+#include <stdlib.h>
+
+static FILE * openinfile( const char * filename )
+{
+ FILE * F = fopen( filename, "rb" );
+ if( F == NULL )
+ {
+ fprintf( stderr, "Couldn't open input file %s\n", filename );
+ perror( "Error was " );
+ exit( -1 );
+ };
+ return F;
+};
+
+static FILE * openoutfile( const char * filename )
+{
+ FILE * F = fopen( filename, "wb" );
+ if( F == NULL )
+ {
+ fprintf( stderr, "Couldn't open output file %s\n", filename );
+ perror( "Error was " );
+ exit( -1 );
+ };
+ return F;
+};
+
+unsigned long calc_csum(const unsigned char* pb, int cb)
+{
+ unsigned long l = 0;
+ while (cb--)
+ l += *pb++;
+ return l;
+}
+
+int gigabeat_s_code(char *infile, char *outfile)
+{
+ FILE *in, *out;
+ unsigned long size = 0;
+ unsigned long data;
+ int imagelength;
+
+ in = openinfile(infile);
+ out = openoutfile(outfile);
+
+ fseek(in, 0, SEEK_END);
+ size = ftell(in);
+ fseek(in, 0, SEEK_SET);
+ unsigned long *binptr = malloc(size);
+ if(binptr == NULL) {
+ fprintf(stderr, "Not enough memory to perform the requested operation. Aborting.\n" );
+ return 0;
+ }
+ fread(binptr, size/4, 4, in);
+ /* 15 bytes for header, three 12 byte headers, the data for the first three
+ * records, 12 byte header for code, code and the 12 byte footer
+ * However, the original nk.bin's length doesn't correspond with
+ * the length of the file, so I don't know what's up...
+ */
+
+ unsigned long header[2];
+ header[0] = 0x88200000;
+ /* header[1] = 15 + 12 + 4 + 12 + 8 + 12 + 4 + 12 + size + 12; */
+ header[1] = 0xCC0CD8; /* The bootloader checks this value and compares */
+ fwrite("B000FF\n", 7, 1, out);
+ fwrite(header, sizeof(header), 1, out);
+
+ unsigned long record[4];
+ unsigned long extra;
+
+ /*First record*/
+ record[0] = 0x88200000;
+ record[1] = 4;
+ record[2] = 0x1eb;
+ record[3] = 0xEA0003FE;
+ fwrite(record, sizeof(record), 1, out);
+
+ /*Second record*/
+ record[0] = 0x88200040;
+ record[1] = 8;
+ record[2] = 0x3e9;
+ record[3] = 0x43454345;
+ extra = 0x88EBF274;
+ fwrite(record, sizeof(record), 1, out);
+ fwrite(&extra, sizeof(extra), 1, out);
+
+ /*Third record*/
+ record[0] = 0x88200048;
+ record[1] = 4;
+ record[2] = 0x231;
+ record[3] = 0x00CBF274;
+ fwrite(record, sizeof(record), 1, out);
+
+ /*Signature bypass record*/
+ unsigned long magic = 0xE3A00001;
+ record[0] = 0x88065A10;
+ record[1] = 4;
+ record[2] = calc_csum((unsigned char*)&magic,4);
+ record[3] = magic;
+ fwrite(record, sizeof(record), 1, out);
+
+ /*The actual code*/
+ header[0] = 0x88201000;
+ header[1] = size;
+ extra = calc_csum((unsigned char*)binptr, size);
+ fwrite(header, sizeof(header), 1, out);
+ fwrite(&extra, sizeof(extra), 1, out);
+ fwrite(binptr, size, 1, out);
+
+ /* Table of contents. It's a start, but it still won't boot.
+ * Looks like it needs the file/module info as well... */
+ binptr[0] = 0x02000000;
+ binptr[1] = 0x02000000;
+ binptr[2] = 0x88040000;
+ binptr[3] = 0x88076338;
+ binptr[4] = 0x1;
+ binptr[5] = 0x88080000;
+ binptr[6] = 0x8809C000;
+ binptr[7] = 0x88100000;
+ binptr[8] = 0x0;
+ binptr[9] = 0x0;
+ binptr[10] = 0x0;
+ binptr[11] = 0x0;
+ binptr[12] = 0x0;
+ binptr[13] = 0x0;
+ binptr[14] = 0x80808080;
+ binptr[15] = 0x0;
+ binptr[16] = 0x0;
+ binptr[17] = 0x201C2;
+ binptr[18] = 0x88050940;
+ binptr[19] = 0x0;
+ binptr[20] = 0x0;
+ header[0] = 0x88EBF274;
+ header[1] = 0x54;
+ extra = calc_csum((unsigned char*)binptr, 84);
+ fwrite(header, sizeof(header), 1, out);
+ fwrite(&extra, sizeof(extra), 1, out);
+ fwrite(binptr, 84, 1, out);
+
+ /*The footer*/
+ header[0] = 0;
+ header[1] = 0x88201000;
+ extra = 0;
+ fwrite(header, sizeof(header), 1, out);
+ fwrite(&extra, sizeof(extra), 1, out);
+
+ fprintf(stderr, "File processed successfully\n" );
+
+ fclose(in);
+ fclose(out);
+ return(0);
+}
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 @@
+/***************************************************************************
+ * __________ __ ___.
+ * Open \______ \ ____ ____ | | _\_ |__ _______ ___
+ * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
+ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
+ * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
+ * \/ \/ \/ \/ \/
+ * $Id$
+ *
+ * Copyright (C) 2006 by Marcoen Hirschberg
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+int 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 @@
#include <string.h>
#include "iriver.h"
#include "gigabeat.h"
+#include "gigabeats.h"
#include "mi4.h"
int iaudio_encode(char *iname, char *oname, char *idstring);
@@ -92,7 +93,8 @@ void usage(void)
"\t-ipod3g ipod firmware partition format (3rd Gen)\n"
"\t-ipod4g ipod firmware partition format (4th Gen, Mini, Nano, Photo/Color)\n"
"\t-ipod5g ipod firmware partition format (5th Gen - aka Video)\n"
- "\t-gigabeat Toshiba Gigabeat format\n"
+ "\t-gigabeat Toshiba Gigabeat F/X format\n"
+ "\t-gigabeats Toshiba Gigabeat S format\n"
"\t-mi4v2 PortalPlayer .mi4 format (revision 010201)\n"
"\t-mi4v3 PortalPlayer .mi4 format (revision 010301)\n"
"\t-mi4r Sandisk Rhapsody .mi4 format\n"
@@ -231,6 +233,8 @@ int main (int argc, char** argv)
modelnum = 19;
else if(!strcmp(&argv[1][5], "c200"))
modelnum = 20;
+ else if(!strcmp(&argv[1][5], "gigs"))
+ modelnum = 21;
else {
fprintf(stderr, "unsupported model: %s\n", &argv[1][5]);
return 2;
@@ -254,6 +258,12 @@ int main (int argc, char** argv)
gigabeat_code(iname, oname);
return 0;
}
+ else if(!strcmp(argv[1], "-gigabeats")) {
+ iname = argv[2];
+ oname = argv[3];
+ gigabeat_s_code(iname, oname);
+ return 0;
+ }
else if(!strcmp(argv[1], "-iaudiox5")) {
iname = argv[2];
oname = argv[3];