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
- 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.
- 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.).
- 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.
- 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.
- 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.
|1||CyU3PThreadPerfGet||Get statistics about a specific thread|
|2||CyU3PThreadSystemPerfGet||Get overall statistics about all threads used in the application (including SDK internal driver threads)|
|3||CyU3PTimerPerfGet||Get statistics about a specific RTOS timer.|
|4||CyU3PTimerSystemPerfGet||Get overall statistics about all RTOS timers.|
|5||CyU3PMutexPerfGet||Get statistics about a specific Mutex object.|
|6||CyU3PMutexSystemPerfGet||Get overall statistics about all Mutex objects.|
|7||CyU3PEventPerfGet||Get statistics about a specific Event group.|
|8||CyU3PEventSystemPerfGet||Get overall statistics about all Event groups.|
|9||CyU3PQueuePerfGet||Get statistics about a specific Message Queue.|
|10||CyU3PQueueSystemPerfGet||Get overall statistics about all Message Queues.|
|11||CyU3PDeviceGetCpuLoad||Get total CPU loading (in percentage) from start of RTOS execution|
|12||CyU3PDeviceGetThreadLoad||Get CPU loading (in percentage) due to a specific thread from start of RTOS execution.|
|13||CyU3PDeviceGetDriverLoad||Get 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.