1) EMSIM-1.0, which only simulates arm-linux- 2.2.2, is no longer available
for download
2) EMSIM-2.0 has been undergoing continuous improvement. Please check this site
regularly for latest version.
EMSIM is an energy simulation framework that simulates a simple embedded system featuring StrongARM microprocessor and Linux OS. The block diagram of the system being simulated is shown below:
The purpose of building this simulation framework is to
facilitate our research in the following areas:
1) To study the effects of an OS on the overall system energy consumption.
2) To characterize and macro-model the energy consumption of Linux OS.
3) To study the effects of OS related software architectural transformation.
As these areas are new and exciting, we believe synergistic advances can be achieved if people from various groups interested in these areas can share some of their work and efforts. Therefore, this simulation framework is being made publicly available.
Reference:
1) T. K. Tan, A. Raghunathan, and N. K. Jha, "EMSIM:
An Energy Simulation Framework for an Embedded Operating System", in
Proc. ISCAS 2002, May 2002.
2) T. K. Tan, A. Raghunathan, N. Jha, “A
simulation framework for energy consumption analysis of OS-driven embedded
applications,” IEEE Trans. Computer-aided Design of Integrated Circuits
and Systems, 22(9) 1284-1294, Sept. 2003.
3) Design document.
WARNING: Our simulation framework only runs in Linux host machine.
Updates:
1) EMSIM-1.0, the old energy simulation framework, was limited in capability because it can only simulate the specific arm-linux 2.2.2 that we have modified to run in the simulator. The limitation is basically caused by the fact that in EMSIM-1.0, the initial ramdisk image (initrd) has to be embedded into the kernel source as initrd.h. Also, the kernel source was modified so that the kernel mounts the ramdisk as root by default.
2) In EMSIM-2.0, we have made the following provisions so that all these
modifications to the kernel source codes are no longer necessary:
a) Instead of embedding the initrd into the kernel source as initrd.h, we have
arranged to include initrd in the bootsim.rom
b) bootsim.rom also set up the kernel parameters so that the DRAM size and the
filesystem root are specified.
3) 2003/12/19 - The infamous old system calls problem has been fixed. Please see the file changes.n3 in the new download for more information.
4) 2005/9/29 - During the past two years, I have received a number of emails regarding EMSIM. Some of these correspondences are attached in the FAQ page. Click here.
We encourage you to install EMSIM-2.0 in a user account different from the account that have EMSIM-1.0 installed. Otherwise, all these steps will be very confusing to you since you need to avoid conflict between the old and the new simulators.
Since this simulation framework is about running the Linux OS in a StrongARM
simulator, several Linux and StrongARM related components are needed. The
following installation instructions assume that you have $HOME as your home
directory. We recommend you make the following directories:
- $HOME/usr
- $HOME/usr/src
- $HOME/usr/arm
- $HOME/gz
1. Download the new simulator itelf.
It was modified from GNU gdb-4.18 with patches from Ben
Williamson. However, since we have made a lot of changes to it, it is no longer
traceable to the recent version of GNU gdb.
- Download new-gdb-4.18.tar.gz into $HOME/gz/
- cd $HOME/usr/src/
- tar xvfz ../../gz/gdb-4.18.tar.gz
- A directory ./gdb-4.18 will be created with all the source codes for the
simulator stored within.
2. Download a version of ARM Linux kernel 2.4.x
We have tested the new simulation framework with arm-linux 2.4.18. Therefore, in
the following, we just assume that you are also using arm-linux 2.4.18
- Download linux-2.4.18.tar.gz into $HOME/gz/
- Download patch-2.4.18-rmk3 into
$HOME/gz/
- cd $HOME/usr/src/
- tar xvfz ../../gz/linux-2.4.18.tar.gz
- A directory ./linux will be created with all the source codes for
arm-linux 2.4.18 stored within
- mv linux linux-2.4.18-arm
- cd linux-2.4.18-arm
- cat ../../gz/patch-2.4.18-rmk3 | patch -p1
- the arm patch has been applied
3. Install the ARM toolchain
Note that you need to re-install the ARM toolchain because the arm-linux
version has changed.
Installing an ARM toolchain is not trivial. Basically, you
need a set of binutils, gcc, and glibc that works together. Information on
installing the toolchain is available at
http://www.armlinux.org/docs/toolchain/. We have used the following:
- binutils-2.11.tar.gz
- gcc-2.95.3.tar.gz
- glibc-2.1.2.tar.gz
- glibc-linuxthreads-2.1.2.tar.gz
- glibc-crypt-2.1.2.tar.gz
Please find them in GNU websites download them into $HOME/gz/
The basic steps involved in the installation of the ARM toolchain are:
3.1 Installing Binutils
- cd $HOME/usr/src
- tar xvfz ../../binutils-2.11.tar.gz
- cd binutils-2.11
- Now, make sure your PATH environment variable does not include current
directory .
- ./configure --target=arm-linux --prefix=$HOME/usr/arm --host=i686-pc-linux-gnu
- make
- make install
- add the $HOME/usr/arm/bin to your PATH. You may want to do this in your .cshrc
too.
3.2 Installing GCC
- cd $HOME/usr/arm/arm-linux/
- mkdir include
- cd include
- Create the symbolic links to the kernel headers before building the GCC:
ln -s $HOME/usr/src/linux-2.4.18-arm/include/asm-arm asm
ln -s $HOME/usr/src/linux-2.4.18-arm/include/linux linux
- Verify the correctness
ls asm
ls linux
You should see a list of .h files for each location.
- cd $HOME/usr/src
- tar xvfz ../../gz/gcc-2.95.3.tar.gz
- cd gcc-2.95.3
- ./configure --target=arm-linux --prefix=$HOME/usr/arm --host=i686-pc-linux-gnu
- make -i LANGUAGES=c
- Note: error messages in the above made have been forced to be ignored.
- Verify the correctness
- dir gcc/xgcc
Response -> gcc/xgcc
- ./gcc/xgcc -dumpmachine
Response -> arm-linux
- Install the C compiler:
make -i LANGUAGES=c install
- You now have the ability to build ARM linux. To build arm-linux applications,
you need GLIBC
3.3 Installing GLIBC
- First create the headers file needed in the arm-linux source
cd $HOME/usr/src/linux-2.4.18-arm/
- Edit the Makefile and check the following
ARCH := arm
CROSS_COMPILE = arm-linux-
- make menuconfig (save the default options)
- make zImage
- The build process does not have to complete successfully. Only the header
files are needed.
- Verify that the header files were created.
find ./include/. -name "version.h"
Response -> ./include/linux/version.h
- Now create a sub-dir to store GLIBC
mkdir $HOME/usr/arm/glibc
mkdir $HOME/usr/arm/glibc/arm-linux-glibc
- cd $HOME/usr/src
- tar xvfz ../../gz/glibc-2.1.2.tar.gz
- cd glibc-2.1.2
- tar xvfz ../../../gz/glibc-linuxthreads-2.1.2.tar.gz
- tar xvfz ../../../gz/glibc-crypt-2.1.2.tar.gz
- setenv CC arm-linux-gcc
- ./configure arm-linux --build=i686-pc-linux-gnu --prefix=$HOME/usr/arm/glibc/arm-linux-glibc
--enable-add-ons --with-headers=$HOME/usr/src/linux-2.4.18-arm/include
- make
- make install
- Setup the correct positions of the libraries and includes
cd $HOME/usr/src/gcc-2.95.3
./configure --target=arm-linux --prefix=$HOME/usr/arm
--with-headers=$HOME/usr/arm/glibc/arm-linux-glibc/include --with-libs=$HOME/usr/arm/glibc/arm-linux-glibc/lib
- Now you are ready to compile C applications.
3.4 Testing the compiler
- Create a simple C program hello.c
- arm-linux-gcc -v -o hello hello.c
- file hello
Response -> hello: ..... something meaningful....
4. Building the ARM linux kernel
- The purpose is to build an arm-linux kernel that can run in the simulator.
- cd $HOME/usr/src/linux-2.4.18-arm
- make menuconfig, so that the ./config generated have the configuration same as
this .config
- make dep
- make
- You should now have vmlinux file in your current directory
- sample vmlinux
5. Building the simulator
- Now we can build the simulator
- cd $HOME/usr/src/
- tar xvfz ../../gz/new-gdb-4.18.tar.gz
- cd gdb-4.18
- ./configure --target=arm-linux --prefix=$HOME/usr/arm --host=i686-pc-linux-gnu
- make
- make install
- arm-linux-run -h for help on simulator options
The simulator is like a pocket computer that boot from a ROM image. Since we do not have model for a hard disk device, we have resort to using RAM disk as the filesystem in the virtual pocket computer. To do that, we first need to embed an initrd into the ROM image. Therefore, what we need before using the simulator is: a tool to generate initrd.
1. Installing new initrd generator
- Download new-env-1.0.tar.gz into $HOME/gz/
- cd $HOME/usr/src
- tar xvfz ../../gz/env-1.0.tar.gz
2. Installing the bootsim.rom generator
This step is new in EMSIM-2.0. Basically, we need this because the
initrd is to be included into bootsim.rom instead of the kernel source directly.
- Get the bootsim.rom generator called
bootsim.tar.gz. Put it into $HOME/gz/
- cd $HOME/usr/src
- tar xvfz ../../gz/bootsim.tar.gz
3. Using the simulation framework
Suppose you want to run an application example.c in the simulation framework, you
should follow these steps:
- arm-linux-gcc -static -o example example.c
- cp example $HOME/usr/src/env-1.0/usrappl
- cd $HOME/usr/src/env-1.0/
- su
- As root, execute
./autogen
exit
- sample output: autogen.log
- You should now see initrd.dummy in the current directory. This file
contains the image of the initrd.
- cp initrd.dummy $HOME/usr/src/bootsim/initrd.dummy
- cd $HOME/usr/src/bootsim
- make
- cp new-bootsim.rom $HOME/usr/src/linux-2.4.18-arm/bootsim.rom
- cd $HOME/usr/src/linux-2.4.18-arm/
- cp $HOME/usr/src/env-1.0/usrappl $HOME/usr/src/linux-2.4.18-arm/init/usrappl
- arm-linux-run -E vmlinux
- The simulator should run now. It will first boot the linux kernel and at the
end of initialization call execve() to run the application binary.
4. Special requirement on writing the application code
- The simulation will only end if the program write a value to address
0x00000000. To do that, you need to add a function call sa110_terminate() into
your program and call it when you want to have the simulation finished. Please
see example.c for details on how to do that.
General Notes:
1. This simulation framework is provided as is. We do not have any resource to
provide support.
2. There are still bugs in the simulator. If you find one, you can tell us at tktan@alumni.princeton.edu
3. Feel free to modify the source codes. We would appreciate if you share your
significant extension to this tool.
Related sites: Tat Kee's Home Software Architectural Transformation Algorithm (SATA)