Page 1 of 1

Bare bones C: trouble with grub

Posted: Mon Mar 30, 2009 5:35 pm
by nuclearmass
Ok so i managed to get help from another thread about bochs and grub, but now im at the part of the Bare bones C tutorial where it says:

Code: Select all

kernel 200+18
boot
but when i try the kernel 200+4(or five not sure) i get:

Code: Select all

Error 13: Invalid or unsupported executable format
now don't get me wrong i have been searching for a way to solve this for awhile but i can't seem to find a solution in troubleshooting, and forums.
Infact i read a thread awhile ago and tried to build my kernel.bin file with mingw instead of cygwin, but it still didn't work. Also i could be doing the number of bytes divided by 512 then rounded to the next integer to find the blocks step wrong

Any help would be nice...

Re: Bare bones C: trouble with grub

Posted: Mon Mar 30, 2009 5:39 pm
by Troy Martin
kernel 200+18

Re: Bare bones C: trouble with grub

Posted: Mon Mar 30, 2009 5:40 pm
by pcmattman
And...
Infact i read a thread awhile ago and tried to build my kernel.bin file with mingw instead of cygwin
Are you using a cross-compiler to build an ELF binary? If not, you'll be using the Cygwin or Mingw toolchain - both of which will produce a PE executable which GRUB can't boot by itself.

Re: Bare bones C: trouble with grub

Posted: Tue Mar 31, 2009 1:19 am
by Solar
Where does that "208" in your posts come from?

What is the size of your kernel.bin?

From the Wiki:
Important: first check the size of your kernel.bin in blocks. This is the length in bytes, divided by 512 and rounded up to the next integer. You will need this number. Let us assume that the kernel size is 18 blocks.
The whole Bochs section is a bit fishy, as it makes assumptions on the sizes of stage1, stage2, and kernel.bin, but doesn't elaborate on how to determine them, so I guess it's easy to fall into the trap of merely copying the values without checking them.

Re: Bare bones C: trouble with grub

Posted: Tue Mar 31, 2009 2:23 am
by JackScott
I've made a note of that in the Wiki (here), hopefully somebody with a bit of knowledge in using Bochs can flesh out that part.

Re: Bare bones C: trouble with grub

Posted: Tue Mar 31, 2009 2:52 am
by Kevin
Wouldn't it be less confusing to use a file system instead of those block lists?

Re: Bare bones C: trouble with grub

Posted: Tue Mar 31, 2009 7:04 am
by Solar
I think the idea here was to avoid having to mount the image (as you would have to to install GRUB the "standard" way). But I agree - one of the biggest benefits of GRUB, IMHO, is that you can exchange the kernel image without having to rewrite stage1 and stage2...

Re: Bare bones C: trouble with grub

Posted: Tue Mar 31, 2009 9:27 am
by Kevin
Yes, that's obviously the idea. And for a quick success it might even be the best. But considering that you need to adapt to the new kernel size each time, I'd say after about the third non-trivial change to the kernel you would have saved time if you had done it right in the first place (even with Windows, where you need additional software to mount images).

Re: Bare bones C: trouble with grub

Posted: Tue Mar 31, 2009 4:50 pm
by nuclearmass
sorry for the day wait, i've been a little busy. My kernel bin size is 2,426 bytes, and that kernel 200+208 was a mistake/typo.