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 /* Maximum allowed firmware image size. 10MB is more than enough */
35 #define MAX_LOADSIZE (10*1024*1024)
37 /* A buffer to load the original firmware or Rockbox into */
38 unsigned char *loadbuffer
= (unsigned char *)DRAM_START
;
40 /* Bootloader version */
41 char version
[] = APPSVERSION
;
48 unsigned short* identify_info
;
49 struct partinfo
* pinfo
;
57 lcd_setfont(FONT_SYSFIXED
);
59 printf("Rockbox boot loader");
60 printf("Version: 20%s", version
);
65 identify_info
=ata_get_identify();
67 for (i
=0; i
< 20; i
++) {
68 ((unsigned short*)buf
)[i
]=htobe16(identify_info
[i
+27]);
71 for (i
=39; i
&& buf
[i
]==' '; i
--) {
76 printf("ATA error: %d", i
);
82 rc
= disk_mount_all();
85 printf("No partition found");
90 pinfo
= disk_partinfo(0);
91 printf("Partition 0: 0x%02x %ld MB", pinfo
->type
, pinfo
->size
/ 2048);
93 i
=button_read_device();
96 /* Load original mi4 firmware. This expects a file called
97 "/System/OF.bin" on the player. It should be a mi4 firmware decrypted
98 and header stripped using mi4code. It reads the file in to a memory
99 buffer called loadbuffer. The rest of the loading is done in crt0.S
101 printf("Loading original firmware...");
102 rc
=load_raw_firmware(loadbuffer
, "/System/OF.bin", MAX_LOADSIZE
);
105 printf("Can't load /System/OF.bin:");
106 printf(strerror(rc
));
111 printf("Loading Rockbox...");
112 rc
=load_firmware(loadbuffer
, BOOTFILE
, MAX_LOADSIZE
);
115 printf("Can't load %s:", BOOTFILE
);
116 printf(strerror(rc
));
122 return (void*)loadbuffer
;
125 /* These functions are present in the firmware library, but we reimplement
126 them here because the originals do a lot more than we want */
127 void usb_acknowledge(void)
131 void usb_wait_for_disconnect(void)