Based on the Sis 630 HOWTO by Ron Minnich.
HOWTO written by Brenden Bixler 

This file contains instructions for the K7SEM, Socket 7 (k7/Duron) based mainboards.

Unfortunately, there is a step in this HOWTO that could be hazardous. The 
hazards include (but are not limited to)
	1) destroying your motherboard
	2) hurting yourself
	3) killing yourself

Because of these hazards, you must take full responsibility if you
decide to install LinuxBIOS following these procedures. Neither Los
Alamos National Labs or any lab personnel can be held responsible for
any adverse consequences of your attempt to follow these procedures.

WARNING: We assume you've built kernels, know how to open up your PC,
and how to yank the flash part out while power is on and put in a
different part. There is NO WARRANTY, express or implied, with this
software. In fact, if you don't know what you're doing, and you get
careless, you're going to end up with a nice paperweight instead of a
motherboard, an emergency room bill, or a funeral service.

			YOU HAVE BEEN WARNED.

Additional information available at: http://www.acl.lanl.gov/linuxbios/

Linux distribution: Most modern distributions are supported. This HOWTO tested using RedHat 7.2

Other software notes: You MUST have 'as' version 2.9.5 or later. You MUST have ssh
to connect to sourceforge

Recommended: you might want to get a 32-DIP Zero Insertion Force (ZIF)
socket for the flash part. This makes taking out flash and putting in Disk
On Chip much easier. 

You need to have a LinuxBIOS machine (the machine that runs LinuxBIOS)
and a build machine (which will let you build LinuxBIOS). These can be
one and the same machine. In this HOWTO we assume they're the same. 
We nevertheless refer to a 'build' machine and 'LinuxBIOS' machine in case you
want to use a different machine. 

Also, freebios and LinuxBIOS still share the same source tree. We use the 
name 'LinuxBIOS' where it makes sense, and 'freebios' otherwise. But they 
are the same source base. 

----
The steps for loading LinuxBIOS are simple:
1) Get Linux installed on your LinuxBIOS machine.
2) Get LinuxBIOS source from Sourceforge.
3) Get a 2.4.0 kernel, patch it, then compile.
4) Configure and build LinuxBIOS.
5) Get the MTD utilities from http://www.linux-mtd.infradead.org/ 
	and build the 'erase' utility.
6) Set up the 'flash_on' program in your path.
7) Put a Disk On Chip into the flash socket.
8) Burn the chip.
9) Reset the machine -- did it work?

---
Step 1) 
	Get Linux installed on your LinuxBIOS machine. Tested on RedHat 7.2
	Note: Do not format disk partitions as ext3! It's not supported by the LinuxBIOS kernel patch for 2.		4.7. Stick with ext2 -- it makes things much easier.

Step 2)
	Grab the LinuxBIOS source.
	cd to the directory you want the source tree to be.

Note: This HOWTO uses /usr/src as the base directory. After running the following commands from this directory, you should have a directory (/usr/src/freebios) with all the source code.

export CVS_RSH=ssh (or in tcsh setenv CVS_RSH ssh)


cvs -d:pserver:anonymous@cvs.freebios.sourceforge.net:/cvsroot/freebios login 
	(at the password prompt, just hit <return>)

cvs -z3 -d:pserver:anonymous@cvs.freebios.sourceforge.net:/cvsroot/freebios co freebios 


Step 3)
 	Surf to www.kernel.org and get linux-2.4.7.tar.gz from the kernel archives.

	Once you have pulled this file down and untar'ed it, 
	apply the proper patch from the freebios/src/kernel_patches 
	directory. (tar xzvf linux-2.4.7.tar.gz; mv linux linux_2.4.7; cd /usr/src/linux_2.4.7) 
		
	The patch is:

        linux-2.4.7-sis.patch

	Your patch command will look like this:
	 
	patch -p1 < /usr/src/freebios/src/kernel_patches/linux-2.4.7-sis.patch
	Now cp /usr/src/freebios/src/kernel_patches/config-2.4.7-sis to .config
	make oldconfig
	make dep
	make vmlinux
	make modules
	make modules_install
	make bzdisk (You should test boot this floppy disk just to be safe)

	You now have a kernel for LinuxBIOS. Now, try booting the floppy to ensure that
	the LinuxBIOS kernel works. On our machine, we received a few errors but the
	machine did boot completely. We were without networking, so you certainly want
	to keep your original kernel if you need to boot back to pull files of the Internet.

	If you want, you can also install this kernel on the LinuxBIOS machine,
	and install the modules as well, since you will need the Disk On Chip
	modules to burn the Disk On Chip part. In our experience, we found it's easiest to
	work within your stock kernel and only boot the LinuxBIOS kernel off the floppy 
	when you're ready to burn the DOC.

