Write Data in PSoC 4 User Flash Section through CLI - KBA218846

Version: **

 

Question:

How can I write my data into the User Flash section of PSoC 4 through the Command-Line Interface (CLI)?

 

Answer:

Using CLI, you can write customized data into specified rows in the User Flash section (0x00000000~0x00007FFF) of the PSoC 4 internal memory space. The data can be customized with a unique ID, specific flag, and so on. The PSoC Programmer Command-Line Interface (CLI) Guide introduces all APIs to complete the operation.

 

The programming operation requires a hardware connection as shown in the following screenshot:

 

KBA218846.png

To host the target device in software, the command-line window should be called first. The commandline window is located at Start > Search program and Files > Input “cmd”. Right-click cmd.exe and run it as an administrator. Then, you can use the following scripts to write data into specified rows in the User Flash section (here, we use CY8CKIT-042 as an example):

 

[C:\Windons\system32]>cd C:\Program Files (x86)\Cypress\Programmer /* Opens the location where PSoC Programmer installed. */

 

[C:\Program Files (x86)\Cypress\Programmer]>ppcli.exe /* Opens the interface of PSoC Programmer CLI command-line. */

 

>OpenPort KitProg/100F143503274400 . /* Opens port to toggle the target device. Please use correct port name as per you are using and don’t miss “ .” at the end. */

 

>SetProtocol 8 /* Chooses correct communication protocol; “8” means SWD protocol. */

 

[>SetProtocolConnector 1] /* This step can be ignored if using KitProg; “0” means 5-pin connector, “1” means 10-pin connector. If you are using MiniProg3, please set it according to actual hardware connection. */

 

>SetPowerVoltage 5.0 /* Sets Voltage of Supply; “5.0” means 5.0 volt. */

 

>DAP_Acquire /* Toggles the target device. */

 

>PowerOn /* Applies power to the VDD pin of the target device. */

 

>PSoC4_WriteRow 0x60 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 0x05 0x06 0x07 0x08 0x09 0x0A 0x01 0x02 0x03 0x04 /* Write one row data at Row#0x60. The absolute starting address should equal to Row# * RowSize; For PSoC4 series, RowSize is always 0x80. In this case, the absolute starting address is 0x00003000. */

 

>PSoC4_ReadRow 0x60 /* Reads back to check if the data has been written correctly. */

 

>PowerOff /* Tells the programmer to stop powering the device. */

 

>ClosePort /* Closes Port.*/

 

>quit /* Quits from ppcli.exe. */

 

If the program runs successfully, the result will be as shown in the following screenshot:

 

KBA218846_1.png

Note that, after writing successfully, original checksum will be ‘Not Valid’. Therefore, this example is not applicapable to projects that require you to periodically recheck the checksum before and after writing the data.

 

There will be some minor changes when it ports to FM0, PSoC 1, PSoC 3, and PSoC 5LP. PSoC Programmer has provided Perl scripts for similar solutions on PSoC 1, PSoC 3, and PSoC 5LP. The latest PSoC Programmer Command-Line Interface (CLI) Guide has enhanced APIs for FM0. Refer to examples and documents in PSoC Programmer for a similar solution on FM0, PSoC 1, PSoC 3, and PSoC 5LP. Contact Cypress Sales or Technical Support for more information.