Page 1 of 1

GRUB error 13 (sorry...)

Posted: Mon Nov 16, 2009 12:20 pm
by Null
Hi,
So I followed the bare bones tutorial, it didn't work and blash blah blah.....
I modified linker script and loader a little bit but I still get Error 13

My loader.asm file

Code: Select all

[BITS 32]

global loader           ; making entry point visible to linker
extern _kmain            ; kmain is defined elsewhere

    SECTION .__mbHeader
    ; 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 loader

section .text
;align 4
;MultiBootHeader:
 ;  dd MAGIC
  ; dd FLAGS
  ; dd CHECKSUM
 
; reserve initial kernel stack space
STACKSIZE equ 0x4000                  ; that's 16k.
 
loader:
   mov esp, stack+STACKSIZE           ; set up the stack
   push eax                           ; pass Multiboot magic number
   push ebx                           ; pass Multiboot info structure
 
   call  _kmain                       ; call kernel proper
 
   cli
hang:
   hlt                                ; halt machine should kernel return
   jmp   hang
 
section .bss
align 4
stack:
   resb STACKSIZE                     ; reserve 16k stack on a doubleword boundary

linker script:

Code: Select all

OUTPUT_FORMAT("pe-i386")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{

   . = phys;
   /* .__mbHeader will begin @ 'phys' */
   .__mbHeader : AT ( ADDR( .__mbHeader ) ) {
      /* mboot = .;*/
      *(.__mbHeader)
   }
  .text : AT(ADDR(.text)) {
    code = .;
    *(.text)
    *(.rodata)
    . = ALIGN(4096);
  }
  .data : AT(ADDR(.text) + (data - code))
  {
    data = .;
    *(.data)
    . = ALIGN(4096);
  }
  .bss : AT(ADDR(.text) + (bss - code))
  {
    bss = .;
    *(.bss)
    . = ALIGN(4096);
  }
  end = .;
}
BUILD.bat

Code: Select all

nasm -f elf -o loader.o loader.asm
gcc -o kernel.o -c kernel.c -nostdlib -nostartfiles -nodefaultlibs
ld -T linker.ld -o kernel.bin loader.o kernel.o
copy /b stage1+stage2+pad+kernel.bin   floppy.img

bochs -q -f bochsrc.bxrc
What a hell is wrong here!?

Re: GRUB error 13 (sorry...)

Posted: Mon Nov 16, 2009 12:27 pm
by Combuster
it didn't work and blash blah blah.....
I see you don't want to be taken seriously

Bottom line, do not deviate from the tutorial and then complain it doesn't work. Knowing how to read is an pretty essential skill :wink: