Booting from USB

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.
Post Reply
johnsa
Member
Member
Posts: 296
Joined: Mon Oct 15, 2007 3:04 pm

Booting from USB

Post by johnsa »

Hi all,

New to the forum (and to OS coding really) except for writing a pmode system for DOS so many years ago I can hardly remember ;)

I've started working on an OS purely for interest sake and have gone with a 2 stage boot-loader design.

Sofar all the bits of it have come together under bochs nicely (using floppy image).

I just wanted to find out if A) there are any "code" differences one should take into account when booting from a USB device, or CD for that matter.

I thought I'd take the time now to test what I have sofar on a few real machines and setups, starting with a USB boot on my laptop.
I've written the 1st and 2nd stage loaders to a USB memory stick but I'm not having any joy in getting it to boot.. All i get is either a flashing cursor (not even executing/loading the 1st stage) or a message that the media is not bootable.

I'm running an AMI bios in this laptop, are there any known problems with it booting of USB?

Lots of questions.. :) Thanks for any help in advance!
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

If youre pc is able to boot an usb device it should not be a problem. The only thing you have to take into account is that your bios might use a different approach to accessing the drive. A floppy in general has 2 heads, 18 sectors and 2880 tracks or something a like. When using an usb device i found out that is is up to the bios to assign values for the head/sector/track. I tested on three different machines and got three different results. Best thing to do is read them with int 0x10 function 8 (GetDriveParameters). Then you can use those parameters for reading the drive. This is what i do and it works perfectly. It will automatically run on harddisk and floppy.
Author of COBOS
johnsa
Member
Member
Posts: 296
Joined: Mon Oct 15, 2007 3:04 pm

Post by johnsa »

Thanks for the info. I will use those returned values when reading the 2nd stage loader.

My problem though seems to be happening before I even do anything (code wise).

The bios will load the 1st sector (1st stage loader automatically), but it doesn't I just get a non-bootable media error come up sometimes and others a blank screen with a flashing cursor. The 1st stage loader has the 55aa end signature marker, works under bochs etc.

So I was wondering if certain AMI bioses which are supposed to be able to boot from usb, don't work properly :)
User avatar
Zacariaz
Member
Member
Posts: 1069
Joined: Tue May 22, 2007 2:36 pm
Contact:

Post by Zacariaz »

my greatest obsticle regarding usb boting has been getting the actual bootsector onto the usb device. I tryed rawrite, but couldnt find any useable parameters, itryed other stuff too, but eventually the only solution to my problem was copy/paste using a lowlevel hex editor i found (by the way i havent been able to find it again and i need it!).
I could choose to open the first sector of any device and then it was just a matter of pasting the binarys and save.

I would like another solution to that problem.
This was supposed to be a cool signature...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

what about using dd?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
os64dev
Member
Member
Posts: 553
Joined: Sat Jan 27, 2007 3:21 pm
Location: Best, Netherlands

Post by os64dev »

Zacariaz wrote:my greatest obsticle regarding usb boting has been getting the actual bootsector onto the usb device. I tryed rawrite, but couldnt find any useable parameters, itryed other stuff too, but eventually the only solution to my problem was copy/paste using a lowlevel hex editor i found (by the way i havent been able to find it again and i need it!).
I could choose to open the first sector of any device and then it was just a matter of pasting the binarys and save.

I would like another solution to that problem.
If you use cygwin or linux you could use dd. It works but can be dangerous, using dd wrong can result in a very clean harddisk :wink: .

I only use usb stick with led indication:

then use: dd if=/dev/sdf of=/dev/null to check if the device i address is indeed the usb stick. otherwise try sdb, sdc, sdd, sde etc. when i have located the correct device i use dd of=/dev/sdf if=bin/drive.img where sdf is the device found with the above check.
Author of COBOS
johnsa
Member
Member
Posts: 296
Joined: Mon Oct 15, 2007 3:04 pm

Post by johnsa »

Hey,

I wrote a program for this purpose, I can send you a copy of it if you like, just send me your email addy.

It basically uses win i/o low level device names like \\.\F: to access a logical device sector by sector.

The little app I made can read/write between devices and files so it's also useful for capturing sectors from disks... works with usb/floppy/hdisk.
Post Reply