# Overview
[UniFlash](https://www.ti.com/tool/UNIFLASH) is a tool for programming TI embedded devices. It is typically used for flash programming but can also be used to program RAM. This document describes how to use UniFlash to program multiple devices that are on the same scan chain and connected to the host computer with a single debug probe. For instructions on how to program multiple boards connected via separate debug probes refer to [UniFlash with multiple boards](https://software-dl.ti.com/ccs/esd/documents/application_notes/appnote-uniflash_multiple_boards.html).
# Procedure
Programming more than one device with UniFlash relies on creating multiple target configuration files. These target configuration files are used to identify the device to program. As the target configuration files here are for a board that has multiple devices it is necessary to use the advanced target configuration editor in Code Composer Studio. A target configuration file (.ccxml) specifies the device/board(s) and debug probe that are being used. Code Composer Studio is only needed to get the environment setup and not required for later using the information in UniFlash.
This document assumes that the desktop version of UniFlash is being used as it is necessary to run UniFlash from the command line. Once the necessary target configuration files are created the command line UniFlash is called to program each device one at a time. A script or batch file can be created to program all devices in a single invocation.
## Create target configuration containing all devices
To start a target configuration file needs to be created for all devices. This file will then be used to create a set of target configuration files where only one device is enabled and the rest are bypassed.
[[b Note:
If you are using Code Composer Studio for developing your application then it is quite possible that you already have a target configuration file that contains all of the devices that can be used.
]]
* Open **Code Composer Studio**
* Open the **Target Configurations* view from the **View** menu
* Click the button to create a new **target configuration file**
* Specify a unique name for the file

* Make note of where the file is going to be saved
* Click **Finish**
* The .ccxml file will now open in the editor
* Select the appropriate **Connection** for the debug probe being used

* Click on the **Advanced** tab at the bottom to switch to advanced settings
* Select the debug probe in the tree on the left
* Click the **Add** button on the right
* In the dialog box that opens select the **Devices** tab at the top
[[b Note:
There are a lot of devices supported by Code Composer Studio. The filter at the top right may help to reduce the size of the list.
]]
* Select the first device that is on your board

* If board contains more than one of the same device you can select to add multiple copies of the device at the bottom right.
* Click **Finish**
* Repeat the process and add the remaining devices. Once complete it should look something like this

* Test the target configuration in Code Composer Studio and ensure that you are able to connect to each device
## Create a target configuration for each device
It is necessary to have a separate target configuration file for each device that is on the board. The target configuration file that contains all devices will be used as a template.
* Make sure that the target configuration file for all devices is open in the editor in **Code Composer Studio**
* The **Advanced** tab needs to be selected
* Bypass every device but the first device. This is done by selecting a device in the tree on the left. Then select each **CPU** on the device and check the box to **bypass** on the right.

* Go to the **File** menu and select **Save As**. Give the file a unique name so that it is obvious which device it is for.
* Repeat the process so that you have a set of files where all but one device is bypassed in each
* Test each target configuration file in Code Composer Studio and ensure that you can connect to the device that is not bypassed
## UniFlash settings
It is recommended to start by using the UniFlash GUI to determine the settings that will be used for flashing. Once these settings are determined they can be saved to a file and then passed to the command line interface. Either the Cloud or desktop version of UniFlash can be used for this section.
* Open UniFlash
* Scroll down to **Create Session From Existing Target Configuration File**.
* Click the **Select** button.

* Select target configuration (.ccxml) file where the first device is enabled and the rest are bypassed
* Click the **Start** button to continue.

* Click the **Browse** button and specify the image to program.


* Click the **Load Image** button to confirm that the image can be programmed on the board

* Set any additional settings that are desired. The settings available vary by device but often their are options for how much memory to erase prior to loading, if to perform a reset when connecting to the device, clock settings...
* Once done with the settings click on **Standalone Command Line** on the left

* Saving settings
* **Option 1**: save just the settings file. Click the **Download** link beside **Settings** to save the file that contains all of the options that were configured in UniFlash. If using the Cloud version of UniFlash this will download the file. If using the Desktop version it will prompt for a location to save the file. Give the file a name that matches the board.
* **Option 2**: generate a command line UniFlash package that includes the uniflash components necessary for flashing the specified device, bundled with the program image, ccxml file and settings file.
* Repeat for the other target configuration files
## Invoking UniFlash
It is recommended to use the command line interface when multiple target configuration files. This interface is described in the [UniFlash Quick Start Guide](https://software-dl.ti.com/ccs/esd/uniflash/docs/v6_2/uniflash_quick_start_guide.html#command-line-interface).
The basic structure of calling UniFlash from the command line consists of calling the **dslite** utility with an action to perform, the target configuration file, options file and program image.
```
dslite flash --config=ccxml-file [options] [image]
```
An example is:
```
dslite --mode flash --config=first_f280025c.ccxml --load-settings=first_f280025c.ufsettings led_ex1_blinky.out
```
To program 2 devices then 2 commands would be run.
```
dslite --mode flash --config=first_f280025c.ccxml --load-settings=first_f280025c.ufsettings led_ex1_blinky.out
dslite --mode flash --config=second_f280025c.ccxml --load-settings=second_f280025c.ufsettingss other_program.out
```
A shell script or batch file can be created to run both commands at once. If the option to generate a command line package was seleted it will include an example.