CyberGuard/SE5100 Disk-On-Chip
------------------------------

These instructions document how to use the OCdemon debugger (with
ARM 20pin JTAG header) to program the Disk-On-Chip of the SE5100
boards.


0. SETTING UP DEBUGGER

   Using OCdemon package, setup with appropriate .gdbinit script.
   (Use new-wave/tools/misc/ng5100.gdb).

   Firstly make sure you have the lp drivers loaded, and then load
   the ocdemon driver:

      insmod parport
      insmod parport_pc
      insmod lp

   (Ignore the ocdemonpp load warnings).
   (use "modprobe ocdemonpp" on 2.6 kernels...)

   Now startup the process demon, and start gdb:

      OcdLibRemote -c XSCALE-IXP &
      xscale-elf-gdb

   This should bring you up to the gdb prompt with no errors.
   (I had to use the xscale-elf-gdb binary from the Macraigor tool chain
   for this to really work properly. Not sure how theirs is better of
   different, but some things just don't work right if you use arm-elf-gdb).


1. FLASHING IPL (Initial Program Loader)

   Inside gdb run the following command:

      doc-programipl

   It will initialize ram and load the modified boot loader programmer
   into RAM, and then program the IPL (~/boot/ixp425/boot.elf) into the
   special IPL sector of the DoC.

   It issues progress ouput on the serial console at 11500 baud, so if
   you have that attached you will know when it is done.

   Note: this step erases some of the normal boot loader sectors to
   calculate its internal CRC, so you should always do this step first.


2. FLASHING BOOT LOADER

   Inside gdb run the following command:

      doc-programboot

   It will initialize ram and load the modified boot loader programmer
   into RAM, and then program the SnapGear Boot Loader.

   It issues progress ouput on the serial console at 11500 baud, so if
   you have that attached you will know when it is done.

   The boot loader is now installed.


3. BOOTING FIRST LINUX

   From now on we use Linux to do the rest of the hard work.

   Power reset the NG5100 (you must power cycle at this point) and get to
   the SnapGear boot loader recovery prompt. Choose to do a network load.
   This will start up the Redboot recovery loader. It can be a little slow
   but it will get there. You need to make sure the generated "recovery.bin"
   file is the one that is network laoded.

   Linux will boot after this (running completely from RAM).


4. FLASHING THE IMAGE

   If this is an un-formated DoC then you need to NFTL format it first.

   Use:

      nftl_format -b /dev/mtd0 262144

   (We start 262144 bytes, 256k, offset into the device to skip over the
   reserved factory blocks [3], leave 128k for our boot loader, and
   32k for RSA keys).

   You will need to reboot after doing this. The Linux NFTL drivers only
   parse the DoC contents at first init.

   Now use netflash to program in the image:

      netflash -i -r /dev/nftla <TFTP-SERVER> image.bin

   When done it should reboot, and run completely from flash.


5. REFLASHING THE BOOT LOADER

   Once you have a working system, you can reprogram the boot loader
   without using the OCdemon debugger.  'make romfs' places the boot
   loader in the /boot directory, so to flash the boot loader:

      cd /boot
      doc_loadbios /dev/mtd0 biosplus.bin 98304
      doc_loadipl -e 98304 /dev/mtd0 bootplus.bin

   Note: biosplus.bin also contains bootplus.bin, and doc_loadipl
   relies on this to calculate the ECC for bootplus.bin.  This means
   you must always run doc_loadbios before running doc_loadipl.
