Page 1 of 2
BOCHS
Posted: Thu Feb 19, 2004 8:50 pm
by firas981
How I can use bochs on linux , especially for debugging
Re:BOCHS
Posted: Fri Feb 20, 2004 2:42 am
by Solar
1) Read the manual,
2) Install,
3) Run,
4) (optional) come back with more detailed questions...
Re:BOCHS
Posted: Fri Feb 20, 2004 10:33 am
by Pype.Clicker
or maybe you could
get a look at the FAQ ...
Bochs is available in most Linux distributions ... it has a lot of pre-compiled versions on the 'download' page of bochs.sf.net ...
Re:BOCHS
Posted: Sat Feb 21, 2004 9:06 am
by kris
I also have a question regarding Bochs. I want to run Grub in Bochs and load my Kernel wich is on my hd. I did cat the 2 stages to a floppy and Bochs boots grub from the floppy as expected. However, if i want to set root to my hd (root(hd0,1)) I get error 21, selected drive does not exist. I guess this is because Bochs does not recognize my hd, but I'm not sure. All I did was set ata0: enabled=1 in the .bochsrc file. Googling I found out that I should maybe create an image, but isn't it possible to directly load from hd ?
I also found some spare floppys, so if it's easier to put the kernel on an extra floppy and then maybe switch floppys while running Bochs, let me know.
Probably simpe and all, I just can't google right I guess.
Re:BOCHS
Posted: Sat Feb 21, 2004 10:14 am
by Tim
You really don't want to run Bochs using your real hard disk as an image. One bug in your code, or Grub, or Bochs, and it takes your real computer down -- and isn't the reason you're using Bochs so that you're not using your main computer for testing?
You should:
1) Create a hard disk image using the bximage program that comes with Bochs
2) Edit your config file so that Bochs knows where to find the new image
3) Download a FreeDOS boot floppy image and set Bochs to use that as A:
4) Boot Bochs from A:
5) Partition and format the C: drive from within Bochs using FDISK and FORMAT from the FreeDOS disk
6)
Copy your kernel onto the hard disk image
Re:BOCHS
Posted: Sat Feb 21, 2004 1:27 pm
by kris
Well, I feel like a total idiot.
I created an image c.img, using bochs' tool.
I got FreeDos and put it on a floppy, booting bochs and I partition and format the c.img in bochs using FreeDos' fdisk and format.
However, when I tried to boot it using root (hd0) grub tells me there's an tells me unknown filesystem and it doesn't work.
I also tried putting a filesystem onto it using mke2fs -F etc. I think it's a fundamental thinking error I'm making and I fiddled with it for too long, any more suggestions before I give up for today ?
Re:BOCHS
Posted: Sat Feb 21, 2004 1:45 pm
by kris
Just in case:
Gentoo Linux 2.6.3 Kernel, latest Bochs, latest Grub.
Re:BOCHS
Posted: Sat Feb 21, 2004 1:51 pm
by Tim
The root command in GRUB isn't very clever -- if you give it a hard disk name, it tries to recognise the MBR as a boot sector.
Try root (hd0,0) instead.
Re:BOCHS
Posted: Sat Feb 21, 2004 4:02 pm
by firas981
I read tutorials about bochs , it is easy however I got trouble with it , I think the best way to describe the problem is to print the bochs screen , and this is :
( Note1 : It is bochs under Windows Xp )
( Note2 : I am trying boot from floppy disk)
========================================================================
Bochs x86 Emulator cvs-snapshot
========================================================================
------------------
Bochs Startup Menu
------------------
1. Read options from...
2. Edit options
3. Save options to...
4. Begin simulation
5. Quit now
Please choose one: [1] 1
What is the configuration file name?
To cancel, type 'none'. [none] bochs.txt
00000000000i[ ] reading configuration from bochs.txt
------------------
Bochs Startup Menu
------------------
1. Read options from...
2. Edit options
3. Save options to...
4. Begin simulation
5. Quit now
Please choose one: [4] 4
00000000000i[ ] using log file bochsout.txt
========================================================================
Event type: PANIC
Device: [BIOS ]
Message: [BIOS ] BIOS panic at rombios.c, line 3417
A PANIC has occurred. Do you want to:
cont - continue execution
alwayscont - continue execution, and don't ask again.
This affects only PANIC events from device [BIOS ]
die - stop execution now
abort - dump core
Choose one of the actions above: [die]
thanks
Re:BOCHS
Posted: Sat Feb 21, 2004 4:28 pm
by Tim
Those are some very nice menus, but what does bochsout.txt say? We know there's something wrong, because it says "A PANIC has occurred", but we don't know what without reading the log.
Re:BOCHS
Posted: Sat Feb 21, 2004 7:54 pm
by firas981
This is the log file :
00000000000i[MEM0 ] 0.00MB
00000000000i[MEM0 ] rom at 0xf0000/65536 ('BIOS-bochs-latest')
00000000000i[MEM0 ] rom at 0xc0000/32769 ('VGABIOS-elpin-2.40')
00000000000i[CMOS ] Setting initial clock to: Sun Feb 22 03:54:34 2004
00000000000i[FDD ] tried to open 1.44 read/write: No such file or directory
00000000000i[FDD ] tried to open 1.44 read only: No such file or directory
00000000000i[FDD ] fd0: '1.44' ro=1, h=0,t=0,spt=0
00000000000i[SB16 ] midi=0, wave=0, log=0, dmatimer=0
00000000000i[VGA ] interval=30000
00000000000i[SER ] com0 at 0x3f8/8 irq 4
00000143281i[BIOS ] BIOS Version is $Id: rombios.c,v 1.13 2001/06/07 18:03:29 bdenney Exp $
00000169302i[FDD ] attempt to read/write sector 1, sectors/track=0
00000172140i[BIOS ] Boot Failure! I could not read floppy drive 0.
00000172182p[BIOS ] >>PANIC<< BIOS panic at rombios.c, line 3417
00000172182i[SYS ] Last time is 1077450874
00000172182i[CPU ] real mode
00000172182i[CPU ] CS.d_b = 16 bit
00000172182i[CPU ] SS.d_b = 16 bit
00000172182i[CPU ] | EAX=00030d59 EBX=0000d732 ECX=00030001 EDX=00000400
00000172182i[CPU ] | ESP=0000fff0 EBP=0000fffa ESI=00000000 EDI=00000500
00000172182i[CPU ] | IOPL=0 NV UP DI PL ZR NA PE NC
00000172182i[CPU ] | SEG selector base limit G D
00000172182i[CPU ] | SEG sltr(index|ti|rpl) base limit G D
00000172182i[CPU ] | DS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00000172182i[CPU ] | ES:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00000172182i[CPU ] | FS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00000172182i[CPU ] | GS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00000172182i[CPU ] | SS:0000( 0000| 0| 0) 00000000 0000ffff 0 0
00000172182i[CPU ] | CS:f000( 0000| 0| 0) 000f0000 0000ffff 0 0
00000172182i[CPU ] | EIP=000038eb (000038ea)
Re:BOCHS
Posted: Sat Feb 21, 2004 9:11 pm
by Schol-R-LEA
Can you post your configuration file as well? What looks to be happening is that it is expecting to use a file named '1.44' as you floppy disk image, and the file is missing. My guess is that you have it set to this line from the example configuration file
[tt]floppya: file=../1.44, status=inserted[/tt]
You will need to change the path and filename to that of whatever file you are actually using as your floppy disk image.
Re:BOCHS
Posted: Sun Feb 22, 2004 7:15 am
by firas981
megs: 32
romimage: file=BIOS-bochs-latest, address=0xf0000
vgaromimage: VGABIOS-elpin-2.40
floppya: 1_44=1.44, status=inserted
boot: a
log: bochsout.txt
mouse: enabled=0
#where 1.44 is in the same directory as bochs
#thanks
Re:BOCHS
Posted: Sun Feb 22, 2004 11:06 am
by kris
Well, I'm totally lost here.
This is what I tried so far:
1) Get Bochs working and set up: check
2) Create a hd-image (c.img) using the defaults used by bximage: check
3) Get a FreeDos image and dd it to a floppy, boot it using Bochs: check
4) fdisk and format the c.img using FreeDos running in Bochs: check
tried the following: default (fat12), fat32, fat32 lba
with and without the MBR that fdisk creates, with and without marking the partition active. According to FreeDos everything works fine.
5) Checked if I can root it from Grub which is started from a floppy in Bochs using root(hd0,0): check
6) Tried to mount it in Linux, so that I could copy the Kernel to the c.img : FAILED
I have support for all possible Microsoft filesystems compiled into the Linux-kernel so that can't be the problem. Here's how I try to mount c.img:
losetup -d /dev/loop0
mount -t vfat/msdos etc. tried them all /dev/loop0 /mnt/lb/
-> wrong fs type, bad option, bad superblock on /dev/loop0,
or too many mounted file systems
I also tried to mount and format the c.img using mkdosfs etc (not using Bochs) didn't work either.
Totally desperate by now, any kind of help would be apreciated.
The problem is getting my file to the c.img somehow so that I can use Grub to boot it.
Re:BOCHS
Posted: Sun Feb 22, 2004 11:52 am
by Tim
I'm no Linux expert, but I'm guessing the problem with mounting it on the loopback device is that you've got an image of an entire hard disk, not just one partition.
If you mounted a normal file system, you'd give mount the name of a partition on a disk, not the disk itself. That's what's happening here: c.img is an entire hard disk image, not just one partition. Linux is looking for a FAT boot sector at the start of the image file, and it's finding an MBR.
Since I'm not a Linux expert, I can't recommend a solution. If you were using Windows, I'll suggest that you used WinImage or Mtools to edit the image.