USB Booting Secrets

Everything you always wanted to know about USB booting but were too USB (Unable or Sophisticated or Busy) to ask.

Have you ever seen this error message when trying to boot from a floppy disk?

Quote:

Remove disks or other media.
Press any key to restart

I guess that floppy is not bootable.
Or how about this message when booting from a CD?

Quote:

Boot from ATAPI CD-ROM :
Press any key to boot from CD. . .

If you don't touch the keyboard, that CD won't boot.
Or maybe you've seen this error message when booting from a USB flash drive?

Quote:

Disk error
Press any key to restart

Gee wiz, another boot failure, right? Wrong!

USB Booting Secret #1:Everything boots!
In fact, all of the above messages came directly or indirectly from the boot sector of the device.
That's the way the PC works, based on the BIOS setup (that's up to you) the BIOS will load the first sector of the
Initial Program Load device to 7C00h, perform a few checks and then jump to 7C00h. Everything boots.
(Of course there are old computers with USB that can't boot a flash drive, but we're not concerned about those here).

USB Booting Secret #2:What happens in the boot sector, stays in the boot sector!
When it comes to USB booting there are basically 4 types of computers:

PC without USB, or with USB and can't boot USB because of old BIOS firmware.
PC that always boots USB with floppy disk emulation.
PC that always boots USB with hard drive emulation.
PC that examines the boot sector to determine the type of emulation and/or with BIOS selection setup.

Because #1 - everything boots and #2 - booting occurs no matter what's in the boot sector (it does of course have to
pass a few simple BIOS checks), we can come up with a simple USB booting method designed specifically for
OS development.

The floppy disk is dead, long live the floppy disk!

Tip # 1
The FAT12 floppy disk format is simple, easy and universal.
Transfering files to the USB is easy and it will run from any PC that can boot from USB.
Use CHS for access and don't assume floppy disk geometry.

Tip # 2
Ask and you shall receive.
Later on, in the second stage, use int 13h function ah=8 to obtain and save the BIOS emulated geometry. This
information can used later to calculate CHS.

Presented here is simple boot sector / boot loader.
The next 35 sectors are loaded to 0:600h. The loaded second stage (filled with "nop" to make it 17 1/2 K in size)
displays a message to the screen.
5 lines of data statements follow to create a basic FAT12 file system structure.

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou cannot attach files in this forumYou can download files in this forum