From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1OyRVl-00046n-BK for mharc-grub-devel@gnu.org; Wed, 22 Sep 2010 11:45:33 -0400 Received: from [140.186.70.92] (port=53349 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OyRVh-00044q-F0 for grub-devel@gnu.org; Wed, 22 Sep 2010 11:45:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OyRVg-0007xp-4D for grub-devel@gnu.org; Wed, 22 Sep 2010 11:45:29 -0400 Received: from smtprelay02.ispgateway.de ([80.67.29.24]:34316) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OyRVf-0007xb-QB for grub-devel@gnu.org; Wed, 22 Sep 2010 11:45:28 -0400 Received: from [87.145.80.71] (helo=[192.168.1.36]) by smtprelay02.ispgateway.de with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.68) (envelope-from ) id 1OyRVe-0006aX-Ez for grub-devel@gnu.org; Wed, 22 Sep 2010 17:45:26 +0200 Message-ID: <4C9A249E.2060100@miray.de> Date: Wed, 22 Sep 2010 17:45:34 +0200 From: Thomas Frauendorfer | Miray Software User-Agent: Thunderbird 2.0.0.24 (Windows/20100228) MIME-Version: 1.0 To: grub-devel@gnu.org Content-Type: multipart/mixed; boundary="------------010705060502080907070909" X-Df-Sender: t.frauendorfer@miray.de X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Subject: [PATCH] Workaround for usb boot failure on some mainboards X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Sep 2010 15:45:31 -0000 This is a multi-part message in MIME format. --------------010705060502080907070909 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Hi, On some boards, like the AsRock K7S41GX, Grub fails to boot from superfloppy fat32 formated usb sticks. The reason for the boot failure is that the bios of the mentioned board replaces byte 0x24 of the bpb with the value 0x00 when it's read through the bios function. In fat16 this byte contains the Disc unit number, so this causes no real harm there. In fat32 this byte is part of the sectors per FAT information, so by modifying this value the bios makes Grub unable to read the fat system. The attached workaround reads the backup bpb information on fat32 filesystems and uses the sectors per fat information stored there. PS: I'm sorry if this mail is a duplicate, but I sent it before but I wasn't subscribed so it might have been blocked/dropped before --------------010705060502080907070909 Content-Type: text/plain; name="fat.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fat.patch" --- ../grub2-upstream/grub2-upstream/grub-core/fs/fat.c 2010-09-21 12:13:17.154835710 +0200 +++ grub2-merge/grub-core/fs/fat.c 2010-09-22 10:23:27.935482451 +0200 @@ -214,6 +214,29 @@ grub_fat_mount (grub_disk_t disk) ? grub_le_to_cpu16 (bpb.sectors_per_fat_16) : grub_le_to_cpu32 (bpb.version_specific.fat32.sectors_per_fat_32)) << data->logical_sector_bits); + if (bpb.sectors_per_fat_16) + data->sectors_per_fat = grub_le_to_cpu16 (bpb.sectors_per_fat_16) << data->logical_sector_bits; + else + { + /* Workaround for buggy BIOSes which replace offset 0x24 in the bpb + with the drive number. This offset is part of sectors_per_fat_32 in + the fat32 structure. + We read the backup bpb (if available) and use the value there */ + struct grub_fat_bpb backup_bpb; + grub_uint32_t backup_bpb_address = grub_le_to_cpu16 (bpb.version_specific.fat32.backup_boot_sector) << data->logical_sector_bits; + if (bpb.version_specific.fat32.backup_boot_sector && + (! grub_disk_read (disk, + backup_bpb_address, + 0, + sizeof (backup_bpb), + &backup_bpb))) + data->sectors_per_fat = grub_le_to_cpu32 (backup_bpb.version_specific.fat32.sectors_per_fat_32) << data->logical_sector_bits; + + if (data->sectors_per_fat == 0) + data->sectors_per_fat = grub_le_to_cpu32 (bpb.version_specific.fat32.sectors_per_fat_32) << data->logical_sector_bits; + } + + if (data->sectors_per_fat == 0) goto fail; --------------010705060502080907070909--