1 Reply Latest reply on Dec 18, 2019 5:00 AM by DheerajK_81

    Erasing and Programming PSoC 6 via CLI and Cypress Programmer

    JoGr_3160431

      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

        • 1. Re: Erasing and Programming PSoC 6 via CLI and Cypress Programmer
          DheerajK_81

          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

          1 of 1 people found this helpful