diff options
Diffstat (limited to 'bootloader/main-pp.c')
-rw-r--r-- | bootloader/main-pp.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c index 5659073457..0f85404fc7 100644 --- a/bootloader/main-pp.c +++ b/bootloader/main-pp.c | |||
@@ -29,7 +29,17 @@ | |||
29 | #include "ata.h" | 29 | #include "ata.h" |
30 | #include "button.h" | 30 | #include "button.h" |
31 | #include "disk.h" | 31 | #include "disk.h" |
32 | #include "power.h" | 32 | |
33 | /* Button definitions */ | ||
34 | #if CONFIG_KEYPAD == IRIVER_H10_PAD | ||
35 | #define BOOTLOADER_VERBOSE BUTTON_PLAY | ||
36 | #define BOOTLOADER_BOOT_OF BUTTON_LEFT | ||
37 | |||
38 | #elif CONFIG_KEYPAD == SANSA_E200_PAD | ||
39 | #define BOOTLOADER_VERBOSE BUTTON_RIGHT | ||
40 | #define BOOTLOADER_BOOT_OF BUTTON_LEFT | ||
41 | |||
42 | #endif | ||
33 | 43 | ||
34 | /* Maximum allowed firmware image size. 10MB is more than enough */ | 44 | /* Maximum allowed firmware image size. 10MB is more than enough */ |
35 | #define MAX_LOADSIZE (10*1024*1024) | 45 | #define MAX_LOADSIZE (10*1024*1024) |
@@ -44,6 +54,7 @@ void* main(void) | |||
44 | { | 54 | { |
45 | char buf[256]; | 55 | char buf[256]; |
46 | int i; | 56 | int i; |
57 | int btn; | ||
47 | int rc; | 58 | int rc; |
48 | unsigned short* identify_info; | 59 | unsigned short* identify_info; |
49 | struct partinfo* pinfo; | 60 | struct partinfo* pinfo; |
@@ -54,6 +65,12 @@ void* main(void) | |||
54 | font_init(); | 65 | font_init(); |
55 | button_init(); | 66 | button_init(); |
56 | 67 | ||
68 | btn = button_read_device(); | ||
69 | |||
70 | /* Enable bootloader messages */ | ||
71 | if (btn==BOOTLOADER_VERBOSE) | ||
72 | verbose = true; | ||
73 | |||
57 | lcd_setfont(FONT_SYSFIXED); | 74 | lcd_setfont(FONT_SYSFIXED); |
58 | 75 | ||
59 | printf("Rockbox boot loader"); | 76 | printf("Rockbox boot loader"); |
@@ -73,25 +90,20 @@ void* main(void) | |||
73 | } | 90 | } |
74 | printf(buf); | 91 | printf(buf); |
75 | } else { | 92 | } else { |
76 | printf("ATA error: %d", i); | 93 | error(EATA, i); |
77 | udelay(5000000); | ||
78 | power_off(); | ||
79 | } | 94 | } |
80 | 95 | ||
81 | disk_init(); | 96 | disk_init(); |
82 | rc = disk_mount_all(); | 97 | rc = disk_mount_all(); |
83 | if (rc<=0) | 98 | if (rc<=0) |
84 | { | 99 | { |
85 | printf("No partition found"); | 100 | error(EDISK,rc); |
86 | udelay(5000000); | ||
87 | power_off(); | ||
88 | } | 101 | } |
89 | 102 | ||
90 | pinfo = disk_partinfo(0); | 103 | pinfo = disk_partinfo(0); |
91 | printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048); | 104 | printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048); |
92 | 105 | ||
93 | i=button_read_device(); | 106 | if(btn==BOOTLOADER_BOOT_OF) |
94 | if(i==BUTTON_LEFT) | ||
95 | { | 107 | { |
96 | /* Load original mi4 firmware. This expects a file called | 108 | /* Load original mi4 firmware. This expects a file called |
97 | "/System/OF.bin" on the player. It should be a mi4 firmware decrypted | 109 | "/System/OF.bin" on the player. It should be a mi4 firmware decrypted |
@@ -101,21 +113,15 @@ void* main(void) | |||
101 | printf("Loading original firmware..."); | 113 | printf("Loading original firmware..."); |
102 | rc=load_raw_firmware(loadbuffer, "/System/OF.bin", MAX_LOADSIZE); | 114 | rc=load_raw_firmware(loadbuffer, "/System/OF.bin", MAX_LOADSIZE); |
103 | if (rc < EOK) { | 115 | if (rc < EOK) { |
104 | printf("Error!"); | 116 | printf("Can't load /System/OF.bin"); |
105 | printf("Can't load /System/OF.bin:"); | 117 | error(EBOOTFILE, rc); |
106 | printf(strerror(rc)); | ||
107 | udelay(5000000); | ||
108 | power_off(); | ||
109 | } | 118 | } |
110 | } else { | 119 | } else { |
111 | printf("Loading Rockbox..."); | 120 | printf("Loading Rockbox..."); |
112 | rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE); | 121 | rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE); |
113 | if (rc < EOK) { | 122 | if (rc < EOK) { |
114 | printf("Error!"); | ||
115 | printf("Can't load %s:", BOOTFILE); | 123 | printf("Can't load %s:", BOOTFILE); |
116 | printf(strerror(rc)); | 124 | error(EBOOTFILE, rc); |
117 | udelay(5000000); | ||
118 | power_off(); | ||
119 | } | 125 | } |
120 | } | 126 | } |
121 | 127 | ||