The project implements USB-UART based bootloader for PSoC5LP. PSoC Creator does not have support for USB-UART based bootloader. So custom communication channel based bootloader needs to be implemented for this.
For a custom bootloader the following functions needs to be implemented manually.
void CyBtldrCommStart(void);
void CyBtldrCommStop (void); void CyBtldrCommReset(void);
cystatus CyBtldrCommWrite(uint8* buffer, uint16 size, uint16* count, uint8 timeOut);
cystatus CyBtldrCommRead (uint8* buffer, uint16 size, uint16* count, uint8 timeOut);
Following functions are written. Files are named as communication.h and communication.c files and are included in the project.
i) void CyBtldrCommStart(void);
This function starts USBUART component.
ii) void CyBtldrCommStop (void);
This function stops USBUART component.
iii) void CyBtldrCommReset(void);
This function initializes OUT endpoint. Initialization is required to be done after enumeration before starting data transfer.
iv) cystatus CyBtldrCommWrite(uint8* buffer, uint16 size, uint16* count, uint8 timeOut);
This function sends data to bootloader host. It is used to send back acknowledgement to the host for different commands. One important thing to note here is, unlike USB-HID bootloader, the USB IN packet size should be just as data size. If you are sending 6 bytes of data, you cannot use full packet length (64) for sending this to host. Because, “Bootloader Host” when configured in UART mode, expects packet length to be just equal to message/data length. See the code in the function.
v) cystatus CyBtldrCommRead (uint8* buffer, uint16 size, uint16* count, uint8 timeOut);
This function reads message sent by host. It also checks for whether enumeration is needed and after enumeration is done, whether initialization is needed. Note that initialization is needed only once after enumeration is done.
Testing the Project:For bootloading the Bootloader Host tool available with PSoC Creator needs to be used. The Bootloader host tools reads the .cyacd file which needs to be bootloaded. For bootloading the data from .cyacd file needs to be sent in a specific format, the tool will sent the data.
Steps for testing:
1) Connect the CY8CKIT-050 and Program the Bootloader Project
2) Plug the CY8CKIT-050 with the USB cable on the Jumper J2.
3) Now the COM PORT device will get enumerated and a new serial device will appear in the Device Manager. Check for this device and note the COM PORT number.
4) Open the Bootloader Host Tool.
5) Select the appropriate COM Port.
6) Give the bootloadable .cyacd file in the ‘File’ text box.
7) Click on Program button. A message “program Finished Successfully” is shown after successful bootloading operation.
Comments