Problems with Grub and/or Bochs

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
Jerkko

Problems with Grub and/or Bochs

Post by Jerkko »

I have problems with getting my kernel work with bochs and grub. I don't know what is wrong. I have a floppy image where is Grub and my kernel. Then when I try to boot it nothing happens. Bochs only shows that "Booting from floppy" message. Maybe Bochs just doesn't find the stage1 file?

I use Editdisk to edit my floppy images. Should I do something to that stage1 file that Bochs finds it as a boot file?

I have also tried to use others OS's floppy images and replaced the kernel with my own one and I have probably done the rigth setting also to menu.ls. With some images it crashes. After that there reads in bochs logfile:
00012730945i[BIOS ] FATAL: floppy recal:f07: ctrl not ready
00012731244p[BIOS ] >>PANIC<< BIOS panic at rombios.c, line 1558
I think these lines has something to do with crashing.

I have read my kernels code through many times and there should not be any bugs or at least I haven't noticed one.

I have noticed that the size of grub's stage2 file is different in different OS's floppy images. Does that matters?
AR

Re:Problems with Grub and/or Bochs

Post by AR »

Bochs is a virtual PC, to that end it has its own BIOS, and like a real BIOS it has absolutely no understanding of files whatsoever, all it sees are disk sectors.

IIRC Stage1 is the bootsector, Stage1.5 is an intermediate loader for finding Stage2 in the filesystem, Stage2 is the bootloader itself.

You may want to try a different GRUB Image, or if you're on Linux you can build your own. The other possible problem is that you are trying to use a real floppy, and the floppy is physically damaged.
Jerkko

Re:Problems with Grub and/or Bochs

Post by Jerkko »

Should I use the Stage1.5 or not? I haven't use or even seen anyone using it.

How does Bochs finds the stage1 from FAT12 formatted floppy disk or image? Should the stage1 be in the first boot sector (first 512 bytes) or can it be in any place on the disk?
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Problems with Grub and/or Bochs

Post by Solar »

It is imperative that GRUB's stage1 is written to sector 1 by GRUB, and that stage2 (or stage1_5 if you use them) is not touched (or at least, not moved on disk) after stage1 was written.

stage1 gets the information where to find stage2 encoded upon installation. Not using the GRUB installation process means stage1 uses invalid information. Moving stage2 without reinstalling stage1 means stage1 uses invalid information.
Every good solution is obvious once you've found it.
Jerkko

Re:Problems with Grub and/or Bochs

Post by Jerkko »

What do you Solar mean with Grub installation process? I think that I haven't heard about that.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Problems with Grub and/or Bochs

Post by Solar »

Check out the FAQ page on GRUB. It will lead you through the installation process of GRUB stage1 and stage2 using two floppies, including explanations.

I have this nagging suspicion that you don't have really understood yet what a bootsector does...
Every good solution is obvious once you've found it.
Tora OS

Re:Problems with Grub and/or Bochs

Post by Tora OS »

ok.....I got a suggestion.


http://osdever.net/bkerndev/Sources/dev_kernel_grub.img

Download that disk image. Reconfiguer GRUB to load your kernel by editing A:\BOOT\GRUB\MENU.LST

A typical entry for a kernel would look like this:

Code: Select all

title   Your OS Title Here
        root    (fd0)
        kernel  /kernel.bin
Replace "Your OS Title Here" with the name of your OS. This will be displayed on the GRUB loader menu.

"root (fd0)" represents that the root will be the root directory of Floppy Disk 0 (also known as A: in DOS and Windows). [NOTE: I think thats what it does]

"kernel /kernel.bin" represents the name of your kernel file relative to the root directory of the drive. So A:\KERNEL.BIN would be /KERNEL.BIN, and A:\KERNEL\TORAOS.BIN would be /KERNEL/TORAOS.BIN.

Hope this helps some...and good luck on your OS project.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Problems with Grub and/or Bochs

Post by Solar »

I'm not sure if it's good advice to skip a step you haven't understood...

...or rather, I am sure that it isn't good advice. It is one thing to use a GRUB image because it's convenient, it's another thing to do it because you don't know how to install a bootsector and why...

Not wanting to offend Jerkko here, but some day he will want other users to install his OS, and he should know what they have to do...
Every good solution is obvious once you've found it.
Tora OS

Re:Problems with Grub and/or Bochs

Post by Tora OS »

ok then..a change in my help then:

Just read the OS-FAQ Wiki page on GRUB or this:


http://osdever.net/tutorials/grub.php?the_id=5


which is where i learned about using GRUB.
Freanan

Re:Problems with Grub and/or Bochs

Post by Freanan »

About stage 1.5:
You need it if you want to use a filesystem.
For example i am using a floppy image that is formatted with ext2.
It has stage 1 in its bootsector and uses the stage 1.5 file which corresponds to ext2 to load the kernel file.

Maybe you want to use the loop-device to be able to access your floppy like real hardware... then you can format the floppy with mke2fs and install grub on it via the grub-shell?
Jerkko

Re:Problems with Grub and/or Bochs

Post by Jerkko »

I got the working disk image, but it still crashes when I try to start my kernel. So there is something wrong in my kernel.

Is it possible to do that GRUB installation for floppy images in Bochs ? I don't (yet) have Linux on my use. I use Win98 and finding good tools for it is hard.

And I have quite good understand about it what bootsector does, how it works and I am all the time studying more and more about.
AR

Re:Problems with Grub and/or Bochs

Post by AR »

Stage1.5 is a pretty much redundant feature of GRUB, it seems to have been brought about by the fact that the GRUB Stage2 is relatively large and they decided that they didn't want to embed all of it into a hidden section of the disk. I personally couldn't care less and would be happy to embed the whole Stage2 directly as it's less then a couple of hundred KB, and it isn't about to be changed or moved [otherwise it wouldn't boot] so there is no point to have it as a file to begin with (provided the tool would be smart enough to install a newer version over the older one when I upgraded it).
Freanan

Re:Problems with Grub and/or Bochs

Post by Freanan »

Jerkko wrote: Is it possible to do that GRUB installation for floppy images in Bochs ? I don't (yet) have Linux on my use. I use Win98 and finding good tools for it is hard.
Yes it is possible...
Configure grub to use two floppy images.
First install grub without filesystem on one image (follow the instructions on the osdever.net tutorial "using grub"), by copying stage1+stage2 into one image file and rawrite it to the beginning of the image.
Format the other image with a filesystem that grub understands (there must be a stage1.5 file for that fs) and create the dirs boot and boot/grub on it (don't quite know how to do this without linux and the loop device) put stage 1, 2 and the correct 1.5 as well as a grub config file to the latter dir and put you kernel somewhere.
Boot the first floppy
Install grub on the second one again according to "using grub".
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Problems with Grub and/or Bochs

Post by Solar »

...just like it says in the FAQ Wiki page I linked above. I never had to use stage1_5 so far - not on FAT floppies, ext2fs or reiserfs /boot mountpoints, not for chainloading my own bootsector from file. On your average system, you can just completely ignore stage1_5.

BTW, the FAQ page links to that nice ready-made GRUB disk image I created... all you have to do is mount it, copy your kernel binary to it, and edit the menu file.
Every good solution is obvious once you've found it.
Post Reply