OSDev.org

The Place to Start for Operating System Developers
It is currently Sun Sep 20, 2020 6:15 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: GRUB Error 7 Troubles
PostPosted: Sat May 14, 2011 7:22 pm 
Offline
Member
Member
User avatar

Joined: Sun May 08, 2011 9:03 am
Posts: 56
Hi, I'm new to this forum! :D

Anyway, I was developing an operating system under DJGPP (following Bran's Kernel Development Tutorial) and it worked until I had to switch to using FreeDOS (due to getting a new 64 bit computer). Whenever I try to run it, I always get GRUB Error 7.

My linker script:
Code:
OUTPUT_FORMAT("binary")
ENTRY(start)

SECTIONS {
  .text 0x0100000 : {
    code = .;
    *(.text)
    . = ALIGN(4096);
  }

  .data : {
    data = .;
    *(.data)
    . = ALIGN(4096);
  }

  .bss : {
    bss = .;
    *(.bss)
    . = ALIGN(4096);
  }

  end = .;
}


And my assembler file:
Code:
[BITS 32]
[extern code]
[extern bss]
[extern end]
[extern _main]
[global start]

; This part MUST be 4byte aligned, so we solve that issue using 'ALIGN 4'
ALIGN 4
mboot:
    ; Multiboot macros to make a few lines later more readable
    MULTIBOOT_PAGE_ALIGN        equ 1<<0
    MULTIBOOT_MEMORY_INFO       equ 1<<1
    MULTIBOOT_AOUT_KLUDGE       equ 1<<16
    MULTIBOOT_HEADER_MAGIC      equ 0x1BADB002
    MULTIBOOT_HEADER_FLAGS      equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO | MULTIBOOT_AOUT_KLUDGE
    MULTIBOOT_CHECKSUM  equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
    EXTERN code, bss, end

    ; This is the GRUB Multiboot header. A boot signature
    dd MULTIBOOT_HEADER_MAGIC
    dd MULTIBOOT_HEADER_FLAGS
    dd MULTIBOOT_CHECKSUM
   
    ; AOUT kludge - must be physical addresses. Make a note of these:
    ; The linker script fills in the data for these ones!
    dd mboot
    dd code
    dd bss
    dd end
    dd start

_________________
Programmer and security enthusiast
DarkSide OS Kernel

Those who do not understand Windows NT are doomed to criticize it, poorly.


Last edited by Marionumber1 on Thu Dec 29, 2011 9:10 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Sun May 15, 2011 1:14 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1097
Location: Tartu, Estonia
Since DJGPP is pretty outdated, you might consider using a GCC Cross-Compiler instead. It makes life much easier.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Sun May 15, 2011 6:16 am 
Offline
Member
Member
User avatar

Joined: Sun May 08, 2011 9:03 am
Posts: 56
I did build one in Cygwin, and it gets me Error 7, 13, or 28 when I tried to use it.

_________________
Programmer and security enthusiast
DarkSide OS Kernel

Those who do not understand Windows NT are doomed to criticize it, poorly.


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Sun May 15, 2011 7:12 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1097
Location: Tartu, Estonia
That looks like a problem with the boot image. How do you create the boot image? Are you booting from a disk image or a real floppy / CD / HDD? Are you booting a real computer or a virtual one, such as Bochs, QEMU, VBox...? Which GRUB version are you using?

Just one quick remark about your multiboot header: In which section does it end up? Did you check that it is placed somewhere in the first 8k of the kernel binary? If not, GRUB will complain and give you an error 13.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Sun May 15, 2011 7:16 am 
Offline
Member
Member
User avatar

Joined: Sun May 08, 2011 9:03 am
Posts: 56
I was creating an ELF with my cross compiler (i586-elf-xxx). I was using AS because LD wouldn't recognize the format of a NASM output file. And I took my ELF file, put it in /boot, and used GRUB legacy to load it on real hardware.

_________________
Programmer and security enthusiast
DarkSide OS Kernel

Those who do not understand Windows NT are doomed to criticize it, poorly.


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Sun May 15, 2011 8:39 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1097
Location: Tartu, Estonia
In that case I recommend that you test your ELF kernel using a PC simulator before you try it on real hardware - that makes debugging much easier.

The best debugging support I found is that of Bochs, but you can also try QEMU, which has the nice feature that it can directly load multiboot kernels with the "-kernel" option.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Mon May 16, 2011 4:12 am 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9287
Location: On the balcony, watching the Swedish Chef
Marionumber1 wrote:
I was using AS because LD wouldn't recognize the format of a NASM output file.
Then you're not using your tools correctly. NASM has a host of formats it can output to, ELF included. It does not magically know however that you want an ELF-formatted file.


Have you tried the Bare Bones tutorial exactly as described, or are you trying to work out your own approach?

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Thu Dec 29, 2011 9:00 am 
Offline
Member
Member
User avatar

Joined: Sun May 08, 2011 9:03 am
Posts: 56
Sorry that I've been away for a while, but I've just been busy. Anyway, I was following Bran's Kernel Dev tutorial and when I used i586-elf-ld to link, it said that my ISR and IRQ routines couldn't be found. His tutorial says that you add leading underscores to every symbol name, but that didn't work. I also tried removing those underscores, which also failed.

_________________
Programmer and security enthusiast
DarkSide OS Kernel

Those who do not understand Windows NT are doomed to criticize it, poorly.


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Thu Dec 29, 2011 12:05 pm 
Offline
Member
Member
User avatar

Joined: Wed Oct 18, 2006 3:45 am
Posts: 9287
Location: On the balcony, watching the Swedish Chef
Quote:
Have you tried the Bare Bones tutorial exactly as described

_________________
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Thu Dec 29, 2011 1:10 pm 
Offline
Member
Member
User avatar

Joined: Sun May 08, 2011 9:03 am
Posts: 56
As I said, I was following Bran's tutorial.

_________________
Programmer and security enthusiast
DarkSide OS Kernel

Those who do not understand Windows NT are doomed to criticize it, poorly.


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Thu Dec 29, 2011 1:29 pm 
Offline
Member
Member
User avatar

Joined: Sun Oct 22, 2006 7:01 am
Posts: 2637
Location: Devon, UK
Hi,

Combuster wrote:
Marionumber1 wrote:
I was using AS because LD wouldn't recognize the format of a NASM output file.
Then you're not using your tools correctly.



What does objdump tell you? Are you certain you're using your cross-ld? Could you post the output of ld -V and the objdump of your binary?

Cheers,
Adam


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Thu Dec 29, 2011 1:42 pm 
Offline
Member
Member
User avatar

Joined: Sun May 08, 2011 9:03 am
Posts: 56
If I build with my cross compiler in Cygwin, the build works.

Output of ld -V:

Code:
GNU ld (GNU Binutils) 2.21
  Supported emulations:
   elf_i386


And what information should I dump in OBJDump?

_________________
Programmer and security enthusiast
DarkSide OS Kernel

Those who do not understand Windows NT are doomed to criticize it, poorly.


Top
 Profile  
 
 Post subject: Re: GRUB Error 7 Troubles
PostPosted: Thu Dec 29, 2011 6:44 pm 
Offline
Member
Member
User avatar

Joined: Sun May 08, 2011 9:03 am
Posts: 56
Never mind, I got it to build with my cross compiler.

_________________
Programmer and security enthusiast
DarkSide OS Kernel

Those who do not understand Windows NT are doomed to criticize it, poorly.


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: 8infy, Google [Bot] and 9 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group