Booting GRUB with a Basic Kernel using QEMU

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
romasi
Posts: 2
Joined: Wed Aug 12, 2009 5:43 am

Booting GRUB with a Basic Kernel using QEMU

Post by romasi »

I created a floppy.img file using the cat command with the files: stage1, stage2 (GRUB), pad, and kernel.bin (created from link.ld, kernel.o (from kernel.c) , and start.o (from start.asm) ) given by one of the tutorials. However, when I use QEMU to load the floppy.img file "qemu -fda floppy.img", input "kernel 200+18" at the GRUB command line (as the author instructed) and input "boot" it hangs. I've even divided the number of bytes used by kernel.bin by 512 and rounded to the nearest digit to make it "kernel 200+10" and it still hangs. I'm not sure if there is a command argument I'm suppose to use to print out the error and if so I will gladly post that information as well.

I'm quite new to OS and bootloader programming and would rather just deal with the kernel at this point then having to implement a custom bootloader when I think GRUB is great already.

Thanks.
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Booting GRUB with a Basic Kernel using QEMU

Post by gravaera »

You haven't really given sufficient information, you know. After you load your executable, nothing is really supposed to happen except for what you programmed your executable to do.

You should have stated why you believe that the fact that nothing displays is a problem (for example: "I have created a basic vga_text_mode driver, and it's supposed to clear the screen on load, but nothing happens"). You won't see any visible changes until you make them happen. From the information you've given, I can't see anything wrong with your setup.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: Booting GRUB with a Basic Kernel using QEMU

Post by jal »

creating an image by using cat? that seems mightily weird. are you sure everything is the right size and such?


JAL
romasi
Posts: 2
Joined: Wed Aug 12, 2009 5:43 am

Re: Booting GRUB with a Basic Kernel using QEMU

Post by romasi »

The kernel is suppose to give option for clearing the screen and entering characters. I am not prompted for any of these things. Furthermore, an OS, regardless of how basic it is, would be worthless if it did not provide some sort of functions to validate that it is working (especially as a tutorial) so I highly doubt it's suppose to do nothing. Lastly, the tutorial stated using the cat command to create the floppy.img (under linux obviously). Total size of floppy.img came out to being roughly 107KB.

PS: You can't win a flame war, either side will continue thinking they're right. Been there and done that. Lol.
torshie
Member
Member
Posts: 89
Joined: Sun Jan 11, 2009 7:41 pm

Re: Booting GRUB with a Basic Kernel using QEMU

Post by torshie »

You should try to let your kernel only print something on the screen, because that's MUCH easier than prompt you to enter some characters.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Booting GRUB with a Basic Kernel using QEMU

Post by neon »

romasi wrote:Furthermore, an OS, regardless of how basic it is, would be worthless if it did not provide some sort of functions to validate that it is working (especially as a tutorial) so I highly doubt it's suppose to do nothing.
Not necessarily. For a tutorial. the tutorial might have focus on booting itself, which is enough material to warrant a basic bootable kernel or bootloader that does nothing. This is one of the reasons we need to ask what the program is supposed to do - else we will not know.
flame war, either side will continue thinking they're right. Been there and done that. Lol.
No one here is starting a flame war.

If you can point us to the tutorial that you are using and its demo, that may help.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
gravaera
Member
Member
Posts: 737
Joined: Tue Jun 02, 2009 4:35 pm
Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.

Re: Booting GRUB with a Basic Kernel using QEMU

Post by gravaera »

He's using the Bare Bones Tutorial. That's where he got the idea about the cat stage1 stage2 pad my_os.bin >floppy.img from.

It works, since I used it in the first month or so of my own Dev-ing.

@OP: A real, purpose driven kernel would, yes, have self checks and whatnot, but not a tutorial stub...and definitely not one contained in a tutorial titled "OSDev BARE BONES".
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Kitsune
Posts: 20
Joined: Wed Aug 05, 2009 7:13 pm

Re: Booting GRUB with a Basic Kernel using QEMU

Post by Kitsune »

How do you attempt to print to the screen? Some code would definitely help with figuring out what's going wrong.
tharkun
Member
Member
Posts: 51
Joined: Sat Mar 21, 2009 1:29 pm
Location: Ireland

Re: Booting GRUB with a Basic Kernel using QEMU

Post by tharkun »

I don't think it's hanging, I think he's just looking in the wrong place.
An 'A' should appear in the top left corner of the screen, not at the cursor position.
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Booting GRUB with a Basic Kernel using QEMU

Post by egos »

Maybe you will use a fully ended FS instead of that one. I can recommend to do this by using fasm.
Making the GRUB auxiliary disk
Elf vs Binary?
Attachments
GrubOnFloppy.zip
(53.73 KiB) Downloaded 170 times
If you have seen bad English in my words, tell me what's wrong, please.
Post Reply