1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Barry Wardell
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
13 * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
15 * All files in this archive are subject to the GNU General Public License.
16 * See the file COPYING in the source tree root for full license agreement.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
34 #include "crc32-mi4.h"
37 #include "backlight-target.h"
39 /* Bootloader version */
40 char version
[] = APPSVERSION
;
42 #define START_SECTOR_OF_ROM 1
43 #define ROMSECTOR_TO_HACK 63
44 #define HACK_OFFSET 498
45 #define KNOWN_CRC32 0x5a09c266
46 char knownBytes
[] = {0x00, 0x24, 0x07, 0xe1};
47 char changedBytes
[] = {0xc0, 0x46, 0xc0, 0x46 };
55 struct partinfo
* pinfo
;
56 chksum_crc32gentab ();
66 lcd_set_foreground(LCD_WHITE
);
67 lcd_set_background(LCD_BLACK
);
70 btn
= button_read_device();
73 lcd_setfont(FONT_SYSFIXED
);
75 printf("Rockbox e200R installer");
76 printf("Version: %s", version
);
81 num_partitions
= disk_mount_all();
82 if (num_partitions
<=0)
84 error(EDISK
,num_partitions
);
86 pinfo
= disk_partinfo(1);
87 printf("--- Partition info ---");
88 printf("start: %x", pinfo
->start
);
89 printf("size: %x", pinfo
->size
);
90 printf("type: %x", pinfo
->type
);
91 printf("reading: %x", (START_SECTOR_OF_ROM
+ ROMSECTOR_TO_HACK
)*512);
92 ata_read_sectors(IF_MV2(0,)
93 pinfo
->start
+ START_SECTOR_OF_ROM
+ ROMSECTOR_TO_HACK
,
95 crc32
= chksum_crc32 (sector
, 512);
96 printf("--- Hack Status ---");
97 printf("Sector checksum: %x", crc32
);
99 if ((crc32
== KNOWN_CRC32
) &&
100 !memcmp(§or
[HACK_OFFSET
], knownBytes
,
101 sizeof(knownBytes
)/sizeof(*knownBytes
)))
104 memcpy(§or
[HACK_OFFSET
], changedBytes
,
105 sizeof(changedBytes
)/sizeof(*changedBytes
));
106 ata_write_sectors(IF_MV2(0,)
107 pinfo
->start
+ START_SECTOR_OF_ROM
+ ROMSECTOR_TO_HACK
,
109 printf("Firmware Hacked");
110 printf("Proceed to Step 2");
113 printf("Unknown bootloader... aborted");
114 GPIOG_OUTPUT_VAL
&=~0x80;