/***************************************************************************
 *                                                                         *
 *                   SiRF Technology, Inc. GPS Software                    *
 *                                                                         *
 *    Copyright (c) 1996-2015 by SiRF Technology, Inc. a CSR plc Company   *
 *                          All rights reserved.                           *
 *                                                                         *
 *    This Software is protected by United States copyright laws and       *
 *    international treaties.  You may not reverse engineer, decompile     *
 *    or disassemble this Software.                                        *
 *                                                                         *
 *    WARNING:                                                             *
 *    This Software contains SiRF Technology Inc.s confidential and        *
 *    proprietary information. UNAUTHORIZED COPYING, USE, DISTRIBUTION,    *
 *    PUBLICATION, TRANSFER, SALE, RENTAL OR DISCLOSURE IS PROHIBITED      *
 *    AND MAY RESULT IN SERIOUS LEGAL CONSEQUENCES.  Do not copy this      *
 *    Software without SiRF Technology, Inc.s  express written             *
 *    permission.   Use of any portion of the contents of this Software    *
 *    is subject to and restricted by your signed written agreement with   *
 *    SiRF Technology, Inc.                                                *
 *                                                                         *
 ***************************************************************************/


SIRFFlashEngineEP UART interface for LINUX PC Host
==================================================
SiRFflashEngineEP Software Package Kit is an easy to port package for programming
flash memories on SiRFStarV B01 and B02 targets based on CSR SiRF Technology.
This document describes the steps required to build and run
SIRFFlashEngineEP via standard UART based serial lines in LINUX PC Host.


TARGET AND LINUX PC HOST
========================
The instructions described below were tested with a PC running
Ubuntu 10.10 (32-bit) to program SiRFStarV EVK.


PREREQUISITES
=============
It is assumed that users have good knowledge of C programming language,
gcc compiler and PC-based Linux.



BUILDING PROCESS
================
The SiRFFlashEngineEP software consists of two main components:
(a) SiRFFlashEngineEP library which supports a range of flash chips.
    (Please contact CSR support for current list flash chips supported).
(b) prgflash_spi main program which demonstrates the use of SiRFFlashEngineEP library
    for flash programming.

So the building process is separated into 2 stages.


Building the Library SiRFflashEngineEP_uart.a
=============================================
1. To build the library, change directory to
   SiRFflashEngineEP/sw/host/library/builds/linux_gcc/SiRFflashEngineEP/uart/
2. Type "make clean<ENTER>" for a new clean build.
3. Then type "make<ENTER>" to build library SiRFflashEngineEP_uart.a.


Building the program prgflash_uart
==================================
1. Change directory to
   SiRFflashEngineEP/sw/host/prgflash/serial/linux_gcc/build/prgflash/Release/
2. Type "make clean<ENTER>" for a new clean build.
3. Then type "make<ENTER>" to build the executable programmer application prgflash_uart.




RUNNING THE PROGRAMMER prgflash_uart
====================================
1. Change directory to
   SiRFflashEngineEP/sw/host/prgflash/serial/linux_gcc/build/prgflash/Release/
2. Connect the UART serial cable to the SiRFStarV EVK target, change the EVK interface switch to
   UART position and power-up the EVK. It is recommended that the Mode switch (if available)
   is set to FLASH position (instead of RUN). For some EVK, this switch is not available. In this case
   the [-x LIVE_BAUDRATE] option must be used.
   Reset the EVK and toggle its POWER button.
3. Run the prgflash_uart executable application that was previously built to program
   the SiRFStarV EVK. To successfully run the prgflash_uart, it may be required to use 
   SUPERUSER permission (sudo).
   The syntax is
   ./prgflash_uart <BINARY IMAGE FILE> <UART PORT NAME> <BAUDRATE> [-e] [-x LIVE_BAUDRATE]
   The [-e] is the option setting for erasing the whole flash before programming.
   Without the -e option, only the necessary sectors are erase before programming.
   The [-x LIVE_BAUDRATE] is the option setting to switch from Live to BOOT mode prior to programming
   and the LIVE_BAUDRATE is the baudrate the target receiver is running in LIVE mode.
   Without the -x option, the target is assumed to be in BOOT mode (this is the preferred method).



