GRUB PROB
GRUB PROB
Hello every one....
I have created a kernel ... but when i try to load it through grub I get error
-------
Booting 'Magneto ver 0.1'
root (fd0)
Filesystem type is fat, using whole disk
kernel /kernel.bin
Error 13: Invalid or unsupported executable format
Press any key to continue...
------
I created that kernel by following :
tlink /x /t obj obj, kernel,bin
/t is for .com file....
how can i make my kernel so that it loads with grub...
I have created a kernel ... but when i try to load it through grub I get error
-------
Booting 'Magneto ver 0.1'
root (fd0)
Filesystem type is fat, using whole disk
kernel /kernel.bin
Error 13: Invalid or unsupported executable format
Press any key to continue...
------
I created that kernel by following :
tlink /x /t obj obj, kernel,bin
/t is for .com file....
how can i make my kernel so that it loads with grub...
Re:GRUB PROB
This is a bit strange...are you using Turbo C? I think that can only generate real mode code, and GRUB boots into 32-bit protected mode.Codemaster Snake wrote: I created that kernel by following :
tlink /x /t obj obj, kernel,bin
/t is for .com file....
how can i make my kernel so that it loads with grub...
If your code is 32-bit, you should look at the hex values at the start of your kernel binary, and compare them with the multiboot header at http://www.gnu.org/software/grub/manual/multiboot/multiboot.html#OS%20image%20format.
If your code is real mode, you can either:
1) Use a different compiler (e.g. GCC, Watcom) and write 32-bit protected mode code
or
2) Use a different bootloader. Alexei Frounze has written one at http://alexfru.chat.ru/epm.html#bootprog, which can load DOS COM and EXE programs. He also has some information about 16-bit code at http://alexfru.narod.ru/os/c16/c16.html.
Re:GRUB PROB
Yeah I know! Many people find it very strange that I use Turbo C++ for development.... They are always curious that how can I use that....
Well I am pretty confortable with turbo c++ and have created 4 versions of my OS with that....
I am presently using own modified bootloader to load raw .com image to memory and then jump to it.
Now I wanted to use grub for my kernel... and have faced the problem where it says: unsupprotd executable file format.
I would still like to stay with Turbo C++. IS there any way by which I could modify the outputted kernel.bin file to be compatible with grub....
Also Turbo C++ does produce 32 bit protected mode code.
and what is the .elf file/foemat mentioned above
Well I am pretty confortable with turbo c++ and have created 4 versions of my OS with that....
I am presently using own modified bootloader to load raw .com image to memory and then jump to it.
Now I wanted to use grub for my kernel... and have faced the problem where it says: unsupprotd executable file format.
I would still like to stay with Turbo C++. IS there any way by which I could modify the outputted kernel.bin file to be compatible with grub....
Also Turbo C++ does produce 32 bit protected mode code.
and what is the .elf file/foemat mentioned above
Re:GRUB PROB
OK, that's fine. I just wanted to make sure
Do you know that for GRUB to load your kernel you need to add a multiboot header? The first link I posted earlier shows what you need to put in it - that data needs to be near the start of the .com file.
Also, GRUB doesn't set ESP. If you're not doing it already, you'll need to reserve some space for a stack (like char stack[4096]) and then set ESP to point at the top of that.
If you do have the multiboot header, get a hex dump of the first few (128 or so) bytes of the .com file, and then check that the header is in there and looks like it should. Post it here if you're not sure.
Also, check that the load_end_addr - load_addr in the multiboot header is the same size as the .com file. If it's bigger than the file, GRUB won't load it.
Do you know that for GRUB to load your kernel you need to add a multiboot header? The first link I posted earlier shows what you need to put in it - that data needs to be near the start of the .com file.
Also, GRUB doesn't set ESP. If you're not doing it already, you'll need to reserve some space for a stack (like char stack[4096]) and then set ESP to point at the top of that.
If you do have the multiboot header, get a hex dump of the first few (128 or so) bytes of the .com file, and then check that the header is in there and looks like it should. Post it here if you're not sure.
Also, check that the load_end_addr - load_addr in the multiboot header is the same size as the .com file. If it's bigger than the file, GRUB won't load it.
Re:GRUB PROB
Sorry, I forgot to mention: ELF is an executable file format used by Unix and very popular for OSDev. GRUB can load ELF files without much change to them.
Re:GRUB PROB
I didn't knew that...nick8325 wrote: OK, that's fine. I just wanted to make sure
Do you know that for GRUB to load your kernel you need to add a multiboot header? The first link I posted earlier shows what you need to put in it - that data needs to be near the start of the .com file.
Also, GRUB doesn't set ESP. If you're not doing it already, you'll need to reserve some space for a stack (like char stack[4096]) and then set ESP to point at the top of that.
If you do have the multiboot header, get a hex dump of the first few (128 or so) bytes of the .com file, and then check that the header is in there and looks like it should. Post it here if you're not sure.
Also, check that the load_end_addr - load_addr in the multiboot header is the same size as the .com file. If it's bigger than the file, GRUB won't load it.
I forgot to mention that my os is a 16bit RM os....
OK I am bit lazy now can you tell me quickly how to add multiboot header...
Re:GRUB PROB
Oh, by:
GRUB can only load 32-bit kernels, so you will have to use something else.
Like I said in my first post, you should be able to use Alexei Frounze's bootloader instead. That will load your kernel from a .EXE or .COM file on a disk and then jump to it.
I thought that you meant that you were using Turbo C++ to make 32 bit code.Codemaster Snake wrote: Also Turbo C++ does produce 32 bit protected mode code.
GRUB can only load 32-bit kernels, so you will have to use something else.
Like I said in my first post, you should be able to use Alexei Frounze's bootloader instead. That will load your kernel from a .EXE or .COM file on a disk and then jump to it.
Re:GRUB PROB
K that means that I'll have to make my kernel 32 bit to be able to make it bootable from GRUB.....
Re:GRUB PROB
Incorrect. GRUB can chainload just about everything. It's only when you're loading a multiboot kernel that this must be a 32bit kernel (since the multiboot procedure activates Protected Mode).nick8325 wrote:GRUB can only load 32-bit kernels, so you will have to use something else.
Every good solution is obvious once you've found it.
Re:GRUB PROB
But AFAIK (and according to grub/stage2/builtins.c:chainloader_func) it will only load one sector, so it only does what the BIOS would do anyway. As such it's not really useful as a bootloader for real mode code.Solar wrote:Incorrect. GRUB can chainload just about everything. It's only when you're loading a multiboot kernel that this must be a 32bit kernel (since the multiboot procedure activates Protected Mode).nick8325 wrote:GRUB can only load 32-bit kernels, so you will have to use something else.
Re:GRUB PROB
With the small difference that it can load that one sector from a wide variety of file systems, by name (it doesn't have to reside in the boot sector), provides a comfortable multiple-choice menu to select whether to chainload your sector or start Windows or Linux or whatever, provides network and CD-ROM booting...nick8325 wrote: But AFAIK (and according to grub/stage2/builtins.c:chainloader_func) it will only load one sector, so it only does what the BIOS would do anyway. As such it's not really useful as a bootloader for real mode code.
Every good solution is obvious once you've found it.