Hymod Board Database

(C) Copyright 2001
Murray Jensen <Murray.Jensen@cmst.csiro.au>
CSIRO Manufacturing Science and Technology, Preston Lab

25-Jun-01

This stuff is a set of PHP/MySQL scripts to implement a custom board
database. It will need *extensive* hacking to modify it to keep the
information about your custom boards that you want, however it is a good
starting point.

How it is used:

	1. a board has gone through all the hardware testing etc and is
	   ready to have the flash programmed for the first time - first you
	   go to a web page and fill in information about the board in a form
	   to register it in a database

	2. the web stuff allocates a (unique) serial number and (optionally)
	   a (locally administered) ethernet address and stores the information
	   in a database using the serial number as the key (can do whole
	   batches of boards in one go and/or use a previously registered board
	   as defaults for the new board(s))

	3. it then creates a file in the tftp area of a server somewhere
	   containing the board information in a simple text format (one
	   per serial number)

	4. all hymod boards have an i2c eeprom, and when U-Boot sees that
	   the eeprom is unitialised, it prompts for a serial number and
	   ethernet address (if not set), then transfers the file created
	   in step 3 from the server and initialises the eeprom from its
	   contents

What this means is you can't boot the board until you have allocated a serial
number, but you don't have to type it all twice - you do it once on the web
and the board then finds the info it needs to initialise its eeprom. The
other side of the coin is the reading of the eeprom and how it gets passed
to Linux (or another O/S).

To see how this is all done for the hymod boards look at the code in the
"board/hymod" directory and in the file "include/asm/hymod.h". Hymod boards
can have a mezzanine card which also have an eeprom that needs allocating,
the same process is used for these as well - just a different i2c address.

Other forms provide the following functions:

	- browsing the board database
	- editing board information (one at a time)
	- maintaining/browsing a (simple) per board event log

You will need: MySQL (I use version 3.23.7-alpha), PHP4 (with MySQL
support enabled) and a web server (I use Apache 1.3.x).

I originally started by using phpMyBuilder (http://kyber.dk/phpMyBuilder)
but it soon got far more complicated than that could handle (but I left
the copyright messages in there anyway). Most of the code resides in the
common defs.php file, which shouldn't need much alteration - all the work
will be in shaping the front-end php files to your liking.

Here's a quick summary of what needs doing to use it for your boards:

1. get phpMyAdmin (http://phpwizard.net/projects/phpMyAdmin/) - it's an
   invaluable tool for this sort of stuff (this step is optional of course)

2. edit "bddb.css" to your taste, if you could be bothered - I have no
   idea what is in there or what it does - I copied it from somewhere else
   ("user.css" from the phpMyEdit (http://phpmyedit.sourcerforge.net) package,
   I think) - I figure one day I'll see what sort of things I can change
   in there.

3. create a mysql database - call it whatever you like

4. edit "create_tables.sql" and modify the "boards" table schema to
   reflect the information you want to keep about your boards. It may or
   may not be easier to do this and the next step in phpMyAdmin. Check out
   the MySQL documentation at http://www.mysql.com/doc/ in particular the
   column types at http://www.mysql.com/doc/C/o/Column_types.html - Note
   there is only support for a few data types:

	int		- presented as an html text input
	char/text	- presented as an html text input
	date		- presented as an html text input
	enum		- presented as an html radio input

   I also have what I call "enum_multi" which is a set of enums with the
   same name, but suffixed with a number e.g. fred0, fred1, fred2. These
   are presented as a number of html select's with a single label "fred"
   this is useful for board characteristics that have multiple items of
   the same type e.g. multiple banks of sdram.

5. use the "create_tables.sql" file to create the "boards" table in the
   database e.g. mysql dbname < create_tables.sql

6. create a user and password for the web server to log into the MySQL
   database with; give this user select, insert and update privileges
   to the database created in 3 (and delete, if you want the "delete"
   functions in the edit forms to work- I have this turned off). phpMyAdmin
   helps in this step.

7. edit "config.php" and set the variables: $mysql_user, $mysql_pw, $mysql_db,
   $bddb_cfgdir and $bddb_label - keep the contents of this file secret - it
   contains the web servers username and password (the three $mysql_* vars
   are set from the previous step)

8. edit "defs.php" and a. adjust the various enum value arrays and b. edit
   the function "pg_foot()" to remove my email address :-)

9. do major hacking on the following files: browse.php, doedit.php, donew.php,
   edit.php and new.php to reflect your database schema - fortunately the
   hacking is fairly straight-forward, but it is boring and time-consuming.

These notes were written rather hastily - if you find any obvious problems
please let me know.
