<deleted>
Re: GRUB error 13: I *have* searched :|
Because you said, "Thanks" I'll give you one more hint just to help you figure out more quickly if it really is an issue with multiboot headers.
Look in your loader.s file. You should see something in it that mentions Multiboot Headers. Verify that it matches exactly with the tutorial you are following. (The header is the part with MAGIC, FLAGS, and then CHECKSUM).
Then, just to be doubly-sure, load your kernel.bin into a hex editor and make sure you find your header in the file. It should be pretty close to the beginning (look at the Multiboot specification to get exactly how close).
One other check that you should do is to load your floppy.img file in a hex editor and make sure that your kernel really starts *exactly* in the file where you think it should.
Standard disclaimer: There are tons of little tiny things that could be causing the problems you are seeing so it is possible that nothing I've told you is even related to your problem.
Look in your loader.s file. You should see something in it that mentions Multiboot Headers. Verify that it matches exactly with the tutorial you are following. (The header is the part with MAGIC, FLAGS, and then CHECKSUM).
Then, just to be doubly-sure, load your kernel.bin into a hex editor and make sure you find your header in the file. It should be pretty close to the beginning (look at the Multiboot specification to get exactly how close).
One other check that you should do is to load your floppy.img file in a hex editor and make sure that your kernel really starts *exactly* in the file where you think it should.
Standard disclaimer: There are tons of little tiny things that could be causing the problems you are seeing so it is possible that nothing I've told you is even related to your problem.
- NickJohnson
- Member
- Posts: 1249
- Joined: Tue Mar 24, 2009 8:11 pm
- Location: Sunnyvale, California
Re: GRUB error 13: I *have* searched :|
The header will not have the words "multiboot", "FLAGS", "MAGIC", etc. because those are just macros within the assembler. Look at the binary in hex (not characters), and you should see the magic number 1BADB002 which signifies the start of the header.
I'm guessing your problem is that the header is in the wrong place - it *must* be linked to be the first thing after the ELF header. Could you post your linker script, and the positioning of the header within it's section?
I'm guessing your problem is that the header is in the wrong place - it *must* be linked to be the first thing after the ELF header. Could you post your linker script, and the positioning of the header within it's section?
Re: GRUB error 13: I *have* searched :|
You probably aren't looking quite far enough. In my little kernel the Multiboot Header starts at offset 0x1000.
Google "Multiboot header" and look at any documentation you can find on gnu.org. In particular, look at section 3 of that documentation. This will tell you how to recognize what a multiboot header should look like (and no, you shouldn't see the words FLAGS, or CHECKSUM, or anything like that in your executable).
Also, when interpreting the numbers make sure you remember that the numbers are little-endian.
Edit: Looks like someone already posted some of the info I told you to look up in documentation.
Google "Multiboot header" and look at any documentation you can find on gnu.org. In particular, look at section 3 of that documentation. This will tell you how to recognize what a multiboot header should look like (and no, you shouldn't see the words FLAGS, or CHECKSUM, or anything like that in your executable).
Also, when interpreting the numbers make sure you remember that the numbers are little-endian.
Edit: Looks like someone already posted some of the info I told you to look up in documentation.
Re: GRUB error 13: I *have* searched :|
I would check to make sure that your floppy image is correct. Your kernel must start on a 0x200 byte boundary. If either your kernel isn't on the right boundary or you don't correctly identify the sector when you try to boot in grub that would also explain the problems you are experiencing.
EDIT: Also, your linker script is the *.ld file.
EDIT Again: He edited his post above to reflect my comment.
EDIT: Also, your linker script is the *.ld file.
EDIT Again: He edited his post above to reflect my comment.
Last edited by terry on Tue Sep 01, 2009 9:27 am, edited 1 time in total.
Re: GRUB error 13: Fixed :)
Hi CJKay,
Just my two cents....
Try not to delete a lot of content when you edit your posts. If you do, then future people who search through the forums trying to find answers to their questions will get much less from the posts.
EDIT: Congratulations on fixing your problem by the way.
Just my two cents....
Try not to delete a lot of content when you edit your posts. If you do, then future people who search through the forums trying to find answers to their questions will get much less from the posts.
EDIT: Congratulations on fixing your problem by the way.
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: GRUB error 13: I *have* searched :|
I was going to post up the solution since page one, but I decided against it since I assumed that if you couldn't troubleshoot something that simple, it would be better if you didn't get through. I had that problem in the beginning. When I was downloading the GrUB files, I went and took 0.94 since it was at the top. (More convenient).When I eventually went through the whole thing again, I decided to take the newest version, and presto: 0.97 worked!CJKay wrote:I fixed it .
That was 10 hours of scrupulous work, only to find I had to redownload GRUB's stage 2 .
Thanks so much for your help guys, even if it didn't help with the actual problem . I learned a lot in the process so it's not all bad.
Thanks .
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
Re: GRUB error 13: Fixed :)
IIRC, you can doCJKay wrote:Well, onto paging!
One more thing, how can I pass the end-of-kernel address from the linker? I have "__END_OF_KERNEL = .;" in linker.ld but how can I pass it through to C as a variable?
Thanks guys lol
Code: Select all
extern int __END_OF_KERNEL;
address_of_the_end_of_the_kernel = &__END_OF_KERNEL;// __END_OF_KERNEL is a variable that's at the end of your kernel and &__END_OF_KERNEL gives you its address
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: GRUB error 13: Fixed :)
Umm...as clarification: that doesn't just pop up magically, by the way. You'd need to edit your linker script.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.
- 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 error 13: Fixed :)
So much for pointer skills.I get: "error: invalid operands to binary & (have 'unsigned int *' and 'unsigned int')".Code: Select all
unsigned int page_aligned_end = (((unsigned int*)__END_OF_KERNEL) & 0xFFFFF000) + 0x1000;
What do I do here? If I remove the pointer it compiles, but doesn't do what I need. If I keep the pointer like the tutorial says it errors :S.
I've also tried &__END_OF_KERNEL but that gives the same error too.
end_of_kernel is a symbol identifying a constant location. You give it a type in the extern declaration, which makes C think it is a variable of a sort, whose data is stored at the location defined by the symbol. So naturally if you ask for end_of_kernel, you'll get the value at the end of the kernel (which obviously isn't there). if you ask for &end_of_kernel, you get the address of that variable, which is the same as the value of the symbol.
Other problem: gcc wont allow you to do several operations on pointers for good reason (most people who do that are morons). So you will have to change the type somewhere too.
Now you should have enough info to figure this one out.
- gravaera
- Member
- Posts: 737
- Joined: Tue Jun 02, 2009 4:35 pm
- Location: Supporting the cause: Use \tabs to indent code. NOT \x20 spaces.
Re: GRUB error 13: Fixed :)
@OP: The problem is that you're trying to use a pointer and a plain integer as operands to the & operator. Your compiler is telling you that it's uncomfortable with that. Simply cast them all to either pointers, or integers. A pointer is nothing more than a number, by the way (in the simplest of terms).
To make things too obvious: remove the * operator on the first operand.
To make things too obvious: remove the * operator on the first operand.
17:56 < sortie> Paging is called paging because you need to draw it on pages in your notebook to succeed at it.