# Downloading Programs

### Program Description

This built-in facility controls the transmission of user programs from a host computer (e.g. an IBM PC or compatible) over the serial interface to the EyeBot RAM or Flash-ROM. It is one of a number of system routines provided with the EyeBot hardware, which allow users to design and run their own applications.

### Settings on Host and EyeBot

- Serial data from host PC

  The routine requires that the user install a terminal program on the host PC, and configure its serial protocol to match that of the EyeBot. This terminal program sends an S-Record file to the EyeBot, under the control of the download routine.

- Parameters given to EyeBot

  The command sequence (below) describes the series of EyeBot key presses required to specify the download parameters. These keypresses are the only direct user input to the download routine.

  - Baudrates: 9600, 19200, 38400, 57600, 115200.
  - Handshakes: None, RTS/CTS.

- Serial Protocol Listing (PC/Mac)

- On Unix systems you can either use Kermit or
  set the line to the appropriate speed once (for COM2):
  stty speed 57600 crtscts < /dev/ttyS1
  you can also check the current settings (for COM2):
  stty -a < /dev/ttyS1
  the Unix data transfer (for COM2) becomes then extremely simple:
  cat myfile.hex > /dev/ttyS1
  you can of course also use the supplied shell script for downloading, which assumes speed 57600, RTS/CTS and port COM2:
  dl myfile.hex

### Data Transmission

During the transmission, the Download Program provides the name of the program being loaded, and a progress report with the number of bytes received. The final output is a successful completion screen, and the opportunity to run the loaded program.

### Exception Reports

The Download Program provides a returncode to the EyeBot operating sytem, in the event that it encounters invalid data transmission events. The download is aborted at the point where the error occurs. The user program cannot be run if an error occurs during its transmission. The condition that caused the error must be corrected, and another download attempt made. A brief error message will be displayed on the LCD.

- List of Exceptions and Posible Solutions

### Program Limitations

- Available Memory

  The portion of the standard EyeBot RAM not in use by its BIOS begins at 20000 hex and extends to 40000 hex, giving 128 KB of available space for user programs. Total RAM is extendable to 1MB.

- Baud Rate

  The maximum possible baudrate is 57600. When 115200 baud was attempted, it produced unavoidable framing errors on each character received.

- Progress Report

  This version of the download routine can only produce a progress report when using RTS/CTS flow control. The use of this feature, however, significantly increases the transfer time. Therefore, the choices are: slower transfer with a progress report, or faster transfer without it.

  The reason for this limitation is the fact that the download routine is doing polled, not interrupt-driven I/O. Any attempt to write to the LCD during the polling process without halting the sender causes a data overrun status error, ie. one or more characters have been lost. When RTS/CTS flow control is used, the Download routine on the EyeBot turns the Clear To Send (CTS) signal off to prevent the PC from sending while it is writing to the display.

### Command Sequence

- hardware requirements: download connector must be attached to EyeBot and the host computer's (e.g. PC) serial port.
- compile or assemble your program first, using the objcopy routine to generate an S-record (".hex") file
- your program may not use addresses below 20000 HEX; these are reserved for the operating system
- have the S-record file (".hex") ready on the host system
- select Set /Ser from the EyeBot menu to set a matching speed (e.g. 57,600 Baud) and handshake on both host and EyeBot

      SerSetup:
      Serial Speed: *
         9600
      Handshake:
         RTS/CTS

       +  -   Nxt END

- select Usr / Ld from the EyeBot menu

      Ready to
      download at
      57600, RTS/CTS:
      Downloading:

                 END

- send the file from the host (PC) using either DOS kermit or Windows Terminal
  kermit: transmit myprog.hex

      Ready to
      download at
      57600, RTS/CTS:
      Downloading:
           myprog.hex
      Bytes:   80260
      Ld Run Rom END

- EyeBot reports completion of the transmission. At this point, the program may be run or deleted. If any errors occured, the program reports them.

      User Prog.:

      Program loaded:
          myprog.hex

      Ld Run Rom END

- On an EyeBot equipped with large Flash-ROM, the "Rom" button allows storing user programs in ROM. Depending on RAM- and ROM-size, up to three user programs can be stored and retireved in/from the Flash-ROM.

      ---Flashdrive---
      Program in RAM:
          myprog.hex
      Programs in ROM:
            NONE.hex *
            NONE.hex
            NONE.hex
      Sav Ld Nxt END

- On an EyeBot equipped with large Flash-ROM, you can create a "turn key" system, ie. a system where a user program is automatically loaded from ROM and executed, every time the EyeBot is powered up or reset. In order to do so, call you downloaded program startup.hex and save it in a ROM slot. If there is more than one program by this name in ROM, the one with the lowest slot number is taken.

  If any key is pressed during startup of the EyeBot, the automatic user progam execution is disabled.

Thomas Bräunl, Barbara Linn, and Klaus Schmitt, 1997