rework the set song rating setting so it uses the standard list. also the menu item...
[Rockbox.git] / bootloader / main-e200r-installer.c
blobc1162c9ebfc9c0c00cb8df07e09222b35227a49c
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
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 ****************************************************************************/
22 #include <stdio.h>
23 #include <stdlib.h>
24 #include "common.h"
25 #include "cpu.h"
26 #include "file.h"
27 #include "system.h"
28 #include "kernel.h"
29 #include "lcd.h"
30 #include "font.h"
31 #include "ata.h"
32 #include "button.h"
33 #include "disk.h"
34 #include "crc32-mi4.h"
35 #include <string.h>
36 #include "i2c.h"
37 #include "backlight-target.h"
38 #include "power.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 };
49 void* main(void)
51 int i;
52 int btn;
53 int num_partitions;
54 int crc32;
55 char sector[512];
56 struct partinfo* pinfo;
57 chksum_crc32gentab ();
59 system_init();
60 kernel_init();
61 lcd_init();
62 font_init();
63 button_init();
64 i2c_init();
65 __backlight_on();
67 lcd_set_foreground(LCD_WHITE);
68 lcd_set_background(LCD_BLACK);
69 lcd_clear_display();
71 btn = button_read_device();
72 verbose = true;
74 lcd_setfont(FONT_SYSFIXED);
76 printf("Rockbox e200R installer");
77 printf("Version: %s", version);
78 printf(MODEL_NAME);
79 printf("");
81 i=ata_init();
82 disk_init(IF_MV(0));
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);
95 #endif
96 ata_read_sectors(IF_MV2(0,)
97 pinfo->start + START_SECTOR_OF_ROM + ROMSECTOR_TO_HACK,
98 1 , sector);
99 crc32 = chksum_crc32 (sector, 512);
100 #if 0 /* not needed in release builds */
101 printf("--- Hack Status ---");
102 printf("Sector checksum: %x", crc32);
103 #endif
104 if ((crc32 == KNOWN_CRC32) &&
105 !memcmp(&sector[HACK_OFFSET], knownBytes,
106 sizeof(knownBytes)/sizeof(*knownBytes)))
109 memcpy(&sector[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,
113 1 , sector);
114 printf("Firmware Unlocked");
115 printf("Proceed to Step 2");
117 else
119 printf("Unknown bootloader");
120 printf("Rockbox installer cannot");
121 printf("continue");
123 GPIOG_OUTPUT_VAL &=~0x80;
124 printf("");
125 if (button_hold())
126 printf("Release Hold and");
127 printf("Press any key to shutdown");
128 while(button_read_device() == BUTTON_NONE)
130 power_off();
131 return NULL;