Hi Ladies and Gentlemen,
Some of you may remember may, while some may not, because I wasn't that famous with you guys.

So let me introduce myself before I introduce my problem. That would create a base for you. I am Shikhin Sethi, a 12 year old programmer, with expeience in C, C++, Java and a little of MySQL. Currently I took up Assembly Language. After a while I got on with trying to make up a OS. Believe me, I know it would take upto 4-6 years, and I also know it wouldnt be the next Windows. ;) Also I am sure I would be pretty simplistic with my design.

So I just started with reading up various articles by searching on google, and various other sites. After much reading on the basics, I decided to go practical. :) I found up this site at the end. http://www.brokenthorn.com/Resources/OSDev0.html

Even though this site was based on Floppy Disks, I was pretty sure I would manage to cope up. This hope vanished when I reached the 5 - 6 tutorial. :'(

These both tutorial focused on multi stage bootloaders using floppies, and includes a OEM block for the formatting. Well it couldnt work on CD Rom even when I tried to change the OEM block specification to a CD ROM.

So do you guys have any ideas on what shall I do on developing this mutli stage bootloaders. Probably and ideas on this OEM block. Probably some other good tutorials.

Regards,
Shikhin

Probably the best place to look for information of this type is the OSDev Wiki and its corresponding forums. However, I will add that even there, most of the information on writing your own bootloader assumes floppy disks, as those were for a long time the easiest medium to come by and remain the easiest to work with for booting as the interface is completely standardized.

Note that writing your own bootloader, while informative, is neither necessary nor (in most cases) useful in writing the rest of an operating system; you may be better off using an existing bootloader such as GRUB to load your system, as that will save a great deal of effort and let you focus on the design of the system as a whole, rather than spending a lot of time on the the boot sequence.

Edited 6 Years Ago by Schol-R-LEA: n/a

Hi Schoil-R-LEA,
I also know that generally all Bootloader tutorials are based on floppy diskettes. Thats why I am asking you all guys. I guess you could provide me at least some information on how to make a mutlistage boot loader.

Also, I wanted to write a COMPLETE OS from scratch. I knew, that writing a bootloader, and re-inventing the wheel wouldnt be too useful, still at least, I would know how my OS is being loaded.

I hope you could help me, even though you have helped a alot already. :)

Regards,
Shikhin

If you look at the wiki a bit, you'll find this page on bootable CDs. However, the process they give does require an existing tool (mkisofs, or it's later replacement genisoimage) and basically allows the CD to emulate a floppy disk image. There's a second page that avoids the emulation, but uses GRUB for the loader.

Finally, there is this thread from their forum on how to write ISO images directly.

I need to add one more thing: if you haven't been doing so already, I strongly recommend using the Bochs emulator while developing your system. Not only does it allow you to simulate various sorts of drives using ordinary image files, it also gives you much better turn-around time on testing, and has a built-in debugger. It will let you simulate the OS as if it were running live, before you try running it on actual hardware, and more conveniently than a virtualizer such as VMWare will.

Edited 6 Years Ago by Schol-R-LEA: n/a

Hi,

First of all I wanted to say thank you for all your dear help, especially about the Bochs emulator, since even I knew that I could use a emulator, I couldnt help thinking which to use.

However, I still have a couple of problems with me. First of all, I know how to make a bootable CD, and even though it was kind on your part, it did me no help, whatsoever. I am not asking how to make a bootable CD sir, I am asking how to make a Multistage Bootloader, which would load another bootloader of the CD ROM. I am sure you could help me in this too, and also perhaps provide me with the source code requires for this type of project.

Regards,
Shikhin

After some quick searching I found this on the OSDev Forums. If you scroll down on that page, you'll find a bootloader that (according to the author) can boot from a CD. I haven't tested it, but it seems it should work. It's written for the GNU Assembler, and boots a 16-bit OS. It's not exactly what you're looking for, but it should be enough to get started.

Hi GuitarComet,

I just found that and am currently trying it. I downloaded the GAS assembler for it, and since I dont know even the 'G' of GAS I made some pretty guesses. I know it would be too much, but can I ask someone from our forum to convert it into NASM.

Regards,
Shikhin

I'm not usually using GAS either, and I don't have the time to convert it, but this site shows some examples on differences between Intel and AT&T syntax. The other things you'll need to know is how to convert GAS directives to NASM ones. GAS directives start with a '.' and should be fairly easy to convert. The lines starting with '1:' seem to be local labels. Some instructions reference '$1f' or '1f', which I don't think is a hex value (I'm not sure though). I would believe it's a reference to the next local label. If someone here's better with GAS syntax than me, feel free to correct me.

Thanks GutairComet,
I just downloaded the AS/GAS Assembler and while linking it using Ld it dispalyed a error saying The file has a bad magic number. Guess what it is?

On the other note, my other friend here suggested me to make a emulation. Well I tried doing that and also failed in that too. I dont understand something. When I make the iso using mkisofs by the following command:

mkisofs -r -J -o Boot.iso -b Boot1.bin Demo1

With Boot1.bin being of 512 bytes I get the following error message:

Boot1.bin is of 4 sectors: Genisoimage: Size of bootsector not allowed. [Error not word to word]

Can somebody explain me what I am doing wrong, and how can I make a emulated disk as I have source code for floppy disks easily available. This would solve all my problems. Hope a soon reply as if I can make this Bootloader easily I would get a high budget from my dad and would also gain LOADS of confidence. Please reply as soon as possible.

Regards,
SHIKHIN

The problem with LD seems to have to do with the format of the file you got from GAS. How are you invoking GAS and LD?

Hi GuitarComet,

Here is the commands I used:

as 1.s -o 1.o

ld 1.o -o 1.bin

By the way, can you help me on the emulation part?

Which operating system are you on? When googling for your error message, most results are for the Mac version of LD. Also, what kind of object file is GAS outputting? Open it in a hex editor and check the first characters. Some magic numbers:

ELF - 0x7F 0x45 0x4C 0x46
Mach-O - 0xFE 0xED 0xFA 0xCE
COFF - 0x4C 0x01

If it's not one of these, then post the fist 4 bytes (in hexadecimal).

I have no idea on the emulation part, unfortunately.

Edited 6 Years Ago by GuitarComet: n/a

Hi,

I am using Linux SUSE Enterprise Desktop Edition 11.0

First of all on th emulation part. It didnt work. I made a ISO file, burned it, but it displayed the same Error which I had specified in the file.

For the CD Bootloader part, I had to compile the file again as I had deleted it, and this time I got the following error with LD:

Bootloader.o: In function `_start':
(.text+0x15): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `_start':
(.text+0x28): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `_start':
(.text+0x30): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `_start':
(.text+0x45): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `_start':
(.text+0x4f): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `_start':
(.text+0x58): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `_start':
(.text+0x5c): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `_start':
(.text+0x63): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `_start':
(.text+0x66): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `assume_2k_sector':
(.text+0x6c): relocation truncated to fit: R_386_16 against `.text'
Bootloader.o: In function `assume_2k_sector':
(.text+0x71): additional relocation overflows omitted from the output

I dont know what the problem is. Can any GAS expert guide me here as I want to make this bootloader BADLY. Please help me guys.

Regards,
Shikhin

This article has been dead for over six months. Start a new discussion instead.