Difference between revisions of "Using linux-dist to Create Disk Images and Kernels for M5"

From gem5
Jump to: navigation, search
(Compiling benchmarks for the image and creating the image with linux-dist)
(Compiling the Kernel)
Line 24: Line 24:
  
 
== Compiling the Kernel ==
 
== Compiling the Kernel ==
We supply a repository of patches against the linux kernel that enables some M5 features and provides default configuration files that work with M5. The repository is a Mercurial Queue (MQ) that is supposed to be applied on top of a linux repository. To compile a kernel using our patches repository you'll need to get a copy of the linux-2.6 repository first. Once you have the repository, you'll need to select the version of linux you wish to compile, select the appropriate version of patches for that version of linux, apply the patches, and then compile. Step-by-step instructions are provided below. Note that currently we only support linux 2.6.13, 2.6.16, 2.6.18, and 2.6.22. There is nothing preventing the patches from working with newer kernels, however no one has gone through the effort of verifying that the patches apply cleanly to newer kernel versions.
 
  
The correct way to use the patches repository is the following:
+
This section has been moved to its own page: [[Compiling a Linux Kernel]].
<pre>
 
#Get a copy of the linux-2.6 mercurial repository
 
hg clone http://www.kernel.org/hg/linux-2.6/
 
 
 
#Get a copy of our patches to linux
 
cd linux-2.6/.hg
 
hg clone http://repo.m5sim.org/linux-patches/ patches
 
 
 
#Return to the root linux directory
 
cd ..
 
 
 
#Update the linux source to the desired version (can take 5 minutes)
 
hg update v2.6.XX
 
 
 
#Select tho appropriate patches for the version of linux you selected (currently 13,16,18,22 are available in the linux-patches repository)
 
hg qselect 2.6.XX
 
 
 
# Apply the patches
 
hg qpush -a
 
 
 
#Copy the default configuration file, so it's used
 
cp .config.m5 .config
 
 
 
#Compile the kernel (assuming the cross compiler is in $PATH, otherwise full path would need to be specified)
 
#The dash after gnu is required.
 
make ARCH=alpha CROSS_COMPILE=alpha-unknown-linux-gnu- vmlinux
 
</pre>
 
  
 
== Compiling benchmarks for the image and creating the image with linux-dist ==
 
== Compiling benchmarks for the image and creating the image with linux-dist ==

Revision as of 20:52, 26 May 2009

This documentation is relevant only for those desiring to use the full-system aspect of M5. When running in full-system, M5 reads a raw disk image as the hard disk. This tells you how to compile both the linux binary and the disk image for full-system simulation.

There is a general 3 step process for doing this:

  1. compile a cross-compiler capable of building alpha binaries.
  2. compile a kernel using this cross-compiler
  3. use linux-dist to build binaries for the M5 disk image, and create the image.

Compiling a Cross Compiler using Crosstool-NG

Go to here, download crosstool-ng and follow the directions listed on the page. This is a new tool based on Dan Kegel's cross tool and is more up to date.

Compiling a Cross Compiler using Crosstool -- OLD

Dan Kegel had a great suite for compiling arbitrary cross compilers called crosstool. Download it here. The version that we have a stable working system with is 0.42.

  • Once you have downloaded and untarred it, check out the demo-alpha.sh script. This is what dictates what exact toolchain you'll build.
    1. Read the Howto/readme on the kegel website - it's helpful to get an idea of what the scripts are doing.
    2. Modify this demo-alpha.sh so that the toolchain file is gcc-3.4.3-glibc-2.3.5.dat.
    3. Modify the gcc-3.4.3-glibc-2.3.5.dat so that the linux version it points to reflects the Linux headers you want to use in your toolchain. Currently in M5 we are using linux-2.6.13, so you should set it accordingly.
    4. in the crosstool-0.42 directory, type the following, which should take about an hour to complete:
%sh demo-alpha.sh 
  • you should have a crosstool in /opt/crosstool/gcc-3.4.3-gcc-2.3.5/
  • NOTE Only a few of the gcc 4 targets appear to successfully build. The build matrix at kegel.com is a good place to get info on tool chains that are building. Everything on this website has been compiled using gcc-3.4 (we used 3.4.4), however we have lately had some success with gcc-4.0.2 coupled with glibc-2.3.6.

Compiling the Kernel

This section has been moved to its own page: Compiling a Linux Kernel.

Compiling benchmarks for the image and creating the image with linux-dist

        • Note that this process is quite deprecated and not well supported. We suggest that you get your disk images either from the downloads page, or if that doesn't satisfy your needs, with a Gentoo stage 3 image. While we're not saying the below will not work, it may require a lot of massaging on your part.

Linux-dist is bootstrapped off of the Pengutronix PTX-dist tool for building disk images for embedded processors (i.e. need to be smaller). Be sure you have downloaded the linux-dist.tgz tarball from here. Untar it, and there is a standard compile/install procedure.

  1. Configure the package with ./configure --prefix=/where/you/want/the/installation
  2. make
  3. make install

You will notice that now, in the place where you have designated, there is now a bin/ and lib/ directory pertaining to linux-dist. Now, you will need to create your m5 image workspace.

  1. set your path to point to /where/you/want/the/installation/bin.
  2. wherever you want your workspace, type: ptxdist clone m5-alpha <your workspace name>. This will create a workspace directory with everything you need to make an image.
  3. cd into that directory, and type: ptxdist menuconfig. The default ptxconfig ought to be sufficient for everything, but you do need to set one value. Find the Image Creation Options menu and ensure that the "Path to kernel src" value points to your linux directory that you got from us.
  4. type: ptxdist toolchain /path/to/your/toolchain/bin (e.g. /opt/crosstool/gcc-3.4.3-glibc-2.3.5/alpha-unknown-linux-gnu/bin). This ensures that in building all of the binaries you are using the appropriate toolchain.
  5. type: ptxdist menuconfig. Note that you will have to go to the Image Creation Options option and set the path to the kernel code that you will be using for your headers and iscsi benchmark module compilation.
  6. type: ptxdist go. This will compile everything you need to run existing M5 full-system benchmarks.
  7. type: ptxdist images. This actually creates the image for you and is somewhat interactive. You'll need to tell it how big you want the image to be (currently 200MB is sufficient), and where you want to put it. Be sure you have sudo privileges.

This is all you need to create the image. To run benchmarks, you merely need to ensure that m5/configs/common/Benchmarks.py points to the image you just created, and m5/configs/common/FSConfig.py points to the vmlinux you created. To run these benchmarks, see Running M5 in Full-System Mode.