bugGNU GRUB - Bugs: bug #34820, Multiboot image not recognized

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #34820: Multiboot image not recognized

Submitter:  Faustino Ribeiro <faust_67>
Submitted:  Mon 14 Nov 2011 04:23:47 PM UTC
   
 
Category:  Booting Severity:  Major
Priority:  5 - Normal Item Group:  Software Error
Status:  Invalid Privacy:  Public
Assigned to:  None Originator Name:  Faustino Ribeiro
Open/Closed:  Closed Release:  other
Release:  Reproducibility:  Every Time
Planned Release:  None

Jump to the original submission

Mon 14 Nov 2011 08:15:44 PM UTC, comment #7: 

I created a Grub image with multiboot module in it and it works fine now. Thanks! It saved me hours of scratching my head!

Faustino Ribeiro <faust_67>
Mon 14 Nov 2011 06:41:32 PM UTC, comment #6: 

Which version is it? Did you try insmod multiboot?

Vladimir Serbinenko <phcoder>
Group administrator
Mon 14 Nov 2011 06:14:03 PM UTC, comment #5: 

multiboot command is not recognized at grub prompt. I created by hand a basic grub.cfg as follows:

set default=0
set timeout=5
set root=(cd)

menuentry "MyOS" {
   multiboot /boot/kernel.bin
   boot
}

When I select "MyOS" menu item, I get the following message:

error: unknown command 'multiboot'

Am I missing something?

PS: I first created grub.cfg file with this menuentry syntax:

menuentry "MyOS"
{
   multiboot /boot/kernel.bin
   boot
}

Note the '{' put on the line after the menuentry declaration (not on the same line). This makes the config file invalid.

Faustino Ribeiro <faust_67>
Mon 14 Nov 2011 05:46:04 PM UTC, comment #4: 

multiboot2 is for new upcoming multiboot2 standard which is being discussed. For the old standrad use "multiboot".

Vladimir Serbinenko <phcoder>
Group administrator
Mon 14 Nov 2011 05:39:03 PM UTC, comment #3: 

Here is the output of mbchk on the kernel.bin file I uploaded:

iso_files/boot/kernel.bin: The Multiboot header is found at the offset 4100.
iso_files/boot/kernel.bin: Page alignment is turned on.
iso_files/boot/kernel.bin: Memory information is turned on.
iso_files/boot/kernel.bin: Address fields is turned off.
iso_files/boot/kernel.bin: All checks passed.

Here is also the linker configuration file I use (perhaps the header is not in the right place, but then why does it work in grub legacy?)



OUTPUT_FORMAT(elf32-i386)

ENTRY(loader)

phys = 0x00100000;

virt = 0xC0001000;

SECTIONS

{

.setup phys : AT (phys)

{

*(.setup)

. = ALIGN(4096);

}



.text virt : AT ( ADDR(.setup) + SIZEOF (.setup) )

{

(.text)

(.rodata)

. = ALIGN(4096);

}



.data : AT ( ADDR(.setup) + SIZEOF (.setup) + SIZEOF(.text) )

{

*(.data)

. = ALIGN(4096);

}



.bss : AT ( ADDR(.setup) + SIZEOF (.setup) + SIZEOF(.text) + SIZEOF(.data) )

{

bss = .;

*(.bss)

. = ALIGN(4096);

*(COMMON)

. = ALIGN(4096);

}



_end = .;

}

Faustino Ribeiro <faust_67>
Mon 14 Nov 2011 05:34:45 PM UTC, comment #2: 

I uploaded the kernel.bin file I try to boot. At the grub 1.99 prompt I use this command to load the image:

multiboot2 /boot/kernel.bin

This results in the "no multiboot header fount" error message. Again this image works fine in grub legacy and mbchk tells me that the image is multiboot compliant.

Thank you.

