floppy drives troubles

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
elias

floppy drives troubles

Post by elias »

ive written a boot loader and a small test kernel, but i dont know to write my boot loader to head 0, cylinder 0, sector 1 of the floppy, and how to write the kernl to sector 2. can anyone heolp me? i have access to btoh windows and linux and would like ot know hwo to do it in either OS
Schol-R-LEA

Re:floppy drives troubles

Post by Schol-R-LEA »

There are solutions under both systems but whichever one you choose, just remember: these are potentially dangerous utilities. A mistake with them could mangle your disk drive. Be very careful when using them, and if you are doing the same operation repeatedly (which you probably will), put your invocations of them in a script so as to minimize the risk of a typo.

In Linux, there is a standard utility, dd(1), which can be used to raw-write a boot sector. Assuming you are writing to the file 'bootldr' to fd0, then the arguements should be:

dd if=bootldr of=/dev/fd0 bs=512 count=1

Check the man and texinfo pages for more details on the syntax and usage. It is not a very typical Unix utility, as you can see, and the Jargon File entry on it suggests that the syntax was meant as a joke.

On Windows, there is no standard utility for this purpose, but there are several you can download for free which will work. The two that seem to be the most popular are RawWrite, which comes in both console and GUI versions, and Partcopy, a console program. There are ports of dd as well, one of which I believe can be gotten with DJGPP.

I generally use either dd or partcopy. For partcopy, the command line syntax is:

PARTCOPY <source> <source_offset> <length> <destination> {<destination_offset>}

the <source> argument refers to the file, or disk, where the data should be copied from, and <destination> refers to the file or disk to copy the data to. <source_offset> is the location, in bytes, to begin copying from; the optional <destination_offset>, thus, is the location to begin copying the data to, and <length> is the size of the data to be copied. all of these numbers are in hex.

The batch files I use (with some slight changes) are like this:

makeimage.bat:

Code: Select all

partcopy bootldr 0 200 boot.img 0
partcopy sndstage 0 200 boot.img 200
makedisk.bat:

Code: Select all

partcopy boot.img 0 400 -f0
I build the boot image separately first, then test it under Bochs, before testing it with a live disk. I'll have to adjust the size arguments as the sndstage file grows or changes; later, when I have a file system, it will be removed, as the second stage loader will then be set up as a file, rather than a raw sector.
Mr_Spam

Re:floppy drives troubles

Post by Mr_Spam »

in windows/DOS there is a program that will write specifically to a boot sector, or drive. open the command prompt, type debug c:/yourfilename.bin
then type w 100 0 0 1 if your writing to the boot sector of a floppy.
Schol-R-LEA

Re:floppy drives troubles

Post by Schol-R-LEA »

Thank you for that; it is somewhat embarrassing that I'd forgotten you could do that. Sometimes you just overlook the obvious. :-[
Tom

Re:floppy drives troubles

Post by Tom »

Cool! now I could easily make a install for Windows or DOS for FritzOS. But...i'd have to make the user type in stuff, is there a way to do that debug thing automaticly?
Post Reply