Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Changes to ipod bootloader to bring in line with the capabilities of ipodpatcher: Detect if the bootloader has been installed without the Apple firmware; load the Apple firmware from an apple_os.ipod file on the FAT32 partition. Also change to use hold switch to decide when to boot into the Apple firmware (turning hold on whilst booting will start the Apple firmware). Plus a cosmetic change to white text on a black background.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11780 a1c6a512-1295-4272-9138-f99709370657

+124 -41
+124 -41
bootloader/ipod.c
··· 60 60 #define BUTTON_PLAY 4 61 61 #define BUTTON_HOLD 5 62 62 63 - /* Size of the buffer to store the loaded Rockbox/Linux image */ 64 - #define MAX_LOADSIZE (4*1024*1024) 63 + /* Size of the buffer to store the loaded Rockbox/Linux/AppleOS image */ 64 + 65 + /* The largest known current (December 2006) firmware is about 7.5MB 66 + (Apple's firmware for the ipod video) so we set this to 8MB. */ 67 + 68 + #define MAX_LOADSIZE (8*1024*1024) 65 69 66 70 char version[] = APPSVERSION; 67 71 ··· 181 185 return 0; 182 186 } 183 187 184 - int load_rockbox(unsigned char* buf) 188 + /* This function is the same on all ipods */ 189 + bool button_hold(void) 190 + { 191 + return (GPIOA_INPUT_VAL & 0x20)?false:true; 192 + } 193 + 194 + int load_rockbox(unsigned char* buf, char* firmware) 185 195 { 186 196 int fd; 187 197 int rc; ··· 191 201 unsigned long sum; 192 202 int i; 193 203 char str[80]; 194 - 195 - fd = open("/.rockbox/" BOOTFILE, O_RDONLY); 204 + char filename[MAX_PATH]; 205 + 206 + snprintf(filename,sizeof(filename),"/.rockbox/%s",firmware); 207 + fd = open(filename, O_RDONLY); 196 208 if(fd < 0) 197 209 { 198 - fd = open("/" BOOTFILE, O_RDONLY); 210 + snprintf(filename,sizeof(filename),"/%s",firmware); 211 + fd = open(filename, O_RDONLY); 199 212 if(fd < 0) 200 213 return -1; 201 214 } ··· 221 234 snprintf(str, 80, "Model: %s", model); 222 235 lcd_puts(0, line++, str); 223 236 snprintf(str, 80, "Checksum: %x", chksum); 237 + lcd_puts(0, line++, str); 238 + snprintf(str, 80, "Loading %s", firmware); 224 239 lcd_puts(0, line++, str); 225 240 lcd_update(); 226 241 ··· 279 294 /* A buffer to load the Linux kernel or Rockbox into */ 280 295 unsigned char loadbuffer[MAX_LOADSIZE]; 281 296 297 + void fatal_error(void) 298 + { 299 + bool holdstatus=false; 300 + 301 + lcd_puts(0, line++, "Press MENU+SELECT to reboot"); 302 + lcd_puts(0, line++, "then SELECT+PLAY for disk mode"); 303 + lcd_update(); 304 + 305 + while (1) { 306 + if (button_hold() != holdstatus) { 307 + if (button_hold()) { 308 + holdstatus=true; 309 + lcd_puts(0, line, "Hold switch on!"); 310 + } else { 311 + holdstatus=false; 312 + lcd_puts(0, line, " "); 313 + } 314 + lcd_update(); 315 + } 316 + udelay(100000); /* 100ms */ 317 + } 318 + 319 + } 320 + 321 + 282 322 void* main(void) 283 323 { 284 324 char buf[256]; 285 325 int i; 286 326 int rc; 327 + bool haveretailos; 328 + bool button_was_held; 287 329 struct partinfo* pinfo; 288 330 unsigned short* identify_info; 331 + 332 + /* Check the button hold status as soon as possible - to 333 + give the user maximum chance to turn it off in order to 334 + reset the settings in rockbox. */ 335 + button_was_held = button_hold(); 289 336 290 337 /* Turn on the backlight */ 291 338 ··· 319 366 lcd_init(); 320 367 font_init(); 321 368 369 + #ifdef HAVE_LCD_COLOR 370 + lcd_set_foreground(LCD_WHITE); 371 + lcd_set_background(LCD_BLACK); 372 + lcd_clear_display(); 373 + #endif 374 + 322 375 #if 0 323 376 /* ADC and button drivers are not yet implemented */ 324 377 adc_init(); ··· 360 413 if (rc<=0) 361 414 { 362 415 lcd_puts(0, line++, "No partition found"); 363 - lcd_update(); 364 - // while(button_get(true) != SYS_USB_CONNECTED) {}; 416 + fatal_error(); 365 417 } 366 418 367 419 pinfo = disk_partinfo(1); ··· 370 422 lcd_puts(0, line++, buf); 371 423 lcd_update(); 372 424 373 - /* Check for a keypress */ 374 - i=key_pressed(); 425 + /* See if there is an Apple firmware image in RAM */ 426 + haveretailos = (memcmp((void*)(DRAM_START+0x20),"portalplayer",12)==0); 375 427 376 - if ((i!=BUTTON_MENU) && (i!=BUTTON_PLAY)) { 377 - lcd_puts(0, line, "Loading Rockbox..."); 378 - lcd_update(); 379 - rc=load_rockbox(loadbuffer); 380 - if (rc < 0) { 381 - snprintf(buf, sizeof(buf), "Rockbox error: %d",rc); 382 - lcd_puts(0, line++, buf); 428 + /* We don't load Rockbox if the hold button is enabled. */ 429 + if (!button_was_held) { 430 + /* Check for a keypress */ 431 + i=key_pressed(); 432 + 433 + if ((i!=BUTTON_MENU) && (i!=BUTTON_PLAY)) { 434 + lcd_puts(0, line, "Loading Rockbox..."); 383 435 lcd_update(); 384 - } else { 385 - lcd_puts(0, line++, "Rockbox loaded."); 386 - lcd_update(); 387 - memcpy((void*)DRAM_START,loadbuffer,rc); 388 - return (void*)DRAM_START; 436 + rc=load_rockbox(loadbuffer, BOOTFILE); 437 + if (rc < 0) { 438 + snprintf(buf, sizeof(buf), "Rockbox error: %d",rc); 439 + lcd_puts(0, line++, buf); 440 + lcd_update(); 441 + } else { 442 + lcd_puts(0, line++, "Rockbox loaded."); 443 + lcd_update(); 444 + memcpy((void*)DRAM_START,loadbuffer,rc); 445 + return (void*)DRAM_START; 446 + } 389 447 } 390 - } 391 448 392 - if (i==BUTTON_PLAY) { 393 - lcd_puts(0, line, "Loading Linux..."); 394 - lcd_update(); 395 - rc=load_linux(loadbuffer); 396 - if (rc < 0) { 397 - snprintf(buf, sizeof(buf), "Linux error: %d",rc); 398 - lcd_puts(0, line++, buf); 449 + if (i==BUTTON_PLAY) { 450 + lcd_puts(0, line, "Loading Linux..."); 399 451 lcd_update(); 400 - } else { 401 - memcpy((void*)DRAM_START,loadbuffer,rc); 402 - return (void*)DRAM_START; 452 + rc=load_linux(loadbuffer); 453 + if (rc < 0) { 454 + snprintf(buf, sizeof(buf), "Linux error: %d",rc); 455 + lcd_puts(0, line++, buf); 456 + lcd_update(); 457 + } else { 458 + memcpy((void*)DRAM_START,loadbuffer,rc); 459 + return (void*)DRAM_START; 460 + } 403 461 } 404 462 } 405 463 406 - /* If everything else failed, try the original firmware */ 464 + 465 + /* If either the hold switch was on, or loading Rockbox/IPL 466 + failed, then try the Apple firmware */ 467 + 407 468 lcd_puts(0, line, "Loading original firmware..."); 408 469 lcd_update(); 409 470 410 - /* The original firmware should already be at the correct location 411 - in RAM - the Rockbox bootloader has been appended to the end of 412 - it, and the "entryOffset" in the firmware header modified to 413 - tell the Apple bootloader to pass execution to our bootloader, 414 - rather than the start of the original firmware - which is 415 - always at the start of RAM. */ 471 + /* First try an apple_os.ipod file on the FAT32 partition 472 + (either in .rockbox or the root) 473 + */ 474 + 475 + rc=load_rockbox(loadbuffer, "apple_os.ipod"); 476 + 477 + /* Only report errors if the file was found */ 478 + if (rc < -1) { 479 + snprintf(buf, sizeof(buf), "apple_os.ipod error: %d",rc); 480 + lcd_puts(0, line++, buf); 481 + lcd_update(); 482 + } else if (rc > 0) { 483 + lcd_puts(0, line++, "apple_os.ipod loaded."); 484 + lcd_update(); 485 + memcpy((void*)DRAM_START,loadbuffer,rc); 486 + return (void*)DRAM_START; 487 + } 416 488 417 - return (void*)DRAM_START; 489 + if (haveretailos) { 490 + /* We have a copy of the retailos in RAM, lets just run it. */ 491 + return (void*)DRAM_START; 492 + } 493 + 494 + /* Everything failed - just loop forever */ 495 + lcd_puts(0, line++, "No RetailOS detected"); 496 + 497 + fatal_error(); 498 + 499 + /* We never get here, but keep gcc happy */ 500 + return (void*)0; 418 501 } 419 502 420 503 /* These functions are present in the firmware library, but we reimplement