OSDev.org

The Place to Start for Operating System Developers
It is currently Tue Sep 17, 2019 3:00 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: [SOLVED] Need help with GRUB
PostPosted: Fri Aug 23, 2019 9:36 am 
Offline

Joined: Mon Apr 29, 2019 1:52 am
Posts: 8
So I've been trying to boot a sample "hello world" kernel with GRUB2 and I've been encountering some issues.
I created the disk image (inside virtualbox) following this: https://wiki.osdev.org/GRUB
I added the kernel image to /mnt/boot and added grub.cfg to /mnt/boot/grub

grub.cfg contains :
Code:
menuentry "sample" {
    multiboot /boot/kernel
    boot
}


What happens is that it boots to a grub prompt, not to the kernel. This happens when I try to do it manually after:
Image

I've tried searching for the issue, but didn't find anything. I hope someone can help me out and point me in the right direction.
Thank you


Last edited by 0xd3ba on Fri Aug 23, 2019 2:24 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Need help with GRUB
PostPosted: Fri Aug 23, 2019 9:40 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3465
Location: Chichester, UK
The message is saying that there is something wrong with your kernel image file (it's too short). With no details of this file it's difficult to know what the problem is, or why.

It would help if you linked to a repository of your source code and the exact instructions that you used.


Top
 Profile  
 
 Post subject: Re: Need help with GRUB
PostPosted: Fri Aug 23, 2019 11:34 am 
Offline

Joined: Mon Apr 29, 2019 1:52 am
Posts: 8
iansjack wrote:
The message is saying that there is something wrong with your kernel image file (it's too short). With no details of this file it's difficult to know what the problem is, or why.

It would help if you linked to a repository of your source code and the exact instructions that you used.


It doesn't contain much - just multiboot stuff and 2 instructions (movl $0xabcdabcd, %eax and hang: jmp hang ) to see if the code's executing or not.
However I don't feel that's what causing the issue though.


Top
 Profile  
 
 Post subject: Re: Need help with GRUB
PostPosted: Fri Aug 23, 2019 11:52 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3465
Location: Chichester, UK
Well, if you want to keep it secret that's fine.

I hope you manage to find the solution to your problem.


Top
 Profile  
 
 Post subject: Re: Need help with GRUB
PostPosted: Fri Aug 23, 2019 1:34 pm 
Offline

Joined: Mon Apr 29, 2019 1:52 am
Posts: 8
iansjack wrote:
Well, if you want to keep it secret that's fine.

I hope you manage to find the solution to your problem.


Huh, like I've mentioned there's nothing much except the multiboot header and the 2 instructions. Its just that I didn't feel like it's worth writing it down (as the code is trivial)
Anyways -

Code:
.code32
.section .text
.globl _start

MB_MAGIC = 0xe85250d6
MB_ARCH = 0
MB_HLEN = mbend - mbstart
MB_CHKSUM = -(MB_MAGIC + MB_HLEN)

.p2align 3
mbstart:
    .long MB_MAGIC
    .long MB_ARCH
    .long MB_HLEN
    .long MB_CHKSUM

    .word 0
    .word 0
    .long 8
mbend:

_start:
    movl $0xabcdabcd, %eax
hang: jmp hang



EDIT
I managed to solve the problem. The issue was that the executable was a raw binary (--oformat=binary set during linking) instead of an elf executable


Top
 Profile  
 
 Post subject: Re: [SOLVED] Need help with GRUB
PostPosted: Fri Aug 23, 2019 3:01 pm 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3465
Location: Chichester, UK
I'm glad you solved your problem.

Perhaps you can understand now why asked to see what instructions you had used to produce your kernel. Just asking "what's wrong" without showing what you have done is a very difficult question to answer.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group