RAM Dump Tool
---------------------
This tool captures of the device memory contents when the device is in memory dump mode.  Memory contents are saved in files written to the directory
specified by the "-o" command line argument or MemDumpOut under the current folder by default.

************
Compilation
************
- By default, the application compiles for hostx86_64 Linux platform.
  "make"

- The application can be compiled for different platform using the CPU option:
  "make CPU=<platform>"
  where <platform> = win32 for compiling with Cygwin on Windows
                     rpi for compiling for Raspberry Pi
                     arm64linaro for compiling for RockPro64

- For rpi and arm64linaro, platform specific toolchains are required. These must be
  installed to the $(HOME) directory once, and can be used for all SDK workspaces.
  If they do not exist, 
    "make CPU=rpi",
    "make CPU=arm64linaro",
  will simply fail.
  
  Toolchains can be found at the following locations.
  - rpi: https://github.com/raspberrypi/tools.git
  - Linaro arm64: http://releases.linaro.org/components/toolchain/binaries/7.4-2019.02/aarch64-linux-gnu/
      gcc-linaro-7.4.1-2019.02-x86_64_aarch64-linux-gnu.tar.xz

*******************
 Prior to Execution
*******************
1. Enter the following AT commands:
    at!entercnd="A710"
    at!eroption=0

2. Either reproduce a crash you are investigating, or reset the device

**********
Execution
**********
Within a shell, execute the following (for hostx86_64):
   ./ram-dumphostx86_64 [-d <device>] [-c <comport>] [-o <output directory>] [-noreset] [-s]

  -d <device>
       Optionally specify device type. i.e -d 9x30.
  -c <comport>
       Optional parameter to specify the DM port, example: -c 3 for COM3 on Windows
       or -c 0 for /dev/ttyUSB0 on Linux
  -pcie
       Optional parameter for using /dev/mhiqdl* pcie channel to collect crash dump.
  -o <output_directory>
       Optional parameter to specify where to store the crash dump.
       If this is not specified, '<current dir>/MemDumpOut' will be used as default
  -noreset
       Optional Parameter to not reset the device after collecting a crash dump
  -s
       Collect crash summary. Only works with devices that support custom Sahara commands.
  -h
       Display this help menu

/dev/ttyUSB<digit> = DM interface ttyUSB device file in boot and hold mode (usually /dev/ttyUSB0)
/dev/mhiqdl<digit> = DM interface mhi device file(PCIe channel) in boot and hold mode (usually /dev/mhiqdl0)

-----
NOTE 1:
-----
  To execute the program in Windows shell command prompt, cygwin dll path needs to be added to Windows environment variable.

-----
NOTE 2:
-----
When running ram-dumphostx86_64 on Ubuntu, ram-dump may exit and prompt message 
"
DM port not detected
Failed to open port
Could not find DM port
"
That means the DM port (/dev/ttyUSBx) is not created, user can add new Id as follow.

user@Ubuntu:~$ lsusb | grep Sierra
Bus 003 Device 035: ID 1199:9100 Sierra Wireless, Inc. 
user@Ubuntu:~$ 
user@Ubuntu:~$ sudo echo 1199 9100 > /sys/bus/usb-serial/drivers/generic/new_id 
user@Ubuntu:~$

************
Known Issues
************
1.
  On Linux, device sometimes does not reset when -noreset option is not specified. This has not been seen on Windows
2.
  The DM port detection logic on Linux relies on 'udevadm' and is rather simple and has not been tested for more complicated setup.
3.
  The application has not been compiled and tested for arm9 and ppc target.
