Ubuntu 12.10 Install Bochs 2.6, debug linux-0.11 kernel

Source: Internet
Author: User
Tags stub

http://blog.csdn.net/sinzou1/article/details/5903968

Linux (Ubuntu) installation Bochs

Http://wenku.baidu.com/view/f968e23b0912a21614792914.html

install Bochs under Ubuntu

Http://www.linuxidc.com/Linux/2011-07/38371.html

Ubuntu 10.04 installation Bochs 2.4.5 notes

http://blog.csdn.net/traceless/article/details/3200169

installation and use of Bochs

Http://hi.baidu.com/_0x55aa/item/38e3ac01d72f0e1bcc34eae6

Startup of Linux Bochs


This article describes how to use the Bochs debug kernel linux-0.11 version under the SuSE Linux Enterprise Desktop System

Objective:
Although linux-0.11 is an early kernel code, the code is not more than 20,000 lines, but it is basically a compact version of the current kernel code, perfectly formed.
Reading and understanding the complete code can have a deep understanding of the whole system's operation process.
I. Preparatory work (performed as root user):
Download the Debug tool Bochs:
In http://sourceforge.net/projects/bochs/download. tar.gz installation package, note, do not download RPM package, because the installation needs to add Gdb-stub function, RPM package does not carry this function, downloaded after the execution:
Tar zxvf bochs-2.3.5.tar.gz
CD bochs-2.3.5
./configure--enable-gdb-stub

If the X Windows libraries were not found error, you can use the software management of SuSE YaST to search xorg and install the Xorg Basic installation package as shown in:

If error:x11/extensions/xrandr.h:no such file or directory appears,

sudo apt-get install Xorg-dev


Alternatively, you may want to install g++ and use the software management of SuSE yast to search for GCC installations.
Continue installing Bochs
Make
Make install
OK, download the linux-0.11 kernel source package and put the source package in/root/kernel/:
Mkdir/root/kernel
Cd/root/kernel
wget http://www.kernel.org/pub/linux/kernel/Historic/old-versions/linux-0.11.tar.gz
Tar zxvf linux-0.11.tar.gz
This source package will eventually be put into the Bochs simulation system to compile, because the debug ring mirror is Bochs simulation of the Intel x86 software, so do not compile this kernel in the SUSE system,
And in the Bochs simulation system to compile the kernel also to change some configuration files, the operation is as follows:


CD linux-0.11

VI Makefile
Change RAMDISK = #-dramdisk=512 to RAMDISK =-dramdisk=2048
Change Root_dev=/dev/hd6 to Root_dev=floppy
In the source directory of all the makefile
Ldflags =-m-x//Remove-s flag
CFLAGS = Wall-o-g-fstrength-reduce-fomit-frame-pointer-fcombine-regs//Add-G flag, remove-mstring-insns
Change the value of syssize in Boot/bootsect.s and TOOLS/BUILD.C to 0x8000

Because makefile files are many, here I wrote a script program adjust_make_for_gdb do the above work directly


#!/bin/sh
Sed-i ' 5 s/#//' Makefile
Sed-i ' 5 s/512/2048/' Makefile
Sed-i ' s/\/dev\/hd6/floppy/' Makefile
Sed-i ' 6 s/3/8/' Boot/bootsect.s
Sed-i ' s/2/8/' TOOLS/BUILD.C
Find. -name ' Makefile ' |while read filename;do
all_lines=$ (grep ldflags $filename-nh | awk-f: ' {print $} ')
first_line=$ (echo $all _lines|awk ' {print $} ')
Echo $first _line
Sed-i "$first _line s/-s//g" $filename
all_lines=$ (grep CFLAGS $filename-nh | awk-f: ' {print $} ')
first_line=$ (echo $all _lines|awk ' {print $} ')
Echo $first _line
Sed-i "$first _line s/-o-fs/-o-g-fs/g" $filename
Sed-i ' 1,$ s/-mstring-insns//g ' $filename
Done
Place this script in the linux-0.11 directory and execute it again.
CD linux-0.11
./adjust_make_for_gdb
After the execution, packaging this source code.
Cd..
Tar cvf Gdb-linux-0.11.tar linux-0.11
My Gdb-linux-0.11.tar file is attached here.
Two. Using Bochs
Here you need to download two packages to http://oldlinux.org/Linux.old/bochs/
wget Http://oldlinux.org/Linux.old/bochs/linux-0.11-devel-050518.zip
wget http://oldlinux.org/Linux.old/bochs/linux-0.11-gdb-rh9-050619.tar.gz
Put these two packages into the/root/kernel/and unzip
Tar zxvf linux-0.11-050518-rh9.tar.gz(the original is linux-0.11-040923-rh9.tar.gz, I found in the extracted files can not find the BOCHSRC-HDBOOT.BXRC file, changed to linux-0.11-050518-rh9.tar.gz)
Unzip linux-0.11-devel-050518.zip-d./
CD linux-0.11-devel-050518/
We only use the BOCHSRC-HDBOOT.BXRC file here.
Vim BOCHSRC-HDBOOT.BXRC

There are two places to make changes:

1, vgaromimage: $BXSHARE\vgabios-lgpl-latest back slash change to get

Vgaromimage: $BXSHARE/vgabios-lgpl-latest

2, romimage:file= $BXSHARE\bios-bochs-latest, address=0xf0000 change to get
romimage:file= $BXSHARE/bios-bochs-latest
This is the time to run Bochs.

#bochs-Q-F BOCHSRC-HDBOOT.BXRC

-----Errors and workarounds are occurring-----

If it works correctly, it will get as shown:

(1) >>PANIC<< bochsrc-hd.bxrc:37:vgaromimage directive Malformed.

A. Comment out the corresponding line

