Page 1 of 1

How do I boot kernel from USB?

Posted: Fri Jan 27, 2017 7:45 am
by stevej150
Hey guys! How would I boot my kernel from an USB? I've tried using AH=08h but it still says the kernel is not found. The floppy image works. However, when I put it on the USB, it says kernel not found. I've tried Plop Boot Manager (for VirtualBox) for the USB. It says kernel not found. What should I do?

Cheers
Steve

Re: How do I boot kernel from USB?

Posted: Fri Jan 27, 2017 8:28 am
by BrightLight
Some BIOSes don't support booting from USB. Other BIOSes support it, while some others can enable/disable it using a BIOS option. It would normally be called USB legacy or USB access from DOS.
Assuming your BIOS can boot from USB, the BIOS will typically emulate a floppy disk or a hard disk, depending on the contents of the first sector. If a valid MBR is found, the BIOS emulates a hard disk and you can see your USB stick as a hard disk, and you can then get its information using INT 0x13 function 0x48 and read/write with functions 0x42 and 0x43, respectively. If a valid MBR is not found, the BIOS will search for a valid BPB. If there is a BPB, it will emulate a floppy disk, and you can read it like you would any floppy disk. In fact, your code shouldn't even be aware that it's booting from USB.
Booting from USB in a beginning stage is not encouraged though, because when you enter 32-bit or 64-bit mode, you won't have access to the BIOS anymore, and will need to access the USB device yourself. To guarantee this works on all hardware, you're going to need drivers for all the major USB controllers (UHCI, OHCI, EHCI and xHCI) as well as drivers for the standard USB mass storage devices (although 99% of USB sticks are of the class "bulk-only").

Re: How do I boot kernel from USB?

Posted: Fri Jan 27, 2017 8:35 am
by stevej150
Do I need to pad out my BPB then? It says kernel not found when I boot from USB. When I use my floppy image, it does work. My USB used to be able to boot my kernels. Until, I recreated my kernel. Maybe it could be something to do with my bootloader.

Re: How do I boot kernel from USB?

Posted: Fri Jan 27, 2017 8:54 am
by BrightLight
stevej150 wrote:Do I need to pad out my BPB then? It says kernel not found when I boot from USB. When I use my floppy image, it does work. My USB used to be able to boot my kernels. Until, I recreated my kernel. Maybe it could be something to do with my bootloader.
Look at your boot loader yourself. Is it meant to go on a hard disk or floppy disk? If the latter, does it have a valid BPB? Else, does it have a valid MBR? Use the Wiki as reference on how MBRs and BPBs look like. Inspect it yourself using a hex editor as well. This is just very basic debugging, really.

Re: How do I boot kernel from USB?

Posted: Tue Feb 07, 2017 10:31 am
by bigbob
Hi,

My OS can boot from a pendrive.
At the bottom of the following webpage see section "Build (Linux)". Booting from USB is explained there.
https://sites.google.com/site/forthoperatingsystem/

Regards,
rob

Re: How do I boot kernel from USB?

Posted: Wed Feb 08, 2017 2:56 am
by mikegonta
bigbob wrote:My OS ...
Very interesting, what is the license by the way?
bigbob wrote:... can boot from a pendrive.
It can, but hard coding the BIOS drive identifier is not a general (nor recommended solution) for systems that boot and run from USB.

Re: How do I boot kernel from USB?

Posted: Wed Feb 08, 2017 10:25 am
by bigbob
mikegonta wrote:Very interesting, what is the license by the way?
A good question. Currently nothing. I am thinking about GPLv3.
It can, but hard coding the BIOS drive identifier is not a general (nor recommended solution) for systems that boot and run from USB.
You must be referring to 0x80. :)
I should get the "BIOS drive identifier" somehow from BIOS, but how?

Re: How do I boot kernel from USB?

Posted: Wed Feb 08, 2017 11:52 am
by mikegonta
bigbob wrote:
It can, but hard coding the BIOS drive identifier is not a general (nor recommended solution) for systems that boot and run from USB.
You must be referring to 0x80.
I should get the "BIOS drive identifier" somehow from BIOS, but how?
It comes free with every classic BIOS boot, just don't idly throw it away (and loose) it.

Re: How do I boot kernel from USB?

Posted: Wed Feb 08, 2017 12:23 pm
by bigbob
mikegonta wrote:It comes free with every classic BIOS boot, just don't idly throw it away (and loose) it.
Now I understand it (dl). Thanks.