Having trouble booting my kernel in an emulator...

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
monsterhunter445
Posts: 20
Joined: Sun Jan 02, 2011 4:46 pm

Having trouble booting my kernel in an emulator...

Post by monsterhunter445 »

Hi, I'm new to OS development but not new to programming. I have a question after I've compiled my NASM code, and C code, and link them together to a *.bin file. How do I boot it with GRUB?

PS. I don't have a floppy drive, and the emulator I'm using is Bochs. Also I've attached the Kernel.bin which is compressed as a tarball.
Attachments
Kernel.tar
This contains the Kernel.
(12.5 KiB) Downloaded 36 times
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Having trouble booting my kernel in an emulator...

Post by gerryg400 »

monsterhunter445 wrote:Hi, I'm new to OS development but not new to programming. I have a question after I've compiled my NASM code, and C code, and link them together to a *.bin file. How do I boot it with GRUB?

PS. I don't have a floppy drive, and the emulator I'm using is Bochs. Also I've attached the Kernel.bin which is compressed as a tarball.
If your kernel is multiboot compliant there should be no problem. What happens when Grub tries to load it ?
If a trainstation is where trains stop, what is a workstation ?
monsterhunter445
Posts: 20
Joined: Sun Jan 02, 2011 4:46 pm

Re: Having trouble booting my kernel in an emulator...

Post by monsterhunter445 »

Its not that GRUB can't boot my kernel, is just that I don't know how to get GRUB to boot my kernel. I've the GRUB.img which is the floppy disk image that contains GRUB, and I have the binary file that contains my kernel. So, my question is how do I use GRUB to boot my kernel. Do I have to link GRUB with my Kernel, or is it something else, because all the tutorials I've read only teaches you how to write a bootloader and a kernel, but not how to load it in an emulator or in an actual computer.

PS. Sorry for the neophyte question, I also know that the command 'kernel' loads the kernel with GRUB.
gerryg400
Member
Member
Posts: 1801
Joined: Thu Mar 25, 2010 11:26 pm
Location: Melbourne, Australia

Re: Having trouble booting my kernel in an emulator...

Post by gerryg400 »

If a trainstation is where trains stop, what is a workstation ?
monsterhunter445
Posts: 20
Joined: Sun Jan 02, 2011 4:46 pm

Re: Having trouble booting my kernel in an emulator...

Post by monsterhunter445 »

Thanks for those links they were very helpful, but one more question. No I've decided to boot my kernel in an emulator called QEMU because it comes built with its very own bootloader. So I used the command below:

Code: Select all

qemu -L . -kernel Kernel.bin -boot c
And I got this error:

Code: Select all

A disk image must be given for 'hda' when booting a Linux kernel
So what does this error mean...oh and thanks for the help I appreciate it.
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: Having trouble booting my kernel in an emulator...

Post by Tosi »

I'm not sure since I don't use QEMU, but when you pass the option "-boot c", QEMU expects there to be a harddrive with the letter C, which becomes hda under linux.

What you need to do is use a loopback device to mount your grub image, put your kernel on the floppy and edit the menu.cfg to tell GRUB where your kernel is.
In case you are using Windows there are tools to create virtual drives as well. All of this is documented on the wiki.
Post Reply