===========================================================================
####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####
===========================================================================

27 Oct 1999, revised on 2000.07.28

How to build and install the GDB module on the EB01

Make GDB module
~~~~~~~~~~~~~~~
Configure and build using the 'stubs' template for the EB01
target. These are the necessary CLI instructions. It can also be done
from the Configtool by selecting the appropriate templates.

 % cd /tmp
 % mkdir stubs
 % cd stubs
 % ecosconfig new eb01 stubs
 % ecosconfig tree
 % make

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

 cygmon.elf:   The built stubs 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)


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 eb01-flash
 % cd eb01-flash
 % ecosconfig new eb01
 % <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 eCos
~~~~~~~~~~~~~~~~~~~~~~
 1. Set switch to LOWER MEM   [boot the Angle code in the 16 bit EPROM]


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

  	(gdb) target rdi <serial device>
	Angel Debug Monitor (serial) 1.04 (Advanced RISC Machines SDT 2.11a) for
	AT91EB0x (1.01)
	Angel Debug Monitor rebuilt on Sep 14 1998 at 14:52:22
	Serial Rate:   9600
	Connected to ARM RDI target.
	(gdb) load
	Loading section .rom_vectors, size 0x44 lma 0x2060000
	Loading section .text, size 0x6d80 lma 0x2060044
	Loading section .rodata, size 0x3bf lma 0x2066dc4
	Loading section .data, size 0x328 lma 0x2067184
	Start address 0x2060044 , load size 29867
	Transfer rate: 6287 bits/sec, 497 bytes/write.
  	(gdb) quit

   This will download the stubs onto the board at 0x02060000..0x02080000

   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 <serial device>
	Angel Debug Monitor (serial) 1.04 (Advanced RISC Machines SDT 2.11a) for
	AT91EB0x (1.01)
	Angel Debug Monitor rebuilt on Sep 14 1998 at 14:52:22
	Serial Rate:   9600
	Connected to ARM RDI target.
	(gdb) load
	Loading section .rom_vectors, size 0x44 lma 0x2018000
	Loading section .text, size 0x5990 lma 0x2018044
	Loading section .rodata, size 0x4d0 lma 0x201d9d4
	Loading section .data, size 0x364 lma 0x201dea4
	Start address 0x2018044 , load size 25096
	Transfer rate: 6274 bits/sec, 492 bytes/write.
 	(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, the stub will be in control, communicating
    on serial port A at 38400 baud. See documentation for further details
    on how to connect with GDB.



Big-Endian operation
~~~~~~~~~~~~~~~~~~~~

  1) If the board is to be used in big-endian mode, the stub should be
     configured for platform 'pidbe' instead of 'pid'.

 2a) If a big-endian rom controller is installed on the board, the
     programming of a new stub into flash is covered in the ARM PID
     manual.

 2b) If a big-endian rom controller is _not_ used, this is what you
     must do:

       1) Follow the above instructions (including jumper settings) ,
          but instead of building and using the 'prog_flash' FLASH
          tool, use the 'prog_flash_BE_image_LE_system' FLASH tool
          (build it by enabling CYGBLD_BUILD_FLASH_TOOL_BE)

       2) Instead of resetting the board after the FLASH has been
          programmed, switch off the power and enable jumper LK4.

     If you have to re-program the FLASH later, you can follow the
     steps above again, but also disable jumper LK4 when changing the
     other jumpers.