(file #24371)

Faustino Ribeiro <faust_67>
Mon 14 Nov 2011 04:31:00 PM UTC, comment #1: 

Could you upload resulting image and tell the exact commands you used?

Vladimir Serbinenko <phcoder>
Group administrator
Mon 14 Nov 2011 04:23:47 PM UTC, original submission:  

I created a minimal kernel image that is multiboot compliant (or at least I hope). The image boots in Grub Legacy but not in Grub 1.99 (final release). Mbchk recognizes the image as a valid multiboot image. I am stuck and don't know what I am doing wrong. Here is the code I use to create a minimal kernel and an iso image I can boot in VirtualBox:

--> loader-test.S

.global start                          # making entry point visible to linker



# setting up the Multiboot header - see GRUB docs for details



.set ALIGN,    1<<0                     # align loaded modules on page boundaries

.set MEMINFO,  1<<1                     # provide memory map

.set FLAGS,    ALIGN | MEMINFO          # this is the Multiboot 'flag' field

.set MAGIC,    0x1BADB002               # 'magic number' lets bootloader find the header

.set CHECKSUM, -(MAGIC + FLAGS)         # checksum required



.code32



start:

jmp loader



.align 4



.long MAGIC

.long FLAGS

.long CHECKSUM

.long 0 # header_addr if flags[16] is set

.long 0 # load_addr if flags[16] is set

.long 0 # load_end_addr if flags[16] is set

.long 0 # bss_end_addr if flags[16] is set

.long 0 # entry_addr if flags[16] is set

.long 0  # mode_type if flags[2] is set

.long 0 # width if flags[2] is set

.long 0 # height if flags[2] is set

.long 0 # depth if flags[2] is set



# reserve initial kernel stack space



.set STACKSIZE, 0x4000                  # that is, 16k.

.comm stack, STACKSIZE, 32              # reserve 16k stack on a quadword boundary



loader:

    mov   $(stack + STACKSIZE), %esp    # set up the stack

    push  %eax                          # Multiboot magic number

    push  %ebx                          # Multiboot data structure



    call kernel_main                          # call kernel proper



    cli

hang:

    hlt                                 # halt machine should kernel return

    jmp   hang



---> kernel_main-test.c

void kernel_main( void* mbd )

{

if (mbd == (void*)0)

{

}

}


---> makefile:

BUILD_DIR = build
SRC_DIR = src
ISO_DIR = iso_files
OBJS := loader-test.o kernel_main-test.o
OBJS := $(addprefix $(BUILD_DIR)/, $(OBJS))
EXECUTABLE = kernel.bin

ASM = nasm
ASMFLAGS = -f elf32 -I $(SRC_DIR)/
CC = gcc
#CCFLAGS = -m64 -I include -Wall -Wextra -Werror -m64 -ffreestanding -nostdlib -mcmodel=large -mno-red-zone -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-3dnow
CCFLAGS = -m32 -I include -Wall -Wextra -Werror -nostdlib -fno-builtin -nostartfiles -nodefaultlibs
LD = ld
LDFLAGS = -T src/linker-test.ld -m elf_i386

all: $(BUILD_DIR)/$(EXECUTABLE)
cp $(BUILD_DIR)/$(EXECUTABLE) $(ISO_DIR)/boot/$(EXECUTABLE)
# cd $(ISO_DIR); genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o ../MyOS.iso $(ISO_DIR); cd ..
# genisoimage -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o MyOS.iso $(ISO_DIR)
genisoimage -R -b boot/grub/eltorito.img -no-emul-boot -boot-load-size 4 -boot-info-table -o MyOS.iso $(ISO_DIR)

$(BUILD_DIR)/$(EXECUTABLE): $(OBJS)
$(LD) $(LDFLAGS) -o $(BUILD_DIR)/$(EXECUTABLE) $(OBJS)

$(BUILD_DIR)/loader-test.o : $(SRC_DIR)/loader-test.S
# $(ASM) $(ASMFLAGS) -o $@ $<
# $(CC) -o $@ -c $< $(CCFLAGS)
as -o $@ -c $< --32

$(BUILD_DIR)/%.o : $(SRC_DIR)/%.S
$(CC) -o $@ -c $< $(CCFLAGS)

$(BUILD_DIR)/%.o : $(SRC_DIR)/%.c
$(CC) -o $@ -c $< $(CCFLAGS)

If I use a stage2_eltorito image with grub legacy, I can boot the mini-kernel with no problem. If I build a grub 1.99 image, I receive the message "Error: no multiboot header found" when I try to boot the same kernel image. Has multiboot specifications changed (and if yes, I found no documentation detailing the changes). I work on a Linux 10.04 box, but I don't think it matters with my problem.

Thank you.


Faustino Ribeiro <faust_67>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #24371:  kernel.bin added by faust_67 (5KiB - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by phcoder (Posted a comment)
  • -email is unavailable- added by faust_67 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-11-14 phcoder StatusNone Invalid
        Open/ClosedOpen Closed
    2011-11-14 faust_67 Attached File- Added kernel.bin, #24371

    Back to the top

    Powered by Savane 3.13-02a9.
    Corresponding source code