Page 2 of 4
Re: GRUB Error 25
Posted: Sat Jun 30, 2012 5:27 am
by zhiayang
JamesM wrote: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.
Ah. As for your first point... It doesn't work in VMWare either.
For your second point, I said before that this is a rewrite of my old OS; I'm using the same stage2_eltorito file.
Re: GRUB Error 25
Posted: Sat Jun 30, 2012 9:43 am
by zhiayang
I have made some progress. (I don't think so). When I format my USB thumb drive as FAT32 and placing the files on it (boot, boot.catalog) I get as far as "Non-system disk". However... If I use the convoluted steps described here:
http://superuser.com/questions/63654/ho ... n-mac-os-x, I get as far as QEMU trying to boot from PXE.
I suspect something very wrong.
EDIT: Another "find". If I use mkisofs ... -b /tmp/boot/grub/stage1 instead of stage2_eltorito, I get as far as
Code: Select all
Booting from Hard Disk...
Boot failed. Not a bootable disk
Booting from DVD/CD...
0MB medium detected
GRUB _
Really I'm just trying random things out here. I really need some advice...
Re: GRUB Error 25
Posted: Sat Jun 30, 2012 5:21 pm
by Kazinsal
Stupid question, but have you tried just using an out-of-the-box GRUB setup?
Re: GRUB Error 25
Posted: Sat Jun 30, 2012 8:59 pm
by zhiayang
Blacklight wrote:Stupid question, but have you tried just using an out-of-the-box GRUB setup?
Yes, yes I have. Same thing, just that it doesn't give Error 8. It still fails to boot and gives error 25.
Re: GRUB Error 25
Posted: Sun Jul 01, 2012 12:08 am
by Lionel
Just wondering, have you tried it with grub2?
Re: GRUB Error 25
Posted: Sun Jul 01, 2012 9:30 am
by zhiayang
Lionel wrote:Just wondering, have you tried it with grub2?
No, no I have not. I'd prefer to stick with GRUB Legacy. I'll only use GRUB 2 as a last resort, but I guess beggars can't be choosers.
Anyway. I've tried with a BRAND NEW kernel, starting from 100% scratch...
Build Script:
Code: Select all
clear
#for OSX
export PATH=$PATH:/opt/local/bin/
echo "---ClothLoader---"
echo "Clearing results of previous failures...\n"
if [ -a output/clothload.bin ]
then
rm output/clothload.bin
fi
if [ -a output/disk.iso ]
then
rm output/disk.iso
fi
rm *.o
echo "Assembling..."
#nasm -f bin src/ClothLoader/clothload.s -o output/clothload.bin
#nasm -f bin src/ClothLoader/clothloaders2.s -o output/clothload2.bin
nasm -f elf src/boot/start.s -o start.o
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
echo "Linking..."
bin/i586-elf-ld -T ../link.ld -o ../output/kernel.bin ../start.o ../main.o
echo "Copying Files..."
cd ..
if [ ! -d img ]
then
mkdir img
fi
mkdir img/boot
mkdir img/boot/grub
cp output/kernel.bin img/boot/kernel.bin
cp grub/stage2_eltorito img/boot/grub/stage2_eltorito
cp grub/menu.lst img/boot/grub/menu.lst
echo "Generating Disk Image..."
mkisofs -R -b boot/grub/stage2_eltorito -quiet -no-emul-boot -boot-load-size 4 -boot-info-table -o output/disk.iso img
rm -r img
qemu -m 32 -cdrom output/disk.iso
Start.s
Code: Select all
[BITS 32]
section .text
global Start
Start:
mov esp, SystemStack ; Set the stack pointer (ESP) to the stack
jmp KernelLoad ; Jump over the multiboot info
ALIGN 4 ; Align the info (Picky GRUB)
MultiBoot:
; Define some constants
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
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
dd MultiBoot
dd code
dd bss
dd end
dd Start
KernelLoad:
extern main
call main
jmp $
section .bss
SystemStack:
resb 4096
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 = .; _end = .; __end = .;
}
DOES THE WORLD HATE ME SO MUCH??!!
Re: GRUB Error 25
Posted: Sun Jul 01, 2012 10:38 am
by Combuster
I suspect it has to do something with reading skill. After all, you haven't apparently fixed the first error we found.
Re: GRUB Error 25
Posted: Sun Jul 01, 2012 10:56 am
by zhiayang
Combuster wrote:I suspect it has to do something with reading skill. After all, you haven't apparently fixed the first error we found.
What's the first error? If the first error is setting root, aka (cd)/boot/kernel.bin then I have added that to my menu.lst
If it's another problem you're referring to... Then could you clarify please?
Re: GRUB Error 25
Posted: Sun Jul 01, 2012 11:16 am
by Combuster
So, the error 25 message is gone? (or any error from grub for that matter)
Re: GRUB Error 25
Posted: Sun Jul 01, 2012 11:17 am
by zhiayang
Combuster wrote:So, the error 25 message is gone?
Of course not. If it were, I'd be jumping for joy all over the place now.
Re: GRUB Error 25
Posted: Sun Jul 01, 2012 11:25 am
by Combuster
I can only say, "works for me".
The setup:
Code: Select all
marcel@daphnis ~/dev/mos/build-ia-pc $ find build-iso/
build-iso/
build-iso/boot
build-iso/boot/gzImage
build-iso/boot/gzRamdisk
build-iso/boot/grub
build-iso/boot/grub/stage2_eltorito
build-iso/boot/grub/menu.lst
marcel@daphnis ~/dev/mos/build-ia-pc $ mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -o grubcd.iso -boot-load-size 4 -boot-info-table build-iso/
Size of boot image is 4 sectors -> No emulation
Total translation table size: 2048
Total rockridge attributes bytes: 1293
Total directory bytes: 4096
Path table size(bytes): 34
Max brk space used 0
480 extents written (0 MB)
marcel@daphnis ~/dev/mos/build-ia-pc $ less build-iso/boot/grub/menu.lst
title MysticOS [cd]
root (cd)
kernel /boot/gzImage
module /boot/gzRamdisk
marcel@daphnis ~/dev/mos/build-ia-pc $ qemu-system-i386 -cdrom grubcd.iso
Re: GRUB Error 25
Posted: Tue Jul 03, 2012 7:15 am
by zhiayang
Nope. Doesn't work. At all.
Code: Select all
clear
#for OSX
export PATH=$PATH:/opt/local/bin/
echo "---ClothLoader---"
echo "Clearing results of previous failures...\n"
if [ -a output/clothload.bin ]
then
rm output/clothload.bin
fi
if [ -a output/cloth.iso ]
then
rm output/cloth.iso
fi
rm *.o
echo "Assembling..."
#nasm -f bin src/ClothLoader/clothload.s -o output/clothload.bin
#nasm -f bin src/ClothLoader/clothloaders2.s -o output/clothload2.bin
nasm -f elf src/boot/start.s -o start.o
echo "Compiling..."
cd toolsx86
bin/i586-elf-gcc -Wall -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/kernel/include -c -o ../main.o ../src/kernel/main.c
bin/i586-elf-gcc -Wall -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/kernel/include -c -o ../textmode.o ../src/kernel/drivers/textmode.c
bin/i586-elf-gcc -Wall -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/kernel/include -c -o ../system.o ../src/kernel/lib/system.c
bin/i586-elf-gcc -Wall -std=gnu99 -fstrength-reduce -fno-leading-underscore -fno-stack-protector -fomit-frame-pointer -finline-functions -nostdinc -fno-builtin -I../src/kernel/include -c -o ../string.o ../src/kernel/lib/string.c
echo "Linking..."
bin/i586-elf-ld -T ../link.ld -o ../output/cloth.bin ../start.o ../main.o ../textmode.o ../system.o ../string.o
echo "Copying Files..."
cd ..
mkdir img
mkdir img/boot
mkdir img/boot/grub
cp output/cloth.bin img/boot/cloth.bin
cp grub/stage2_eltorito img/boot/grub/stage2_eltorito
cp grub/menu.lst img/boot/grub/menu.lst
echo "Generating Disk Image..."
mkisofs -R -b boot/grub/stage2_eltorito -no-emul-boot -o output/cloth.iso -boot-load-size 4 -boot-info-table img/
rm -r img
rm *.o
qemu -m 32 -cdrom output/cloth.iso
I'm very sure the mkisofs line is correct, because I copied it from the snippet you posted.
I also managed to get grub to show something about "shtab" once, I think it was the section info or something. Problem is, i was unable to reproduce it.
Code: Select all
title Cloth 0.3
root (cd)
kernel /boot/cloth.bin
boot
Same thing. Error 8. Any attempts to load the kernel give Error 25.
If you have time, (please?) could you help me test it on your setup?
(It assumes there is a toolsx86 folder in the root directory; that contains my GCC toolchain, where i586-elf-gcc is in toolsx86/bin/)
https://dl.dropbox.com/u/20627716/Archive.zip
Thanks a googolplex.
Re: GRUB Error 25
Posted: Wed Jul 04, 2012 10:52 am
by zhiayang
Bump...? I really want to continue OSDev, but I can't when things are not working out.
I am trying to build grub2 here. I'm using OSX; ./configure tells me that mcmodel=large isn't supported.... I tried pointing it to my cross-compiler but it "cannot create executables".
What do do? I don't see a way out. I'm having troubles loading sectors from a disk in real mode, so that's out of the question for now.
Re: GRUB Error 25
Posted: Thu Jul 05, 2012 5:17 am
by Solar
Generic debugging advice 101:
Don't look for a solution, look for the error.
If some change breaks things for you, go back to the last known-good version, check that it works out, then re-do the changes in smaller steps.
If going back to the last known-good version doesn't work out, go back to something that
does work (like our
Bare Bones), then add custom things piece by piece (e.g. booting from an image, booting
your code from an image, ...) until you identify what, exactly, broke things for you.
Poking around in the dark hoping to get it right (if you don't know what's going wrong in the first place) doesn't help.
Find that bug / misunderstanding / change of format / ..., understand why it broke things for you,
then fix it.
Re: GRUB Error 25
Posted: Fri Jul 06, 2012 9:26 am
by Combuster
Can't reproduce error. I took the build script, created the missing directories, replaced the harcoded paths to gcc and ld (not good), and replaced qemu with qemu-system-i386. Kernel got started without error but wasn't particularly interesting.
In other words: Go fix your tools.
I used the following tool from my system. Make sure your versions are at least that.
Binutils 2.18
GCC 4.1.2
mkisofs 3.00
qemu 1.0-r3