Page 1 of 1

Suppose neither of my computers has a floppy drive......

Posted: Sat Mar 10, 2007 1:23 pm
by dustpyle_x2
...and I don't want to use up all of my CD-Rs going through the baby steps of OS development. I want to use my usb flash drive to test my stuff. I know my computer can boot from USB, so all I need to know is how I would get my stuff on there and make it bootable. Can anyone help me out?

Posted: Sat Mar 10, 2007 1:47 pm
by muisei
If you are working on UNIX/LINUX like system, there is a 'dd' command.

Example:dd if={mbr file} of=/dev/{your falsh} count=1 This will copy your MBR to the beginning of the flash

Example:dd if={kernel file} of=/dev/{your flash} count={kernel size in 512 byte blocks} seek={where you want to put your kernel} This will copy your kernel

For more info read the man page.
For reading from the flash you have to use int 13h ah=42h BIOS function or some function which doesn't use CHS.

Posted: Sat Mar 10, 2007 5:53 pm
by pcmattman
If you don't have a *nix system, get Cygwin. It's what I use for writing disk images to floppies for testing. It's also useful because it gives you a *nix-style shell on your Windows box.

Posted: Sat Mar 10, 2007 8:27 pm
by Dex
There only one way i have found that work, with all PC that can boot USB.
That is to make your kernel a mz exe or com file, so that it can load from DOS.
Than you put your usb in and let windows see it as a drive, you then format it and click to add sys file (which makes it bootable).
Next you add your exe kernel to the drive, once it boots to dos type the name of your kernel (or you can add it to autoexe.bat), this works with fdd or hdd emulation.
Note: if you go to pmode emultion stops, but if you go back to realmode it starts again.
As i have a pmode and a go back to realmode fdd and hdd drivers, i can read/write to USB keyfob in my OS.

RE: usb kernel boot windows linux rawrite fat32

Posted: Sat Mar 10, 2007 9:23 pm
by Kevin McGuire
(Overall)
Treat the USB drive in Windows or Linux just like it is a floppy drive.

(Detailed)
Dex almost had it I think. The format on the stick is going to be FAT32, and the BIOS should look at the drive as if it is a normal hard disk with a boot sector. You might __try__ http://www.tux.org/pub/dos/rawrite/.


I have never actually done this myself. It is just a suggestion.

Posted: Sat Mar 10, 2007 9:29 pm
by pcmattman
If you have money, go down to a second-hand hardware shop or a wholesaler, find a floppy drive and install it. As humbling as this experience may be, remember that your OS design will help you.

Also look into an emulator (Google: Bochs) and a method of using disk images (Google: vfdwin, winimage, cygwin). Read the Wiki/OSFAQ as well, they have some good information about disk images and emulators.

Re: RE: usb kernel boot windows linux rawrite fat32

Posted: Sat Mar 10, 2007 10:08 pm
by Dex
kmcguire wrote:(Overall)
Treat the USB drive in Windows or Linux just like it is a floppy drive.

(Detailed)
Dex almost had it I think. The format on the stick is going to be FAT32, and the BIOS should look at the drive as if it is a normal hard disk with a boot sector. You might __try__ http://www.tux.org/pub/dos/rawrite/.


I have never actually done this myself. It is just a suggestion.
The format is down to size of fob, so most are formatted as fat16, but it will be called FAT under xp eg: if it says FAT12 its FAT12, if it says FAT32 its FAT32, if it says FAT its FAT16.
Why XP does not like saying FAT16 I do not know. :? .

Posted: Sun Mar 11, 2007 5:30 am
by muisei
You do not need to use neither FAT nor DOS to boot your kernel !

I'm using ext2fs file system and my own bootloder to run the kernel.

Re: Suppose neither of my computers has a floppy drive......

Posted: Sun Mar 11, 2007 5:33 am
by Combuster
dustpyle_x2 wrote:...and I don't want to use up all of my CD-Rs
Ever considered using CD-RWs? :wink:

Posted: Sun Mar 11, 2007 6:02 am
by Candy
Dex wrote:There only one way i have found that work, with all PC that can boot USB.
That is to make your kernel a mz exe or com file, so that it can load from DOS.
Than you put your usb in and let windows see it as a drive, you then format it and click to add sys file (which makes it bootable).
Next you add your exe kernel to the drive, once it boots to dos type the name of your kernel (or you can add it to autoexe.bat), this works with fdd or hdd emulation.
Note: if you go to pmode emultion stops, but if you go back to realmode it starts again.
As i have a pmode and a go back to realmode fdd and hdd drivers, i can read/write to USB keyfob in my OS.
The bios doesn't know anything about the filesystem that you're using on your USB stick, nor if the code in the boot sector is actually bootable. It only checks the 0x55 0xAA signature and loads the rest of it. The code should use the method your bios supplies for accessing the USB stick for loading the rest of the disk, and then you're all set. There is NOTHING that windows can do that you can't do without it.

Posted: Sun Mar 11, 2007 2:19 pm
by Dex
@muisei and Candy, What i am saying is right from my experience, i do not say that the BIOS knows what file sys is on the USB or you need Dos.
But if you want to boot your OS from a USB key fob, from differant PC, the only way to do it is use Dos. Why this is the case is not for to tell you, just try it and see.
You may be lucky, but most likey you will get:

Eg: Try put your boot sector on the usb fob in windows of any hobby OS and booting,
You will most likey get "Operating system missing" ,Than try add sys file (dos) and see the differance ?.
I wish people would try things rather that just read some thing.

Here is some problems you get with your methord.
http://menuet.2.forumer.com/index.php?s ... =1112&st=0

Posted: Sun Mar 11, 2007 3:01 pm
by muisei
I'm developing my OS on a flash drive and I've never encountered such probles.

I've written my own MBR which loads and executes the first 1024 bytes of the ext2fs file system.There is my first stage bootloader which enable A20 gate,create a memory map,reads the kernel from ext2fs,enter to PM and then execute it.

I've tried it on several PCs and it works great on all of them.
If you set your BIOS to emulate a HDD and use INT 13h AH=42h to read from the flash, I don't see why I have to be lucky.

Posted: Sun Mar 11, 2007 5:55 pm
by Dex
Do you use linux to load it to the fob ?.

Posted: Mon Mar 12, 2007 3:47 am
by muisei
Dex, you are right it doesn't boot on all PCs. :shock:
I tested it on 5 laptops and on one quite new desktop PC and everything worked fine.
After your post I decided to test my OS on older PC(about 3 years old).It booted only MBR.I've tried 3 different method to read the block after the MBR and none of the worked.The first method is using the BIOS function int 13h AH=42h, the second is writing CHS data to the HDD ports and the third is writing LBA data to the HDD ports.
I tested them with qemu and all worked.On my laptop only the BIOS function worked.
I think that the problem is in the BIOS.

BTW I'm using FreeBSD 6.1