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

From gem5
Jump to: navigation, search
 
(Compiling a Cross Compiler using Crosstool)
Line 13: Line 13:
 
** Modify this demo-alpha.sh so that the toolchain file is gcc-3.4.3-glibc-2.3.5.dat.
 
** Modify this demo-alpha.sh so that the toolchain file is gcc-3.4.3-glibc-2.3.5.dat.
 
** 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.
 
** 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.
** in the crosstool-0.42 directory, type "sh demo-alpha.sh". This should take at least an hour to build.
+
** in the crosstool-0.42 directory, type:
 +
<pre>%sh demo-alpha.sh</pre>
 +
This should take at least an hour to build.
 
** you should have a crosstool in /opt/crosstool/gcc-3.4.3-gcc-2.3.5/
 
** you should have a crosstool in /opt/crosstool/gcc-3.4.3-gcc-2.3.5/
 
* NOTE that we have been unable to build a gcc-4.0.2 toolchain that works correctly, nor have we been able to compile a toolchain using a native gcc-4+ compiler.  You will need gcc-3.4 (we used 3.4.4) to compile a successful toolchain.
 
* NOTE that we have been unable to build a gcc-4.0.2 toolchain that works correctly, nor have we been able to compile a toolchain using a native gcc-4+ compiler.  You will need gcc-3.4 (we used 3.4.4) to compile a successful toolchain.

Revision as of 00:30, 17 August 2006

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:

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

Compiling a Cross Compiler using Crosstool

Dan Kegel had a great suite for compiling arbitrary cross compilers called crosstool. Download it at www.kegel.com/crosstool. 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.
    • Read the Howto/readme on the kegel website - it's helpful to get an idea of what the scripts are doing.
    • Modify this demo-alpha.sh so that the toolchain file is gcc-3.4.3-glibc-2.3.5.dat.
    • 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.
    • in the crosstool-0.42 directory, type:
%sh demo-alpha.sh
This should take at least an hour to build.
    • you should have a crosstool in /opt/crosstool/gcc-3.4.3-gcc-2.3.5/
  • NOTE that we have been unable to build a gcc-4.0.2 toolchain that works correctly, nor have we been able to compile a toolchain using a native gcc-4+ compiler. You will need gcc-3.4 (we used 3.4.4) to compile a successful toolchain.

Compiling the Kernel

Be sure you have a copy of the linux 2.6.13 kernel. Though a stock copy will work, you probably want to make sure you have the performance patches that we have distributed. To compile the kernel for alpha/M5:

  • from the top directory in the linux tree, type: make ARCH=alpha CROSS_COMPILE=/opt/crosstool/gcc-3.4.3-glibc-2.3.5/alpha-unknown-linux-gnu/bin/alpha-unknown-linux-gnu-
  • the key is to have the CROSS_COMPILE parameter point to the bin where all the crosstools are like gcc, ar, ranlib, etc. and have the appropriate prefix.
  • voila, you should have a vmlinux that works with m5.

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

Be sure you have downloaded the linux-dist.tgz tarball. Untar it, and there is a standard compile/install procedure.

  • Configure the package with ./configure --prefix=/where/you/want/the/installation
  • make
  • 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.

  • set your path to point to /where/you/want/the/installation/bin.
  • 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.
  • 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.
  • 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.
  • type: ptxdist go. This will compile everything you need to run existing M5 full-system benchmarks.
  • 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.