Translation - Japanese: CY8CKIT-049 を使用して他の PSoC® 4 をプログラムする - KBA93541 - Community Translated (JA)
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
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:
- Download and install Python on your PC. Python is a free download available at https://www.python.org/download/. This project is tested with Python 2.7.
- 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: https://pypi.python.org/pypi/pyserial.
Step 2a: Setup your CY8CKIT-049 (Skip to Step 2b if you have a CY8CKIT-049-42xx):
- Download and extract the .zip file provided with this article. (4 dollar programmer.zip)
- Extract the file PSoC 4 Firmware.zip to a folder.
- 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.
- 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\”.
- 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):
- Download and extract the .zip file given with this article. (4 dollar programmer.zip)
- Open the Bootloader Host tool from Start > Cypress > PSoC Creator 3.0 > Bootloader Host.
- 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
Figure 3. Test Setup
Step 4: Program the target:
Right-click on the file Python Programmer and open the Python script file using IDLE.
- Change the COM port number in the .py file to the COM port number of your USB-Serial device in CY8CKIT-049.
Type in the path of your source file for the target PSoC 4. Note that the path contains two backward slashes (\\) between folder names.
Press F5 or select Run Module from the Run menu to begin programming.
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.
Figure 8. Test Setup
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
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
|I||Verify Silicon ID|
|E||Erase All Flash|
|P||Program Flash Row||<Number>||Row Number|
|V||Verify Flash Row||<Number>||Row Number|
|R||Program Protection Settings|
|T||Verify Protection Settings|
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).