1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 by Christian Gmeiner
12 * This particular source code file is licensed under the X11 license. See the
13 * bottom of the COPYING file for details on this license.
15 ****************************************************************************/
17 /* This little application updates the checksum of a modifized iAudio x5
19 And this is how it works:
21 The byte at offset 0x102b contains the 8-bit sum of all the bytes starting with the one at 0x1030.
28 #define CHECKSUM_BIT 0x102b
29 #define CHECKSUM_START 0x1030
33 printf("usage: iaudio <input file> <output file>\n");
34 printf("\n\nThis tool updates the checksum of an iaudio fw bin\n");
38 int main (int argc
, char* argv
[]) {
42 unsigned long length
, i
;
44 char* iname
= argv
[1];
45 char* oname
= argv
[2];
53 pFile
= fopen(iname
, "rb");
59 /* print old checksum */
60 fseek (pFile
, CHECKSUM_BIT
, SEEK_SET
);
62 printf("Old checksum: 0x%02x\n", byte
& 0xff);
65 fseek(pFile
,0,SEEK_END
);
66 length
= ftell(pFile
);
67 fseek(pFile
,0,SEEK_SET
);
69 /* try to allocate memory */
70 inbuf
= malloc(length
);
72 printf("out of memory!\n");
77 i
= fread(inbuf
, 1, length
, pFile
);
84 /* calculate new checksum */
85 for (i
= CHECKSUM_START
; i
< length
; i
++) {
88 printf("New checksum: 0x%02x\n", checksum
& 0xff);
90 /* save new checksum */
91 inbuf
[CHECKSUM_BIT
] = (unsigned char) checksum
;
94 pFile
= fopen(oname
,"wb");
100 i
= fwrite(inbuf
, 1, length
, pFile
);