===========================================================================
####COPYRIGHTBEGIN####
                                                                          
 -------------------------------------------                              
 The contents of this file are subject to the Red Hat eCos Public License 
 Version 1.1 (the "License"); you may not use this file except in         
 compliance with the License.  You may obtain a copy of the License at    
 http://www.redhat.com/                                                   
                                                                          
 Software distributed under the License is distributed on an "AS IS"      
 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See the 
 License for the specific language governing rights and limitations under 
 the License.                                                             
                                                                          
 The Original Code is eCos - Embedded Configurable Operating System,      
 released September 30, 1998.                                             
                                                                          
 The Initial Developer of the Original Code is Red Hat.                   
 Portions created by Red Hat are                                          
 Copyright (C) 1998, 1999, 2000 Red Hat, Inc.                             
 All Rights Reserved.                                                     
 -------------------------------------------                              
                                                                          
####COPYRIGHTEND####
===========================================================================

28 Jan 2000

How to build and install CygMon on the PID

Make CygMon image
~~~~~~~~~~~~~~~~~

Configure and build using the 'cygmon' template for the PID
target. These are the necessary CLI instructions. It can also be done
from the Configtool by selecting the appropriate templates.

 % cd /tmp
 % mkdir cygmon
 % cd cygmon
 % ecosconfig new pid cygmon
 % ecosconfig tree
 % make

This will install some files in ./install/bin:

 cygmon.elf:   The built CygMon image
 cygmon.bin:   The image converted to binary (suitable for burning to ROM)
 cygmon.img:   The relocated ELF image (suitable for FLASH writing, see below)
 cygmon.srec:  The image converted to srecords

Make FLASH tool
~~~~~~~~~~~~~~~

Again, these are the necessary CLI instructions. It can also be done
from the Configtool by selecting the appropriate templates, and
enabling the option.

 % cd /tmp
 % mkdir pid-flash
 % cd pid-flash
 % ecosconfig new pid
 % <edit ecos.ecc, enabling the CYGBLD_BUILD_FLASH_TOOL option:>
      --- ecos.ecc.orig       Fri Jan 28 11:21:43 2000
      +++ ecos.ecc            Fri Jan 28 11:22:01 2000
      @@ -150,7 +150,7 @@
       cdl_option CYGBLD_BUILD_FLASH_TOOL {
      	   # Flavor: bool
      	   # No user value, uncomment the following line to provide one.
      -    # user_value 0
      +    user_value 1
      	   # value_source default
      	   # Default value: 0
      	   # Requires:  CYG_HAL_STARTUP == "RAM" 
 % ecosconfig resolve
 % ecosconfig tree
 % make

The flash tool is installed in ./install/bin

Prepare board for CygMon
~~~~~~~~~~~~~~~~~~~~~~~~
 1. Set jumper 7-8 on LK6   [using the Angle code in the 16 bit EPROM]
 2. Set jumper 5-6 on LK6   [select 8bit ROM mode]
 3. Set jumper LK18         [ROM remap - this is also required for eCos]
 4. Set S1 to 0-0-1-1       [20MHz operation]


Program FLASH
~~~~~~~~~~~~~
 1. Download the CygMon relocated image onto the PID board:
      % cd /tmp
      % arm-elf-gdb -nw cygmon/install/bin/cygmon.img

  	(gdb) target rdi s=<serial device>
 	Angel Debug Monitor V1.04 (Advanced RISC Machines SDT 2.11a) for PID
 	Built with Serial(x1), Parallel, DCC
 	Rebuilt on Apr  7 1998 at 22:20:43
 	Serial Rate:   9600
 	Connected to ARM RDI target.
  	(gdb) load
 	Loading section .rom_vectors, size 0x60 lma 0x60000
 	Loading section .text, size 0xeea8 lma 0x60060
 	Loading section .rodata, size 0x304c lma 0x6ef08
 	Loading section .data, size 0x7f8 lma 0x71f54
 	Start address 0x60060 , load size 75596
 	Transfer rate: 5548 bits/sec.
  	(gdb) quit

   This will download the stubs onto the board at 0x60000..0x80000

   Use /dev/ttyS0, COM1 or similar for the <serial device> name.

 2. Now download the FLASH programmer tool
      % arm-elf-gdb -nw pid-flash/install/bin/prog_flash.img

 	(gdb) target rdi s=<serial device>
 	Angel Debug Monitor V1.04 (Advanced RISC Machines SDT 2.11a) for PID
 	Built with Serial(x1), Parallel, DCC
 	Rebuilt on Apr  7 1998 at 22:20:43
 	Serial Rate:   9600
 	Connected to ARM RDI target.
 	(gdb) load
 	Loading section .rom_vectors, size 0x60 lma 0x4000
 	Loading section .text, size 0x4964 lma 0x4060
 	Loading section .rodata, size 0x384 lma 0x89c4
 	Loading section .data, size 0x28c lma 0x8d48
 	Start address 0x4060 , load size 20436
 	Transfer rate: 5449 bits/sec.
 	(gdb) cont

 3. The FLASH tool will output some text on the board serial port B at
    38400 baud:

       ARM eCos
       FLASH here!
       manuf: 8, device: 40
       Error: Wrong Manufaturer: 08
       ... Please change FLASH jumper

 4. This text is repeated until you remove the jumper 7-8 on LK6. Then
    the output should be:

       manuf: 1F, device: A4
       AT29C040A recognised
       About to program FLASH using data at 60000..80000
       *** Press RESET now to abort!
    
 5. You have about 10 seconds to abort the operation by pressing
    reset. After this timeout, the FLASH programming happens:
  
      ...Programming FLASH
      All done!

 6. Quit/kill the GDB process which will hang.

 7. Next time you reset the board, CygMon will be in control, communicating
    on serial port A at 38400 baud. See documentation for further details
    on how to connect with GDB.
