support scrambling for the Sansa R models
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12465 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
c2925814ce
commit
34080491fa
3 changed files with 15 additions and 6 deletions
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue