Can't for the life of me load my kernel!!

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
necroCoder
Posts: 1
Joined: Sat Jul 06, 2013 3:52 pm

Can't for the life of me load my kernel!!

Post by necroCoder »

Hello Everybody,
This is my first time posting in this forum, so... I've been attempting to write a bootloader that boots off of a floppy to load my next stage for the last couple of weeks now, and I'm having no success. I'm using VirtualBox along with the nasm assembler. I can usally get a simple bootloader assembled and working, but any time I try and get a kernel or a stage two loaded...nothing happens. I'm stuck and I think that my linking is wrong somewhere. Also I have tried to load off of an .iso file, and still no success. Does anybody know how to format a bootable .vdi formatted file?
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Can't for the life of me load my kernel!!

Post by Antti »

You can create a bootable raw image with NASM. Then you can use VBoxManage program to convert that into .vdi format.
http://www.virtualbox.org/manual/ch08.html wrote:VBoxManage convertfromraw

This command converts a raw disk image to a VirtualBox Disk Image (VDI) file
In this case the command would be something like this:

Code: Select all

VBoxManage convertfromraw --format VDI <my_raw_image.bin> <my_vdi_image.vdi>
Be sure to check the manual for proper description. If you are creating a bootable floppy, then you can easily just use the raw-image directly. Rename the file extension to .img and the VirtualBox directly regocnizes (the file browser in Windows, in fact) it when you are attaching the image to floppy device. Also, make sure that the size of the image is something that is standardised for floppies. E.g. 1474560 bytes.

This trick works easily in NASM when you add this at last line in your NASM source (you probably did use same approach with the boot signature).

Code: Select all

times 1474560 - ($ - $$) db 0
Good luck with low-level programming and welcome to this forum! By the way, I think floppies are a good way to start. Creating a good hard-drive image is not so simple.
HugeCode
Member
Member
Posts: 112
Joined: Mon Dec 17, 2012 9:12 am

Re: Can't for the life of me load my kernel!!

Post by HugeCode »

@Antti: for this purpose I used 'convertdd' command and I didn't need to have aligned size of file - if .img file was too small (128, 256KB...), vboxmanage created 1MB disk without complaining. Is this the difference between 'convertdd' and 'convertfromraw' (as 'convertdd' is older version of 'convertfromraw')?
Antti
Member
Member
Posts: 923
Joined: Thu Jul 05, 2012 5:12 am
Location: Finland

Re: Can't for the life of me load my kernel!!

Post by Antti »

@HugeCode: I think all the converting methods handle the issue. When someone creates a floppy image directly, the "aligned" size matters. Whether that is created with NASM or some hex editor. Any of those converting methods are not in use in that case. VirtualBox accepts that flat format for floppies.
Post Reply