Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
You cannot really tell which machine is going to do what.. the only option is to try and make them all happy at the same time
My first stage boot loader is even worse for me at the moment because i've effectively unified first stage loaders to deal with FDD,HDD,USB in both modes and native CDROM booting (eltorito) where the sector size is 2kb.
The idea for me was that i'd eventually land up with a single loader (code+bin) which could be applied to any device instead of having to select an appropriate one for each type of media.
I have it working on about 80% of machines so-far.. still not perfect!
Thanks for all the replies !
Your Post has actually been more helpful than all the ones I've come across after searching for a couple of days
I've come across the code blocks at the start of a few bootloaders but never really paid attention to them :O
I would really appreciate it if someone could link me to some material online that would explain all the stuff about using and FINDING OUT the oem, sectors, bytes_sectors and what not . I didn't actually read up on finding all that stuff out
I have it working on about 80% of machines so-far.. still not perfect!
Well 80% is pretty damn impressive considering all the problems I've run into trying to display a message!
Booting from a USB is *usually* just like booting from a hard disk. You need to use ORG 0x7C00 and properly set up your segments (DS, ES) and stack (SS, SP).
This code from my own OS might help (it boots from USB sticks and hard disks and it works on real hardware.) Notice that when the BIOS gives control to the bootloader, the state of registers are all undefined (except DL which *always* contains the BIOS drive number.
Here's the code of my own boot sector.
I can almost guarantee you that bootsector will not boot on my machines as a HDD style load. Firstly you've put a pseudo-BPB in, and it has no partition table structure, unless you're formatting the USB with a file system first, using a valid MBR and putting this loader in an actual partition ?
johnsa wrote:I can almost guarantee you that bootsector will not boot on my machines as a HDD style load. Firstly you've put a pseudo-BPB in, and it has no partition table structure, unless you're formatting the USB with a file system first, using a valid MBR and putting this loader in an actual partition ?
My OS boots from USB sticks as HDD on two of my computers. Yes my boot sector is on a partition and of course I have an MBR (originally by Muazzam.) Here it is:
Just wanted to make it clear so that MustLearn can see that the structure for the boot loader is very different if it's sitting in place of the MBR or on the bootable partition, and that you can't expect it to work if the machine boots as USB HDD and you've just written your 512b loader to sector 0 (because then it is replacing the MBR).
johnsa wrote:unless you're formatting the USB with a file system first, using a valid MBR and putting this loader in an actual partition
It is a really helpful solution. It can deal with most of BIOSes, just because they try to infer media type by reading some information from a USB stick and if the stick has valid file system, then it is most probable that most BIOSes are able to identify the media type properly.