.. _commandline_flashing_cc23xx:

Flashing |DEVICE| via UniFlash Command Line
===========================================

In a production environment, it is desireable to be able to flash
the |DEVICE| via a command line. Command line flashing can be used to
automate a portion of the production process. This flashing method
can be used to flash the |DEVICE| devices.

To flash a device via the UniFlash command line, then `UniFlash 8.2.0 <http://www.ti.com/tool/UNIFLASH>`_ or
newer must be installed. The flashing procedure described in this section
can be used to flash blank and non-blank devices.

In order to flash the |DEVICE| via command line, the following steps must be
followed:

#. Compile and generate the image that will be flashed on the device. The generated
   image should be a ``.bin`` or ``.out`` file.

#. Prepare a target configuration:

   * The target configuration used in the project that generated the image may be used.
     By default, the target configuration of a project may be found in
     ``{PROJECT_DIR}/targetConfigs/CC2340R5.ccxml``. The ``CC2340R5.ccxml``
     is the target configuration file.

   * The target configuration file may also be generated via UniFlash. This can be done
     by selecting a |DEVICE| configuration in UniFlash, navigating to the "Standalone Command Line"
     menu in UniFlash and clicking on ``Generate Package``. This will generate an archive 
     which will contain the target configuration in ``{archiveDir}\user_files\configs\cc2340r5.ccxml```

#. Open a command line shell and navigate to the UniFlash installation directory. By default,
   UniFlash will be installed to ``C:\ti\uniflash_8.x.x``.

#. Ensure the generated image file and the target configuration file are both located
   in directories that are visible and accessible to the command line.

   * If desired, the image file and the target configuration file may both be placed
     at the root of the UniFlash installation to ensure that the files are accessible.

#. Connect the |DEVICE| device.

#. Run the following command: ``dslite --mode noConnectFlash --config={targetConfigDir} {imageDir}``
   
   * ``{targetConfigDir}`` is the location where your target configuration file is found.
   
   * ``{imageDir}`` is the location where your image is found.

The image below shows the expected output. The target configuration file and the image to be
flashed were both located in the default UniFlash installation directory:

.. figure:: /cc23xx/resources/CommandLineFlashing_cc23xx.png
    :align: center

To learn more about UniFlash and the UniFlash command line functionality, please reference
the `UniFlash Quick Start Guide <http://software-dl.ti.com/ccs/esd/uniflash/docs/v8_2/uniflash_quick_start_guide.html>`_.
