PEmicro Blog

Cyclone Control SDK: Automated Flash Programming with C

PEmicro’s product line of Cyclone stand-alone programmers provides a fast, robust, and automated solution for production-scale programming of microprocessors. However, production facilities may desire an even higher level of automation than the single-button touch capability that is offered by the Cyclone. PEmicro offers several means of automating control, including a console application, Ethernet/Serial protocol communications, or the SDK included in PEmicro's new Cyclone Control Suite. In this article, we discuss using the SDK to automate programmer control and the levels of flexibility and scalability that it offers our customers.

NOTE: This example is shown in C. The Cyclone Control SDK interface code and demo applications are included for GCC, LabView, Microsoft Visual C, Microsoft Visual C#, Delphi/FPC, Python, and Microsoft Visual Basic.

1. Introduction – Controlling a Cyclone through the PC

PEmicro’s new Cyclone Control SDK provides the developer with a dynamic link library (DLL), example applications, and supporting documentation to allow custom software applications to directly control the Cyclone.

Binary data information, algorithm information, programming operations, and other settings are stored together in a SAP image which is saved directly into the FLASH memory of the Cyclone. Programming operations can be initiated by the push of a button on the Cyclone, however, the SDK enables a PC to issue a command to the Cyclone to start the same programming sequence, and also to provide other capabilities, such as the ability to add dynamic data to each board being programmed, and the ability to recover error information.

The use of a PC to control the Cyclone enhances the functionality of the stand-alone programming operations and introduces new capabilities that were not available previously. In the following sections, we explore the features of the SDK and present practical examples of how to use it in your own automated production line.

2. Using the SDK – Simple Example

Example Configuration settings
Figure 4: Code Example (CLICK TO ENLARGE)

The above code example shows a very basic operation that is supported by the SDK. Below are the steps we have taken:

  1. Contact the desired Cyclone by specifying its name (“Fixture1Cyclone1”). The port enumeration (“USB1”, “ETHERNET1”, or “COM1”) or the IP address (“”) of the unit may also be specified. The handle of the Cyclone is returned, and is used to identify the Cyclone in all subsequent function calls.
  2. Send a command to the Cyclone to begin the programming operations specified in image #1. These operations were specified during the image creation process.
  3. Wait for the Cyclone to complete the programming operations before proceeding.
  4. Check to see if any errors occurred during programming and return the error code and a message to the user.
  5. Terminate the current session with the Cyclone.

3. Using the SDK – More Advanced Operations

a. Programming a serial number

The Cyclone already has a serial number programming mechanism built into the SAP image. The Cyclone can keep track of the serial number and auto-increment after a board is successfully programmed. Serial numbers can also be programmed into target boards via the SDK as dynamic data, in which case the serial number capability of the Cyclone is not used. Rather, the calling application provides the dynamic data and programs it after programming of the main image data has already occurred.

Example Configuration settings
Figure 5: Serial Number Example Code (CLICK TO ENLARGE)

Note: The following are placeholder functions used to simplify the example, and are not provided by the automated control package:

  • get_serial_from_file
  • increment_serial_number
  • save_serial_back_to_file

The above example code is based on the previous simple example which instructs the Cyclone to perform the stand-alone programming operations of the image stored on the Cyclone. Afterwards, we program a dynamic 2-byte serial number into address 0x1000 of the target processor. The serial number is then incremented and written back to a file for later use.

The SDK offers a lot of flexibility in handling serial numbers. This code example can easily be modified to program dynamic data that is not sequential. For example, if we wish to program the current date or a lot number. This code example can also be expanded to use multiple Cyclones (see Section 5) that share an incrementing serial number between all Cyclone units. Any of these requirements can be easily met by writing your own custom application using the SDK.

b. Automatically update image stored on the Cyclone

Example Configuration settings
Figure 6: Code Example: Keep Stored Images Current (CLICK TO ENLARGE)

This is a very simple example of how to ensure that the image stored on a Cyclone is always up to date. A comparison is performed between the image which currently resides on the Cyclone and an image file at a specified location on the host PC. If there is a mismatch, then we update the image. Afterwards, we proceed with the normal programming operations as seen in the previous examples.

c. Working with properties

Cyclone, Cyclone network, and stored image settings can now be retrieved directly from a Cyclone using the property mechanism. Image properties allows you to read out information such as the image CRC, the current serial number, and the power settings. Cyclone properties allows you to read or set values such as the Cyclone name which can then be used in the future to open the Cyclone. You can see a list of the categories and properties in the header file of the programming examples that are included with the SDK.

Example Configuration settings
Figure 7: Code Example: Keep Stored Images Current

The routine getPropertyList returns a list of valid categories and their properties. The routine getPropertyValue returns the value of the category and property that you pass in as arguments.

4. Using the SDK - Gang Operation Example

We have discussed some uses of the SDK with a single Cyclone unit in previous examples. Since the host PC only sends minimal control information to control each Cyclone, a single PC is actually capable of controlling multiple Cyclone units simultaneously.

Example Configuration settings
Figure 8: Program 3 Cyclones

Here, we begin programming operations on 3 separate Cyclone units that are connected to the host PC. This will work even if all the Cyclones are connected on a mix of different ports. Then we wait for their completion before proceeding. In essence, we are programming 3 separate devices in parallel. This can be easily extended up to 100 Cyclone units in a network controlled in parallel from a single host PC.

More Info - Setting Up a Stand Alone Programming Image

The first step is always to create the actual stand-alone images that will be stored onto the Cyclone. These images contain the algorithm needed to program FLASH / EEPROM, the actual binary data to be programmed, the sequence of programming operations, and many user-specified Cyclone settings. PEmicro’s “Cyclone Image Creation Utility” allows the user to properly configure the stand-alone images.

Example Configuration settings
Figure 1: Configure Stand-Alone Image (CLICK TO ENLARGE)

Above is a screenshot of the dialog in the Cyclone Image Creation Utility which allows the user to configure the stand-alone image. The field on the right shows the programming steps and also the order in which these steps execute.

  1. First, we select the appropriate algorithm for our processor. In this example, we are using the NXP Kinetis KL25Z128.
  2. Next, we specify the target object file that represents the binary data to be programmed into the processor’s FLASH memory. Here, we are using a Motorola S-record file.
  3. Once the algorithm and the target object file are specified, we are ready to begin programming. Typically, the procedure is to erase the device to make sure it’s blank, program the target, and verify that the contents were written correctly. If you select the Launch Script Wizard option, the utility will automatically create the programming sequence for you.
Example Configuration settings
Figure 2: Additional Settings

In addition to the programming sequence, there are also settings for the Cyclone that we can configure. In the above screenshot, we are using the Cyclone Universal’s power relays to provide the 3.0 volts to power up our processor. This way, we do not need a separate power supply for our target board, simplifying our production line.

Example Configuration settings
Figure 3: Specify Image Description (CLICK TO ENLARGE)

Finally, we specify the image description so that we can easily identify the image later on. This is the text that appears on the screen of Cyclone. By using the “Store Image to Disk” option, we are able to save this image and its configuration as a .SAP file for future use with the SDK.

Tags related to this Blog Post

Cyclone     Cyclone FX     ARM     NXP     Production Programming     Automated Control