Write comments

[SOLVED] magic number

13. Mar 2017, 11:14

Hi,

i watched the tutorial on youtube "writing your own OS in 1 hour":
https://www.youtube.com/watch?v=1rnA6wpF0o4

unfortunatelly my grub2 boot loader has problems with the magic number, saying: it is invalid

it tried 0x1badb002 and 0x2badb002 with kubuntu 15.10, ubuntu 13.04 and ubuntu 10.10 on VMware Player.

nothing works.

has anyone any idea? or is the problem sitting right in front of the screen? :D

cheers,
hugo

13. Mar 2017, 11:14

Re: magic number

13. Mar 2017, 11:43

0x1badb002 should be correct.

Did you put the magic number at the beginning of the file? grub will only search through the first (iirc) 2 MiB of the file, so if you have a large stack and put the magic number behind it, that would cause grub to just not find it.

Re: magic number

13. Mar 2017, 12:58

hi,

sure: its the first line of code in loader.s

its exactly the same code as in your youtube tutorial!

.set MAGIC, 0x1badb002 #assembler variable magic number for boot loader
.set FLAGS, (1<<0 | 1<<1) #flag for boot loader
.set CHECKSUM, -(MAGIC + FLAGS) #checksum for boot loader

.section .multiboot
.long MAGIC
.long FLAGS
.long CHECKSUM

.section .text
.extern kernelMain
.global loader

loader:
mov $kernel_stack, %esp
push %eax
push %ebx
call kernelMain

_stop:
cli
hlt
jmp _stop


.section .bss
.space 2*1024*1024; # 2MiB for stack
kernel_stack:

Re: magic number

13. Mar 2017, 13:11

i found the problem at least.

and as i guessed: the problem was sitting right in front of the screen.

i configured the wrong menuentry in grub.

instead of:

menuentry 'mykernel' {
multiboot /boot/mykernel.bin
}

i did:

menuentry 'mykernel' {
linux /boot/mykernel.bin
}

thanx a lot for your great support!
and you really do a great stuff in your tutorials!
Write comments




Bei iphpbb3.com bekommen Sie ein kostenloses Forum mit vielen tollen Extras
Forum kostenlos einrichten - Hot Topics - Tags
Beliebteste Themen: NES, Mode, Linux, Rap, Programm

Impressum | Datenschutz