summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBarry Wardell <rockbox@barrywardell.net>2007-03-14 13:51:05 +0000
committerBarry Wardell <rockbox@barrywardell.net>2007-03-14 13:51:05 +0000
commit12df774d9f0093f614df6698231bdeb71934d416 (patch)
treec37009aa5aef8a56d59c3d0d745aa9d923d6a961 /tools
parent9d264806e87b4ded6b5fd88b14998e7311a8d53f (diff)
downloadrockbox-12df774d9f0093f614df6698231bdeb71934d416.tar.gz
rockbox-12df774d9f0093f614df6698231bdeb71934d416.tar.bz2
rockbox-12df774d9f0093f614df6698231bdeb71934d416.zip
Add support for scramble to put a 4 character string indicating binary type and the 4 character model id at the end of the mi4 header.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12760 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r--tools/mi4.c8
-rw-r--r--tools/mi4.h3
-rw-r--r--tools/scramble.c53
3 files changed, 49 insertions, 15 deletions
diff --git a/tools/mi4.c b/tools/mi4.c
index f466ad779f..b9f7e25393 100644
--- a/tools/mi4.c
+++ b/tools/mi4.c
@@ -102,7 +102,8 @@ static void int2le(unsigned int val, unsigned char* addr)
addr[3] = (val >> 24) & 0xff;
}
-int mi4_encode(char *iname, char *oname, int version, int magic)
+int mi4_encode(char *iname, char *oname, int version, int magic,
+ char *model, char *type)
{
size_t len;
int length;
@@ -150,7 +151,10 @@ int mi4_encode(char *iname, char *oname, int version, int magic)
int2le(length+4, &outbuf[0x2e8]); /* length plus 0xaa55aa55 */
int2le(0xaa55aa55, &outbuf[0x200+length]); /* More Magic */
-
+
+ strncpy((char *)outbuf+0x1f8, type, 4); /* type of binary - RBBL, RBOS, ... */
+ strncpy((char *)outbuf+0x1fc, model, 4); /* type of binary - RBBL, RBOS, ... */
+
/* Calculate CRC32 checksum */
chksum_crc32gentab ();
crc = chksum_crc32 (outbuf+28,mi4length-28);
diff --git a/tools/mi4.h b/tools/mi4.h
index ac55f59579..fa26f2ed57 100644
--- a/tools/mi4.h
+++ b/tools/mi4.h
@@ -23,6 +23,7 @@
#define MI4_MAGIC_DEFAULT 0xec
#define MI4_MAGIC_R 0xfc
-int mi4_encode(char *iname, char *oname, int version, int magic);
+int mi4_encode(char *iname, char *oname, int version, int magic,
+ char *model, char *type);
#endif
diff --git a/tools/scramble.c b/tools/scramble.c
index ccd6712297..7e6ca1f51c 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -89,6 +89,10 @@ void usage(void)
"\t-mi4v2 PortalPlayer .mi4 format (revision 010201)\n"
"\t-mi4v3 PortalPlayer .mi4 format (revision 010301)\n"
"\t-mi4r Sandisk Rhapsody .mi4 format\n"
+ "\t All mi4 options take two optional arguments:\n"
+ "\t -model=XXXX where XXXX is the model id string\n"
+ "\t -type=XXXX where XXXX is a string indicating the \n"
+ "\t type of binary, eg. RBOS, RBBL\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"
@@ -266,20 +270,45 @@ int main (int argc, char** argv)
oname = argv[3];
return ipod_encode(iname, oname, 3, true); /* Firmware image v3 */
}
- else if(!strcmp(argv[1], "-mi4v2")) {
- iname = argv[2];
- oname = argv[3];
- 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, MI4_MAGIC_DEFAULT);
- }
- else if(!strcmp(argv[1], "-mi4r")) {
+ else if(!strncmp(argv[1], "-mi4", 4)) {
+ int mi4magic;
+ int version;
+ char model[4] = "";
+ char type[4] = "";
+
+ if(!strcmp(&argv[1][4], "v2")) {
+ mi4magic = MI4_MAGIC_DEFAULT;
+ version = 0x00010201;
+ }
+ else if(!strcmp(&argv[1][4], "v3")) {
+ mi4magic = MI4_MAGIC_DEFAULT;
+ version = 0x00010301;
+ }
+ else if(!strcmp(&argv[1][4], "r")) {
+ mi4magic = MI4_MAGIC_R;
+ version = 0x00010301;
+ }
+ else {
+ printf( "Invalid mi4 version: %s\n", &argv[1][4]);
+ return -1;
+ }
+
iname = argv[2];
oname = argv[3];
- return mi4_encode(iname, oname, 0x00010301, MI4_MAGIC_R);
+
+ if(!strncmp(argv[2], "-model=", 7)) {
+ iname = argv[3];
+ oname = argv[4];
+ strncpy(model, &argv[2][7], 4);
+
+ if(!strncmp(argv[3], "-type=", 6)) {
+ iname = argv[4];
+ oname = argv[5];
+ strncpy(type, &argv[3][6], 4);
+ }
+ }
+
+ return mi4_encode(iname, oname, version, mi4magic, model, type);
}
/* open file */