Using linux-dist to Create Disk Images and Kernels for M5

From gem5
Revision as of 21:29, 10 November 2007 by Stever (talk | contribs) (Compiling a Cross Compiler using Crosstool: wikify link)
Jump to: navigation, search

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

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

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. And YES, you do need the dash at the end. When this is finished, voila, you should have a vmlinux that works with m5.

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

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.