News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Boot my OS from USB drive

Started by liquidsilver, November 14, 2005, 12:53:21 PM

Previous topic - Next topic

liquidsilver

I'm deciding whether or not to make my hobby OS boot from a floppy or a USB flash drive. This is what I think the differences will be:
FloppyFlash Drive
Use int 13h to read when bootingSame here?
Obviously less space, errors more likelyMuch more memory, faster, no errors
Use ports to access in PMNo clue how to access in PM

I can't decide which I should do. I would prefer to go flash drive route, but not sure if I can get it to work.

I tried to boot off flash drive, but didn't work properly so I think I did something wrong. My boot sector just read the boot sector off the drive and displayed it, but it displayed some weird data: 33C08ED0 BC007CFB... which should have been: EB3C904D 5357494E... It worked fine off a floppy so I have no idea why it didn't work. Please help. Maybe you guys have some experience in this matter.

Tedd

I would say start with floppy first, and then when (if) you get far enough you can add support for usb and such.
I think most (newer) BIOS' will provide legacy support for int13 from a usb device (but don't quote me on that.) But of course, once you're in PM, you need to have all of the device 'drivers' ready yourself (no BIOS :bdg)
There is a lot to learn from creating a driver for a floppy drive - much of which can be used to help creating a driver for an ide hdd. And the driver for a floppy will be considerably easier/simpler than the usb one. Plus the mountain of examples, etc.
I don't think space will be a problem untill you start padding out the OS considerably.

Remember: 512k should be enough for anyone! :lol



P.S. Mistakes will happen. Which would you rather trash - a flash drive, or a floppy disk?
No snowflake in an avalanche feels responsible.

liquidsilver

My os does already boot off a floppy. I just don't want to get stuck into one thing and then later decide to change after long hours of work. I would like to know if writing a usb driver is really that much work. I don't need the space yet, but that won't be forever, and I preferthe reliability of a flash drive. Also the flash drive would be almost entirely for my os, so any mess-ups only require a format, nothing important lost.

I would much prefer to use a flash drive. If a usb driver is just too much, I could consider jumping back into real mode to use bios, but that's a last option. Has anyone tried something similar with a flash drive?

Tedd

Assuming your OS is going to support reading from a floppy, then it's hardly wated work. If you choose to be able to read from other devices, then that's also good.
A usb driver will actually require at least two drivers. The first being one for the usb hub (chipset dependent, not sure how standard they are) and then the one for actually recognizing your particular brand of flash drive and communicating with it. It could conceptually be split into yet more components, but it depends how compact you want to make it (and how flexible.)
On the point of trashing a drive, I meant killing it completely, not just messing up the format.
At this point I would try to get past booting and into the meaty stuff. You can always come back to it when you feel like it and understand devices and how your OS will handle them. Most hobby OSes never make it much past booting, largely from not expecting just how much work is required (and lack of actual design past the point of booting.)
On top of the disk drivers, you will also need support for filesystems, irq management, interrupt handling, exception handling, timing, some form of memory allocation/management... And you'll probably want processes and threads...
And if you manage to do all of this, I would still be suprised if it totalled more than 1.5MB
No snowflake in an avalanche feels responsible.

mnemonic

Hi liquidsilver,

maybe I can help you out with some links:
- http://bootdisk.com/, there you might find a solution which ships with source
- start a search on http://google.com about "usb boot", some interesting stuff showed up there
- as well watch out for linux distributions that are capable of being booted off a usb stick, source is certainly available

Good luck
Be kind. Everyone you meet is fighting a hard battle.--Plato
-------
How To Ask Questions The Smart Way

liquidsilver

I've decided the following: I will use int13 to load my kernel into memory (still in real mode) then the kernel will load a "ramdisk" into memory and only then switch to pmode. This way I can switch between floppy or flash drive without a problem, and I can get my process and memory management done before drivers.  :bg

How can you trash a flash drive? :eek This is making me scared.

BTW: My os is past booting. It has interrupts, exceptions, timer, keyboard input and irq handling. Yes I know it won't get to more than 1MB, but I want to carry it around with me and it's fun dreaming... :bg

Tedd

Aha, the old 'ramdisk' trick eh? :lol It's the way to go in most cases :wink

I can't say I've actively tried to kill a flash drive, but it's entirely possible to destroy most storage devices with a few wrong commands (usually a low-level format - i.e. below the file-system) and then it's very difficult to get it going again (though not impossible, but if you knew what to do, then you wouldn't have killed it in the first place.)

Prepare to re-write much of what you've done previously; and don't be afraid to :U
And also double-check your information, especially for devices. Using other people's examples is useful, but you also end up copying their mistakes. (I looked at cogs a while ago and saw a few :P)

But good luck with it :green2
No snowflake in an avalanche feels responsible.