Yet another grub 13 error

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
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

Yet another grub 13 error

Post by evoex »

Hi all,

Today I had to re-start coding from scratch as my laptop died (and I'm too lazy to make backups). I've set up a cross compiler for x86_64 on my Mac. Now I'm getting grub error 13 and, yes, I did try what it says on the Wiki...

My code is extremely simple so far. First, I took the RDOS grub disk image. My "entry.s" file is simply:

Code: Select all

[section .__mbHeader]
MODULEALIGN	equ 1 << 0
MEMINFO		equ 1 << 1
FLAGS		equ MODULEALIGN | MEMINFO
MAGIC		equ 0x1BADB002
CHECKSUM	equ ~(MAGIC | FLAGS)

align 0x4
	dd MAGIC
	dd FLAGS
	dd CHECKSUM

[section .setup]
[global _start]

_start:
	jmp	$
My Link.ld:

Code: Select all

OUTPUT_FORMAT(elf32-i386)
ENTRY(_start)

SECTIONS {

    . = 0x00100000;
    .__mbHeader : {
        *(.__mbHeader)
    }

    .text ALIGN(0x1000) : {
        *(.setup)
    }


    /DISCARD/ :
    {
        *(.comment)
        *(.eh_frame)
    }
}
And it gets compiled as:
/opt/local/bin/yasm -f elf32 -o entry.o entry.s
/usr/local/cross/bin/x86_64-elf-ld -melf_i386 -T Link.ld -o kernel ./entry.o
Yes, I do link it with a 64 bit linker, as my cross compiler is 64 bits, but I believe that should work fine for compiling 32 bit applications... right?

All looks fine, except that I get a grub error 13: Invalid or unsupported executable format.

Some information about the kernel binary:
$ /usr/local/cross/bin/x86_64-elf-objdump -s kernel/kernel

kernel/kernel: file format elf32-i386

Contents of section .__mbHeader:
100000 02b0ad1b 03000000 fc4f52e4 .........OR.
Contents of section .text:
101000 ebfe0000 00000000 00000000 00000000 ................
$ /usr/local/cross/bin/x86_64-elf-objdump -f kernel/kernel

kernel/kernel: file format elf32-i386
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x00101000
What's the issue? Is there something wrong with my multiboot header?


Thanks in advance
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

Re: Yet another grub 13 error

Post by evoex »

Ok, I solved it...

The line

Code: Select all

CHECKSUM   equ ~(MAGIC | FLAGS)
should have been

Code: Select all

CHECKSUM   equ -(MAGIC | FLAGS)
That is, no bitwise not, but the negative value... Those two symbols can look quite similar in some fonts ;-).
User avatar
CocaCola
Member
Member
Posts: 36
Joined: Fri Sep 07, 2012 9:11 am

Re: Yet another grub 13 error

Post by CocaCola »

