Bare bones C: trouble with grub

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.
Post Reply
nuclearmass
Posts: 4
Joined: Sun Mar 29, 2009 3:59 pm

Bare bones C: trouble with grub

Post 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...
Last edited by nuclearmass on Wed Apr 01, 2009 5:12 pm, edited 1 time in total.
User avatar
Troy Martin
Member
Member
Posts: 1686
Joined: Fri Apr 18, 2008 4:40 pm
Location: Langley, Vancouver, BC, Canada
Contact:

Re: Bare bones C: trouble with grub

Post by Troy Martin »

kernel 200+18
Image
Image
Solar wrote:It keeps stunning me how friendly we - as a community - are towards people who start programming "their first OS" who don't even have a solid understanding of pointers, their compiler, or how a OS is structured.
I wish I could add more tex
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Re: Bare bones C: trouble with grub

Post 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.
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Bare bones C: trouble with grub

Post 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.
Every good solution is obvious once you've found it.
User avatar
JackScott
Member
Member
Posts: 1035
Joined: Thu Dec 21, 2006 3:03 am
Location: Hobart, Australia
Mastodon: https://aus.social/@jackscottau
Matrix: @JackScottAU:matrix.org
GitHub: https://github.com/JackScottAU
Contact:

Re: Bare bones C: trouble with grub

Post 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.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Bare bones C: trouble with grub

Post by Kevin »

Wouldn't it be less confusing to use a file system instead of those block lists?
Developer of tyndur - community OS of Lowlevel (German)
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re: Bare bones C: trouble with grub

Post 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...
Every good solution is obvious once you've found it.
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Bare bones C: trouble with grub

Post 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).
Developer of tyndur - community OS of Lowlevel (German)
nuclearmass
Posts: 4
Joined: Sun Mar 29, 2009 3:59 pm

Re: Bare bones C: trouble with grub

Post 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.
Post Reply