Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

Using the CY8CKIT-049 to Program Another PSoC® 4

lock attach
Attachments are accessible only for community members.

Using the CY8CKIT-049 to Program Another PSoC® 4

Anonymous
Not applicable

How can you use the CY8CKIT-049 to program another PSoC® 4 device?

- The CY8CKIT-049 does not have an onboard programmer. Instead, it uses a UART bootloader in PSoC 4 and a USB-Serial chip to bootload new application images.

Figure 1. CY8CKIT-049

CY8CKIT-049

Even though the bootloader region is write protected, you might not be comfortable modifying it because there a risk that the bootloader could be corrupted. If the bootloader section is corrupted, then you have to buy a MiniProg3 to reprogram the bootloader.

The method explained below allows you to use the modified Host Sourced Serial Programming (HSSP) example project using a CY8CKIT-049 so that you can reprogram one CY8CKIT-049 kit using another CY8CKIT-049. This is a hack that you can do on your CY8CKIT-049 PSoC 4 Stamp board to convert it to a simple PSoC 4 programmer. Note that this only allows you to program your PSoC 4 device and does not allow debugging.

This method uses a Python™ script to program a PSoC 4 device using CY8CKIT-049. The .hex file to be programmed is opened by a Python script that parses the .hex file and sends it over a COM port. This data is streamed through the USB-Serial chip in CY8CKIT-049 to the PSoC 4 on this kit.

The implementation uses PSoC 4 in CY8CKIT-049 as a UART-to-SWD bridge. The firmware in CY8CKIT-049 uses a modified version of PSoC 4 HSSP to program the target PSoC 4 device. The archived PSoC Creator™ firmware and the Python script are provided at the end of the article.

How to use the projects:

Step 1: Set up your PC:

  1. Download and install Python on your PC. Python is a free download available here. This project is tested with Python 2.7.
  2. Install the PySerial libraries. This is required by Python to access the emulated COM port of your PC. You can download the PySerial libraries from the following website.

Step 2a: Setup your CY8CKIT-049 (Skip to Step 2b if you have a CY8CKIT-049-42xx):

  1. Download and extract the .zip file provided with this article. (4 dollar programmer.zip)
  2. Extract the file PSoC 4 Firmware.zip to a folder.
  3. Open and build the project files using PSoC Creator 3.0 SP1 or later. Note that this project is built for CY8CKIT-049-42xx (CY8C4245AXI-483). If you need to use this for CY8CKIT-049-41xx, change the part number to CY8C4125AXI-483 and rebuild the project.
  4. The UART_SWD_Bridge.cyacd file is generated in the location
      “\\4 dollar programmer\PSoC 4 Firmware\UART_SWD\UART_SWD_Bridge.cydsn\CortexM0\ARM_GCC_473\Debug\”.
  5. Press and hold the switch on the kit and plug CY8CKIT-049 into the PC. The PSoC 4 device enters the bootloader mode and is ready to accept a new bootloadable application. Bootload this file to the PSoC 4 device in CY8CKIT-049. Details on how to bootload a new project are given in the CY8CKIT-049-4xxx Kit Guide.

Step 2b: Setup your CY8CKIT-049 (Skip to Step 3 if you followed Step 2a):

  1. Download and extract the .zip file given with this article. (4 dollar programmer.zip)
  2. Open the Bootloader Host tool from Start > Cypress > PSoC Creator 3.0 > Bootloader Host.
  3. Select the source file as <Download directory> \4 dollar programmer\PSoC 4 Firmware\Bootloadable\ UART_SWD_Bridge.cyacd and bootload the PSoC 4 device.

Step 3: Wire up the circuit as shown in the following connection diagram:

Figure 2. Connection Diagram

Connection Diagram

Figure 3. Test Setup

Test Setup

 

Step 4: Program the target:

  1. Right-click on the file Python Programmer and open the Python script file using IDLE.
         

    Figure 4. Context Menu Showing Option to Edit with IDLE
       Edit with IDLE

  2. Change the COM port number in the .py file to the COM port number of your USB-Serial device in CY8CKIT-049. 

     

Figure 5. Location in Python Script to Edit COM Port Number
   COM Port

  1. Type in the path of your source file for the target PSoC 4. Note that the path contains two backward slashes (\\) between folder names.

    Figure 6. Location in Python Script to Edit the Path to the Source Hex File
       Hex file

  2. Press F5 or select Run Module from the Run menu to begin programming.
     

    Figure 7. Run Module Option in Run Menu of IDLE
       Run Menu

 

The Status LED on CY8CKIT-049 turns OFF once programming starts. The LED turns ON after a successful programming operation. The LED blinks if the programming operation is unsuccessful. If the programming operation is unsuccessful, unplug and replug CY8CKIT-049 and restart the Python script.

Implementation:

Figure 8. Test Setup

Test Setup

Python Script:

The Python script accesses a .hex file from the specified path and parses it to find the following:

  • Silicon ID
  • Actual flash data
  • Flash protection settings
  • Checksum

The script then sends out commands to the specified COM port as follows:

‘S’, <Command1>, <Command2>, <1 to 128 data bytes>, 'P'

Command1 is a single character with the meaning given in Table 1.

                                                                                       Table 1. Meaning of Command1                                                                                

Command1 Meaning Command2 Meaning
A Acquire Target    
I Verify Silicon ID    
E Erase All Flash    
C Checksum Privileged    
P Program Flash Row <Number> Row Number
V Verify Flash Row <Number> Row Number
R Program Protection Settings    
T Verify Protection Settings    
S Verify Checksum    

 

The script does not implement a handshake protocol and the communication is unidirectional.

PSoC 4 Firmware:

The PSoC 4 device on CY8CKIT-049 receives the data from the USB-Serial chip (sent out by the Python script). The PSoC 4 device then decodes the commands to program the target PSoC 4 device. The programming sequence follows the method illustrated in AN84858 - PSoC® 4 Programming Using an External Microcontroller (HSSP).

 

Version: *A

Translation - Japanese: CY8CKIT-049 を使用して他の PSoC® 4 をプログラムする - KBA93541 - Community Translated (JA)

Attachments
6453 Views