Page 3 of 4
Re: USB Compatible BPB Issue
Posted: Tue Oct 24, 2017 4:06 pm
by BenLunt
Hi Mike,
mikegonta wrote:Here is a simple hello world boot sector with the same BPB to see if it will list and boot.
That is a negative. This machine (BIOS/Firmware), no matter what I tried, requires a valid Partition Table with at least one valid entry or it won't recognize it at all, not including it in the list of devices to boot.
Of course the partition entry doesn't have to point to anything either. It simply has to have the first byte 80h, with the Sys_ID field non-zero. Period. I haven't tried it, but I could probably place some code at 0x1BE as long as the assembled bytes produced either 80h or 00h in the first byte of each entry, I bet it would find it bootable and list it.
Ben
Re: USB Compatible BPB Issue
Posted: Tue Oct 24, 2017 4:13 pm
by mikegonta
BenLunt wrote:This machine (BIOS/Firmware), no matter what I tried, requires a valid Partition Table with at least one valid entry or it won't recognize it at all, not including it in the list of devices to boot.
Does that include a Windows formatted non partitioned flash drive?
Funnily enough Windows will not recognize (as formatted) an exFAT volume image on a flash drive that is not the same size as the
physical drive unless it is partitioned.
How about a floppy disk image on a flash drive?
Re: USB Compatible BPB Issue
Posted: Tue Oct 24, 2017 6:21 pm
by BenLunt
mikegonta wrote:BenLunt wrote:This machine (BIOS/Firmware), no matter what I tried, requires a valid Partition Table with at least one valid entry or it won't recognize it at all, not including it in the list of devices to boot.
Does that include a Windows formatted non partitioned flash drive?
If I format the drive using Windows to a FAT32 file system, there is no MBR nor a Partition Table, so no, it does not allow me to boot it. WinXP won't allow me to create partitions on it (through the normal routes), since it is a removable device.
mikegonta wrote:How about a floppy disk image on a flash drive?
Nope. The BIOS on this machine will not recognize it since there is not Partition Table.
Ben
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 3:28 am
by Antti
BenLunt wrote:If I format the drive using Windows to a FAT32 file system, there is no MBR nor a Partition Table, so no, it does not allow me to boot it.
Just to be sure, have you tested this or is this a conclusion ("there is no MBR nor a Partition Table") based on previous tests? Octocontrabass mentioned a little detail that may be relevant, i.e. what if the filesystem size does match with the flash drive size (e.g. 128 MiB filesystem on a much larger flash drive). Windows should format it based on the flash drive size.
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 4:38 am
by mikegonta
BenLunt wrote:HP Pavillion g6 Notebook, 64-bit, BIOS: "Insyde", version F.17:
- Doesn't recognize a valid USB bootable device. Does not show in the list of boot options.
Apparently, there are many
real problems with
Insyde H20 BIOS and the MBR.
Insyde BIOS Issues.
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 11:05 am
by Octocontrabass
BenLunt wrote:This machine can be either/or. I can set it to use UEFI or I can set it to use Legacy BIOS. I currently have it set to boot Legacy BIOS.
And I suppose in UEFI mode it can't load EFI binaries from an unpartitioned flash drive?
At least now I have a good excuse to force most media to be partitioned before installing a bootloader.
BenLunt wrote:It has 15,950,592 sectors.
That means 992/255/63 is the geometry closest to its actual size. It's good to know how little you can trust the BIOS.
BenLunt wrote:WinXP won't allow me to create partitions on it (through the normal routes), since it is a removable device.
Windows 7's disk management refuses to partition a flash drive like this unless I first clean it with diskpart. Perhaps that also works on Windows XP?
The Dell Phoenix-Award BIOS has a similar issue. If something resembling a BPB exists (either in the first sector of an unpartitioned flash drive or the first sector of the partition) but it claims zero heads per cylinder and zero sectors per track, the BIOS will hang.
If the drive is plugged in when the computer turns on, it hangs during POST. If the drive is plugged in after POST but while the BIOS is still in control of USB, the computer hangs.
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 11:18 am
by BenLunt
Antti wrote:BenLunt wrote:If I format the drive using Windows to a FAT32 file system, there is no MBR nor a Partition Table, so no, it does not allow me to boot it.
Just to be sure, have you tested this or is this a conclusion ("there is no MBR nor a Partition Table") based on previous tests? Octocontrabass mentioned a little detail that may be relevant, i.e. what if the filesystem size does match with the flash drive size (e.g. 128 MiB filesystem on a much larger flash drive). Windows should format it based on the flash drive size.
WinXP, the development platform I use, will only format a partition. A partition can be the whole thumb drive starting with LBA 0 and no MBR. If I place a MBR and Partition Table on the thumb drive, then WinXP will format one or more of these partitions, but it is still
my Partition Table. WinXP's Storage Utility won't partition the removable media device.
With Mike's comments, it looks like "Insyde" may have some problems.
My conclusion is that if you wish to have (most) all machines boot your USB device, have a first sector that contains a BPB and a Partition Table with code within this first sector to parse and boot one of the Partition Table Entries.
Ben
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 11:22 am
by BenLunt
Octocontrabass wrote:BenLunt wrote:This machine can be either/or. I can set it to use UEFI or I can set it to use Legacy BIOS. I currently have it set to boot Legacy BIOS.
And I suppose in UEFI mode it can't load EFI binaries from an unpartitioned flash drive?
I have not tried a UEFI boot from USB yet. That is on my TODO list though.
Octocontrabass wrote:BenLunt wrote:WinXP won't allow me to create partitions on it (through the normal routes), since it is a removable device.
Windows 7's disk management refuses to partition a flash drive like this unless I first clean it with diskpart. Perhaps that also works on Windows XP?
This is what I was going to try next.
Ben
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 11:48 am
by Antti
Octocontrabass wrote:The Dell Phoenix-Award BIOS has a similar issue. If something resembling a BPB exists (either in the first sector of an unpartitioned flash drive or the first sector of the partition) but it claims zero heads per cylinder and zero sectors per track, the BIOS will hang.
Very interesting information. Have you investigated what is the threshold of "resembles" a BPB? My MBR has zero bytes from offset 0x08 to 0x1F so I guess it does not resemble a BPB. It is trivial to add sectors per track and number of heads values but would it do more harm than good? That modification itself would make it slightly more like a valid BPB.
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 12:39 pm
by BenLunt
BenLunt wrote:Octocontrabass wrote:BenLunt wrote:This machine can be either/or. I can set it to use UEFI or I can set it to use Legacy BIOS. I currently have it set to boot Legacy BIOS.
And I suppose in UEFI mode it can't load EFI binaries from an unpartitioned flash drive?
I have not tried a UEFI boot from USB yet. That is on my TODO list though.
I created a UEFI partition type boot and changed the "Insyde" machine back to UEFI. It booted my USB Thumb Drive until the point it said that my loader is not certified. :-) Caught by the TPM (Trusted Platform Module).
BenLunt wrote:Octocontrabass wrote:BenLunt wrote:WinXP won't allow me to create partitions on it (through the normal routes), since it is a removable device.
Windows 7's disk management refuses to partition a flash drive like this unless I first clean it with diskpart. Perhaps that also works on Windows XP?
This is what I was going to try next.
As for zeroing out the Thumb Drive and seeing if WinXP will partition it, that's a negative. WinXP sees the whole thing as a removable media device and a single partition containing the whole device capacity.
Anyway, I found out what I needed throughout the life of this thread. Thanks to all of for your comments and input.
Ben
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 4:05 pm
by BenLunt
Just for fun, I dug out my USB floppy drive and plugged it into those same three machines.
The two DELL machines would boot it if there was a valid 1.44Meg BPB on the floppy. They would not boot it if there was no BPB. The BIOS knows it is a floppy due to the USB device descriptor. In fact, it lists the floppy as "Diskette" in the Boot menu.
The "Insyde" machine would not boot it no matter what, even with a proper BPB and/or Partition Table. It at least understands that it is a USB floppy drive attached, reads from the inserted disk, but will not show it in the list of boot options.
Ben
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 4:06 pm
by mikegonta
BenLunt wrote:My conclusion is that if you wish to have (most) all machines boot your USB device, have a first sector that contains a BPB and a Partition Table with code within this first sector to parse and boot one of the Partition Table Entries.
Or use a self referencing partition table entry which requires no code since it points to itself (LBA 0).
Re: USB Compatible BPB Issue
Posted: Wed Oct 25, 2017 7:23 pm
by BenLunt
mikegonta wrote:BenLunt wrote:My conclusion is that if you wish to have (most) all machines boot your USB device, have a first sector that contains a BPB and a Partition Table with code within this first sector to parse and boot one of the Partition Table Entries.
Or use a self referencing partition table entry which requires no code since it points to itself (LBA 0).
Which is perfectly fine, though now you have a BPB and a Partition Table in the way of the file system. Some file systems, FAT for example, won't care and require the BPB anyway. Other file systems will not like a BPB and/or Partition Table within the first sector. Ext2 for example, leaves you with only two sectors for your boot code. Two sectors is really tight, let alone having to leave room for the BPB and Partition Table. :-)
But, you are quite right. A self referencing partition table entry does work, and I have tried it on all my USB bootable machines.
Ben
Re: USB Compatible BPB Issue
Posted: Thu Oct 26, 2017 5:21 am
by mikegonta
BenLunt wrote:mikegonta wrote:BenLunt wrote:My conclusion is that if you wish to have (most) all machines boot your USB device, have a first sector that contains a BPB and a Partition Table with code within this first sector to parse and boot one of the Partition Table Entries.
Or use a self referencing partition table entry which requires no code since it points to itself (LBA 0).
Which is perfectly fine, though now you have a BPB and a Partition Table in the way of the file system. Some file systems, FAT for example, won't care and require the BPB anyway. Other file systems will not like a BPB and/or Partition Table within the first sector.
There doesn't seem to any booting requirement for a
BPB for non FAT file systems and generally assumed that partitioned media has
the best chance.
BenLunt wrote:Ext2 for example, leaves you with only two sectors for your boot code. Two sectors is really tight, let alone having to leave room for the BPB and Partition Table.
A simple rearrangement of
your ext2_hd.asm costs only
5 extra bytes (out of the 25 spare bytes that you have) to implement
a self referencing
MBR.
Code: Select all
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; These data items must be in the first sector already loaded by the BIOS
diskerrorS db 13,10,'Error reading disk/non-system disk'
db 13,10,'Press a key',0
; =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
; Pad out to fill 512 bytes, including self referencing MBR and final word 0xAA55
%PRINT (510-64-$) ; 20 byte(s) free in this area
; mbr is located here
org (200h-66)
boot_data ; st S_BOOT_DATA ; booted data to pass to loader.sys
db 80h ; status
db 0,0,0 ; chs of first active sector
db 83h ; EXT2 partition type
db 0,0,0 ; chs of last absolute sector (initialize if required)
dd 0 ; volume LBA
dd VOLUME_SIZE ; requires initialization
dup 12,0 ; don't care
dd 0 ; required
dup 12,0 ; don't care
dd 0 ; required
dup 12,0 ; don't care
dd 0 ; required
loadname db 'loader.sys',0
db 0
dd 0 ; required
dw 0AA55h
Re: USB Compatible BPB Issue
Posted: Thu Oct 26, 2017 10:15 am
by Octocontrabass
Antti wrote:Have you investigated what is the threshold of "resembles" a BPB? My MBR has zero bytes from offset 0x08 to 0x1F so I guess it does not resemble a BPB. It is trivial to add sectors per track and number of heads values but would it do more harm than good? That modification itself would make it slightly more like a valid BPB.
I zeroed all of the values not necessary for my bootloader to function, and the only one of those that made a difference to the Phoenix-Award BIOS was the extended boot signature at offset 0x26. When I set that byte to zero, the BIOS no longer attempted to read the BPB. I didn't test any further because I'll be placing my bootloader in a FAT partition anyway, so I don't have to worry about the BPB (or lack thereof). I haven't checked to see how it behaves with FAT32.
BenLunt wrote:I created a UEFI partition type boot and changed the "Insyde" machine back to UEFI. It booted my USB Thumb Drive until the point it said that my loader is not certified.
Caught by the TPM (Trusted Platform Module).
You created a partition? I wanted to know what it does when the disk isn't partitioned at all.
BenLunt wrote:As for zeroing out the Thumb Drive and seeing if WinXP will partition it, that's a negative. WinXP sees the whole thing as a removable media device and a single partition containing the whole device capacity.
Diskpart's clean command doesn't zero the disk, only the partition table. It also sets the 0xAA55 signature if that's not already present. I don't know if that makes a difference to XP, but it does to 7.