Difference between revisions of "Ubuntu Disk Image for ARM Full System"

From gem5
Jump to: navigation, search
(Created page with "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 t...")
 
(Setting up Upstart to be Gem5 friendly)
Line 38: Line 38:
 
To the scrip field on the mountall.conf file, add at least the following:
 
To the scrip field on the mountall.conf file, add at least the following:
  
<nowiki>
+
<nowiki>
# Mount appropriate file systems from fstab and remount root.
+
# Mount appropriate file systems from fstab and remount root.
mount /proc
+
mount /proc
mount /tmp
+
mount /tmp
mount /sys
+
mount /sys
mount -o remount,rw /dev/sda1 /
+
mount -o remount,rw /dev/sda1 /
swapon /swapfile # if present
+
swapon /swapfile # if present
  
# Make sure to emit all events that mountall would have
+
# Make sure to emit all events that mountall would have
initctl emit virtual-filesystems
+
initctl emit virtual-filesystems
initctl emit local-filesystems
+
initctl emit local-filesystems
initctl emit remote-filesystems
+
initctl emit remote-filesystems
initctl emit all-swaps
+
initctl emit all-swaps
initctl emit filesystem
+
initctl emit filesystem
initctl emit mounting
+
initctl emit mounting
initctl emit mounted
+
initctl emit mounted
</nowiki>
+
</nowiki>
  
 
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:
 
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:
  
<nowiki>
+
<nowiki>
script
+
script
  if [ ! -c /dev/ttyAMA0 ]
+
  if [ ! -c /dev/ttyAMA0 ]
  then
+
  then
    mknod /dev/ttyAMA0 c 204 64
+
    mknod /dev/ttyAMA0 c 204 64
  fi
+
  fi
  if [ ! -c /dev/ttySA0 ]
+
  if [ ! -c /dev/ttySA0 ]
  then
+
  then
    if [ ! -L /dev/ttySA0 ]
+
    if [ ! -L /dev/ttySA0 ]
    then
+
    then
      ln -s /dev/ttyAMA0 /dev/ttySA0
+
      ln -s /dev/ttyAMA0 /dev/ttySA0
    fi
+
    fi
  fi
+
  fi  
  
  /sbin/m5 readfile > /tmp/script
+
  /sbin/m5 readfile > /tmp/script
  chmod 755 /tmp/script
+
  chmod 755 /tmp/script
  if [ -s /tmp/script ]
+
  if [ -s /tmp/script ]
  then
+
  then
    exec su root -c '/tmp/script' # gives script full privileges as root user in multi-user mode
+
    exec su root -c '/tmp/script' # gives script full privileges as root user in multi-user mode
    exit 0
+
    exit 0
  else
+
  else
    exec /sbin/getty -L ttySA0 38400 vt100 # login prompt
+
    exec /sbin/getty -L ttySA0 38400 vt100 # login prompt
  fi
+
  fi
end script
+
end script
</nowiki>
+
</nowiki>

Revision as of 20:25, 8 August 2011

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 --user 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.

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
  • 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 scrip 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