summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2007-02-23 22:45:00 +0000
committerDaniel Stenberg <daniel@haxx.se>2007-02-23 22:45:00 +0000
commit34080491fa8e49ad155ff2ae6f6a0715cae3b26f (patch)
tree4c16e61fbfd3150011296431928cc23b35cf5427 /tools
parentc2925814cea31709a73b46b539d27ab0c8793d98 (diff)
downloadrockbox-34080491fa8e49ad155ff2ae6f6a0715cae3b26f.tar.gz
rockbox-34080491fa8e49ad155ff2ae6f6a0715cae3b26f.tar.bz2
rockbox-34080491fa8e49ad155ff2ae6f6a0715cae3b26f.zip
support scrambling for the Sansa R models
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12465 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r--tools/mi4.c4
-rw-r--r--tools/mi4.h5
-rw-r--r--tools/scramble.c12
3 files changed, 15 insertions, 6 deletions
diff --git a/tools/mi4.c b/tools/mi4.c
index b0fff98e1c..f466ad779f 100644
--- a/tools/mi4.c
+++ b/tools/mi4.c
@@ -102,7 +102,7 @@ static void int2le(unsigned int val, unsigned char* addr)
addr[3] = (val >> 24) & 0xff;
}
-int mi4_encode(char *iname, char *oname, int version)
+int mi4_encode(char *iname, char *oname, int version, int magic)
{
size_t len;
int length;
@@ -146,7 +146,7 @@ int mi4_encode(char *iname, char *oname, int version)
/* We need to write some data into the actual image - before calculating
the CRC. */
int2le(0x00000100, &outbuf[0x2e0]); /* magic */
- int2le(0x000000ec, &outbuf[0x2e4]); /* magic */
+ int2le(magic, &outbuf[0x2e4]); /* magic */
int2le(length+4, &outbuf[0x2e8]); /* length plus 0xaa55aa55 */
int2le(0xaa55aa55, &outbuf[0x200+length]); /* More Magic */
diff --git a/tools/mi4.h b/tools/mi4.h
index ec3a7342d0..ac55f59579 100644
--- a/tools/mi4.h
+++ b/tools/mi4.h
@@ -20,6 +20,9 @@
#ifndef _MI4_H
#define _MI4_H
-int mi4_encode(char *iname, char *oname, int version);
+#define MI4_MAGIC_DEFAULT 0xec
+#define MI4_MAGIC_R 0xfc
+
+int mi4_encode(char *iname, char *oname, int version, int magic);
#endif
diff --git a/tools/scramble.c b/tools/scramble.c
index 07b11930e1..ea91b9b034 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -7,7 +7,7 @@
* \/ \/ \/ \/ \/
* $Id$
*
- * Copyright (C) 2002 by Björn Stenberg
+ * Copyright (C) 2002 - 2007 by Björn Stenberg
*
* 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.
@@ -87,6 +87,7 @@ void usage(void)
"\t-gigabeat Toshiba Gigabeat 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"
"\t-add=X Rockbox generic \"add-up\" checksum format\n"
"\t (X values: h100, h120, h140, h300, ipco, nano, ipvd, mn2g\n"
"\t ip3g, ip4g, mini, iax5, h10, h10_5gb, tpj2, e200)\n"
@@ -260,12 +261,17 @@ int main (int argc, char** argv)
else if(!strcmp(argv[1], "-mi4v2")) {
iname = argv[2];
oname = argv[3];
- return mi4_encode(iname, oname, 0x00010201);
+ return mi4_encode(iname, oname, 0x00010201, MI4_MAGIC_DEFAULT);
}
else if(!strcmp(argv[1], "-mi4v3")) {
iname = argv[2];
oname = argv[3];
- return mi4_encode(iname, oname, 0x00010301);
+ return mi4_encode(iname, oname, 0x00010301, MI4_MAGIC_DEFAULT);
+ }
+ else if(!strcmp(argv[1], "-mi4r")) {
+ iname = argv[2];
+ oname = argv[3];
+ return mi4_encode(iname, oname, 0x00010301, MI4_MAGIC_R);
}
/* open file */