Read CC2340R5 MAC Address via UniFlash
=======================================

The MAC address of a specific CC2340R5 device may be read
through UniFlash. This can be done through the UniFlash GUI
or through the UniFlash CLI.

Prerequisites
=============

The user is expected to have/do the following:

* |DEVICE|
* A computer running a supported operating system listed in the Release Notes
* Latest version of `UniFlash`_
* Read the UniFlash QuickStart Guide located in ``{UNIFLASH_INSTALL_DIR}/docs/quick_start_guide/uniflash_quick_start_guide.html``


.. _read-MAC-Address-UniFlash-GUI:

Reading MAC Address through UniFlash GUI
----------------------------------------

Reading the MAC address through the UniFlash GUI is most
useful when the MAC address needs to be read once for testing
or documentation. If the value needs to be read as part of
some automation process or manufacturing process, then the
CLI method discussed in :ref:`read-MAC-Address-UniFlash-CLI`.
is recommended.

This step-by-step guide will help you to read the MAC address
written to your device through the UniFlash GUI.

#.  While the |DEVICE| is connected to your computer, 
    open UniFlash.

#.  Launch the device configuration of the |DEVICE| by using
    the auto-detect feature or by manually searching for the
    |DEVICE| in the ``New Configuration`` section and clicking
    on ``Start``. 

    .. figure:: /debugging/resources/cc23xx_Uniflash_Device_Configuration.jpg
        :align: center

#.  Once the device configuration has been launched, navigate to
    to the ``Memory`` tab on the left and click on ``Read Target Device``

    .. figure:: /debugging/resources/cc23xx_Read_Target_Memory.jpg
        :align: center

#.  On the ``Address`` search bar on the top left, type ``0x4E000058``
    and click on ``Go``

#.  The device memory will be read and the ``0x4E000058`` address
    will be highlighted in the browser.

    .. figure:: /debugging/resources/cc23xx_Uniflash_GUI_Address.jpg
        :align: center    

#. The highlighted data will contain the MAC address of the device.



.. _read-MAC-Address-UniFlash-CLI:

Reading MAC Address through UniFlash CLI
----------------------------------------

If the MAC Address must be read due to a fabrication workflow
or as part of an automated testing process, then reading the
address through the UniFlash Command Line Interface (CLI) 
will likely be the most useful method.

This step-by-step guide will help you to read the MAC address
written to your device through the UniFlash CLI

#.  While the |DEVICE| is connected to your computer, 
    open UniFlash.

#.  Launch the device configuration of the |DEVICE| by using
    the auto-detect feature or by manually searching for the
    |DEVICE| in the ``New Configuration`` section and clicking
    on ``Start``. 

    .. figure:: /debugging/resources/cc23xx_Uniflash_Device_Configuration.jpg
        :align: center

#.  Once the device configuration has been launched, navigate to
    to the ``Standalone Command Line`` tab on the left and 
    click on ``Generate Package``. This may take a few minutes.

    .. figure:: /debugging/resources/cc23xx_generate_Uniflash_CLI_package.jpg
        :align: center

#.  On the save the generated package to a known location (for
    example, ``C:\ti``) and unzip the archive that the known
    location. The newly extracted folder, should look like
    the following image:

    .. figure:: /debugging/resources/cc23xx_extracted_CLI_package.jpg
        :align: center

#.  Run the ``one_time_setup.bat`` script. This script will generated
    all the necessary setup-files to use the CLI.

#.  Open a command-line and navigate to the newly extracted folder.

    .. figure:: /debugging/resources/cc23xx_extracted_CLI_package_commandline.jpg
        :align: center

#.  Type and run the following command:
    
    ``.\dslite-Cortex_M0P.bat --mode memory --config .\user_files\configs\cc2340r5.ccxml --range=0x4E000058,1 --output=result.hex``
    
    The command will read one entire word at memory address ``0x4E000058`` which
    will contain the MAC address of the device. The read data
    will be written to a ``result.hex`` file located in the
    extracted folder.

    .. figure:: /debugging/resources/cc23xx_extracted_CLI_package_command_ran.jpg
        :align: center

    .. figure:: /debugging/resources/cc23xx_extracted_CLI_package_command_output_file.jpg
        :align: center

#.  The file may be read through a hex viewer/editor program.
    Looking into the file, we see the following:

    .. figure:: /debugging/resources/cc23xx_extracted_CLI_package_command_output_hex_viewer.jpg
        :align: center

The commands specified in this section may be utilized in
scripting languages to allow for easy automation.

More information about the UniFlash Command Line Interface
may be found in the Quick Start Guide included with your
UniFlash installation.