# This is i a small hacking HOWTO for the eB103, please update it with
# corrections and improvements. The original is located i the root directory
# of the source tree, i.e. esw/readme. Improvments and questions can also be
# sent to <ulf@eklund.com>

# Retrieve the cross-compiler from the CVS-repository. 

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/eB103 login 
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/eB103 co -d /tmp/cross cross/eB100-2.1.2.tbz

# Unpack the cross-compiler to /opt/crossdev, the cross-compiler is compiled
# for this location and the eB103 build environment relies on it. 

mkdir -p /opt/crossdev
tar -C /opt/crossdev -xjf /tmp/cross/eB100-2.1.2.tbz 

# After this it is ok to remove the 12Mb tbz from /tmp

rm -rf /tmp/cross

# Retrieve the soutce tree from the CVS-repository. e-src can be changed to
# something with more appropriate name for the checkout directory.

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/eB103 co -P -d e-src esw ecvs 

# Create an configuration file in your home directory by copying the
# .esw_config file from the source tree and editing it. Make sure that 
# SERIAL_PORT, ETH_IF, IP is correct.

cp e-src/.esw_config ~/.esw_config
emacs .esw_config

# Run cook for the standard and uOS distribution. Cook will build all files
# and package the epb-files. Only nodes with changes will be rebuild.
# bin/cook uses bin/done to build a node do_node can be envoked seperatly. 
# bin/done setsup the crosscompiler, which is trolled by the target specifer
# in this example AC, use AA for a native build. bin/do_node will in turn use
# the entry file in each node to execute the specific builds.
# bin/cook -> bin/do_node -> nodes/*/entry -> nodes/*/src/Makfile

e-src/bin/cook eB103 uOS AC
e-src/bin/cook eB103 standard AC

# Individual paclkages can be build with cook, e.g.

e-src/bin/cook kernel kernel AC
 
# Use bin/xml_doc to create the documentation file doc.xml. CXC1321674-AC1-P1A
# and CXC1321674-AC2-P1A is the product identifiers for the uOS and the 
# standard distribution. This step is optional and not required for the actual
# build. The xml.doc file can be browsed with IE5...

e-src/bin/xml_doc CXC1321674-AC1-P1A CXC1321674-AC2-P1A

# As root run make_esw_images. It will expand the distributions into 
# $TFTP_BOOT, /tftpboot/esw,  defined in esw_config. Make sure that the
# directory exists and is readable by everyone.

e-src/bin/make_esw_images CXC1321674-AC1-P1A CXC1321674-AC2-P1A

# The uOS epbs will be unpacked into an ext2 ram-image, named esw-uOS.img. 
# A kernel, boot/kernel.img, will be extracted from that image. 
# The kenrel will be namde esw-kernel.img.

# Use start_esw_serial to ram load and execute the esw-uOS.img and the
# esw-kernel.img in the ebox. start_esw_serial will also make sure that 
# the correct EBL is installed. If every thing is ok a mincom will be started.
# The minicom sesion is duplicated to /tmp/minicom.cap.

# Make sure that the tftp server is running an exporting "/". The settings for
# this is found in /etc/xinetd.d/tftp file in RH7.X, it is by default disabled
# and the export root is set to /tftpboot. Make sure that disable is set to "no"
# and that server_args is set to "-s /"

e-src/bin/start_esw_serial 

# The ebox should startup and a login in prompt should appear after a while,
# the time can vary mostly due to old trash in the e2-memory. The password to
# gain access to a shell is eboxjul. By default the eBox will start to hand 
# out DHCP addresses on eth0, slot 1, from the IP range 172.24.85.1-253. The
# ebox will reside on .254 and the netmask is set to /24. DHCP server will
# also provide a DNS and a NTP reference, which will point to the ebox. This
# way local private DNS names is added to the public. The ebox will operate as
# an DNS cache/proxy and proxy requests to one or several DNSs on the access
# net. The ebox will register the DNS name gateway for it own IP. 

# The ebox might contain old sw that is disturbing the new sw. It is therefore
# a good idea to do some cleaning on new boxes. The e2-memory can be cleaned
# from the eBox commmandline with nconfig -w. This will also remove the UK, 
# uOS and kernel, mapping from the e2. This mapping is needed for the eBox to
# boot from flash. A new mapping can be achieved with sh command neatboot, 
# which retrives the latest ram booted U&K and maps it. 
# neatboot finds the U&K set through the Neatboot  parameters which can be
# setup from the webpages.
# neatboot can also be invoked with a url argument pointing to a directory
# with a U&K set.

neatboot ftp://user:password@172.24.85.1/tftpboot/esw

# The ebox webpages can by default only be reached from the local net, i.e.
# eth0/slot 1. The address is "http://gateway".

# Most configurations are stored in the db configuration database. db uses
# a default setting found in the uOS directory /opt/config, read-only, the
# default settings are shadowed by the setting in /var/opt/config, which is
# a is persistent read-write since /var/opt is symbolic linked to 
# /mnt/flash/var. eBox configurations will hence survive sw updates. db
# configurations can be manipulated with the db sh tool.

# The flash can easiest be clean from previous instalations by running the dd 1
# command from the EBL. To enter the EBL type ctrl-d when the text "eBox" is 
# displayed on the serial console at boot time.

# TBD:
#  How to toggle the serial console
#  Elaborate on the kernel mapping
#  HTTP info
#  SWUD Details
#  COOK essentials
#  uOS Details