B. Change to: Vgaromimage:file=/usr/share/bochs/vgabios-lgpl-latest

(2) >>PANIC<< bochsrc-hd.bxrc:284:directive ' floppy_command_delay ' not understood

A. Comment out the corresponding line

(3) Bochsrc-hd.bxrc:194:unknown parameter for Parport1 ignored.

4 Event Type:panic

Device: [MEM0]
Message:ROM:couldn ' t open ROM image file '/usr/share/bochs/vgabios-lgpl-latest '.

Go to directory view, find/usr/share/bochs/directory below and no vgabios-lgpl-latest file
Find/-name Vgabios-lgpl-latest

/usr/local/share/bochs/vgabios-lgpl-latest
Solution: Change Vgaromimage: $BXSHARE/vgabios-lgpl-latest to
Vgaromimage:file=/usr/local/share/bochs/vgabios-lgpl-latest

Showing the 4 partitions of the virtual hard disk, the first partition with a bootable Linux 0.11 system, and the Linux 0.11 system running by the number 1 key, I will eventually compile the Linux 0.11 kernel code on this system:

There are other. bxrc files in the linux-0.11-devel-050518 directory:
BOCHSRC-FDA.BXRC BOCHSRC-FDB.BXRC BOCHSRC-HD.BXRC
Here no longer used, interested can try it yourself, about Bochs use method, you can go to
Http://bochs.sourceforge.net Query
Three. Copy the source file to the Bochs simulation system
Can run the above BOCHSRC-HDBOOT.BXRC, now it is necessary to put the preparation of the Gdb-linux-0.11.tar in the system.
The principle is to copy files to each other via virtual floppy disks (1.44M).
In the linux-0.11-devel-050518 directory, you can see DISKA.IMG and diskb.img, copying an. img File:
#cd linux-0.11-devel-050518
#cp diska.img tmp.img
#mkdir: /mount_img
# Mount-o Loop tmp.img. /mount_img/
# CD: /mount_img/
Delete all the files inside
# RM-RF *
Copy the Gdb-linux-0.11.tar into the virtual floppy disk
# CP.. /gdb-linux-0.11.tar./
# CD: /linux-0.11-devel-050518
# Umount Tmp.img
Run Bochs
# bochs-q-F BOCHSRC-HDBOOT.BXRC
Press the number 1 key to enter the system, click on the Bochs toolbar config, red circle position:
Then switch back to the terminal and you can see:

Select 1, change the first floppy drive, set to just tmp.img:

The rest is set by default.
And then switch back to the Bochs virtual machine, then the system a:/floppy drive is tmp.img, will Gdb-linux-0.11.tar copied to the user directory, unzip the compilation:
# CD
# mcopy a:/gdb*./
# tar XVF Gdb*.tar
# CD linux-0.11
# make
Build image System.map file after success
Four. Package the Bochs compiled files and source code and put them back into the floppy drive
Since the floppy drive size is 1.44M and the compiled code is very large, I transfer the files in batches.
# Cp-r Kernel. /
# Cp-r Tools. /
# RM-RF Kernel Tools
# CD: /
# tar CVF kernel.tar kernel
# tar CVF tools.tar Tools
# tar CVF linux.tar linux-0.11

Remove the original files from the floppy disk and put the Kernel.tar into the floppy disk (Tools.tar Linux.tar the next copy):
# Mdel a:/gdb*
# mcopy Kernel.tar a:/

Then open a new terminal in SuSE, mount the floppy disk in the linux-0.11-devel-050518 directory:
# CD kernel/linux-0.11-devel-050518/
# Mount-o Loop tmp.img. /mount_img
# CD: /mount_img/
# MV Kernel.tar. /linux-gdb-rh9/
Go back to Bochs and re-mount the floppy disk, as described in the second step (click Config ...) and copy the Tools.tar Linux.tar to the Linux-gdb-rh9 directory of SuSE using the same method
There is no longer a statement here.
After copying, you can close Bochs, in the Linux-gdb-rh9 directory, delete the original Linux directory, Kernel.tar Tools.tar Linux.tar extracted to the Linux directory:
# RM-RF Linux
# tar XVF Linux.tar
# tar XVF Tools.tar
# tar XVF Kernel.tar
# mv-f Kernel linux-0.11
# Mv-f Tools linux-0.11
# mv-f linux-0.11 Linux
Copy the rootimage-0.11 of the linux-0.11-devel-050518 directory to the directory, which is used later.
# CP.. /linux-0.11-devel-050518/rootimage-0.11./
Five. Start Debugging linux-0.11 Source code
OK, running the run file in the Linux-gdb-rh9 directory:
./run
Effect:


At this time the Bochs interface is a black screen, at the running terminal is
Waiting for GDB connection on port 1234
Words.
Open a new terminal, enter the Linux directory under the Linux-gdb-rh9 directory, run GDB Tools/system
# CD kernel/linux-gdb-rh9/linux/linux/
# GDB Tools/system
Run the target remote localhost:1234 under GDB
(GDB) Target remote localhost:1234

Run Continue:
(GDB) Continue
At this point, the Bochs interface will display:
To continue running continue (press ENTER directly), Bochs will prompt for insert root floppy and press ENTER, then click Config on the toolbar:


and switch back to Bochs start terminal, select 1, then enter rootimage-0.11, the rest by default settings:

Then go back to the Bochs interface press ENTER, and then switch to the GDB terminal, running continue (no-go), the final interface will display such as:

Ok, now you can track every step of the command:
GDB Interface:
You will always be prompted filename:no such file or directory.
Just move all the source files to the current directory, I use the following script Mv_file implementation
#!/bin/sh
Find. -name ' *. * ' |while read filename;do
MV $filename.
Done
Then execute it under the Linux directory
#./mv_file
Moving all source files to the current directory and then debugging is normal.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.