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:
Step 2a: Setup your CY8CKIT-049 (Skip to Step 2b if you have a CY8CKIT-049-42xx):
Step 2b: Setup your CY8CKIT-049 (Skip to Step 3 if you followed Step 2a):
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.
Figure 4. Context Menu Showing Option to Edit with IDLE
Figure 5. Location in Python Script to Edit COM Port Number
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.
Figure 7. Run Module Option in Run Menu of IDLE
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:
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).