Page 1 of 3

building OS from scratch (HELP ME .......)

Posted: Tue Dec 16, 2003 9:27 am
by neuRopac
???

I'm new to OS programming, but want to make a small (toy) OS of my own supporting unitasking and which would run from a CD-R/FDD and would have some very basic applications as a text editor, calculator etc.. the files would be stored on to a FDD (since HDD may be complex, i think so..)...
PLease Please help me in this regard...

Re:building OS from scratch (HELP ME .......)

Posted: Tue Dec 16, 2003 10:03 am
by Pype.Clicker
well, probably sneaking around .:QuickLinkz:. thread and sites like Bona Fide OSDev and Operating System Resource Center will help you starting up (finding what's needed, how things actually work,etc) ...

Check out for pmode informations (Intel Manual), keyboard controller and text mode video controller, Floppy/Hard disk (unlike what you might think, Hard disk are easier to deal with, but you'll need an old "crash" disk (i.e. that has nothing important on it ;) in a test machine ...

Using GRUB to load your OS and using BOCHS for very first tests will also save you time ...

Feel free to come back if you have any more precise questions ...

Re:building OS from scratch (HELP ME .......)

Posted: Tue Dec 16, 2003 10:17 am
by neuRopac
Thank you very much sir for that quick reply...

I've already tried the bonafide sites and the OS Journal sites,
the documentations were fine. i even compiled, linked and made a flat binary file but i'don't know how to test them,
i wrote the .bin file into the FDD using the dd command in linux

dd if=<filename>.bin of=/dev/fd0

i then restarted the system and inserted the Floppy into the FDD by setting FDD as the 1st bootable disk inthe BIOS settings.

but it didn't workout and the system did not boot..
the screen was blank and i had to restart the system...
this id the thing going on for me all the time...
whatever may be the website where i've referred...

please help me in this regard...

i am a Dummy as of now and don't know how to proceed(actually start) ..

please reply...

Re:building OS from scratch (HELP ME .......)

Posted: Tue Dec 16, 2003 10:55 am
by mr. xsism
you need a bootloader to load that binary. We have some examples and tutorials on www.osdever.net (BFosdev) or you can try www.osdever.net/halfix wich has old yet slightly buggy code of my OS project. There are also numerous people on this board that are willing to help out with providing you examples and such. :D

Re:building OS from scratch (HELP ME .......)

Posted: Wed Dec 17, 2003 1:56 am
by Pype.Clicker
http://osdev.neopages.net/tutorials/hel ... ?the_id=85 may help you understand what has to be done ...

You may also simply get a GRUB bootdisk and put your kernel in a directory on it, then boot GRUB and on the small command line type

root (fd0)
kernel <yourkernelfile>
boot

call "info grub" on a Linux shell for more info ...

Re:building OS from scratch (HELP ME .......)

Posted: Wed Dec 17, 2003 7:19 am
by neuRopac
Hello... :-) ...
    ??? ??? ::) i tried to download grub, extracted the file, the final file comes to 3.3 MB how do i copy this to the floppy disk.. since it is only 1.44MB. tell me a way to get the Grub floppy....

Keep replying, since i'm a student and a beginner....

Re:building OS from scratch (HELP ME .......)

Posted: Wed Dec 17, 2003 7:56 am
by Pype.Clicker
i dunno what you extracted nor where you get it from, but i would suggest you download
http://www.gnu.org/software/grub/grub-0 ... -pc.tar.gz,

copy the 'boot' directory of this archive in a FAT12 formatted floppy
(see man mkdosfs or format A: using MS-DOS/windows ...),

and then follow instructions on http://www.gnu.org/software/grub/manual ... stallation

you may also create a "kernel" directory on the floppy and put your kernel files there ...

Re:building OS from scratch (HELP ME .......)

Posted: Wed Dec 17, 2003 8:00 am
by Pype.Clicker
There's also a nice tutorial on http://osdev.berlios.de/grub.html ... personnally i haven't tried to follow it yet, but it looks valuable.

