GRUB doesn't want to boot my OS
GRUB doesn't want to boot my OS
Hi all,
finally. I. am. in. this. board.
[offtopic: I created an account with username Clund and email [email protected] ... but freenet simply doesn't recieve any emails from you, so I used my 2nd email ... maybe some Admin can fix this ]
I currently got a kernel, that can boot from a floppy (self written bootloader, etc): sf.net/p/imks
(Don't ask me, what it should do later ... I will make a post about that soon and fill my sf wiki ... it should restart parts of itself without rebooting)
This works fine, I can get into 32 bit mode and got some basic libc working. Well, it works in bochs, but not in "RL". I think thats because some wierd floppy behavior or something ... but thats not what I want to fix.
My problem is, that grub simply doesn't accept my kernel. I got the multiboot header set up and everything and it is liked and bless shows me, that it is in the ELF file (little endian ... I hope thats correct) but it still doesnt work ;(
[In attachment you have my complete compiled file ... in case you don't want to run my whole build scripts ]
ooooops, the board wont let me upload it ... you can download it here: http://www.clundxiii.com/myos.elf
Clund(XIII)
(Sorry for my long intro ... I am new in this forum )
finally. I. am. in. this. board.
[offtopic: I created an account with username Clund and email [email protected] ... but freenet simply doesn't recieve any emails from you, so I used my 2nd email ... maybe some Admin can fix this ]
I currently got a kernel, that can boot from a floppy (self written bootloader, etc): sf.net/p/imks
(Don't ask me, what it should do later ... I will make a post about that soon and fill my sf wiki ... it should restart parts of itself without rebooting)
This works fine, I can get into 32 bit mode and got some basic libc working. Well, it works in bochs, but not in "RL". I think thats because some wierd floppy behavior or something ... but thats not what I want to fix.
My problem is, that grub simply doesn't accept my kernel. I got the multiboot header set up and everything and it is liked and bless shows me, that it is in the ELF file (little endian ... I hope thats correct) but it still doesnt work ;(
[In attachment you have my complete compiled file ... in case you don't want to run my whole build scripts ]
ooooops, the board wont let me upload it ... you can download it here: http://www.clundxiii.com/myos.elf
Clund(XIII)
(Sorry for my long intro ... I am new in this forum )
- Bender
- Member
- Posts: 449
- Joined: Wed Aug 21, 2013 3:53 am
- Libera.chat IRC: bender|
- Location: Asia, Singapore
Re: GRUB doesn't want to boot my OS
Hi,
What message do you get?
I haven't seen your kernel binary btw.
Is it GRUB 13 Unsupported Format?
Also,
The Bare Bones shows a good example of how to set up a multiboot kernel using GRUB.
-Bender
What message do you get?
I haven't seen your kernel binary btw.
Is it GRUB 13 Unsupported Format?
Also,
The Bare Bones shows a good example of how to set up a multiboot kernel using GRUB.
-Bender
Last edited by Bender on Tue Mar 04, 2014 8:15 am, edited 1 time in total.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
(R3X Runtime VM)(CHIP8 Interpreter OS)
Re: GRUB doesn't want to boot my OS
GRUB says "bad magic number"
yea i know this page I know this whole site and I used code from this wiki (I hope you don't mind )
but as you might see with your hex editor ... the magic number is at 0x2000
Clund
yea i know this page I know this whole site and I used code from this wiki (I hope you don't mind )
but as you might see with your hex editor ... the magic number is at 0x2000
Clund
- Combuster
- 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 doesn't want to boot my OS
Code: Select all
1 .multiboot_header 0000001e 00001000 00001000 00002000 2**12
Make sure you use a proper cross-compiler and linker script.
Re: GRUB doesn't want to boot my OS
http://sourceforge.net/p/imks/code/ci/m ... nkerscript
Code: Select all
...snip...
/* First put the multiboot header, as it is required to be put very early
early in the image or the bootloader won't recognize the file format.
Next we'll put the .text section. */
.multiboot_header BLOCK(4K) : ALIGN(4K)
{
./temp/grub-header.o(.multiboot)
./temp/grub-header.o(.text)
}
...snip...
and my laptop is from '06 (Pentium M) ... I think creating my own cross compiler wont work so nice xD
... what do you mean with out or range
- Bender
- Member
- Posts: 449
- Joined: Wed Aug 21, 2013 3:53 am
- Libera.chat IRC: bender|
- Location: Asia, Singapore
Re: GRUB doesn't want to boot my OS
I think he means that GRUB (IIRC) searches for the header withinwhat do you mean with out or range
the first 8K of the kernel binary.
I could be wrong though.
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
(R3X Runtime VM)(CHIP8 Interpreter OS)
Re: GRUB doesn't want to boot my OS
Hi. Try actually following the instructions at http://wiki.osdev.org/Bare_Bones.
Please note that sourceforge is a pretty crappy project host. Use github or something better. Normally, I wouldn't even visit sourceforge but I feel in a good mood and I'll have a look at your code, prepare for some criticism:
You are not using a cross-compiler! I can see you are on a Linux system, no excuses! You also appear to be passing harmful options like -fno-strict-aliasing (or what it is called). What the ****, are your Makefile replacing your Linux kernel with myos.elf? Note that Linux isn't a multiboot kernel, but uses its own boot protocol. You are loading your kernel at 0x1000 (4 KiB), while Bare Bones tell you to load it at 1 MiB instead. I don't think GRUB can load your kernel that lowly. You also have to use a cross-compiler, no excuses. It looks as if you have taken bits from Bare Bones and butchered it into whatever you have. Your C files are almost more inline assembly than C.
Your directory structure and build system is a bit incomprehensible, I have little idea where to start looking. It doesn't fully help that part of it is in German. Actually, I give up, I have no idea what is going on. Go follow Bare Bones instead of whatever you currently are doing. Perhaps try follow my experimental draft tutorial with an example project structure.
Please note that sourceforge is a pretty crappy project host. Use github or something better. Normally, I wouldn't even visit sourceforge but I feel in a good mood and I'll have a look at your code, prepare for some criticism:
You are not using a cross-compiler! I can see you are on a Linux system, no excuses! You also appear to be passing harmful options like -fno-strict-aliasing (or what it is called). What the ****, are your Makefile replacing your Linux kernel with myos.elf? Note that Linux isn't a multiboot kernel, but uses its own boot protocol. You are loading your kernel at 0x1000 (4 KiB), while Bare Bones tell you to load it at 1 MiB instead. I don't think GRUB can load your kernel that lowly. You also have to use a cross-compiler, no excuses. It looks as if you have taken bits from Bare Bones and butchered it into whatever you have. Your C files are almost more inline assembly than C.
Your directory structure and build system is a bit incomprehensible, I have little idea where to start looking. It doesn't fully help that part of it is in German. Actually, I give up, I have no idea what is going on. Go follow Bare Bones instead of whatever you currently are doing. Perhaps try follow my experimental draft tutorial with an example project structure.
Re: GRUB doesn't want to boot my OS
well, that will f*** up my planned memory but it seems there is no other way ;(
http://sourceforge.net/p/imks/code/ci/m ... y-overview
And, yes, I followed the instructions
I will build my cross compiler and everything else, give me 2 hours or so.
But ... that is not why GRUB wont recognize the magic number ... ?
Clund
http://sourceforge.net/p/imks/code/ci/m ... y-overview
And, yes, I followed the instructions
I will build my cross compiler and everything else, give me 2 hours or so.
But ... that is not why GRUB wont recognize the magic number ... ?
Clund
- Combuster
- 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 doesn't want to boot my OS
and my laptop is from '06 (Pentium M) ... I think creating my own cross compiler wont work so nice xD
Code: Select all
i386-elf-objdump -s -j .comment myos.elf
(...)/myos.elf: file format elf32-i386
Contents of section .comment:
0000 4743433a 20285562 756e7475 2f4c696e GCC: (Ubuntu/Lin
0010 61726f20 342e362e 332d3175 62756e74 aro 4.6.3-1ubunt
0020 75352920 342e362e 3300 u5) 4.6.3.
Besides, the time it took you to get this question asked would have already built you that crosscompiler.
Re: GRUB doesn't want to boot my OS
Oh, you posted after than I could edit my above post. No, you are not following the instructions of Bare Bones. Please don't lie.ClundXIII wrote:And, yes, I followed the instructions
You have multiple problems here. A cross-compiler is just one of them. Linking your kernel at the wrong place is another. I haven't verified, but if your multiboot header is in the wrong place in the file that's a third problem. If you fail to follow instructions, that's a fourth problem. If you are loading your kernel with GRUB as if it was a Linux kernel, that's a fifth problem.
Note how Combuster is pointing out that your are using a GCC that came with your distribution and has been altered by your distribution. You have no idea what defaults and other semantics are changed in addition to the compiler thinking it is producing code for a Linux system (rather than a new OS). This is why you want a cross-compiler. Note that you attempting to poorly cover up this mistake by passing bad compiler options you wouldn't need with a cross-compiler.
- Bender
- Member
- Posts: 449
- Joined: Wed Aug 21, 2013 3:53 am
- Libera.chat IRC: bender|
- Location: Asia, Singapore
Re: GRUB doesn't want to boot my OS
For your info: Loading Kernels below 1MB is the limitation of GRUB not of the multiboot standard.ClundXIII wrote:well, that will f*** up my planned memory but it seems there is no other way ;(
http://sourceforge.net/p/imks/code/ci/m ... y-overview
And, yes, I followed the instructions
I will build my cross compiler and everything else, give me 2 hours or so.
But ... that is not why GRUB wont recognize the magic number ... ?
Clund
"In a time of universal deceit - telling the truth is a revolutionary act." -- George Orwell
(R3X Runtime VM)(CHIP8 Interpreter OS)
(R3X Runtime VM)(CHIP8 Interpreter OS)
Re: GRUB doesn't want to boot my OS
okay sorry
hold on everybody ... let me work and please let the shitstorm stop
my goal REALLY wasn't to get it working, i just wanted grub to recognize my multiboot header.
I am using an entry via /etc/grub.d/40_custom now
Because of the german ... that are very old obsolete parts, that shouldn't be used now. My docs (aka text files) are all english.
And sorry because of my edits, I am sometimes thinking too fast
EDIT: here you are: http://sourceforge.net/p/imks/code/ci/4 ... a131b951a/
*gives an virtual coin to Linux Software Foundation for doing this sacrilege*
Clund
hold on everybody ... let me work and please let the shitstorm stop
my goal REALLY wasn't to get it working, i just wanted grub to recognize my multiboot header.
that was an older linux version that was left ... as I said, I just want the multiboot header to be recognizedWhat the ****, are your Makefile replacing your Linux kernel with myos.elf?
I am using an entry via /etc/grub.d/40_custom now
Because of the german ... that are very old obsolete parts, that shouldn't be used now. My docs (aka text files) are all english.
okay, thanks how can i change it? should it be like this:Regardless of linkerscript, your multiboot header is not the first thing in the file.
I added 1M to all other sections/* Begin putting sections at 1 MiB, a conventional place for kernels to be
loaded at by the bootloader. */
. = 1M;
/* aka 0x100000 */
/* First put the multiboot header, as it is required to be put very early
early in the image or the bootloader won't recognize the file format.
Next we'll put the .text section. */
.multiboot_header BLOCK(4K) : ALIGN(4K)
{
./temp/grub-header.o(.multiboot)
./temp/grub-header.o(.text)
}
And sorry because of my edits, I am sometimes thinking too fast
EDIT: here you are: http://sourceforge.net/p/imks/code/ci/4 ... a131b951a/
*gives an virtual coin to Linux Software Foundation for doing this sacrilege*
Clund
Re: GRUB doesn't want to boot my OS
Okay so ...
I am currently downloading the gcc source to compile it (because I have linux I am cloning the repo )
To multiboot and Linux: I didn't know, that Linux is not using the multiboot specification ... I just thought that would be the easiest way to boot a multibot kernel
Clund
I am currently downloading the gcc source to compile it (because I have linux I am cloning the repo )
To multiboot and Linux: I didn't know, that Linux is not using the multiboot specification ... I just thought that would be the easiest way to boot a multibot kernel
yes, I had (and still have) a "floppybuilder" wokingIt looks as if you have taken bits from Bare Bones and butchered it into whatever you have.
Clund
Re: GRUB doesn't want to boot my OS
Hi,
Please don't consider our responses a shitstorm. We are trying to help you, you have committed some unusual beginner mistakes, that's all. :-)
GCC repo? Please don't tell me you are downloading an experimental unstable version of binutils or gcc, which could lead to all sorts trouble. Simply use the latest stable release of binutils and gcc as compressed archives.
Floppies? They are an obsolete technology and quite space limited. If you wish to produce a portable bootable image, try use the Bare Bones method of creating a bootable cdrom image with grub-mkrescue (or any other program that does so).
Please don't consider our responses a shitstorm. We are trying to help you, you have committed some unusual beginner mistakes, that's all. :-)
GCC repo? Please don't tell me you are downloading an experimental unstable version of binutils or gcc, which could lead to all sorts trouble. Simply use the latest stable release of binutils and gcc as compressed archives.
Floppies? They are an obsolete technology and quite space limited. If you wish to produce a portable bootable image, try use the Bare Bones method of creating a bootable cdrom image with grub-mkrescue (or any other program that does so).
Re: GRUB doesn't want to boot my OS
Here I am again
binutils fails after a while with "types in conflict for "malloc" (error msg translated)
it happens at:
../../binutils-2.9.1/binutils/../libiberty/cplus-dem.c8:
god, how I hate german error messages
do I have to copy these files or are they otional? do I have to copy them from my system libraries? (I installed everything with the package manager)
"make all-gcc" and "make all-target-libgcc" works fine, but when I want to install it (with "make install-gcc"), it wants to create a folder in my root directory: "/libexec" ... I set the path vars correctly
export:
http://pastebin.com/UJ1mNChJ
EDIT: maybe you want the output:
(and yes, I clean it, exported the vars again and everything ... but nothing works )
Clund
binutils fails after a while with "types in conflict for "malloc" (error msg translated)
it happens at:
../../binutils-2.9.1/binutils/../libiberty/cplus-dem.c8:
god, how I hate german error messages
do I have to copy these files or are they otional? do I have to copy them from my system libraries? (I installed everything with the package manager)
Code: Select all
mv gmp-x.y.z gcc-x.y.z/gmp
mv mpfr-x.y.z gcc-x.y.z/mpfr
mv mpc-x.y.z gcc-x.y.z/mpc
export:
http://pastebin.com/UJ1mNChJ
EDIT: maybe you want the output:
Code: Select all
simon@simon-audi:~/build-gcc$ make install-gcc
/bin/bash ../gcc-4.8.2/mkinstalldirs
make[1]: Betrete Verzeichnis '/home/simon/build-gcc/fixincludes'
rm -rf /libexec/gcc/i686-pc-linux-gnu/4.8.2/install-tools
/bin/bash ../../gcc-4.8.2/fixincludes/../mkinstalldirs /libexec/gcc/i686-pc-linux-gnu/4.8.2/install-tools
mkdir -p -- /libexec/gcc/i686-pc-linux-gnu/4.8.2/install-tools
mkdir: das Verzeichnis »/libexec“ kann nicht angelegt werden: Keine Berechtigung
make[1]: *** [install] Fehler 1
make[1]: Verlasse Verzeichnis '/home/simon/build-gcc/fixincludes'
make: *** [install-fixincludes] Fehler 2
Clund