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"
40 /* Bootloader version */
41 char version
[] = APPSVERSION
;
43 #define START_SECTOR_OF_ROM 1
44 #define ROMSECTOR_TO_HACK 63
45 #define HACK_OFFSET 498
46 #define KNOWN_CRC32 0x5a09c266
47 char knownBytes
[] = {0x00, 0x24, 0x07, 0xe1};
48 char changedBytes
[] = {0xc0, 0x46, 0xc0, 0x46 };
56 struct partinfo
* pinfo
;
57 chksum_crc32gentab ();
67 lcd_set_foreground(LCD_WHITE
);
68 lcd_set_background(LCD_BLACK
);
71 btn
= button_read_device();
74 lcd_setfont(FONT_SYSFIXED
);
76 printf("Rockbox e200R installer");
77 printf("Version: %s", version
);
83 num_partitions
= disk_mount_all();
84 if (num_partitions
<=0)
86 error(EDISK
,num_partitions
);
88 pinfo
= disk_partinfo(1);
89 #if 0 /* not needed in release builds */
90 printf("--- Partition info ---");
91 printf("start: %x", pinfo
->start
);
92 printf("size: %x", pinfo
->size
);
93 printf("type: %x", pinfo
->type
);
94 printf("reading: %x", (START_SECTOR_OF_ROM
+ ROMSECTOR_TO_HACK
)*512);
96 ata_read_sectors(IF_MV2(0,)
97 pinfo
->start
+ START_SECTOR_OF_ROM
+ ROMSECTOR_TO_HACK
,
99 crc32
= chksum_crc32 (sector
, 512);
100 #if 0 /* not needed in release builds */
101 printf("--- Hack Status ---");
102 printf("Sector checksum: %x", crc32
);
104 if ((crc32
== KNOWN_CRC32
) &&
105 !memcmp(§or
[HACK_OFFSET
], knownBytes
,
106 sizeof(knownBytes
)/sizeof(*knownBytes
)))
109 memcpy(§or
[HACK_OFFSET
], changedBytes
,
110 sizeof(changedBytes
)/sizeof(*changedBytes
));
111 ata_write_sectors(IF_MV2(0,)
112 pinfo
->start
+ START_SECTOR_OF_ROM
+ ROMSECTOR_TO_HACK
,
114 printf("Firmware Unlocked");
115 printf("Proceed to Step 2");
119 printf("Unknown bootloader");
120 printf("Rockbox installer cannot");
123 GPIOG_OUTPUT_VAL
&=~0x80;
126 printf("Release Hold and");
127 printf("Press any key to shutdown");
128 while(button_read_device() == BUTTON_NONE
)