If anyone else has other GRUB tutorials to provide, feel free ... i'm not really what Tim would call a "Gnu Grub Guru" ...

Re:building OS from scratch (HELP ME .......)

Posted: Wed Dec 17, 2003 8:07 am
by Tim
GRUB is the One True Bootloader :).

Follow the GRUB tutorial that Pype posted and you shouldn't have any problems. But realise that no boot loader will be as easy to install as dumping one binary file onto a disk. You will always need to put a boot sector in the first sector, sometimes a second stage loader somewhere else, and the kernel and modules and drivers and apps elsewhere.

Re:building OS from scratch (HELP ME .......)

Posted: Wed Dec 17, 2003 10:03 am
by neuRopac
Ya ;D , now i've got the right thing... 8)
thank you very much...
please keep on guiding on further and help me to complete my project...
tell me do i have to learn ALP to proceed further
i'm pretty good in C (I believe) is that enough, or whatelse do i have to learn to complete my project...
keep writing...

Re:building OS from scratch (HELP ME .......)

Posted: Wed Dec 17, 2003 12:17 pm
by Tim
No, you don't need to know any ALP for OS development. However, learning some assembler (ASM) would be useful.

Re:building OS from scratch (HELP ME .......)

Posted: Thu Dec 18, 2003 3:30 am
by neuRopac
i found a tutorial named 'Making a simple c kernel' at
'www.osdever.net/tutorials/basickernel.php?the_id=12#notes'
as the tutorial said i followed all things except
option'-f aout' instead i used '-f elf' because it caused some error...
i got 'kernel.bin' file sizing 4.0 kb that contains program to write string to a screen...


after that i downloaded grub .....
actually i used two floppies to load my kernel,
i made first floppy as GRUB bootdisk .....]
and in second floppy i placed my kernel.bin' file into directory named 'kernel' ...

i booted my system using GRUB bootdisk..
then the following happened . .

* i got the grub prompt (grub>)
* i typed
grub> root (fd0)
* i got
-file system is fat,using whole disk

grub>kernel /kernel/kernel.bin
*i think i got
-error 13 : invalid or unsupported executable file format

i dunno why this happens . . . .
pls pls pls do help me out . . . . . . . . .

Re:building OS from scratch (HELP ME .......)

Posted: Thu Dec 18, 2003 4:02 am
by Pype.Clicker
what happens is that GRUB is able to load a plain ELF but not a plain A.OUT. If you're using A.OUT format (more likely because you're under windows or because your platform uses 'elf-i386' rather than 'elf'), you need to provide a multiboot header to your kernel.

hint: use "ld --help" to know what are the supported targets
on my linux, i need have

Code: Select all

ld: supported targets: elf32-i386 a.out-i386-linux efi-app-ia32 elf32-little elf32-big elf64-x86-64 elf64-little elf64-big srec symbolsrec tekhex binary ihex trad-core
ld: supported emulations: elf_i386 i386linux elf_x86_64
ld: emulation specific options:
so if i'm trying to use "elf" the compiler toolchain do not know if i want elf32-little, elf32-big, etc.

Re:building OS from scratch (HELP ME .......)

Posted: Thu Dec 18, 2003 5:27 am
by neuRopac
sir ,
thank you for your quick reply ....
but i tried to understand what u've said,but in vain . . . . . . . .::)
could u pls explain me that. i'm really tensed.
waiting for the earliest reply from you . . . . . . . . ::)

Re:building OS from scratch (HELP ME .......)

Posted: Thu Dec 18, 2003 5:47 am
by Tim
I think you need to:
1. Sit down
2. Relax
3. Get a clue

Go through the OS development sites mentioned in the QuickLinks thread. Read what is written there. Make sure you understand it. Download other peoples' operating systems. Understand how they work. Then come back here with any questions you have.