OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Apr 25, 2024 5:18 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: How do I boot kernel from USB?
PostPosted: Fri Jan 27, 2017 7:45 am 
Offline

Joined: Wed Jan 25, 2017 8:16 am
Posts: 23
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

_________________
One day in the future... computers will be holograms...


Top
 Profile  
 
 Post subject: Re: How do I boot kernel from USB?
PostPosted: Fri Jan 27, 2017 8:28 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
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").

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: How do I boot kernel from USB?
PostPosted: Fri Jan 27, 2017 8:35 am 
Offline

Joined: Wed Jan 25, 2017 8:16 am
Posts: 23
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.

_________________
One day in the future... computers will be holograms...


Top
 Profile  
 
 Post subject: Re: How do I boot kernel from USB?
PostPosted: Fri Jan 27, 2017 8:54 am 
Offline
Member
Member
User avatar

Joined: Sat Dec 27, 2014 9:11 am
Posts: 901
Location: Maadi, Cairo, Egypt
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.

_________________
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: How do I boot kernel from USB?
PostPosted: Tue Feb 07, 2017 10:31 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
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


Top
 Profile  
 
 Post subject: Re: How do I boot kernel from USB?
PostPosted: Wed Feb 08, 2017 2:56 am 
Offline
Member
Member

Joined: Thu May 19, 2011 5:13 am
Posts: 229
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.

_________________
Mike Gonta
look and see - many look but few see

https://mikegonta.com


Top
 Profile  
 
 Post subject: Re: How do I boot kernel from USB?
PostPosted: Wed Feb 08, 2017 10:25 am 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
mikegonta wrote:
Very interesting, what is the license by the way?

A good question. Currently nothing. I am thinking about GPLv3.
Quote:
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?


Top
 Profile  
 
 Post subject: Re: How do I boot kernel from USB?
PostPosted: Wed Feb 08, 2017 11:52 am 
Offline
Member
Member

Joined: Thu May 19, 2011 5:13 am
Posts: 229
bigbob wrote:
Quote:
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.

_________________
Mike Gonta
look and see - many look but few see

https://mikegonta.com


Top
 Profile  
 
 Post subject: Re: How do I boot kernel from USB?
PostPosted: Wed Feb 08, 2017 12:23 pm 
Offline
Member
Member

Joined: Tue Oct 01, 2013 2:50 am
Posts: 118
Location: Budapest, Hungary
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 241 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group