This blog is intended to make a brief introduction to profiling support of ThreadX in FX3/CX3 based application. Cypress has built four variants of buliding configurations in all the example firmwares and these demos are released to customer in latest version of EZ-USB SDK.  The configurations are

 

  1. FX3_debug: This is  the standard debug version of the firmware. This is built at compiler optimization level O0, and performs sanity checks on the parameters passed into the API.
  2. FX3_release:This is the standard release version of the firmware. This is built at compiler optimization level O3, and only has the minimal parameter validity checks required to prevent memory error (NULL pointer access etc.).
  3. FX3_profile_debug:This is a profiling enabled version of the fx3_debug library. This version enables collection and reporting of statistics on the RTOS objects used by the FX3 firmware. It also allows the user to register FX3 GPIOs which can be used for indication of RTOS usage.
  4. FX3_profile_release:This is a profiling enabled version of the fx3_release library. The profiling support is similar to that in the fx3_profile_debug library.

 

For some projects whcih are extracted from previous version of EZ-USB SDK, FX3_profile_debug and FX3_profile_release settings may not be available. Follow the steps below to add profile_debug and profile_release settings into projects.

  • Right click the project name on the project explorer, then choose Build Configurations and then choose Manage.

   1.png

  • Create a new configuration.

 

  • Fill up the blanks of name and description. Here we have import an example project BulkLpAutoCpp in advance which has profile_debug and profile_realease configurations. It could be convenient for users to import configurations from other projects. Choose Import from projects and select BulkLpAutoCpp>ProfileDebug

  • Save the change and set ProfileDebug as the active build option. Profiling APIs are now available in firmware.

 

The profiling-enabled builds of the FX3 library collect a wide range of usage statistics on the RTOS objects used in a firmware application. These statistics are obtained through the APIs below.

No.
API name
Description
1CyU3PThreadPerfGetGet statistics about a specific thread
2CyU3PThreadSystemPerfGetGet overall statistics about all threads used in the application (including SDK internal driver threads)
3CyU3PTimerPerfGetGet statistics about a specific RTOS timer.
4CyU3PTimerSystemPerfGetGet overall statistics about all RTOS timers.
5CyU3PMutexPerfGetGet statistics about a specific Mutex object.
6CyU3PMutexSystemPerfGetGet overall statistics about all Mutex objects.
7CyU3PEventPerfGetGet statistics about a specific Event group.
8CyU3PEventSystemPerfGetGet overall statistics about all Event groups.
9CyU3PQueuePerfGetGet statistics about a specific Message Queue.
10CyU3PQueueSystemPerfGetGet overall statistics about all Message Queues.
11CyU3PDeviceGetCpuLoadGet total CPU loading (in percentage) from start of RTOS execution
12CyU3PDeviceGetThreadLoadGet CPU loading (in percentage) due to a specific thread from start of RTOS execution.
13CyU3PDeviceGetDriverLoadGet CPU loading (in percentage) due to all FX3 driver threads from start of RTOS execution.

 

 

Refer to FX3 API guide to get detailed information about how to use these APIs. The example firmware BulkLpAutoCpp is attached for reference.