------------------------------------------------------------------------------------------
DESCRIPTION:
    Upgrade_tool for FIBOCOM Wireless Modules.
Applicable Models:
    FM150 FG150 FM101 FG101 FM160 FG160 NL668 LC116 MC116 MA510 MC109
------------------------------------------------------------------------------------------
             Upgrade Parameter Description

    Parameter               Necessary   Description
------------------------------------------------------------------------------------------
 -f  <image dir or 7z package>   Yes    Directory of firmware image or firmware 7z package
 -r  <0/1>                       No     This parameter is only set for MDM9x07 LE Models.
                                        When -r 1 is set, NV will be restored automatically after downloading.
                                            If -r 1 is not set, you need to manually execute at command to restore NV after downloading.
 -s </sys/bus/usb/devices/xx>    No     When multiple modules are connected to the host,this parameter is used to specify the module.
                                        When only one module is connected to the host, this parameter does not need to be set.

 -p  <port>                      No     Upgrade port <-p /dev/ttyUSBX> or TCP USB Remote Upgrade <-p 9008 and -p IP:9008>

 -z  <0/1>                       No     Send Zero-length package.Defaults is 0. No special instructions, no need to set parameters.
 -e                              No     Erase All Before Upgrade.The all the calibration nv data will be erased. 
                                        No special instructions, no need to set parameters
 -l <log dir>                    No     set log dir and save the upgrade failed log.
------------------------------------------------------------------------------------------

==================================================================================
*    Notice
*
* If the module is in normal mode, send 'at+disk=0,0,0' to unlock diag port first.
*
===================================================================================

------------------------------------------------------------------------------------------
For example:
1. MDM9205 TX Models
    ./upgrade_tool -f ./19010.1000.00.02.73.01/Maincode
2. MDM9x07 LE Models
    ./upgrade_tool -f ./19010.1000.00.02.73.01/Maincode -r 1
3. support -f 7z package, but need md5 file in the same dir.
 ./upgrade_tool -f ./89100.1000.00.02.02.01.7z(Upgrade package name) <-p /dev/ttyUSB0>
------------------------------------------------------------------------------------------

------------------------------------------------------------------------------------------
    RESTORE NV
------------------------------------------------------------------------------------------
1. MDM9205 TX Models restore NV
    MDM9205 TX Models will not restore NV automatically, so NV needs to be restored manually.
    The operation steps:
    a. Send at command: at+efserrfatal
    b. Send at command: at+cfun=15
    c. After restart, check whether IMEI and SN are normal.

2. MDM9x07 LE Models restore NV
    Adding <-r 1> during MDM9x07 LE Models upgrade can automatically restore NV.
    If you forget to add <-r 1> during upgrade, you can also execute at command to restore.
    The operation steps:
    a. Send at command:  at+syscmd=odm_upgrader restore
    b. Send at command: at+cfun=15
    c. After restart, check whether IMEI and SN are normal.
3. Other Models can resotre NV automatically.

*************************************************************************************************/

/************************************************************************************************
   TCP USB Remote Upgrade
------------------------------------------------------------
1. The host connects to the network without using the module to be upgraded.
   On the host which connecting the fibocom module.
   Execute: ./upgrade_tool -p 9008
   Get the IP address. For example: 192.168.1.2
2. On the remote Linux computer.
   Execute: ./upgrade_tool -p IP:9008 -f <firmware image dir>
   For example: ./upgrade_tool -f ./19010.1000.00.02.73.01/Maincode -p 192.168.1.2:9008
*************************************************************************************************/

=================================================================================================
                            Version Record
  This section contains version comments describing changes made to the module.
  Notice that  changes are listed in reverse chronological order.


Version                 Date            Modification
--------------------    --------     ------------------------------------------------------------
Download_TooL_V1.0      08/23/2021    The initial release
Download_TooL_V1.1      01/04/2022    Support pcie upgrade. Save the upgrade result. Support firmware package specified path.
Download_TooL_V1.2      02/16/2022    Solve the pcie upgrade problem
Download_TooL_V1.3      03/22/2022    Support rawprogram_nand_XX.xml without erase. Add -r for MDM9205 to auto restore NV.
                                      After the upgrade is successful, delete the upgrade log.

=================================================================================================
