Announcements

Help us improve the Power & Sensing Selection Guide. Share feedback

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

cross mob
wmaxfield
Level 4
Level 4
10 replies posted 10 likes received 5 questions asked

I can program the psoc5 using openocd now, with some caveats. However, if an NVL entry exists, it stops.

I have a project which somehow did something to the NVL.

I understand setting the Reset condition on the Pins can cause this.  However, setting the pins to Don't Care doesn't fix this problem, so I suspect something else is causing the NVL to change.

Is there *any* gui / command line interface to find out what is causing the NVL to be set? (so it can be "fixed" in the project?)

This would not normally be a problem, but using openocd to program the psoc halts when the NVL entry is in the Creator generated hex file.  I have multiple reasons for using openocd, some of which involve production machines. Others are very fast compile/debug cycle.  (https://socmaker.com/?p=1004, and https://socmaker.com/?p=1027)

If I use objcopy, could I exclude that from the elf file for the new obj?  (before making a hex file) If so, would it be by address? If so, which address?  otherwise, how would I do that exclusion?

Is there a way to use openocd to program the NVL (perhaps kitprog in kitprog mode?) (Just checking)

Thanks!

 

0 Likes
1 Solution
wmaxfield
Level 4
Level 4
10 replies posted 10 likes received 5 questions asked

 Ugh.  Finally answered my own question.

I own a legal Segger Jlink.  I found some psoc5 comments on their forum(s). That provided the key:

   https://forum.segger.com/index.php/Thread/4031-SOLVED-JLinkExe-flashing-PSoC-CY8C4247-gives-error/

   https://wiki.segger.com/Flashing_Infineon_PSoC_Creator_output_data_files_with_J-Flash

   If you are using command line, it can be automated.

  I used JFlash to delete from 0x8000 0000 to 0xffff ffff, operating on the hex file, then saved it to an output file (I added stripped to the end of the name).

  Then you can program with openocd, the NVL contents are stripped, along with some psoc6 information.

Notes:

  1) This method requires previously programming the psoc5lp with a small program to disable Flash protection and ECC.  Also, whatever settings you have in NVL are carried over to the new program if you use this method.

   2)  I used "blink" with modifications for Unprotecting flash, disabling ECC.   This serves as our board production test app.

   3)  You can, if you wish, write code to update the NVL on first boot to (possibly) enable flash protection.  ECC must be programmed by PSOC Programmer.  Be careful, and look at the volatile register information before programming the NVL, as it can only handle a few writes (maximum is 1000, minimum is 10, per Cypress comments.)

 

openocdPgm.sh contents:  (with this one, I was able to use the "adapter speed 1500" blended with the rest of the commands.  Not sure why.

-----

#!/bin/bash

$TOOLS_LOC/openocd/bin/openocd -s $TOOLS_LOC/openocd/scripts -f interface/kitprog3.cfg  -f target/psoc5lp.cfg -c "adapter speed 1500 ; init ; reset halt; program $1 reset exit"

-----

TOOLS_LOC is an environment variable on my Mac, OSX, pointing to the open ocd and its scripts that came with ModusToolbox 2.0

Command line invocation and result:

w$ ./openocdPgm.sh GammaRay-brd5V0B3-4-24-24-stripped.hex
Open On-Chip Debugger 0.10.0+dev-3.0.0.665 (2020-03-20-17:12)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
cortex_m reset_config sysresetreq
adapter speed: 1500 kHz
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : KitProg3: FW version: 2.40.1241
Info : KitProg3: Pipelined transfers enabled
Info : VTarget = 4.799 V
Info : clock speed 1500 kHz
Info : SWD DPIDR 0x2ba01477
Info : psoc5lp.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : psoc5lp.cpu: external reset detected
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000010 msp: 0x20008000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000010 msp: 0x20008000
** Programming Started **
auto erase enabled
wrote 262144 bytes from file GammaRay-brd5V0B3-4-24-24-stripped.hex in 8.224964s (31.125 KiB/s)
** Programming Finished **
** Resetting Target **
shutdown command invoked
w$


View solution in original post

0 Likes
3 Replies
LeoMathews
Moderator
Moderator
Moderator
First question asked 500 replies posted 100 solutions authored

Hi @wmaxfield 

You can utilize the PSoC3_ReadNvlArray API from PPCLI tool to read the NVL array from the acquired chip. Also NVL arrays can be read using PSoC programmer by reading the target flash.  Is your OpenOCD scripts working for PSoC5 working for hex files without NVL entry? Can you share the details of the configuration files used for programming the PSoC5 device using OpenOCD?

I'm afraid that excluding the NVL data may affect the integrity of hex file. Also please refer to PPCLI programming(suitable for production programming) for PSoC5 and check if it helps. Currently we do not provide OpenOCD configs to program PSoC5 or programming the NVL. But you can utilize the PSoC3_WriteNvlArray API to write the NVL data using PPCLI.

Thanks and Regards,
Leo

0 Likes

 Is your OpenOCD scripts working for PSoC5 working for hex files without NVL entry?

YES

 

Can you share the details of the configuration files used for programming the PSoC5 device using OpenOCD?

$TOOLS_LOC/openocd/bin/openocd -s $TOOLS_LOC/openocd/scripts -f interface/kitprog3.cfg -f target/psoc5lp.cfg -c " adapter speed 1500 " -c " init ; reset halt; program test.hex reset exit"

 

After much trial and error, that worked on the mac, using ModusToolbox 2.0 and its tools_2.0 directory, on a KitProg3 with latest firmware. Not tried with later versions of Modus Toolbox.  The file being programmed is test.hex.  Currently working on Monterrey 12.7.4

Notes:

1) The -c "adapter speed 1500" by itself on the line is critical.  Without it, the programming fails. If you attempt to blend it like this: -c "adapter speed 1500 ; init ; reset halt;.....", then it will fail.

2) The "init; reset halt;" are also critical. Weird error messages will result if not used. 

3) If the NVL latch changes are not in the hex file, then the programming works, with some complaints about flash not found, if using the PSOC Creator hex file generator.

4)  The -s parameter sets the base script directory to start looking for config files.

5)  You must first remove ECC and Flash Protection using Psoc Programmer. We have a "blink led" file that does this for us during initial production test.

6) If you are on OSX Catalina or higher, you FIRST have to run each of the arm executables by double clicking using Finder GUI. (running from command line does not give you the option to allow execution. It just silently fails.)  Then tell OSX that it can run those unsigned executables anyway.  (But first use the spctl command described at https://osxdaily.com/2016/09/27/allow-apps-from-anywhere-macos-gatekeeper/   )

sudo spctl --master-disable 

(then reboot)

 

History:

rolf Nooteboom at OneThinx posted a year or so back on these forums about using VSCode to debug psoc5lp.  I took his work and further developed it, to work with the CY8cKit-059 as delivered to the consumer, using the on-board kitprog.

The result of my trials start at https://socmaker.com/?p=1004  You need to read that post and several following posts to get the full results.  I currently compile and debug on a iMac with I9, full compiles for code are less than 5 seconds (using a fusion drive), and debug is very fast using kitProg3.  With KitProg3, you also get a serial port you can use to talk to the target while debugging; it allows one debugger stub for serial/debug.

Even so, to use this, you still go to a VM and use PSOC Creator to generate the API's and fabric for the schematic .cysh components.  The OneThinx PostBuild command takes the API's library (a .a file) and makes them available to the VSCode on my Mac (using VMWare shared directories).   Takes several minutes.

I'm afraid that excluding the NVL data may affect the integrity of hex file.

Hmm.   After the blink hex is loaded, the NVL does not need to be changed.  The CyElfTool that NooteBoom uses (which was provided by Cypress) does not make the NVL part of the ELF to Hex conversion, and that result is used to program the PSOC5LP during development/debug cycles.

I'm trying to strip the NVL from the "official" elf file before turning into hex, probably using the Arm provided objcopy.  (After setting my NVL using the Blink file as a default test after board build)  I was unclear about that.

Also please refer to PPCLI programming(suitable for production programming) for PSoC5 and check if it helps.

Thanks! I had a passing knowledge of PPCLI.  I will have to look at it closer.  I did not know it could use API's specified from the command line.

I am trying to move to a production stance where I don't have to worry about windows vulnerabilities.  Plus keep using older machines.  This is probably a futile exercise, since I*n is not actively supporting P*5LP, but I suspect there are enough open source people here to make it work. It is  *so* close!

Currently we do not provide OpenOCD configs to program PSoC5 or programming the NVL. But you can utilize the PSoC3_WriteNvlArray API to write the NVL data using PPCLI.

Thanks again!  I have *most* of the default settings for PSOC5 NVL from the family datasheet.  The default clock phase delay is the only one not specified on page 20 of the CY8C58LP Family Datasheet.  Ugh.  Just one little step.

So, you are saying the PSOC3 api will work on the PSOC5LP?  Interesting.

Thank you for your answer!


 

0 Likes
wmaxfield
Level 4
Level 4
10 replies posted 10 likes received 5 questions asked

 Ugh.  Finally answered my own question.

I own a legal Segger Jlink.  I found some psoc5 comments on their forum(s). That provided the key:

   https://forum.segger.com/index.php/Thread/4031-SOLVED-JLinkExe-flashing-PSoC-CY8C4247-gives-error/

   https://wiki.segger.com/Flashing_Infineon_PSoC_Creator_output_data_files_with_J-Flash

   If you are using command line, it can be automated.

  I used JFlash to delete from 0x8000 0000 to 0xffff ffff, operating on the hex file, then saved it to an output file (I added stripped to the end of the name).

  Then you can program with openocd, the NVL contents are stripped, along with some psoc6 information.

Notes:

  1) This method requires previously programming the psoc5lp with a small program to disable Flash protection and ECC.  Also, whatever settings you have in NVL are carried over to the new program if you use this method.

   2)  I used "blink" with modifications for Unprotecting flash, disabling ECC.   This serves as our board production test app.

   3)  You can, if you wish, write code to update the NVL on first boot to (possibly) enable flash protection.  ECC must be programmed by PSOC Programmer.  Be careful, and look at the volatile register information before programming the NVL, as it can only handle a few writes (maximum is 1000, minimum is 10, per Cypress comments.)

 

openocdPgm.sh contents:  (with this one, I was able to use the "adapter speed 1500" blended with the rest of the commands.  Not sure why.

-----

#!/bin/bash

$TOOLS_LOC/openocd/bin/openocd -s $TOOLS_LOC/openocd/scripts -f interface/kitprog3.cfg  -f target/psoc5lp.cfg -c "adapter speed 1500 ; init ; reset halt; program $1 reset exit"

-----

TOOLS_LOC is an environment variable on my Mac, OSX, pointing to the open ocd and its scripts that came with ModusToolbox 2.0

Command line invocation and result:

w$ ./openocdPgm.sh GammaRay-brd5V0B3-4-24-24-stripped.hex
Open On-Chip Debugger 0.10.0+dev-3.0.0.665 (2020-03-20-17:12)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
Info : auto-selecting first available session transport "swd". To override use 'transport select <transport>'.
cortex_m reset_config sysresetreq
adapter speed: 1500 kHz
Info : CMSIS-DAP: SWD  Supported
Info : CMSIS-DAP: FW Version = 2.0.0
Info : CMSIS-DAP: Interface Initialised (SWD)
Info : SWCLK/TCK = 1 SWDIO/TMS = 1 TDI = 0 TDO = 0 nTRST = 0 nRESET = 1
Info : CMSIS-DAP: Interface ready
Info : KitProg3: FW version: 2.40.1241
Info : KitProg3: Pipelined transfers enabled
Info : VTarget = 4.799 V
Info : clock speed 1500 kHz
Info : SWD DPIDR 0x2ba01477
Info : psoc5lp.cpu: hardware has 6 breakpoints, 4 watchpoints
Info : psoc5lp.cpu: external reset detected
Info : Listening on port 3333 for gdb connections
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000010 msp: 0x20008000
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x00000010 msp: 0x20008000
** Programming Started **
auto erase enabled
wrote 262144 bytes from file GammaRay-brd5V0B3-4-24-24-stripped.hex in 8.224964s (31.125 KiB/s)
** Programming Finished **
** Resetting Target **
shutdown command invoked
w$


0 Likes