Step 4)

	You now need to figure out where you want to put your build images. We used /usr/src/build
	a directory we created.
 
	DO NOT PUT THESE IN THE LinuxBIOS SOURCE TREE. 
	
	You want to put them OUTSIDE THE TREE, so you can always
	cvs update 	and not lose any of your build directory. LinuxBIOS does all the builds in
	a single directory, much as BSD does. 
	
	To build LinuxBIOS requires a Makefile, a crt0.S file, and a ld script
	file. These are generated by a config tool located in 
	freebios/utils/config. 	The config tool is a Python program originally written by 
	Dean Risinger of the ACL. 	

	To build the initial Makefile, assembly stub, and ld script, 
	you need to build a config file, run the config tool,
	cd to the build directory, and type 'make'. That said, first create your config file using
	the text editor of your choice. This file can be located anywhere... we used /usr/src/sis.config.

	Here is the config file for the k7SEM:

	# This will dump all the files in /usr/src/build
	target /usr/src/build

	# Elitegroup K7sem
	mainboard elitegroup/k7sem

	# Request this level of debugging output
	option DEFAULT_CONSOLE_LOGLEVEL=8
	# At a maximum only compile in this level of debugging
	option MAXIMUM_CONSOLE_LOGLEVEL=8
	#option DEBUG

	# Enable Serial Console for debugging
	# It will come up at 115200,8n1
	option SERIAL_CONSOLE=1
	option SERIAL_POST=1

	# Use the internal VGA frame buffer device
	option HAVE_FRAMEBUFFER=1

	#floppy is nice
	option MUST_ENABLE_FLOPPY=1

	# We're using disk on chip. Tell it where to find the docipl code
	option USE_DOC_MIL=1
	docipl northsouthbridge/sis/730/ipl.S

	# Path to your kernel (vmlinux)
	# NOTE; you need a path to your kernel here.
	linux /usr/src/linux_2.4.7/

	# Kernel command line parameters
	commandline root=/dev/hda3 single console=ttyS0,115200 console=tty0 video=sisfb:1024x768-8@60
	
	The target command names the build directory. The mainboard command
	names the mainboard. We have set options for a serial console which
	will get you LinuxBIOS debug output via the serial port. You have to tell it where
	to find the vmlinux	you build (the 'linux' command); and finally you need a commandline
	for now. 

	To run the config tool, you need two arguments: the first is the
	name of a config file, and the second is the (absolute) pathname
	of the freebios source tree. The config tool is NLBConfig.py. Make sure you use that and not
	LBConfig.py, the older version. 

	Now, just run the configuration tool to generate the Makefile. 

 	python /usr/src/freebios/util/config/NLBConfig.py sis.config /usr/src/freebios

	Assuming no errors, cd into /usr/src/build and type make. If you receive an error message
	then verify your configuration file is correct and/or consult the LinuxBios website.

	After running make, we now have three files to be loaded into the Disk On Chip. The first
	is called docipl. It is 512 bytes. The second is called LinuxBIOS.strip,
	and is the binary image of the LinuxBIOS that gets loaded into Doc. 
	The third file  is your kernel, and is stripped and compressed, 
	linux.bin.gz

	-rw-------    1 rminnich CIC-ACL       512 Dec 20 08:41 docipl
	-rwx------    1 rminnich CIC-ACL     33494 Dec 20 08:41 LinuxBIOS.strip*
	-rwx------    1 rminnich CIC-ACL    756069 Dec 20 08:41 linux.bin.gz*

	Ensure that all of the above files exist. Very important: mv linux.bin.gz vmlinux.bin.gz
	This is your compressed kernel image.

	You're now ready to burn the Disk On Chip, but first .... 

Step 5) Get the MTD utilities from http://www.linux-mtd.infradead.org/ 
	cd /usr/src (this is going to create another sub-directory)
	cvs -d :pserver:anoncvs@cvs.infradead.org:/home/cvs login (password: anoncvs)
	cvs -d :pserver:anoncvs@cvs.infradead.org:/home/cvs co mtd
	cd /mtd/util/
    	sh -x MAKEDEV
	make
	This creates the 'erase' utility.
	Install the erase utility where it is in your path.
	One such method is to use vi and edit the .bashrc
		PATH=$PATH:/usr/src/mtd/util; export PATH
	. .bashrc (run in the same directory as the .bashrc file is located) 

Step 6) Set up flash_on utility. cd /usr/src/freebios/util/sis/
	flash_on.c is found in freebios/util/sis/flash_on.c
	Make the utility, and put it in your path.
	Path in the .bashrc file should look like this now:
	PATH=$PATH:/usr/src/mtd/util:/usr/src/freebios/util/sis; export PATH
	Make sure to re-read the path by running the file again:
	. .bashrc
	echo $PATH to ensure both directories are included.

Step 7) 
	NOTE: BE ADVISED THAT THIS STEP CAN HURT OR KILL YOU!
	YOU ARE WORKING WITH A POWERED-ON COMPUTER AT THIS POINT. 
	THE COMPUTER NEEDS TO BE OPENED  UP, AND YOU NEED TO REMOVE A CHIP
	WHILE THE COMPUTER IS ON. IF YOU HAVE NOT DONE THIS TYPE OF WORK, DO NOT DO IT!
	WE TAKE NO RESPONSIBILITY FOR ANYTHING THAT HAPPENS AT THIS STEP.
	BEFORE DOING THIS STEP WITH POWER ON, YOU SHOULD TRY IT WITH POWER OFF.

	Reboot the machine and boot off the floppy. You need to be running the LinuxBIOS
	kernel with all the loaded DOC modules to successfully burn the chip. 

	Open the machine (LEAVE THE POWER ON), yank the flash, and 
	plug in the DoC. We recommend you practice this first with the 
	power off. Make sure that whatever you do, you are not shorting 
	things out. Avoid using a metal tool!

	NOTE: YOU CAN HURT YOURSELF AT THIS STEP. We can't take any
	responsibility for what happens to you here. If you haven't 
	done this, or are not trained, or have a history of getting
	hurt by hardware, DON'T DO IT.

Step 8) cd to /usr/src/build (imperative -- won't burn correctly unless you run the script
	while inside this directory)
	Run /usr/src/freebios/util/mtd/burn_mtd
	
Step 9) POWER OFF THE MACHINE. DoC requires this. 
	Turn it back on. LinuxBIOS should come up in a few seconds. 

DEBUGGING
___________

   If you can, hook up a serial line to your LinuxBIOS machine, 
   settings 115200,8n1 and see what messages come out. If you can capture them, send them
   to linuxbios@lanl.gov with a description of your problem. 



