diff options
Diffstat (limited to 'bootloader/main-pp.c')
-rw-r--r-- | bootloader/main-pp.c | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/bootloader/main-pp.c b/bootloader/main-pp.c index a533cc7044..ee2af38731 100644 --- a/bootloader/main-pp.c +++ b/bootloader/main-pp.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | #include <stdio.h> | 25 | #include <stdio.h> |
26 | #include <string.h> | 26 | #include <string.h> |
27 | #include <stdarg.h> | ||
27 | #include "cpu.h" | 28 | #include "cpu.h" |
28 | #include "system.h" | 29 | #include "system.h" |
29 | #include "lcd.h" | 30 | #include "lcd.h" |
@@ -51,6 +52,31 @@ char version[] = APPSVERSION; | |||
51 | #define DRAM_START 0x10000000 | 52 | #define DRAM_START 0x10000000 |
52 | 53 | ||
53 | int line=0; | 54 | int line=0; |
55 | char printfbuf[256]; | ||
56 | |||
57 | void reset_screen(void) | ||
58 | { | ||
59 | lcd_clear_display(); | ||
60 | line = 0; | ||
61 | } | ||
62 | |||
63 | void printf(const char *format, ...) | ||
64 | { | ||
65 | int len; | ||
66 | unsigned char *ptr; | ||
67 | va_list ap; | ||
68 | va_start(ap, format); | ||
69 | |||
70 | |||
71 | ptr = printfbuf; | ||
72 | len = vsnprintf(ptr, sizeof(printfbuf), format, ap); | ||
73 | va_end(ap); | ||
74 | |||
75 | lcd_puts(0, line++, ptr); | ||
76 | lcd_update(); | ||
77 | if(line >= (LCD_HEIGHT/SYSFONT_HEIGHT)) | ||
78 | line = 0; | ||
79 | } | ||
54 | 80 | ||
55 | /* Load original mi4 firmware. This function expects a file called | 81 | /* Load original mi4 firmware. This function expects a file called |
56 | "/System/OF.bin" on the player. It should be a mi4 firmware decrypted | 82 | "/System/OF.bin" on the player. It should be a mi4 firmware decrypted |
@@ -100,9 +126,7 @@ int load_rockbox(unsigned char* buf) | |||
100 | 126 | ||
101 | len = filesize(fd) - 8; | 127 | len = filesize(fd) - 8; |
102 | 128 | ||
103 | snprintf(str, sizeof(str), "Length: %x", len); | 129 | printf("Length: %x", len); |
104 | lcd_puts(0, line++ ,str); | ||
105 | lcd_update(); | ||
106 | 130 | ||
107 | if (len > MAX_LOADSIZE) | 131 | if (len > MAX_LOADSIZE) |
108 | return -6; | 132 | return -6; |
@@ -114,9 +138,7 @@ int load_rockbox(unsigned char* buf) | |||
114 | if(rc < 4) | 138 | if(rc < 4) |
115 | return -2; | 139 | return -2; |
116 | 140 | ||
117 | snprintf(str, sizeof(str), "Checksum: %x", chksum); | 141 | printf("Checksum: %x", chksum); |
118 | lcd_puts(0, line++ ,str); | ||
119 | lcd_update(); | ||
120 | 142 | ||
121 | rc = read(fd, model, 4); | 143 | rc = read(fd, model, 4); |
122 | if(rc < 4) | 144 | if(rc < 4) |
@@ -124,9 +146,7 @@ int load_rockbox(unsigned char* buf) | |||
124 | 146 | ||
125 | model[4] = 0; | 147 | model[4] = 0; |
126 | 148 | ||
127 | snprintf(str, sizeof(str), "Model name: %s", model); | 149 | printf("Model name: %s", model); |
128 | lcd_puts(0, line++ ,str); | ||
129 | lcd_update(); | ||
130 | 150 | ||
131 | lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); | 151 | lseek(fd, FIRMWARE_OFFSET_FILE_DATA, SEEK_SET); |
132 | 152 | ||
@@ -142,10 +162,8 @@ int load_rockbox(unsigned char* buf) | |||
142 | sum += buf[i]; | 162 | sum += buf[i]; |
143 | } | 163 | } |
144 | 164 | ||
145 | snprintf(str, sizeof(str), "Sum: %x", sum); | 165 | printf("Sum: %x", sum); |
146 | lcd_puts(0, line++ ,str); | 166 | |
147 | lcd_update(); | ||
148 | |||
149 | if(sum != chksum) | 167 | if(sum != chksum) |
150 | return -5; | 168 | return -5; |
151 | 169 | ||
@@ -170,12 +188,9 @@ void* main(void) | |||
170 | 188 | ||
171 | lcd_setfont(FONT_SYSFIXED); | 189 | lcd_setfont(FONT_SYSFIXED); |
172 | 190 | ||
173 | lcd_puts(0, line++, "Rockbox boot loader"); | 191 | printf("Rockbox boot loader"); |
174 | snprintf(buf, sizeof(buf), "Version: 20%s", version); | 192 | printf("Version: 20%s", version); |
175 | lcd_puts(0, line++, buf); | 193 | printf(MODEL_NAME); |
176 | snprintf(buf, sizeof(buf), MODEL_NAME); | ||
177 | lcd_puts(0, line++, buf); | ||
178 | lcd_update(); | ||
179 | 194 | ||
180 | i=ata_init(); | 195 | i=ata_init(); |
181 | if (i==0) { | 196 | if (i==0) { |
@@ -188,44 +203,33 @@ void* main(void) | |||
188 | for (i=39; i && buf[i]==' '; i--) { | 203 | for (i=39; i && buf[i]==' '; i--) { |
189 | buf[i]=0; | 204 | buf[i]=0; |
190 | } | 205 | } |
191 | lcd_puts(0, line++, buf); | 206 | printf(buf); |
192 | lcd_update(); | ||
193 | } else { | 207 | } else { |
194 | snprintf(buf, sizeof(buf), "ATA: %d", i); | 208 | printf("ATA: %d", i); |
195 | lcd_puts(0, line++, buf); | ||
196 | lcd_update(); | ||
197 | } | 209 | } |
198 | 210 | ||
199 | disk_init(); | 211 | disk_init(); |
200 | rc = disk_mount_all(); | 212 | rc = disk_mount_all(); |
201 | if (rc<=0) | 213 | if (rc<=0) |
202 | { | 214 | { |
203 | lcd_puts(0, line++, "No partition found"); | 215 | printf("No partition found"); |
204 | lcd_update(); | ||
205 | } | 216 | } |
206 | 217 | ||
207 | pinfo = disk_partinfo(0); | 218 | pinfo = disk_partinfo(0); |
208 | snprintf(buf, sizeof(buf), "Partition 0: 0x%02x %ld MB", | 219 | printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048); |
209 | pinfo->type, pinfo->size / 2048); | ||
210 | lcd_puts(0, line++, buf); | ||
211 | lcd_update(); | ||
212 | 220 | ||
213 | i=button_read_device(); | 221 | i=button_read_device(); |
214 | if(i==BUTTON_LEFT) | 222 | if(i==BUTTON_LEFT) |
215 | { | 223 | { |
216 | lcd_puts(0, line++, "Loading original firmware..."); | 224 | printf("Loading original firmware..."); |
217 | lcd_update(); | ||
218 | rc=load_original_firmware(loadbuffer); | 225 | rc=load_original_firmware(loadbuffer); |
219 | } else { | 226 | } else { |
220 | lcd_puts(0, line++, "Loading Rockbox..."); | 227 | printf("Loading Rockbox..."); |
221 | lcd_update(); | ||
222 | rc=load_rockbox(loadbuffer); | 228 | rc=load_rockbox(loadbuffer); |
223 | } | 229 | } |
224 | 230 | ||
225 | if (rc < 0) { | 231 | if (rc < 0) { |
226 | snprintf(buf, sizeof(buf), "Rockbox error: %d",rc); | 232 | printf("Rockbox error: %d",rc); |
227 | lcd_puts(0, line++, buf); | ||
228 | lcd_update(); | ||
229 | while(1) {} | 233 | while(1) {} |
230 | } | 234 | } |
231 | 235 | ||