GRUB Error 25

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.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

GRUB Error 25

Post by zhiayang »

I bet when you saw 'GRUB Err' you thought it was another one of those stupid error 13 topics? Not today.

I recently got back into osdev'ing. But I looked at my code and realised it was a big mess. So i started from scratch, copying what useful functions I had written into the new one. Then comes the horror...

I did not change the build script, only the files it compiles. Nothing else. Yet for some reason...

Code: Select all

Blackcomb Codename LikeOS
By Nikolaus Rangos  0x118: Direct colour, 1024x768x24
 [ Minimal BASH-like line editing is supported. For the first word, TAB
   lists possible command completions. Anywhere else TAB lists the possible
   completions of a device/filename.  ]

Error 8: Kernel must be loaded before booting

grub> kernel /boot/kernel.bin

Error 25: Disk read error

grub>

As you can tell, I'm using a patched version of GRUB. But that didn't affect me for the past 6 months, so it's definitely not the problem here. I suspect corruption somewhere with the ISO file, because I'm using no-emulation El-Torito booting.


Linker script:

Code: Select all

OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
phys = 0x00100000;
SECTIONS
{
	.text phys : AT(phys)
	{
		code = .;
		*(.text)
		*(.rodata)
		. = ALIGN(4096);
	}
	.data : AT(phys + (data - code))
	{
		data = .;
		*(.data)
		. = ALIGN(4096);
	}
	.bss : AT(phys + (bss - code))
	{
		bss = .;
		*(.bss)
		. = ALIGN(4096);
	}
	end = .;
}
Making the ISO (Can't get genisoimage on mac)

Code: Select all

mkdir -p tmp/boot/grub
cp grub/stage2_eltorito tmp/boot/grub/
cp output/kernel.bin tmp/boot/
cp grub/menu.lst tmp/boot/grub/

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o output/disk.iso tmp
QEMU options:

Code: Select all

qemu -hda output/hdd.vmdk -m 32 -cdrom output/disk.iso

What's the problem? I have the kernel.bin and disk.iso if it helps. Also note that it doesn't work in whichever emulator I try, neither does it work on real hardware.

Relevant files:
https://dl.dropbox.com/u/20627716/disk.iso
https://dl.dropbox.com/u/20627716/kernel.bin
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: GRUB Error 25

Post by Combuster »

Have you used the right "root" directive before trying to load the kernel?
"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 ]
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: GRUB Error 25

Post by zhiayang »

Combuster wrote:Have you used the right "root" directive before trying to load the kernel?
Yup.

Code: Select all

mkdir -p tmp/boot/grub
cp grub/stage2_eltorito tmp/boot/grub/
cp output/kernel.bin tmp/boot/
cp grub/menu.lst tmp/boot/grub/

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o output/disk.iso tmp
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: GRUB Error 25

Post by Combuster »

*doesn't see it*
"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 ]
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: GRUB Error 25

Post by zhiayang »

Combuster wrote:*doesn't see it*

Code: Select all

cp output/kernel.bin tmp/boot/

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o output/disk.iso tmp
EDIT: Damn, I think I found the actual problem. When I boot my kernel with QEMU's -kernel option, I hang at "Booting from ROM..."

You already have the linker script, here's my compilation thingy:

Code: Select all

nasm -f elf -o start.o src/asm/start.s

#compile
echo "Compiling..."
cd toolsx86

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../main.o ../src/kernel/main.c

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../gdt.o ../src/drivers/gdt.c

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../idt.o ../src/drivers/idt.c

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../isr.o ../src/drivers/isr.c

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../irq.o ../src/drivers/irq.c

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../string.o ../src/lib/string.c

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../textmode.o ../src/drivers/textmode.c

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../stdio.o ../src/lib/stdio.c

bin/i586-elf-gcc -w -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/include -c -o ../system.o ../src/kernel/system.c


#link
echo "Linking..."

bin/i586-elf-ld -T ../link.ld -o ../output/kernel.bin ../start.o ../main.o ../gdt.o ../idt.o ../isr.o ../irq.o ../string.o ../textmode.o ../stdio.o ../system.o
EDIT 2:

Here's my start.asm:

Code: Select all


[BITS 32]
section .text

global start
start:
	mov esp, sys_stack	 ; This points the stack to our new stack area
	jmp stublet

; 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
	
	
	dd mboot
	dd code
	dd bss
	dd end
	dd start
	dd 0
	dd 0
	dd 0
	dd 0

stublet:
	extern main   	
	
	push ebx			; Multiboot info
	push eax			; Multiboot magic number
	
	call main	
	
	jmp $				; Should main() return...
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: GRUB Error 25

Post by Combuster »

requimrar wrote:
Combuster wrote:*doesn't see it*

Code: Select all

cp output/kernel.bin tmp/boot/

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o output/disk.iso tmp
"root directive", not boot
It'd have to be in menu.lst, or on the grub command line. I see neither :wink:
"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 ]
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: GRUB Error 25

Post by zhiayang »

Combuster wrote:
requimrar wrote:
Combuster wrote:*doesn't see it*

Code: Select all

cp output/kernel.bin tmp/boot/

mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -boot-load-size 4 -boot-info-table -o output/disk.iso tmp
"root directive", not boot
It'd have to be in menu.lst, or on the grub command line. I see neither :wink:

Code: Select all


default 0
timeout 0
 
#title Boot from hard disk
#chainloader (hd0)+1
 
title Orion OS
kernel /boot/kernel.bin # Edit it to the filename of your kernel.
#vbeset 0x114
boot
I can confirm that that the ISO contains the kernel.bin file. However, I mentioned that the problem could be with the kernel.bin itself... I have the necessary code in the previous post.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: GRUB Error 25

Post by JamesM »

You don't set root, like combuster said.

Code: Select all

root (hd0,0) # Boot from first partition on first drive
root (hd1)    # Boot from second drive (CD)
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: GRUB Error 25

Post by zhiayang »

JamesM wrote:You don't set root, like combuster said.

Code: Select all

root (hd0,0) # Boot from first partition on first drive
root (hd1)    # Boot from second drive (CD)
Nope. Besides, I don't see why it would change suddenly; I am confident there is something wrong with my kernel.bin, but I don't know what.

Attempting root (x,y) at both the menu.lst file and the command line does nothing; for the latter, it gives me "Error 21: Selected disk does not exist", for any combination of any numbers. Using just "root" apparently uses (hd96), for which the filesystem type is unknown, however it says it is using the whole disk.

Typing "root (hd96)" separately gives me Error 25.
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: GRUB Error 25

Post by xenos »

Shouldn't it be "root (cd)" in this case? Try the following at GRUBs command prompt:

find /boot/kernel.bin

This should tell you GRUB's name for the disk where your kernel can be found.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: GRUB Error 25

Post by JamesM »

XenOS wrote:Shouldn't it be "root (cd)" in this case? Try the following at GRUBs command prompt:

find /boot/kernel.bin

This should tell you GRUB's name for the disk where your kernel can be found.
Indeed, however he is correct, grub bails with that error no matter what filesystem command you try. Although linux mounts the ISO properly.
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: GRUB Error 25

Post by zhiayang »

JamesM wrote:
XenOS wrote:Shouldn't it be "root (cd)" in this case? Try the following at GRUBs command prompt:

find /boot/kernel.bin

This should tell you GRUB's name for the disk where your kernel can be found.
Indeed, however he is correct, grub bails with that error no matter what filesystem command you try. Although linux mounts the ISO properly.
Indeed, I can extract and mount the ISO, which means the problem is with the kernel.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: GRUB Error 25

Post by Combuster »

Unless you get grub to give you an error 13 or the section information, the kernel hasn't even been seen and therefore can't be a part of the problem.
"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 ]
User avatar
zhiayang
Member
Member
Posts: 368
Joined: Tue Dec 27, 2011 7:57 am
Libera.chat IRC: zhiayang

Re: GRUB Error 25

Post by zhiayang »

Combuster wrote:Unless you get grub to give you an error 13 or the section information, the kernel hasn't even been seen and therefore can't be a part of the problem.
So what do you suggest? I am 100% completely stumped.


EDIT: The problem must lie in more than one place. Booting my kernel with QEMU's -kernel flag hangs it at "Booting from ROM".
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: GRUB Error 25

Post by JamesM »

Combuster wrote:Unless you get grub to give you an error 13 or the section information, the kernel hasn't even been seen and therefore can't be a part of the problem.
Indeed, GRUB can't read the disk or filesystem. As it's a Qemu emulated drive, I'd say the latter. Why? I don't know.

You say this is a patched version of GRUB "but that can't possibly be the problem". I'm skeptical of this.
Post Reply