Ubuntu Disk Image for ARM Full System

From gem5
Revision as of 20:09, 28 August 2011 by Saidi (talk | contribs)
Jump to: navigation, search

This page describes how to build a serial-console filesystem of Ubuntu Linux for ARM ISA simulation after the bare image file is created.


Using Rootstock and Qemu to build the filesystem

The easiest way to create a disk image is to use the rootstock tool provided in Ubuntu to build an ARM filesystem. To create a base 2GB filesystem that can be booted to the serial console, run the following command:

%>rootstock --fqdn gem5sim --login gem5 --password 5meg --imagesize 2G --seed build-essential

Other packages can be added to the --seed option list to be installed by rootstock. Rootstock will create a tar file containing the file system. Unpack this tar file into the blank disk image. Packages can also be installed at a later date by mounting the filesystem to a loop device, mounting its proc filesystem and chroot'ing into the filesystem. Qemu will be used to emulate the binaries within the ARM filesystem to install additional packages using apt-get. For example mount -oloop,offset=32256 /tmp/Ubuntu-arm.img /mnt cd /mnt mount -o bind /proc /mnt/proj mount -o bind /dev /mnt/dev mount -o bind /sys /mnt/sys chroot . exec /bin/bash # This is the arm version of bash apt-get install <what ever packages you want>

Setting up Upstart to be Gem5 friendly

Instead of the old SysV and init.d, Ubuntu uses Upstart for mounting filesystems and loading the various daemons upon boot. To speed up the process and subsequent simulations the following upstart scripts should be removed from the /etc/init folder in the new filesystem:

  • cron.conf
  • dmesg.conf
  • hwclock.conf
  • hwclock-save.conf
  • mounted-debugfs.conf
  • mountall-net.conf
  • network-interface-security.conf
  • plymouth.conf
  • plymouth-log.conf
  • plymouth-splash.conf
  • plymouth-stop.conf
  • plymouth-upstart-bridge.conf
  • rsyslog.conf
  • setvtrgb.conf
  • udev-fallback-graphics.conf
  • ureadahead.conf
  • ureadahead-other.conf

The following changes should be made to the mountall.conf script:

  • Remove the fsck checks at the beginning of the script declaration
  • Remove the fsck checks in the post-script declaration
  • Remove the exec mountall --daemon declaration so total control of what filesystems are mounted and when is retained

To the script field on the mountall.conf file, add at least the following:

 # Mount appropriate file systems from fstab and remount root.
 mount /proc
 mount /tmp
 mount /sys
 mount -o remount,rw /dev/sda1 /
 swapon /swapfile # if present

 # Make sure to emit all events that mountall would have
 initctl emit virtual-filesystems
 initctl emit local-filesystems
 initctl emit remote-filesystems
 initctl emit all-swaps
 initctl emit filesystem
 initctl emit mounting
 initctl emit mounted
 

Additionally, one of the tty.conf scripts should be modified like below to get a login prompt within m5term or load an .rcS job script with multi-user and job-control enabled:

 script
   if [ ! -c /dev/ttyAMA0 ]
   then
     mknod /dev/ttyAMA0 c 204 64
   fi
   if [ ! -c /dev/ttySA0 ]
   then
     if [ ! -L /dev/ttySA0 ]
     then
       ln -s /dev/ttyAMA0 /dev/ttySA0
     fi
   fi 

   /sbin/m5 readfile > /tmp/script
   chmod 755 /tmp/script
   if [ -s /tmp/script ]
   then
     exec su root -c '/tmp/script' # gives script full privileges as root user in multi-user mode
     exit 0
   else
     exec /sbin/getty -L ttySA0 38400 vt100 # login prompt
   fi
 end script
 

By default a modules.dep file will not be created by rootstock, this file is needed to prevent certain upstart scripts from failing. To create this file, add the following to the beginning of the script declaration in init/modules-init-tools.conf, or simply add your own custom modules.dep file in the appropriate directory for your kernel.

 if [ ! -e /lib/modules/`uname -r`/modules.dep ]
 then
   mkdir /lib/modules/`uname -r`
   echo "#No modules for this run of Gem5" > /lib/modules/`uname -r`/modules.dep
 done
 

To allow passwordless login to the filesystem, edit the /etc/shadow file to have the gem5 and root entries look like the following.

 
 root::15201:0:99999:7:::
 gem5::15201:0:99999:7:::
 

Ensure that the tty that will be used as the login tty is contained within the /etc/securetty file. In most cases this will probably be ttyAMA0. Go through the mounted-proc.conf, mounted-dev.conf, mounted.tmp.conf and mounted-varrun.conf and verify all use the clause

 start on mounted 
 

so the scripts start running.