2006-08-11 08:35:27 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 by Barry Wardell
|
|
|
|
*
|
|
|
|
* Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
|
|
|
|
* and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "common.h"
|
2006-08-11 08:35:27 +00:00
|
|
|
#include "cpu.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "file.h"
|
2006-08-11 08:35:27 +00:00
|
|
|
#include "system.h"
|
|
|
|
#include "kernel.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "lcd.h"
|
2006-08-11 08:35:27 +00:00
|
|
|
#include "font.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "ata.h"
|
2006-08-11 08:35:27 +00:00
|
|
|
#include "button.h"
|
2007-01-28 18:42:11 +00:00
|
|
|
#include "disk.h"
|
2007-03-12 22:12:20 +00:00
|
|
|
|
|
|
|
/* Button definitions */
|
|
|
|
#if CONFIG_KEYPAD == IRIVER_H10_PAD
|
|
|
|
#define BOOTLOADER_VERBOSE BUTTON_PLAY
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_LEFT
|
|
|
|
|
|
|
|
#elif CONFIG_KEYPAD == SANSA_E200_PAD
|
|
|
|
#define BOOTLOADER_VERBOSE BUTTON_RIGHT
|
|
|
|
#define BOOTLOADER_BOOT_OF BUTTON_LEFT
|
|
|
|
|
|
|
|
#endif
|
2006-08-11 08:35:27 +00:00
|
|
|
|
2007-01-28 18:42:11 +00:00
|
|
|
/* Maximum allowed firmware image size. 10MB is more than enough */
|
2006-12-19 11:33:53 +00:00
|
|
|
#define MAX_LOADSIZE (10*1024*1024)
|
2006-08-11 08:35:27 +00:00
|
|
|
|
2007-01-28 18:42:11 +00:00
|
|
|
/* A buffer to load the original firmware or Rockbox into */
|
|
|
|
unsigned char *loadbuffer = (unsigned char *)DRAM_START;
|
2006-08-28 08:11:32 +00:00
|
|
|
|
2007-01-28 18:42:11 +00:00
|
|
|
/* Bootloader version */
|
2006-08-28 08:11:32 +00:00
|
|
|
char version[] = APPSVERSION;
|
|
|
|
|
|
|
|
void* main(void)
|
|
|
|
{
|
|
|
|
char buf[256];
|
|
|
|
int i;
|
2007-03-12 22:12:20 +00:00
|
|
|
int btn;
|
2006-08-28 08:11:32 +00:00
|
|
|
int rc;
|
|
|
|
unsigned short* identify_info;
|
|
|
|
struct partinfo* pinfo;
|
|
|
|
|
|
|
|
system_init();
|
|
|
|
kernel_init();
|
|
|
|
lcd_init();
|
|
|
|
font_init();
|
2006-12-19 11:33:53 +00:00
|
|
|
button_init();
|
2006-08-28 08:11:32 +00:00
|
|
|
|
2007-03-12 22:12:20 +00:00
|
|
|
btn = button_read_device();
|
|
|
|
|
|
|
|
/* Enable bootloader messages */
|
2007-03-15 22:32:58 +00:00
|
|
|
if (btn & BOOTLOADER_VERBOSE)
|
2007-03-12 22:12:20 +00:00
|
|
|
verbose = true;
|
|
|
|
|
2006-08-28 08:11:32 +00:00
|
|
|
lcd_setfont(FONT_SYSFIXED);
|
|
|
|
|
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
2007-01-17 12:20:38 +00:00
|
|
|
printf("Rockbox boot loader");
|
|
|
|
printf("Version: 20%s", version);
|
|
|
|
printf(MODEL_NAME);
|
2006-08-28 08:11:32 +00:00
|
|
|
|
|
|
|
i=ata_init();
|
|
|
|
if (i==0) {
|
2007-01-28 18:42:11 +00:00
|
|
|
identify_info=ata_get_identify();
|
|
|
|
/* Show model */
|
|
|
|
for (i=0; i < 20; i++) {
|
|
|
|
((unsigned short*)buf)[i]=htobe16(identify_info[i+27]);
|
|
|
|
}
|
|
|
|
buf[40]=0;
|
|
|
|
for (i=39; i && buf[i]==' '; i--) {
|
|
|
|
buf[i]=0;
|
|
|
|
}
|
|
|
|
printf(buf);
|
2006-08-28 08:11:32 +00:00
|
|
|
} else {
|
2007-03-12 22:12:20 +00:00
|
|
|
error(EATA, i);
|
2006-08-28 08:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
disk_init();
|
|
|
|
rc = disk_mount_all();
|
|
|
|
if (rc<=0)
|
|
|
|
{
|
2007-03-12 22:12:20 +00:00
|
|
|
error(EDISK,rc);
|
2006-08-28 08:11:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pinfo = disk_partinfo(0);
|
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
2007-01-17 12:20:38 +00:00
|
|
|
printf("Partition 0: 0x%02x %ld MB", pinfo->type, pinfo->size / 2048);
|
2006-08-28 08:11:32 +00:00
|
|
|
|
2007-03-15 22:32:58 +00:00
|
|
|
if(btn & BOOTLOADER_BOOT_OF)
|
2006-08-28 08:11:32 +00:00
|
|
|
{
|
2007-01-28 18:42:11 +00:00
|
|
|
/* Load original mi4 firmware. This expects a file called
|
|
|
|
"/System/OF.bin" on the player. It should be a mi4 firmware decrypted
|
|
|
|
and header stripped using mi4code. It reads the file in to a memory
|
|
|
|
buffer called loadbuffer. The rest of the loading is done in crt0.S
|
|
|
|
*/
|
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
2007-01-17 12:20:38 +00:00
|
|
|
printf("Loading original firmware...");
|
2007-01-28 18:42:11 +00:00
|
|
|
rc=load_raw_firmware(loadbuffer, "/System/OF.bin", MAX_LOADSIZE);
|
|
|
|
if (rc < EOK) {
|
2007-03-12 22:12:20 +00:00
|
|
|
printf("Can't load /System/OF.bin");
|
|
|
|
error(EBOOTFILE, rc);
|
2007-01-28 18:42:11 +00:00
|
|
|
}
|
2006-08-28 08:11:32 +00:00
|
|
|
} else {
|
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
2007-01-17 12:20:38 +00:00
|
|
|
printf("Loading Rockbox...");
|
2007-01-28 18:42:11 +00:00
|
|
|
rc=load_firmware(loadbuffer, BOOTFILE, MAX_LOADSIZE);
|
|
|
|
if (rc < EOK) {
|
|
|
|
printf("Can't load %s:", BOOTFILE);
|
2007-03-12 22:12:20 +00:00
|
|
|
error(EBOOTFILE, rc);
|
2007-01-28 18:42:11 +00:00
|
|
|
}
|
2006-08-28 08:11:32 +00:00
|
|
|
}
|
2006-08-11 09:51:04 +00:00
|
|
|
|
2007-01-28 18:42:11 +00:00
|
|
|
return (void*)loadbuffer;
|
2006-08-11 08:35:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* These functions are present in the firmware library, but we reimplement
|
|
|
|
them here because the originals do a lot more than we want */
|
|
|
|
void usb_acknowledge(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void usb_wait_for_disconnect(void)
|
|
|
|
{
|
|
|
|
}
|