Erasing and Programming PSoC 6 via CLI and Cypress Programmer

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

cross mob
JoGr_3160431
Level 1
Level 1
5 replies posted 5 questions asked First question asked

Hello,

I have a handful of questions related to using tools other than the IDE (for us, ModusToolbox 1.1) to program PSoC 6 devices via a MiniProg 4.

1) When you build the project what is the correct .elf file/output to use as the input to either OpenOCD or the Cypress Programmer program? I use PROJECT_NAME_mainapp_signed.elf in the Debug folder of the ModusToolbox project directory . This sometimes works, but not always. 

2) What is the correct CLI argument for programming a PSoC? I currently use the following command:

"{OPENOCD_BIN} -s {OPENOCD_SCRIPTS_DIR} -c \"interface kitprog3; cmsis_dap_serial {PSOC_PROGRAMMER_SN}; transport select swd; adapter_khz 1500\" -f target/psoc6.cfg -c \"init; reset init; program {PSOC_FILE} verify reset; exit\"

Where OPENOCD_BIN, OPENOCD_SCRIPTS_DIR, PSOC_PROGRAMMER_SN, and PSOC_FILE are replaced with their correct equivalents.

3) If I use the Cypress Programmer GUI tools, there are options to erase, program, read, and verify. If I erase a PSoC and then program it with an .elf file, it doesn't seem to program (LED pins and UARTs never come alive). However, if I erase using Cypress Programmer and then program using the ModusToolbox IDE with the project that created the .elf file, the box does work. What does the IDE do that Cypress Programmer program does not do?

Thanks,

Josh

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

1) When you build the project what is the correct .elf file/output to use as the input to either OpenOCD or the Cypress Programmer program? I use PROJECT_NAME_mainapp_signed.elf in the Debug folder of the ModusToolbox project directory . This sometimes works, but not always.

OpenOCD or Cypress Programmer 2.1.0 can accept .elf, .srec, .bin or the .hex files as input for programming. When you build your application in ModusToolbox 1.1, there are three types of .elf files generated namely <app_name>.elf, <app_name>_signed.elf and <app_name>_final.elf. Please have a look at "cymcuelftool_postbuild.bash" located in the path "C:/ModusToolbox_1.1/libraries/psoc6sw-1.1/makefiles/platforms/PSoC6_cm4_dual/" to understand what these files mean. I would suggest using the <app_name>_final.elf because it is generated after merging the signed elf files of CM0p and CM4 application.

2) What is the correct CLI argument for programming a PSoC? I currently use the following command:

"{OPENOCD_BIN} -s {OPENOCD_SCRIPTS_DIR} -c \"interface kitprog3; cmsis_dap_serial {PSOC_PROGRAMMER_SN}; transport select swd; adapter_khz 1500\" -f target/psoc6.cfg -c \"init; reset init; program {PSOC_FILE} verify reset; exit\"

Use the following command:

openocd -s {OPENOCD_SCRIPTS_DIR} -f interface/kitprog3.cfg -f target/psoc6.cfg -c "cmsis_dap_serial <serial_number>" -c "program "D:/<app_name>.hex" verify exit"

If you want the program to run after programming you can add "reset run" at the end as shown below:

openocd -s {OPENOCD_SCRIPTS_DIR} -f interface/kitprog3.cfg -f target/psoc6.cfg -c "cmsis_dap_serial <serial_number>" -c "program "D:/<app_name>.hex" verify" -c "reset run; shutdown"

If I use the Cypress Programmer GUI tools, there are options to erase, program, read, and verify. If I erase a PSoC and then program it with an .elf file, it doesn't seem to program (LED pins and UARTs never come alive). However, if I erase using Cypress Programmer and then program using the ModusToolbox IDE with the project that created the .elf file, the box does work. What does the IDE do that Cypress Programmer program does not do?

ModusToolbox internally uses the Cypress Programmer itself to program and it uses the <app_name>.final.elf file. So, the behaviour in Modus and Cypress Programmer will be the same if the inputs are the same.

Hope this answers your query!

Regards,

Dheeraj

View solution in original post

1 Reply
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

1) When you build the project what is the correct .elf file/output to use as the input to either OpenOCD or the Cypress Programmer program? I use PROJECT_NAME_mainapp_signed.elf in the Debug folder of the ModusToolbox project directory . This sometimes works, but not always.

OpenOCD or Cypress Programmer 2.1.0 can accept .elf, .srec, .bin or the .hex files as input for programming. When you build your application in ModusToolbox 1.1, there are three types of .elf files generated namely <app_name>.elf, <app_name>_signed.elf and <app_name>_final.elf. Please have a look at "cymcuelftool_postbuild.bash" located in the path "C:/ModusToolbox_1.1/libraries/psoc6sw-1.1/makefiles/platforms/PSoC6_cm4_dual/" to understand what these files mean. I would suggest using the <app_name>_final.elf because it is generated after merging the signed elf files of CM0p and CM4 application.

2) What is the correct CLI argument for programming a PSoC? I currently use the following command:

"{OPENOCD_BIN} -s {OPENOCD_SCRIPTS_DIR} -c \"interface kitprog3; cmsis_dap_serial {PSOC_PROGRAMMER_SN}; transport select swd; adapter_khz 1500\" -f target/psoc6.cfg -c \"init; reset init; program {PSOC_FILE} verify reset; exit\"

Use the following command:

openocd -s {OPENOCD_SCRIPTS_DIR} -f interface/kitprog3.cfg -f target/psoc6.cfg -c "cmsis_dap_serial <serial_number>" -c "program "D:/<app_name>.hex" verify exit"

If you want the program to run after programming you can add "reset run" at the end as shown below:

openocd -s {OPENOCD_SCRIPTS_DIR} -f interface/kitprog3.cfg -f target/psoc6.cfg -c "cmsis_dap_serial <serial_number>" -c "program "D:/<app_name>.hex" verify" -c "reset run; shutdown"

If I use the Cypress Programmer GUI tools, there are options to erase, program, read, and verify. If I erase a PSoC and then program it with an .elf file, it doesn't seem to program (LED pins and UARTs never come alive). However, if I erase using Cypress Programmer and then program using the ModusToolbox IDE with the project that created the .elf file, the box does work. What does the IDE do that Cypress Programmer program does not do?

ModusToolbox internally uses the Cypress Programmer itself to program and it uses the <app_name>.final.elf file. So, the behaviour in Modus and Cypress Programmer will be the same if the inputs are the same.

Hope this answers your query!

Regards,

Dheeraj