Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# WARNING:: This whole exercise is performed while logged in as root.
# Setup a working directory anywhere you like. I'm using /vb/snakex.
mkdir /vb/snakex
cd /vb/snakex
export MYTOP=`pwd`
# Get the snakeos sdk
tar -xvjf *
# Set up your PATH for the toolchain.
# I found it helpful to keep this in a script.
vi /root/.bashrc
export MYTOP=/vb/snakex
# Logout & back in to get these settings. Or just execute the 2 previous commands.
# I spent quite a while trying to convert the existing config kernel file so that the kernel would work
# under QEMU, but could not make it happen.
# Finally, I just made one change to the "versatile_defconfig" config:
cd $MYTOP/snakeos-sdk/configs
mv str8132_defconfig_jffs2 str8132_defconfig_jffs2.orig
cd $MYTOP/snakeos-sdk/kernels/linux
make versatile_defconfig
vi .config
#Line 840: change "# CONFIG_TMPFS is not set" to "CONFIG_TMPFS=y"
cp .config ../../configs/str8132_defconfig_jffs2
cd $MYTOP/snakeos-sdk
# change it so that it so that it exits after line 53. i.e. add new line 54 "exit".
# This may not be needed, but the script has done all I need by this point.
#Following the build SDK instructions (, build twice, but record the output if interested.
./ > /tmp/mk.log.1 2>&1
./ > /tmp/mk.log.2 2>&1
#Make somewhere to keep the good stuff:
mkdir -p $MYTOP/runtime
cd $MYTOP/runtime
cp -a $MYTOP/snakeos-sdk/rootfs/target $MYTOP/runtime/
cp $MYTOP/snakeos-sdk/kernels/linux/arch/arm/boot/zImage $MYTOP/runtime/
# Set up the root file system ($MYTOP/runtime/target) so that it is accesible via NFS. (you need an NFS server on your machine).
vi /etc/exports
/vb/snakex/runtime/target -rw
# Permissions may be important here - don't know, so leave it wide open:
chmod 777 $MYTOP/runtime/target
# You may need to restart nfs to pickup the new config.
service netfs restart
# May be different on depending on you linux distro.
# Make sure that the ip we give snake is allowed access to this machine.
# Moy PC is on I'm giving access to everything on my network...
vi /etc/hosts.allow
# Note that we are going to run snake on
# A small change to snake:
vi $MYTOP/runtime/target/etc/inittab
# This will give a command line directly onto snake from qemu. It is good.
# Force a static IP.
# This isn't nice at all, but I just want to get things working for now:
vi $MYTOP/runtime/target/usr/share/snake/rc.sysinit
# The entries start at lien 48
# Opendns name servers (I think)
# Next we need to setup networking to play nice with qemu.
# Make a file called $MYTOP/runtime/
#-----------------------------------stat of file - don't include this line ----------------------------
# Turn off the firewall & iptables to avoid possible issues I don't want to deal with right now:
service shorewall stop
service iptables stop
/usr/sbin/brctl addbr br0
routing=`/sbin/ip route | grep eth0`
# Get current eth0 address.
addr=`/sbin/ip addr | grep eth0 | grep inet | sed -e 's/eth0/dev br0/' -e 's/inet//'`
echo $addr
# Make eth0 promisc
/sbin/ifconfig eth0 promisc
/sbin/ifconfig br0 up
/sbin/ip addr add $addr
/usr/sbin/brctl addif br0 eth0
/usr/sbin/brctl stp br0 off
# Reset the routing
echo "$routing" | while read route
/sbin/ip route del $route
newroute=`echo $route | sed s/eth0/br0/ `
/sbin/ip route add $newroute
# Create a "tap" for the virtual machine.
tunctl -t tap1 -u admin
brctl addif br0 tap1
ifconfig tap1 up
#-----------------------------------end of file---------------------------------------------
# The above could be done better. Come back to it some time.
# When you want to run snake under qemu, run *just once*.
# If you kill snake and want to start it again, don't re-run
# If you do, unless you can figure out what's happening, you may need to reboot your PC
# to get networking back in order. After a reboot, run again (once).
# Execute it..
chmod +x $MYTOP/runtime/
#qemu seems to want a script to run when the tap is 'up'. I'm not sure how this should be used,
#but it needs a file anyway so give it an emply one:
echo '#!/bin/bash' > $MYTOP/runtime/tap-up
chmod +x $MYTOP/runtime/tap-up
#Feeling lucky?
qemu-system-arm -kernel $MYTOP/runtime/zImage -append "root=nfs nfsroot=$MYTOP/runtime/target,tcp wsize=4096 ip= console=ttyAMA0" -nographic -net nic -net tap,ifname=tap1,script=$MYTOP/runtime/tap-up -M versatilepb
#If all goes well you will see snake boot up.
#When it finishes, hit 'ENTER' and you will be at a snake shell command prompt.
#From your PC's web browser try: (works, but something is not right - can't see any images). Come back to this.
#From your PCs shell try:
ssh ro...@ (Works.)
#I kill the qemu snake system by running '
killall qemu-system-arm
#' from another prompt.
#Note that you can create a directory, say
cd $MYTOP/runtime/target/newdir
# .. and it will immediately appear in snake as /newdir. But its read only.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment