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

cross mob
lock attach
Attachments are accessible only for community members.
OmSa_4786791
Level 3
Level 3
25 sign-ins 10 replies posted 10 sign-ins

Hi,

I have a PSoC 4 MCU that I want to program using a Linux machine (raspberry pi, to be precise). Unfortunately, I couldn't figure out how to do it and would appreciate any help.

 

I have MiniProg3 and MiniProg4 available.

I can program the device from Windows using PSoC Programmer (3.29.0) without any issue with both programmers. However, this program does not have a Linux port, so I can't use it on Linux systems.

I tried to program the device with MiniProg4 and Cypress Programmer (still on Windows). Unfortunately, this fails when I try to connect to the device (log attached - as docx cause .txt or .log extensions didn't work).  I tried to do it because the programmer has an option to choose the platform of PSoC 4. Since PSoC 4 was not described as supported for the Cypress Programmer I assume that this is not working. It always fails when I try to connect to the device, regardless of the configuration I tried to connect to the processer with.

 

Should the Cypress Programmer be able to program PSoC 4 devices? If not, is there any other option to program the device using a Linux machine?

 

I understand that I can write my own software to program PSoC devices using the SWD protocol, but want to avoid doing this if possible.
Since I am running from a Raspberry Pi I am not able to run virtual machines to program the PSoC, so unfortunately this is not an option as well.

 

Any help will be greatly appreciated.

With Kind Regards,
Omri

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
OmSa_4786791
Level 3
Level 3
25 sign-ins 10 replies posted 10 sign-ins

After quite a lot of work, I found a work-around for this issue.
This in no way solves the issue of being unable to program the device from Cypress Programmer, but let me program the device from a raspberry pi, which is what I wanted.

Programming PSoC4 Using OpenOCD

As @Renate suggested, I tried to program the device from the OpenOCD provided with the Cypress Programmer.

First, this resulted in the same issues - the device could not be acquired ("Error: kitprog3: failed to acquire the device").
To fix this issue (or more precisely, to ignore it), I disabled the acquiring stage of the programming. This was done by setting the PSOC4_USE_ACQUIRE option to 0. This worked for programming the device.
The command line looked like this:
openocd -s ..\scripts -c "set PSOC4_USE_ACQUIRE 0; source [find interface/kitprog3.cfg]; source [find target/psoc4.cfg]; program <path_to_file> verify exit"
I run this command from the OpenOCD bin directory from Cypress Programmer (c:\Program Files (x86)\Cypress\Cypress Programmer 4.0\openocd\bin\).
The path to the file needs to be escaped (E.g. // instead of /). The error message printed when it is not escaped can be hard to understand, as the name of the file is messed up in it.

I found the information I needed for the command line handling mainly in this document.

Programming From a Raspberry Pi

Making the programming work from the RPi wasn't super difficult, but required some work.
The OpenOCD used by the Cypress Programmer is a fork from the open-source OpenOCD, it is not the original one. Cypress' version can be found here. The fork is needed to use Cypress' scripts and configuration.

All the build releases of this project are only for x64 based systems, so they cannot run from the RPi. I cloned the repository on the RPi and build it again from sources.
To build the repository, I just run the script from build/build_all.sh. This script failed every time it had a missing library, which I then installed and run the script again (I was not organized enough to note down all the needed libraries, but finding the missing library from the different errors was quite straightforward).
The build file (32bit version of Cypress OpenOCD) is attached (for anyone wanting the same functionality), though I don't know if it is enough for it to work, and maybe a build from sources will be needed.

After I had Cyress OpenOCD working, I run the Linux version of the same command I run to program the device from Windows, which worked. Cypress scripts from Cypress Programmer are needed for correct communication with the PSoC device. The command was:
<path_to_build_openocd> -s ../scripts -c "set PSOC4_USE_ACQUIRE 0; source [find interface/kitprog3.cfg]; source [find target/psoc4.cfg]; program <path_to_hex_file> verify exit"
Again, this command ran from the bin directory in the Cypress Programmer directory tree, even though the OpenOCD used is not the one from this directory.

View solution in original post

7 Replies
Rakshith
Moderator
Moderator
Moderator
250 likes received 1000 replies posted 750 replies posted

Hi Omri, 

From the log, I see that the detected device is CY8C4147AZI-S443. Can you please confirm that this is the correct target MPN? Also, can you please let me know the version of Cypress Programmer that you are using?

Additionally, I do not think you will be able to use Cypress Programmer on a Raspberry Pi device as Cypress Programmer is supported only in these platforms - 

Rakshith_0-1633353407126.png

Thanks and Regards,
Rakshith M B

Hi Rakshith M B,

 

Thank you for your reply.

 

My MCU is indeed CY8C4147AZI-S443, as the programmer detects it.

I am using version 4.0.0 of Cypress Programmer:

OmSa_4786791_0-1633353844335.png

 

 

I assumed it will be working for Raspberry Pi because the Host OS in the programmer page says it can run on Linux systems. I did not think to look at the programmer release notes as well. Having it working in Ubuntu can still help me, even though it was not my original goal.

OmSa_4786791_1-1633354101540.png

 

With Kind Regards,
Omri

0 Likes

Hi Omri, 

From the logs, I see that the MiniProg4 device is in HID mode. Can you please try programming the device after changing it to BULK mode? Please use the Firmware-loader to change the mode. You can use the command - fw-loader.exe --mode kp3-bulk 

Also, can you please share a screenshot of the PSoC Programmer when you program the device?

Thanks and Regards,
Rakshith M B
lock attach
Attachments are accessible only for community members.

Hi Rakshith M B,

 

Thank you very much for your reply.

Unfortunately, changing the device to BULK mode does not resolve this issue.
As far as I can tell, the error stays the same. I am attaching a log of this as well.

 

The PSoC Programmer continues to program the device successfully in the BULK mode as well. A screenshot of this operation is attached:

psoc_programmer_screenshot.png

 

With Kind Regards,
Omri

0 Likes
Renate
Level 3
Level 3
25 replies posted 25 sign-ins 10 replies posted

OpenOCD should work with/without gdb.

https://openocd.org/pages/getting-openocd.html

There are interface scripts for KitProg & CMSIS-DAP. You could also use the Raspberry Pi directly.

0 Likes

Hi Renate,

Thank you very much for your reply.
I was hoping to use the commercial programmer instead of working with the underline openocd software, but I'll have a look at that as well.

 

With Kind Regards,
Omri

0 Likes
lock attach
Attachments are accessible only for community members.
OmSa_4786791
Level 3
Level 3
25 sign-ins 10 replies posted 10 sign-ins

After quite a lot of work, I found a work-around for this issue.
This in no way solves the issue of being unable to program the device from Cypress Programmer, but let me program the device from a raspberry pi, which is what I wanted.

Programming PSoC4 Using OpenOCD

As @Renate suggested, I tried to program the device from the OpenOCD provided with the Cypress Programmer.

First, this resulted in the same issues - the device could not be acquired ("Error: kitprog3: failed to acquire the device").
To fix this issue (or more precisely, to ignore it), I disabled the acquiring stage of the programming. This was done by setting the PSOC4_USE_ACQUIRE option to 0. This worked for programming the device.
The command line looked like this:
openocd -s ..\scripts -c "set PSOC4_USE_ACQUIRE 0; source [find interface/kitprog3.cfg]; source [find target/psoc4.cfg]; program <path_to_file> verify exit"
I run this command from the OpenOCD bin directory from Cypress Programmer (c:\Program Files (x86)\Cypress\Cypress Programmer 4.0\openocd\bin\).
The path to the file needs to be escaped (E.g. // instead of /). The error message printed when it is not escaped can be hard to understand, as the name of the file is messed up in it.

I found the information I needed for the command line handling mainly in this document.

Programming From a Raspberry Pi

Making the programming work from the RPi wasn't super difficult, but required some work.
The OpenOCD used by the Cypress Programmer is a fork from the open-source OpenOCD, it is not the original one. Cypress' version can be found here. The fork is needed to use Cypress' scripts and configuration.

All the build releases of this project are only for x64 based systems, so they cannot run from the RPi. I cloned the repository on the RPi and build it again from sources.
To build the repository, I just run the script from build/build_all.sh. This script failed every time it had a missing library, which I then installed and run the script again (I was not organized enough to note down all the needed libraries, but finding the missing library from the different errors was quite straightforward).
The build file (32bit version of Cypress OpenOCD) is attached (for anyone wanting the same functionality), though I don't know if it is enough for it to work, and maybe a build from sources will be needed.

After I had Cyress OpenOCD working, I run the Linux version of the same command I run to program the device from Windows, which worked. Cypress scripts from Cypress Programmer are needed for correct communication with the PSoC device. The command was:
<path_to_build_openocd> -s ../scripts -c "set PSOC4_USE_ACQUIRE 0; source [find interface/kitprog3.cfg]; source [find target/psoc4.cfg]; program <path_to_hex_file> verify exit"
Again, this command ran from the bin directory in the Cypress Programmer directory tree, even though the OpenOCD used is not the one from this directory.