This blog post documents the method to read out the firmware version from a CCG3PA chip.
The firmware version information can be retrieved in the form of VDMs. This handling is taken care in the uvdm.c file in the Power SDK:
Since CCG3PA supports only single firmware image, the bootloader version and the firmware version of image 1 are read from the metadata by the system functions. The firmware and the bootloader version are given out in hex format.
The above implementation is with respect to the op-code present in the VDM sent by a Cypress board. In case if custom standard testers are employed in production environment for reading out the firmware version that is programmed into the PD controller, the customers can form their custom VDM command in the tester and can customize the SDK accordingly to form the custom UVDM response.
Below is a sample code snippet in which CCG3PA gives out the firmware version information if it is connected to a BCR device. CCG3PA first sends Discover Identity VDM command after the completion of PD negotiation between source and sink. If the VID and PID of sink matches with the VID and PID of EZ PD BCR device (i.e. VID= 0X4B4 and PID=0x3177), CCG3PA will respond by sending a UVDM command which contains the firmware version.
As per USB-PD spec,
The unstructured vendor defined message is sent with the vendor ID set to appropriate value (0x4B4), VDM type set to 0 (unstructured vdm) and rest fields were set to 0 (which can be customized as per requirement).
The UVDM is sent after detection of EZ PD BCR through a timer callback. The function cc_device_version() is used to send the UVDM.
App event APP_EVT_PD_CONTRACT_NEGOTIATION_COMPLETE is triggered in app_event_handler() function once the PD negotiation is complete. Discover Identity message is sent after negotiation complete event through a timer callback.
The above image presents the code being used to extract the firmware version information from the metadata using the system functions once EZ PD BCR device is detected.
Following is the detail of the UVDM from CC logs captured using CY4500 EZ PD Protocol Analyzer.
DATA OBJECT 4 and DATA OBJECT 5 contain the firmware version.
For information on CCGx firmware version structure, refer to Table-13 in the CCGx Power SDK User Guide: (https://www.cypress.com/documentation/software-and-drivers/ez-pd-ccgx-power-software-development-kit).
Attached to this post is the project which recognizes Ez-PD BCR as a sink and sends UVDM containing the firmware version information. All changes to project are made in app.c file.