mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
ipod5g/6g: support DEFAULT_VIRT_SECTOR_SIZE
This way if there's no valid partition/filesystem we still report the "correct" sector size out via USB. Update the ipod5g/6g bootloaders so they do the right thing too. Change-Id: I0d93ae7e6664f1591d8edf1c0252c586e329cd4b
This commit is contained in:
parent
1516c48a37
commit
c8e1da8e90
4 changed files with 35 additions and 16 deletions
|
@ -11,7 +11,7 @@
|
||||||
*
|
*
|
||||||
* Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
|
* Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
|
||||||
* and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
|
* and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation; either version 2
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
@ -50,7 +50,7 @@
|
||||||
#define XSC(X) #X
|
#define XSC(X) #X
|
||||||
#define SC(X) XSC(X)
|
#define SC(X) XSC(X)
|
||||||
|
|
||||||
/* Maximum allowed firmware image size. The largest known current
|
/* Maximum allowed firmware image size. The largest known current
|
||||||
(December 2006) firmware is about 7.5MB (Apple's firmware for the ipod video)
|
(December 2006) firmware is about 7.5MB (Apple's firmware for the ipod video)
|
||||||
so we set this to 8MB. */
|
so we set this to 8MB. */
|
||||||
#define MAX_LOADSIZE (8*1024*1024)
|
#define MAX_LOADSIZE (8*1024*1024)
|
||||||
|
@ -202,6 +202,13 @@ void fatal_error(void)
|
||||||
#endif
|
#endif
|
||||||
lcd_update();
|
lcd_update();
|
||||||
|
|
||||||
|
#if defined(MAX_VIRT_SECTOR_SIZE) && defined(DEFAULT_VIRT_SECTOR_SIZE)
|
||||||
|
#ifdef HAVE_MULTIDRIVE
|
||||||
|
for (int i = 0 ; i < NUM_DRIVES ; i++)
|
||||||
|
#endif
|
||||||
|
disk_set_sector_multiplier(IF_MD(i,) DEFAULT_VIRT_SECTOR_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
usb_init();
|
usb_init();
|
||||||
while (1) {
|
while (1) {
|
||||||
if (button_hold() != holdstatus) {
|
if (button_hold() != holdstatus) {
|
||||||
|
@ -298,7 +305,7 @@ void* main(void)
|
||||||
struct partinfo pinfo;
|
struct partinfo pinfo;
|
||||||
unsigned short* identify_info;
|
unsigned short* identify_info;
|
||||||
|
|
||||||
/* Check the button hold status as soon as possible - to
|
/* Check the button hold status as soon as possible - to
|
||||||
give the user maximum chance to turn it off in order to
|
give the user maximum chance to turn it off in order to
|
||||||
reset the settings in rockbox. */
|
reset the settings in rockbox. */
|
||||||
button_was_held = button_hold();
|
button_was_held = button_hold();
|
||||||
|
@ -362,26 +369,26 @@ void* main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
disk_partinfo(1, &pinfo);
|
disk_partinfo(1, &pinfo);
|
||||||
printf("Partition 1: 0x%02x %ld sectors",
|
printf("Partition 1: 0x%02x %ld sectors",
|
||||||
pinfo.type, pinfo.size);
|
pinfo.type, pinfo.size);
|
||||||
|
|
||||||
if (button_was_held || (btn==BUTTON_MENU)) {
|
if (button_was_held || (btn==BUTTON_MENU)) {
|
||||||
/* If either the hold switch was on, or the Menu button was held, then
|
/* If either the hold switch was on, or the Menu button was held, then
|
||||||
try the Apple firmware */
|
try the Apple firmware */
|
||||||
|
|
||||||
printf("Loading original firmware...");
|
printf("Loading original firmware...");
|
||||||
|
|
||||||
/* First try an apple_os.ipod file on the FAT32 partition
|
/* First try an apple_os.ipod file on the FAT32 partition
|
||||||
(either in .rockbox or the root)
|
(either in .rockbox or the root)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
rc=load_firmware(loadbuffer, "apple_os.ipod", MAX_LOADSIZE);
|
rc=load_firmware(loadbuffer, "apple_os.ipod", MAX_LOADSIZE);
|
||||||
|
|
||||||
if (rc > 0) {
|
if (rc > 0) {
|
||||||
printf("apple_os.ipod loaded.");
|
printf("apple_os.ipod loaded.");
|
||||||
return (void*)DRAM_START;
|
return (void*)DRAM_START;
|
||||||
} else if (rc == EFILE_NOT_FOUND) {
|
} else if (rc == EFILE_NOT_FOUND) {
|
||||||
/* If apple_os.ipod doesn't exist, then check if there is an Apple
|
/* If apple_os.ipod doesn't exist, then check if there is an Apple
|
||||||
firmware image in RAM */
|
firmware image in RAM */
|
||||||
haveramos = (memcmp((void*)(DRAM_START+0x20),"portalplayer",12)==0);
|
haveramos = (memcmp((void*)(DRAM_START+0x20),"portalplayer",12)==0);
|
||||||
if (haveramos) {
|
if (haveramos) {
|
||||||
|
@ -393,10 +400,10 @@ void* main(void)
|
||||||
printf("Can't load apple_os.ipod:");
|
printf("Can't load apple_os.ipod:");
|
||||||
printf(loader_strerror(rc));
|
printf(loader_strerror(rc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Everything failed - just loop forever */
|
/* Everything failed - just loop forever */
|
||||||
printf("No RetailOS detected");
|
printf("No RetailOS detected");
|
||||||
|
|
||||||
} else if (btn==BUTTON_PLAY) {
|
} else if (btn==BUTTON_PLAY) {
|
||||||
printf("Loading Linux...");
|
printf("Loading Linux...");
|
||||||
rc=load_raw_firmware(loadbuffer, "/linux.bin", MAX_LOADSIZE);
|
rc=load_raw_firmware(loadbuffer, "/linux.bin", MAX_LOADSIZE);
|
||||||
|
@ -427,10 +434,10 @@ void* main(void)
|
||||||
printf("Can't load " BOOTFILE ": ");
|
printf("Can't load " BOOTFILE ": ");
|
||||||
printf(loader_strerror(rc));
|
printf(loader_strerror(rc));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we get to here, then we haven't been able to load any firmware */
|
/* If we get to here, then we haven't been able to load any firmware */
|
||||||
fatal_error();
|
fatal_error();
|
||||||
|
|
||||||
/* We never get here, but keep gcc happy */
|
/* We never get here, but keep gcc happy */
|
||||||
return (void*)0;
|
return (void*)0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -424,8 +424,15 @@ void main(void)
|
||||||
|
|
||||||
#ifdef HAVE_BOOTLOADER_USB_MODE
|
#ifdef HAVE_BOOTLOADER_USB_MODE
|
||||||
/* Enter USB mode if SELECT+RIGHT are pressed */
|
/* Enter USB mode if SELECT+RIGHT are pressed */
|
||||||
if (button_read_device() == (BUTTON_SELECT|BUTTON_RIGHT))
|
if (button_read_device() == (BUTTON_SELECT|BUTTON_RIGHT)) {
|
||||||
|
#if defined(MAX_VIRT_SECTOR_SIZE) && defined(DEFAULT_VIRT_SECTOR_SIZE)
|
||||||
|
#ifdef HAVE_MULTIDRIVE
|
||||||
|
for (int i = 0 ; i < NUM_DRIVES ; i++)
|
||||||
|
#endif
|
||||||
|
disk_set_sector_multiplier(IF_MD(i,) DEFAULT_VIRT_SECTOR_SIZE);
|
||||||
|
#endif
|
||||||
usb_mode();
|
usb_mode();
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = disk_mount_all();
|
rc = disk_mount_all();
|
||||||
|
|
|
@ -194,6 +194,9 @@
|
||||||
/* define this if the device has larger sectors when accessed via USB */
|
/* define this if the device has larger sectors when accessed via USB */
|
||||||
#define MAX_VIRT_SECTOR_SIZE 4096
|
#define MAX_VIRT_SECTOR_SIZE 4096
|
||||||
|
|
||||||
|
/* If we have no valid paritions, advertise this as our sector size */
|
||||||
|
#define DEFAULT_VIRT_SECTOR_SIZE 4096
|
||||||
|
|
||||||
/* This is the minimum access size for the device, even if it's larger than the logical sector size */
|
/* This is the minimum access size for the device, even if it's larger than the logical sector size */
|
||||||
#define MAX_PHYS_SECTOR_SIZE 4096
|
#define MAX_PHYS_SECTOR_SIZE 4096
|
||||||
|
|
||||||
|
|
|
@ -214,9 +214,11 @@
|
||||||
#define HAVE_HARDWARE_CLICK
|
#define HAVE_HARDWARE_CLICK
|
||||||
|
|
||||||
/* define this if the device has larger sectors when accessed via USB */
|
/* define this if the device has larger sectors when accessed via USB */
|
||||||
/* (only relevant in disk.c, fat.c now always supports large virtual sectors) */
|
|
||||||
#define MAX_VIRT_SECTOR_SIZE 2048
|
#define MAX_VIRT_SECTOR_SIZE 2048
|
||||||
|
|
||||||
|
/* If we have no valid paritions, advertise this as our sector size */
|
||||||
|
#define DEFAULT_VIRT_SECTOR_SIZE 2048
|
||||||
|
|
||||||
/* define this if the hard drive uses large physical sectors (ATA-7 feature) */
|
/* define this if the hard drive uses large physical sectors (ATA-7 feature) */
|
||||||
/* and doesn't handle them in the drive firmware */
|
/* and doesn't handle them in the drive firmware */
|
||||||
#define MAX_PHYS_SECTOR_SIZE 1024
|
#define MAX_PHYS_SECTOR_SIZE 1024
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue