SWD programming using python - can I speed it up?

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

cross mob
ViRa_1964436
Level 2
Level 2
First like received First like given Welcome!

I am  looking to speed up SWD programming of PSOC4 (we are programming using Cypress python example code).

  • We are using the python example code from PSOC programmer examples (from C:\Program Files (x86)\Cypress\Programmer\Examples\Programming\PSoC4\SWD\Python_Ex).
  • It takes around approx. 15 seconds to run this program, per device
    • 13.5 seconds of this is Execute(), in the attached file
    • This is then split into approx. 10 seconds for ProgramFlash() and 3.5 seconds for PSOC4_VerifyFlash().

Any ways to speed these up?

Thanks in advance!

Regards,

Vishnu

0 Likes
1 Solution
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello Vishnu,

Here are a couple of things you can use to increase the speed of programming:

(1) In the InitializePort function, you can increase SWD Clock frequency in the pp.SetProtocolClock(enumFrequencies.FREQ_03_0). By default it is set to 3MHz. For list of frequencies, refer to the PPCOM.py file where all the enumerations are listed.

Note that the frequency should be less than one third of the bus-clock at which the PSoC operates.

(2) In the ProgramAll function, you can remove the verification related functions if you are confident that the hex file is targeted at the correct device, if you chip protection is set to normal. etc. These functions are:HEX_ReadChipProtection(), CheckHexAndDeviceCompatibility(), PSoC4_VerifyFlash(), PSoC4_VerifyProtect(), HEX_ReadChecksum(), PSoC4_CheckSum()

Let me know your observations after making these changes. Hope this helps

Regards,

Dheeraj

View solution in original post

4 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Hello Vishnu,

Here are a couple of things you can use to increase the speed of programming:

(1) In the InitializePort function, you can increase SWD Clock frequency in the pp.SetProtocolClock(enumFrequencies.FREQ_03_0). By default it is set to 3MHz. For list of frequencies, refer to the PPCOM.py file where all the enumerations are listed.

Note that the frequency should be less than one third of the bus-clock at which the PSoC operates.

(2) In the ProgramAll function, you can remove the verification related functions if you are confident that the hex file is targeted at the correct device, if you chip protection is set to normal. etc. These functions are:HEX_ReadChipProtection(), CheckHexAndDeviceCompatibility(), PSoC4_VerifyFlash(), PSoC4_VerifyProtect(), HEX_ReadChecksum(), PSoC4_CheckSum()

Let me know your observations after making these changes. Hope this helps

Regards,

Dheeraj

Hi Dheeraj,

Thank you very much for your response.

After doing the changes you suggested in item #2, I can reduce the time from 15 secs to 11.5 seconds. The biggest impact was from commenting out PSoC4_VerifyFlash(). This accounted for almost all of the 3.5 second time reduction.

However, doing the change in #1 (that is, changing the SWD clock frequency) had no effect whatsoever.

This was very surprising for me, I was expecting a drastic reduction in flashing time if I increased the SWD clock frequency. Is this expectation of reduction in flashing time, a correct expectation?

- I am flashing the PSOC4 Analog Coprocessor. I have connected it to PC using kitprog.

- For 11.5 seconds flashing time, the SWD clock speed was set as follows: pp.SetProtocolClock(enumFrequencies.FREQ_03_0)

- I tried changing it to FREQ_06_0, FREQ_08_0. No change in flashing time, it still remained at 11.5 seconds

- What is the max supported SWD clock frequency on PSOC4 Analog Co processor?

Regards,

Vishnu

0 Likes

Hi ViRa_1964436​,

I tried programming PSoC Analog Processor using one of my hex files and the default Python_Ex.py script and I was able to program the device with programming time less than 5 seconds.

Can you please share your hex file and the script that you are using to program the device so that we can reproduce the issue at our end?

Thanks and Regards,

Rakshith M B

Thanks and Regards,
Rakshith M B
0 Likes

Thanks Rakshith,

Thanks for helping look into this.

Can you please let me know how to send you the file? I can email it to you. I do not want to post it here.

Regards,

Vishnu

0 Likes