Search:  
Gentoo Wiki

HOWTO_Softgun_ARM_Emulator


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Contents

Abstract

This HOWTO presents a step by step guide to run ARM GNU/Linux operating system in the Softgun ARM Emulator. The presented way intends to be more comfortable, flexible and easier to use (in the point of view of the author of this document) than the restricted to a couple of boards (with very limited storage and memory) way softgun is intended to be used with. This is archived by patching the kernel to allow the use of up to 256 MB of RAM and the use of Network File System (NFS) for storage.

What is Softgun?

Softgun is a Software ARM. It is Intended to help developers of embedded systems without real Hardware. Currently it emulates an ARM-9 with MMU and many Netsilicon NS9750 peripherals, Flash, PCI, CAN-Bus and network.

What will we need?

Steps outline

  1. Compile Linux Kernel for use in Softgun
  2. Configure Host Computer
  3. Configure Softgun

Linux Kernel Compilation

At this step we will generate the kernel image that we will later boot softgun with.

Patch

First we need to download the vanilla kernel and patches, we need this files:

  1. The kernel itself: linux-2.6.10.tar.bz2 from http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.10.tar.bz2
  2. Softgun's kernel patch: ns9750_kernelpatch-0.02.gz from http://sourceforge.net/projects/softgun/
  3. My patch: ns9750-kernel-2.6.10-gentoo.patch from http://yvasilev.main.hsphere.com/zentoo/softgun/patches/ns9750-kernel-2.6.10-gentoo.patch

Then we unpack the kernel:

$ tar -xjvpf linux-2.6.10.tar.bz2

Patch the vanilla kernel for ns9750 support:

$ zcat ns9750_kernelpatch-0.02.gz | patch -p1

This also gives us a working kernel configuration which we will use as a starting point when we will reconfigure the kernel.

And finally, apply my patch:

$ patch -p1 < ns9750-kernel-2.6.10-gentoo.patch

This patch will allow us to configure softgun to provide more than 64MB of RAM (the current maximum is 256MB) to the guest ARM GNU/Linux softgun will run, as well as, it disables (actually not enables) the watchdog timer as there is no public source code available for the module dealing with watchdog.

Configure

This section contains the minimum changes we have to do to the default configuration so we can boot softgun form an NFS export. But there isn't any reason why we can not change and personalize other settings.

To make this changes with menuconfig:

Code: ARCH="arm" make menuconfig

First we configure the Network Interface Card drivers to be compiled into the kernel, as at the time we want our kernel to boot from NFS there is no way to load modules into it:

Networking support  --->
	Ethernet (10 or 100Mbit)  --->
		<*> NS9750 Ethernet Support
		Tulip family network device support  ---> 
			[*] "Tulip" family network device support
			 <*>   DECchip Tulip (dc2114x) PCI support

Then we allow the kernel to configure the network form the information we'll pass it in the command line:

Networking support  --->
	Networking options  --->
		[*]   IP: kernel level autoconfiguration

Then we configure it to support NFS and to be able to boot form it:

File systems  --->
	Network File Systems  --->
		<*> NFS file system support
			[*]   Provide NFSv3 client support
		[*] Root file system on NFS

And finally we specify the command line we pass to the kernel:

General setup  --->
	(mem=128M root=/dev/nfs nfsroot=192.168.81.3:/var/exports/softgun/root,rw,sync,dirsync,rsize=8192,wsize=8192,hard,intr,tcp,nolock ip=192.168.81.10::192.168.81.3:255.255.255.0:softgun:eth1:) Default kernel command string

This is what we tell to the kernel:

Also we need to create an empty file usr/initrd.image that will work as a fake root image that the kernel will expect to boot from:

$ touch usr/initrd.image

Cross compile

Note: At this stage we will use an ARM crosscompiler which is expected to be found in the PATH.

This is the easy part:

$ make ARCH="arm"

And after a little delay the kernel image arch/arm/boot/zImage should be ready to be booted.

Host Configuration

In this section we configure the host computer. Which should provide network capabilities and storage space (via NFS) to softgun.

TUN/TAP

For networking in softgun to work the hosts kernel needs to provide TUN/TAP network driver compiled into it or as a module. This is found in:

Code: make menuconfig
Device Drivers  --->
	Networking support  --->
		[*] Network device support
			<*/M>   Universal TUN/TAP device driver support

If this is compiled as a module we need to load it with:

# modprobe tun

And if we want Gentoo to load it at boot:

# echo tun >> /etc/modules.autoload.d/kernel-2.6

sudo

The app-admin/sudo package is used by softgun to configure host's virtual network interfaces (provided by TUN/TAP driver) to provide network connectivity for the ARM GNU/Linux that will run inside softgun. So all softgun needs form sudo is to have the ability to run ifconfig as root.

To modify sudo's configuration:

# visudo

And then we add:

username        ALL=(ALL)       NOPASSWD: /sbin/ifconfig

Where username is the username of the user that will run softgun.

NFS Exports

For our host linux to work as a NFS server we need to make sure that the kernel supports this and to have net-fs/nfs-utils installed.

Code: make menuconfig

The kernel options we need to check for:

File systems  --->
	Network File Systems  --->
		<*/M> NFS server support
			[*]   Provide NFSv3 server support
			[*]   Provide NFS server over TCP support

In case we have compiled it as a module:

# modprobe nfsd

And if we want Gentoo to load it at boot:

# echo nfsd >> /etc/modules.autoload.d/kernel-2.6

Then we add the NFS export with the root filesystem to be used by softgun:

# echo "/var/exports/softgun/root          192.168.81.0/24(sync,rw,no_root_squash,no_all_squash)" >> /etc/exports

And [re]start nfsd:

# /etc/init.d/nfs restart

Softgun Configuration

This is the final part, in this part we just have to create a configuration file for softgun to read it's settings form.

First we create the default configuration file:

$ gzcat /usr/share/doc/softgun-X.XX/defaultconfig.gz > ~/.emuconfig

Then we may want to change imagedir to something meaningful:

imagedir: /the/dir/for/kernel/images

And manually set the RAM bank settings:

[dram0]
size: 128M

[dram1]
size: 128M

Boot into ARM GNU/Linux

Finally we are ready to test what we have done.

To do so we just copy/unpack the root file system of the soft float ARM GNU/Linux we would like to use to /var/exports/softgun/root.

And then try to boot into it with:

$ softgun path/to/linux-2.6.10/arch/arm/boot/zImage

And if everything goes right, we can copy path/to/linux-2.6.10/arch/arm/boot/zImage to /the/dir/for/kernel/images/nice-and-meaningful-kernel-name.

Retrieved from "http://www.gentoo-wiki.info/HOWTO_Softgun_ARM_Emulator"

Last modified: Fri, 05 Sep 2008 10:55:00 +0000 Hits: 23,480