evoex wrote:Today I had to re-start coding from scratch as my laptop died (and I'm too lazy to make backups).
I don't know about the toolchain you use on your Mac, but on Linux you can certainly use the Makefile to automate backups. I myself have a Backup section which cleans, then creates a nice archive of the current source.
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Yet another grub 13 error

Post by bluemoon »

You can always do code backup by doing nothing. That's what computer for - it do things so you don't need to get involved.

Try svn post-commit hook.
User avatar
JamesM
Member
Member
Posts: 2935
Joined: Tue Jul 10, 2007 5:27 am
Location: York, United Kingdom
Contact:

Re: Yet another grub 13 error

Post by JamesM »

CocaCola wrote:
evoex wrote:Today I had to re-start coding from scratch as my laptop died (and I'm too lazy to make backups).
I don't know about the toolchain you use on your Mac, but on Linux you can certainly use the Makefile to automate backups. I myself have a Backup section which cleans, then creates a nice archive of the current source.
It's almost like you haven't heard of version control...
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Yet another grub 13 error

Post by Kevin »

evoex wrote:should have been

Code: Select all

CHECKSUM   equ -(MAGIC | FLAGS)
This fixes only one of the two wrong operators...
Developer of tyndur - community OS of Lowlevel (German)
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

Re: Yet another grub 13 error

Post by evoex »

Kevin wrote:
evoex wrote:should have been

Code: Select all

CHECKSUM   equ -(MAGIC | FLAGS)
This fixes only one of the two wrong operators...
Good point, I fixed that somewhere along the way :P. Final version:

Code: Select all

CHECKSUM   equ -(MAGIC + FLAGS)
And I know backing up can be quite easy, I was just too lazy to set up a back up system. Terrible, I know...
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Yet another grub 13 error

Post by Kevin »

evoex wrote:And I know backing up can be quite easy, I was just too lazy to set up a back up system. Terrible, I know...
You want a version control system, not just some backup. And this is essential for anything larger than Hello World.
Developer of tyndur - community OS of Lowlevel (German)
User avatar
bluemoon
Member
Member
Posts: 1761
Joined: Wed Dec 01, 2010 3:41 am
Location: Hong Kong

Re: Yet another grub 13 error

Post by bluemoon »

OS development involves years of work, I cannot imagine doing it without version control & multiple site remote backup; and I also do wiki, bug tracker, and scan backup of physical papers - it only take a day or two to setup but it will be useful for the next ten years of development.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Yet another grub 13 error

Post by Antti »

Kevin wrote:You want a version control system, not just some backup. And this is essential for anything larger than Hello World.
I do not use any version control system in my OS project but proper backups are made regularly. This is interesting because I do not have any reasonable explanation for not having it. I somehow do not like the revisions, commits, comments for commits, and things like that. Rather convincing arguments, right? Is there anyone here how has not used any version control system and still has a "larger than Hello World project" going well?

I have used version control systems in projects with other developers involved in and it worked very well there. It may be that I will start using it also with my OS project after the system is "stable" and "ready for it."
User avatar
Jezze
Member
Member
Posts: 395
Joined: Thu Jul 26, 2007 1:53 am
Libera.chat IRC: jfu
Contact:

Re: Yet another grub 13 error

Post by Jezze »

A version control system is awesome even if you are the only person working on something. I start programming on something and then notice this was a stupid idea and I just go "git checkout -f" and then I'm back where I was before. No need to keep track of backups or any sort of crap. If I want to do a backup I just write "git push". I want to know what files I've done changes it is "git status". I would not be able to live without these shortcuts. It just makes life so much easier.
Fudge - Simplicity, clarity and speed.
http://github.com/Jezze/fudge/
Kevin
Member
Member
Posts: 1071
Joined: Sun Feb 01, 2009 6:11 am
Location: Germany
Contact:

Re: Yet another grub 13 error

Post by Kevin »

Antti wrote:I do not use any version control system in my OS project but proper backups are made regularly.
I think in part I have to take back what I implied. With such backups, you do have some version control, just a very bad one. At least it allows you to roll back when you've really messed up.
This is interesting because I do not have any reasonable explanation for not having it. I somehow do not like the revisions, commits, comments for commits, and things like that. Rather convincing arguments, right?
Yes, almost. ;)

Does it never occur to you that you want to check some things in the history of your project? Like "hm, in what context did I introduce this code"? Or maybe you don't even think about things like this, because you can't get the information anyway.
Developer of tyndur - community OS of Lowlevel (German)
evoex
Member
Member
Posts: 103
Joined: Tue Dec 13, 2011 4:11 pm

Re: Yet another grub 13 error

Post by evoex »

I agree, version control is brilliant. And would've set it up for my OS, but I was at too early stage, and couldn't be bothered to set it up yet (to be fair, I only lost 2 weeks of work :P). Yes, "apt-get install git", "git init", is WAY too much work :P.

Now I've got XCode set up for osdev, and I do use source control ;-).

No wiki as of yet. Doxygen style comments, though... Wiki maybe in the future.
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Yet another grub 13 error

Post by Antti »

Kevin wrote:With such backups, you do have some version control, just a very bad one.
Yes, it is not very elegant. However, it works well.
Kevin wrote:Does it never occur to you that you want to check some things in the history of your project?
The current status is the one that counts. Of course all the releases are archived.

To be serious, there are no plausible arguments against the version control system. It is better in every reasonable aspect. However, I think that it is not absolutely necessary or even very "brilliant."
rdos
Member
Member
Posts: 3307
Joined: Wed Oct 01, 2008 1:55 pm

Re: Yet another grub 13 error

Post by rdos »

Backups only allow you to revert back to a few points, and provides no simple tools to locate changes. It happens from time to time that I discover bugs in something I rarely test, or instability. Then I just check out all relevant versions and build them and can then pretty easy locate the point that breaks the system.
Post Reply