Bootloader

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.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Bootloader

Post by neon »

ChrisSkura wrote:k, I am not using Bochs because It doesn't find anything on my floppy disk. I test my bootloader off startup and it prints out
Okay... I suspect the above is the problem. What do you mean by "off startup"? You test your bootloader on what if you dont use bochs? CD? Floppy disk? Emulator? Real PC? Need details, details, details! Does this disk have your kernel.bin on it? Dont guess here - physically put the disk in a Windows machine and check.

I also do not think bochs fails to find anything on the floppy disk unless i)It is configured incorrectly (your config file), or ii) There really is nothing on your boot disk.

...I am also still waiting for your bochs crash log.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

Re: Bootloader

Post by ChrisSkura »

k, after I've assembled my bootloader and my kernel, I drag my bootloader and kernel from c:\ to a:\ and it shows the Icons on the screen (and they are on my floppy disk) after that I use the debug function in command prompt:

Code: Select all

debug a:\boot.bin
w 100 0 0 1
in bochs even if I have a floppy disk in my computer with a bootable program on it, bochs acts like there's no floppy disk in my computer.

I test it by turning off my computer and putting in my floppy disk then turning the computer back on and waiting for my program to load. the bootloader loads and displays

loading boot image . . . . . . . . . . . . . . . . .

but then it doesn't load my kernel.
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

Re: Bootloader

Post by ChrisSkura »

bochs doesn't really crash it just doesn't do anything.
User avatar
Combuster
Member
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: Bootloader

Post by Combuster »

We might be able to help if you actually listened. There still is no bochs log, you repeat the same things over and over yet all the details are missing.

Are you even trying, because right now you are just wasting our time.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

Re: Bootloader

Post by ChrisSkura »

when I run bochs it says:

Booting from Floppy. . .
Booting failed: could not read the boot disk

FATAL: No bootable device.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Bootloader

Post by neon »

Post your configuration file please. Testing on real hardware is a good idea - but I highly do recommend using emulators and virtual environments as well - not just because it is easier, but also for the safety of your own machine.

It should not effect anything, however try writing your bootloader to the 1st sector first - then copy the kernel over.
Last edited by neon on Wed Nov 18, 2009 5:06 pm, edited 1 time in total.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Bootloader

Post by neon »

When you run bochs, select [2] (read options from) and type the filename in. The file is just a plain text file with options. For example, this should work for you:

Code: Select all

# ROM and VGA BIOS images ---------------------------------------------

romimage:    file=BIOS-bochs-latest
vgaromimage: VGABIOS-lgpl-latest 

# boot from floppy using our disk image -------------------------------

floppya: 1_44=a:, status=inserted  # Boot from drive A

# logging and reporting -----------------------------------------------

log:         Crash.log             # All errors and info logs will output to here
error:       action=report 
info:        action=report
Select [6] (or just hit <enter> after) and it should work. The bochs crash log is whatever filename you give it (its Crash.log) above.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

Re: Bootloader

Post by ChrisSkura »

when I try to load the config files it says

00000000000i[ ] reading configuration from c:\config.txt
00000000000p[ ] >>PANIC<< c:\config.txt: romimage directive: wrong # args.
00000000000i[SYS ] Last time is 0
00000000000i[ ] restoring default signal behavior
========================================================================
Bochs is exiting with the following message:
[ ] c:\config.txt: romimage directive: wrong # args.
========================================================================
00000000000i[CTRL ] quit_sim called with exit code 1

Bochs is exiting. Press ENTER when you're ready to close this window.
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Bootloader

Post by neon »

Assuming you have an older version of bochs, try replacing the romimage line with romimage: file=BIOS-bochs-latest, address=0xf0000 If that fails to work, post the version of bochs that you are using.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Bootloader

Post by Love4Boobies »

I didn't really look at the code but I noticed your origins are 0 for both the kernel and the boot sector. Shouldn't you use whatever offset you load the kernel to and 7C00h, respectively? I'm unsure if that's really an issue; I didn't take a close look to see if the code is PIC.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

Re: Bootloader

Post by ChrisSkura »

one down, I got bochs working. I unistalled the version I had and installed v2.3
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

Re: Bootloader

Post by ChrisSkura »

after testing it on bochs it just loops back to

main:

this part of the crash log keeps repeating

00001691169i[FDD ] read() on floppy image returns 0
00002540757i[FDD ] read() on floppy image returns 0
00003411845i[FDD ] read() on floppy image returns 0
00004282907i[FDD ] read() on floppy image returns 0
00005153950i[FDD ] read() on floppy image returns 0
00006024993i[FDD ] read() on floppy image returns 0
00006896036i[FDD ] read() on floppy image returns 0
00007767169i[FDD ] read() on floppy image returns 0
00008638257i[FDD ] read() on floppy image returns 0
00009511365i[FDD ] read() on floppy image returns 0
00010382453i[FDD ] read() on floppy image returns 0
00011253541i[FDD ] read() on floppy image returns 0
ChrisSkura
Member
Member
Posts: 33
Joined: Sat Nov 07, 2009 2:47 am

Re: Bootloader

Post by ChrisSkura »

I got it working.

For some reason if I assemble my bootloader first and then assemble my kernel it doesn't work but if I assemble my kernel then my bootloader it works fine!

Thanks everyone that helped me get this working!
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: Bootloader

Post by Love4Boobies »

Maybe you don't read enough sectors and kernel.bin is too far away or something?
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Post Reply