-------
BUGboot - Matt Porter <mmporter@home.com>
-------

Builds Linux images suitable for booting from flash memory on
Motorola Computer Group PPCBUG equipped PowerPC boards.

Needed:
-------

* MCG PowerPlus board with dual flash banks.
  MVME23xx/24xx/26xx/27xx/36xx/46xx, MCPx750, and MTX variants are suitable.

* PPC1BUG 3.8+ or any version of PPC4BUG. 

* TFTP server

* A Linux kernel zImage or zImage.initrd including a full root filesystem
  which already works using NBO or PBOOT to start the image.

* A Linux/PowerPC host system or suitable cross-development machine to
  build this package for a powerpc-linux target.

Setup:
------

1. Configure the PowerPlus board using NIOT with the client IP address and
   your tftp server's IP address.

2. Create a dummy file, "res_data" in /tftpboot (or the equivalent
   directory) on your tftp server.  "touch res_data" will work, but
   insure that the file has world write permissions with 
   "chmod 666 res_data".

3. Be sure that the "Network PReP boot enable" option is turned on as
   shown below: 

   PPC4-Bug>env
   Bug or System environment [B/S] = B? 
   Field Service Menu Enable [Y/N] = N? 
   Remote Start Method Switch [G/M/B/N] = B? 
   Probe System for Supported I/O Controllers [Y/N] = Y? 
   Auto-Initialize of NVRAM Header Enable [Y/N] = Y? 
   Network PReP-Boot Mode Enable [Y/N] = N? Y
   Negate VMEbus SYSFAIL* Always [Y/N] = N? .

   Update Non-Volatile RAM (Y/N)? Y

   Reset Local System (CPU) (Y/N)? Y

4. "NBH" the dummy file like this: "nbh 0 0 ,,, res_data".  Note the address
   given in the message: "Residual-Data Located at: $xxxxxxxx".

5. Issue a "MD xxxxxxxx" where the address is the one noted in step 4. Note
   the value of the first 4 bytes.  This is the size of the residual data
   area

6. Using NIOP, copy the contents of residual data from memory to the dummy
   file on your tftp server.  This is an example:

   PPC4-Bug>niop 
   Controller LUN =00?         [Onboard Ethernet is CLUN 00, DLUN 00.]
   Device LUN     =00? 
   Get/Put        =P? 
   File Name      =res_data?   [The name of our dummy file]
   Memory Address =01F78000?   [This is the address we noted in step 4.]
   Length         =00006A0C?   [This is the size we noted in step 5.]
 
7. Copy res_data and the kernel image into your bugboot source tree, be
   sure that the kernel image is named "kernel_image". 

Building
--------
 
1. Modify the config file so that the RESDATA_DEST variable is the residual
   data address noted in step 4 of Setup and the RESDATA_SIZE variable is
   the value noted in step 5 of Setup.  If you are cross-compiling, set the
   CROSS_COMPILE variable to your cross-compiler prefix (powerpc-linux-).
   
2. "make bugboot.bin"

Flashing
--------

1. Copy "bugboot.bin" to your /tftpboot directory on the tftpserver.

2. On the target board, use NIOP to retrieve bugboot.bin into memory:

   PPC4-Bug>niop
   Controller LUN =00? 
   Device LUN     =00? 
   Get/Put        =G? 
   File Name      =? bugboot.bin
   Memory Address =00004000? 
   Length         =00000000? 
   Byte Offset    =00000000? 

   Bytes Received =&629832, Bytes Loaded =&629832
   Bytes/Second   =&41988, Elapsed Time =15 Second(s)

3. Use PFLASH to write the contents into flash bank A on the board (the 
   first argument is the source address from above, second argument is
   number of bytes to flash which can safely be large than our complete
   image size, and the last argument is the beginning of flash bank A):

   PPC4-Bug>pflash 4000:100000 ff000000
   Source Starting/Ending Addresses      =00004000/00103FFF
   Destination Starting/Ending Addresses =FF000000/FF0FFFFF
   Number of Effective Bytes             =00100000 (&1048576)

   Program FLASH Memory (Y/N)? Y
   Virtual-Device-Number    =00
   Manufacturer-Identifier  =10001
   Device-Identifier        =22C422C4
   Virtual-Device-Number    =01
   Manufacturer-Identifier  =10001
   Device-Identifier        =22C422C4
   Address-Mask             =FF800000
   Erasing sector     =$FF000000
   Erasing sector     =$FF040000
   Erasing sector     =$FF080000
   Erasing sector     =$FF0C0000
   Programming sector =$FF000000
   Programming sector =$FF040000
   Programming sector =$FF080000
   Programming sector =$FF0C0000
   FLASH Memory Programming Complete

4. Set ENV ROM Direct addressing to top of flash bank A:

   PPC4-Bug>env
   .
   .
   .
   ROM Boot Direct Starting Address = F0000000? FF000000
   ROM Boot Direct Ending Address   = FFC00000? FF000100
   Network Auto Boot Enable [Y/N]           = N? .
 
   Update Non-Volatile RAM (Y/N)? Y
 
   Reset Local System (CPU) (Y/N)? Y                    

Booting
-------

1. Issue an RB command:

   PPC4-Bug>rb

   ROMBoot about to Begin... Press <ESC> to Bypass, <SPC> to Continue
   loaded at:     00005400 0001C210
   relocated to:  00800000 00816E10
   board data at: 01F78000 01F7EA0C
   relocated to:  00810304 00816D10
   zimage at:     00010400 0009596D
   relocated to:  00817000 0089C56D
   avail ram:     00400000 00800000

   Linux/PPC load:  

2. If desired, enable the auto romboot feature so Linux is automagically
   booted from flash on powerup/reset.
