Trouble booting kernel with Grub legacy

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.
depletionmode
Posts: 16
Joined: Sun Oct 20, 2013 1:28 pm

Trouble booting kernel with Grub legacy

Post by depletionmode »

I'm trying to boot my kernel based off the Bare Bones tutorial with Grub legacy but I'm getting error 13.

Ive checked the kernel binary and the multi boot header is at 0x1000 (ie 4K)

In my Grub config I've got:
root (hd0,0)
kernel /kernel.bin

I've tried changing the command to:
multiboot /kernel.bin

But I I don't think my version of grub understands the multiboot command.

It boots fine in QEMU with -kernel

I've tried tons of stuff but to no avail. What should I be doing to get grub legacy to boot it?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Trouble booting kernel with Grub legacy

Post by egos »

First of all look at Grub_Error_13 and show your kernel image/dump of Multiboot header. Also I can try to load your kernel in my environment.

If your kernel is located on the same disk/partition where grub was booted from, try to drop out "root (hd0,0)". For example:

Code: Select all

title Link 0.52
kernel /system/link.os system
module /system/link.fs
If you have seen bad English in my words, tell me what's wrong, please.
depletionmode
Posts: 16
Joined: Sun Oct 20, 2013 1:28 pm

Re: Trouble booting kernel with Grub legacy

Post by depletionmode »

Thanks egos, I'd really appreciate you taking a look. :)

I took a look at that wiki page. My kernel *seems* to conform...

Kernel is attached. It's just a simple kernel with basic PCI and uart-over-pci driver (which most likely doesn't work - it's my first go at it :)).

The multiboot header looks like this:

Code: Select all

00001000 02 B0 AD 1B 03 00 00 00 FB 4F 52 E4
Attachments
kernel.zip
(1.5 KiB) Downloaded 41 times
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Trouble booting kernel with Grub legacy

Post by egos »

Your kernel was loaded successfully in my invironment (except it stops at 0x00000000001002f0>> jmp .-2 (0x001002f0) : EBFE). So I think the problem in the loader. Try this version of Modified GRUB with Yoda's stage 0/stage 1 boot loaders (search on this forum).

Edited. Link updated.
Last edited by egos on Sun Apr 20, 2014 2:15 am, edited 2 times in total.
If you have seen bad English in my words, tell me what's wrong, please.
depletionmode
Posts: 16
Joined: Sun Oct 20, 2013 1:28 pm

Re: Trouble booting kernel with Grub legacy

Post by depletionmode »

Thanks for testing!

I guess something must be up with the version of Grub I'm using. Issue is it's a dev board and getting a new version of Grub on to it isn't so easy (resident on SPI and needs to be compiled from sources I don't have to support the platform).

Is there any grub command that I can use to get Grub to boot an ISO?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Trouble booting kernel with Grub legacy

Post by egos »

Are you interesting exactly in GRUB command? Or just how to get bootable ISO mage with GRUB Legacy/your kernel? If second one then you can use first command (where mkisofs is used) from my post in this topic.
If you have seen bad English in my words, tell me what's wrong, please.
depletionmode
Posts: 16
Joined: Sun Oct 20, 2013 1:28 pm

Re: Trouble booting kernel with Grub legacy

Post by depletionmode »

Using Grub command to do it.

I already can get the kernel all packaged up with Grub into an ISO.
What I was thinking was that if I'm having trouble getting this strange custom Grub booting my kernel directly, maybe I can somehow get it to boot the ISO (and thereby pass it off to the Grub instance on the ISO itself which has no trouble booting my kernel.)...
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Trouble booting kernel with Grub legacy

Post by egos »

GRUB cannot see CD if it's booted not from CD. But you can try to load GRUB 2 (it has Multiboot entry point) by GRUB Legacy, and then to load your kernel by GRUB 2. If it will work I can add Multiboot entry point in my Modified Grub (Legacy) later (to use following boot sequence: GRUB Legacy -> my Modified GRUB Legacy -> your kernel). So put GRUB 2 into /boot/grub/i386-pc and edit configuration files:

menu.lst

Code: Select all

title Run GRUB 2
kernel /boot/grub/i386-pc/core.img
grub.cfg

Code: Select all

menuentry "Run my kernel" {
multiboot /kernel.bin
}
You can take GRUB 2 here:
sys-grubldr-2.13-original-core.zip
sys-grubldr-2.13-compact-add.zip

Edited. Links updated.
Last edited by egos on Sun Apr 20, 2014 2:14 am, edited 2 times in total.
If you have seen bad English in my words, tell me what's wrong, please.
depletionmode
Posts: 16
Joined: Sun Oct 20, 2013 1:28 pm

Re: Trouble booting kernel with Grub legacy

Post by depletionmode »

Thanks. I gave it a go. Have error 13 when trying to load Grub 2's core.img. It seems that they've compiled a version of Grub without multiboot support or something...?

I'm checking with them...

What format is a Linux Kernel in? It seems to boot that fine... Is there any way to get my little kernel to be like that? :)
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Trouble booting kernel with Grub legacy

Post by egos »

depletionmode wrote:It seems that they've compiled a version of Grub without multiboot support or something...?
:o
What format is a Linux Kernel in?
Linux kernel :wink:
It seems to boot that fine... Is there any way to get my little kernel to be like that? :)
OK, I will try to convert GRUB into Linux kernel format. Can you build your kernel in raw binary format?
If you have seen bad English in my words, tell me what's wrong, please.
depletionmode
Posts: 16
Joined: Sun Oct 20, 2013 1:28 pm

Re: Trouble booting kernel with Grub legacy

Post by depletionmode »

egos wrote:OK, I will try to convert GRUB into Linux kernel format. Can you build your kernel in raw binary format?
Thanks! Raw binary as in http://forum.osdev.org/viewtopic.php?f=1&t=2401?
I'll get that done... What bootloader can load this?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Trouble booting kernel with Grub legacy

Post by egos »

depletionmode wrote:Raw binary as in http://forum.osdev.org/viewtopic.php?f=1&t=2401?
Yes. Base address 0x100000 would be preferable too.
What bootloader can load this?
Raw binary can be useful to convert it into Linux kernel format (to load your kernel by your strange boot loader directly).

But check this image first. Is it loaded by your boot loader?
If you have seen bad English in my words, tell me what's wrong, please.
depletionmode
Posts: 16
Joined: Sun Oct 20, 2013 1:28 pm

Re: Trouble booting kernel with Grub legacy

Post by depletionmode »

That image doesn't seem to be loaded by my bootloader :( "cannot read the linux header"

I've attached the flat kernel @ 0x100000.
Attachments
kernel-flat.zip
(1.54 KiB) Downloaded 35 times
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Trouble booting kernel with Grub legacy

Post by egos »

Check this image.

Show first kb of your Linux kernel (that is loaded successfully by your boot loader).
If you have seen bad English in my words, tell me what's wrong, please.
depletionmode
Posts: 16
Joined: Sun Oct 20, 2013 1:28 pm

Re: Trouble booting kernel with Grub legacy

Post by depletionmode »

I left the board at work so I can't check until tomorrow.

I've attached 1kb of my kernel...
Attachments
linux-kernel0001.zip
(828 Bytes) Downloaded 34 times
Post Reply