cfenollosa / os-tutorial

How to create an OS from scratch
BSD 3-Clause "New" or "Revised" License
27.28k stars 3.31k forks source link

[Kernel Bare Bones] Hard Disk load disk error Qemu. #278

Open Nabir14 opened 3 months ago

Nabir14 commented 3 months ago

I followed everything step by step to 13 Kernel Bare Bones where I encountered a problem.

While running os-image.bin in Qemu it says: Booting From Hard Disk... Boot Failed: Cannot boot from hard disk

Running it with -hda instead of -fda my bootloader throws the error Disk Error with Hex 0x0c80.

Also it gives this warning while linking kernel.o and kernel_entrypoint.o:

/usr/local/i386elfgcc/bin/i386-elf-ld: warning: cannot find entry symbol _start; defaulting to 00001000

Same code. How to fix?

blingo77 commented 3 months ago

make sure that the kernel offset is 0x1000 in bootsect.asm and that you are loading 2 into the dh register before calling disk_load.

also running qemu-system-x86_64 -fda os-image.bin works pretty well for me.

The warning that you are getting that it's defaulting to 00001000 is just the kernel offset specified in bootsect.asm. Which is where the kernel will be found in memory. So this warning is nothing to worry about and will not cause any trouble when linking all your files together.

hopefully this helps

Nabir14 commented 3 months ago

make sure that the kernel offset is 0x1000 in bootsect.asm and that you are loading 2 into the dh register before calling disk_load.

also running qemu-system-x86_64 -fda os-image.bin works pretty well for me.

The warning that you are getting that it's defaulting to 00001000 is just the kernel offset specified in bootsect.asm. Which is where the kernel will be found in memory. So this warning is nothing to worry about and will not cause any trouble when linking all your files together.

hopefully this helps

It didn't work. I mean everything you said is correct and in my code they are too. The problem is it can't load the disk so if I use -fda it loads from floppy disk (since it can't load from hard disk) but I want it to load from hard disk so I use -hda and it returns error code 0x0c80. My disk.asm is alright.

Why don't you check my source code and see if I am doing anything wrong. https://github.com/Nabir14/AmpereOS