diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2024-11-09 16:43:11 -0500 |
---|---|---|
committer | Solomon Peachy <pizza@shaftnet.org> | 2024-11-09 17:48:09 -0500 |
commit | c8e1da8e908c3cf3559664a5b70105548c91db54 (patch) | |
tree | f0f76fb1c4a91b5fc3ab328744215df5347092e9 | |
parent | 1516c48a37bbd231c6c86272fd5ca88d0ffffe9b (diff) | |
download | rockbox-c8e1da8e90.tar.gz rockbox-c8e1da8e90.zip |
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
-rw-r--r-- | bootloader/ipod.c | 35 | ||||
-rw-r--r-- | bootloader/ipod6g.c | 9 | ||||
-rw-r--r-- | firmware/export/config/ipod6g.h | 3 | ||||
-rw-r--r-- | firmware/export/config/ipodvideo.h | 4 |
4 files changed, 35 insertions, 16 deletions
diff --git a/bootloader/ipod.c b/bootloader/ipod.c index 9583afe0fb..4234a67e61 100644 --- a/bootloader/ipod.c +++ b/bootloader/ipod.c @@ -11,7 +11,7 @@ * * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach - * + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 @@ -50,7 +50,7 @@ #define XSC(X) #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) so we set this to 8MB. */ #define MAX_LOADSIZE (8*1024*1024) @@ -202,6 +202,13 @@ void fatal_error(void) #endif 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(); while (1) { if (button_hold() != holdstatus) { @@ -298,7 +305,7 @@ void* main(void) struct partinfo pinfo; 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 reset the settings in rockbox. */ button_was_held = button_hold(); @@ -362,26 +369,26 @@ void* main(void) } disk_partinfo(1, &pinfo); - printf("Partition 1: 0x%02x %ld sectors", + printf("Partition 1: 0x%02x %ld sectors", pinfo.type, pinfo.size); 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 */ printf("Loading original firmware..."); - + /* 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); - + if (rc > 0) { printf("apple_os.ipod loaded."); return (void*)DRAM_START; } 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 */ haveramos = (memcmp((void*)(DRAM_START+0x20),"portalplayer",12)==0); if (haveramos) { @@ -393,10 +400,10 @@ void* main(void) printf("Can't load apple_os.ipod:"); printf(loader_strerror(rc)); } - + /* Everything failed - just loop forever */ printf("No RetailOS detected"); - + } else if (btn==BUTTON_PLAY) { printf("Loading Linux..."); rc=load_raw_firmware(loadbuffer, "/linux.bin", MAX_LOADSIZE); @@ -427,10 +434,10 @@ void* main(void) printf("Can't load " BOOTFILE ": "); printf(loader_strerror(rc)); } - + /* If we get to here, then we haven't been able to load any firmware */ fatal_error(); - + /* We never get here, but keep gcc happy */ return (void*)0; } diff --git a/bootloader/ipod6g.c b/bootloader/ipod6g.c index 30db29c783..884af6025d 100644 --- a/bootloader/ipod6g.c +++ b/bootloader/ipod6g.c @@ -424,8 +424,15 @@ void main(void) #ifdef HAVE_BOOTLOADER_USB_MODE /* 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(); + } #endif rc = disk_mount_all(); diff --git a/firmware/export/config/ipod6g.h b/firmware/export/config/ipod6g.h index c13e35d7df..0b508b15e3 100644 --- a/firmware/export/config/ipod6g.h +++ b/firmware/export/config/ipod6g.h @@ -194,6 +194,9 @@ /* define this if the device has larger sectors when accessed via USB */ #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 */ #define MAX_PHYS_SECTOR_SIZE 4096 diff --git a/firmware/export/config/ipodvideo.h b/firmware/export/config/ipodvideo.h index 15b188fbe6..62727b1554 100644 --- a/firmware/export/config/ipodvideo.h +++ b/firmware/export/config/ipodvideo.h @@ -214,9 +214,11 @@ #define HAVE_HARDWARE_CLICK /* 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 +/* 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) */ /* and doesn't handle them in the drive firmware */ #define MAX_PHYS_SECTOR_SIZE 1024 |