1. Right-click on the

    mtb-example-psoc6-hello-world

    directory in the µVision Project view, and select

    Options for Target '<application-name>' …


    ../figures/image12.png

  2. On the dialog, select the

    C/C++ (AC6)

    tab.

    • Check that the Language C version was automatically set to c99.

    • Select "AC5-like warnings" in the Warnings drop-down list.

    • Select "-Os balanced" in the Optimization drop-down list.

    • To reduce memory usage, select the One ELF Section per Function check box.


    ../figures/image13.png

  3. Select the

    Debug

    tab, and select KitProg3 CMSIS-DAP as an active debug adapter:


    ../figures/image14.png

  4. Click

    OK

    to close the Options dialog.

    Note:

    For applications using the

    PSOC™ 64 application configuration

    ,

    AIROC™ CYW20829 device configuration

    , or

    PSOC™ Control C3 device configuration

    skip the next step. Instead, perform the steps outlined in the applicable section.

  5. Select

    Project > Build target

    .


    ../figures/image15.png

  6. To suppress the linker warnings about unused sections defined in the linker scripts, add "6314,6329" to the

    Disable Warnings

    setting in the Project Linker Options.

PSOC™ 64 application configuration

Before building an application for a PSOC™ 64 secure MCU in Keil µVision, you must perform the following configuration steps:

  1. Build the application using the ModusToolbox™

    make build

    command. You can do this by using a stand-alone terminal (modus-shell for Windows), or by exporting the application to Eclipse or VS Code and using the terminal in the IDE.

  2. Copy the post-build command from the log. For example:

    .../python.exe C:/UG/CY8CPROTO-064S1-SB_Secure_Blinky_LED_FreeRTOS_UG/bsps/TARGET_APP_CY8CPROTO-064S1-SB/psoc64_postbuild.py --core CM4 --secure-boot-stage single --policy policy_single_CM0_CM4 --target cyb06xx7 --toolchain-path C:/Infineon/Tools/ModusToolbox/tools_3.3/gcc --toolchain GCC_ARM --build-dir C:/UG/CY8CPROTO-064S1-SB_Secure_Blinky_LED_FreeRTOS_UG/build/APP_CY8CPROTO-064S1-SB/Debug --app-name mtb-example-psoc6-secure-blinkyled-freertos --cm0-app-path ../mtb_shared/cat1cm0p/release-v1.0.0/COMPONENT_CAT1A/COMPONENT_CM0P_SECURE --cm0-app-name psoc6_01_cm0p_secure

    Note:

    Python was removed from the tools package in version 3.2 and later. The path here is a suggestion. Refer to this KBA for more details:

    https://community.infineon.com/t5/Knowledge-Base-Articles/Using-Python-with-a-ModusToolbox-application/ta-p/709737

  3. Paste the command into an appropriate editor, and make the following edits:

    • Change

      --toolchain-path

      to the ARM toolchain; for example,

      C:/Keil_v5/ARM/ARMCLANG

    • Change

      --toolchain

      to ARM

    • Change

      --build-dir

      to Keil µVision build directory

    Example of command after edit:

    C:/Infineon/Tools/ModusToolbox/tools_3.3/python/python.exe C:/UG/CY8CPROTO-064S1-SB_Secure_Blinky_LED_FreeRTOS_UG/bsps/TARGET_APP_CY8CPROTO-064S1-SB/psoc64_postbuild.py --core CM4 --secure-boot-stage single --policy policy_single_CM0_CM4 --target cyb06xx7 --toolchain-path C:/Keil_v5/ARM/ARMCLANG --toolchain ARM --build-dir C:/UG/CY8CPROTO-064S1-SB_Secure_Blinky_LED_FreeRTOS_UG/mtb-example-psoc6-secure-blinkyled-freertos_Objects --app-name mtb-example-psoc6-secure-blinkyled-freertos --cm0-app-path ../mtb_shared/cat1cm0p/release-v1.0.0/COMPONENT_CAT1A/COMPONENT_CM0P_SECURE --cm0-app-name psoc6_01_cm0p_secure

  4. Copy the edited command.

  5. In µVision, select

    Project > Options for Target 'Target 1'…

    to open the Options dialog.

  6. Select the

    User

    tab and enable the

    Run #1

    check box under

    After Build/Rebuild

    . Then, paste the edited command.


    ../figures/image16.png

  7. Select the

    Output

    tab and enable the

    Create HEX File

    check box.


    ../figures/image17.png

  8. On the same

    Output

    tab, add an ".elf" extension in the

    Name of Executable

    field.


    ../figures/image18.png

  9. Create an empty

    project.ini

    file in the project root folder.

  10. On the Options dialog, select the

    Utilities

    tab and select the

    project.ini

    file using the [

    ] button. Then, click

    Edit

    to open the file and click

    OK

    to close the options dialog.


    ../figures/image19.png

  11. Type

    LOAD $L@L.hex

    in the

    project.ini

    file and save the file.


    ../figures/image20.png

  12. Select

    Project > Build Target

    to build the application and execute post-build commands.

After performing these steps, you should be able to run debug, erase, and program for PSOC™ 64 secure MCUs.

AIROC™ CYW20829 device configuration

Before building an application for an AIROC™ CYW20829 device in Keil µVision, you must perform the following configuration steps:

  1. Create a

    postbuild.bat

    file in the root directory of the project.

  2. Add

    SET PATH=%PATH%;"/usr/bin"

    at the start of the file.

  3. Build the application using the ModusToolbox™

    make build

    command. You can do this by using a stand-alone terminal (modus-shell for Windows), or by exporting the application to Eclipse or VS Code and using the terminal in the IDE.

  4. Copy the post-build command output from the log. For example:

    C:/Infineon/Tools/ModusToolbox/tools_3.3/gcc/bin/arm-none-eabi-objcopy -O ihex C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug/mtb-example-hal-hello-world.elf C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug/mtb-example-hal-hello-world.hex

    C:/Infineon/Tools/ModusToolbox/tools_3.3/gcc/bin/arm-none-eabi-objcopy C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug/mtb-example-hal-hello-world.elf -S -O binary C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug/mtb-example-hal-hello-world.bin;

    "C:/Infineon/Tools/ModusToolbox/tools_3.3/modus-shell/bin/bash.exe" --norc --noprofile ../mtb_shared/recipe-make-cat1b/release-v2.2.1/make/scripts/20829/flash_postbuild.sh "GCC_ARM" "C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug" "mtb-example-hal-hello-world" "C:/Infineon/Tools/ModusToolbox/tools_3.3/gcc/bin" "C:/Infineon/Tools/ModusToolbox/tools_3.3/srecord/bin/srec_cat.exe" "0x00002400"

    "C:/Infineon/Tools/ModusToolbox/tools_3.3/modus-shell/bin/bash.exe" --norc --noprofile ../mtb_shared/recipe-make-cat1b/release-v2.2.1/make/scripts/20829/run_toc2_generator.sh "NORMAL_NO_SECURE" "C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug" "mtb-example-hal-hello-world" "flash" "bsps/TARGET_APP_CYW920829M2EVK-02" "NONE" "C:/Infineon/Tools/ModusToolbox/tools_3.3/gcc" "" 0x20000 0 "" "0x00002400" "256"

    C:/Infineon/Tools/ModusToolbox/tools_3.3/srecord/bin/srec_cat.exe C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug/mtb-example-hal-hello-world.final.bin -Binary -offset 0x60000000 -o C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug/mtb-example-hal-hello-world.final.hex -Intel -Output_Block_Size=16

    rm -rf C:/20829_keil/Hello_World/build/APP_CYW920829M2EVK-02/Debug/mtb-example-hal-hello-world.bin;

  5. Paste the command into the

    postbuild.bat

    file and make changes to the file to match the Keil µVision structure (changing paths to .elf and .hex files, etc.):

    Example of file after edit:

    SET PATH=%PATH%;"/usr/bin"

    "C:/Keil_v5/ARM/ARMCLANG/bin/fromelf" C:/20829_keil/Hello_World/mtb-example-hal-hello-world_Objects/mtb-example-hal-hello-world.elf --bin --output=C:/20829_keil/Hello_World/mtb-example-hal-hello-world_Objects/mtb-example-hal-hello-world.bin

    "C:/Infineon/Tools/ModusToolbox/tools_3.3/modus-shell/bin/bash.exe" --norc --noprofile ../mtb_shared/recipe-make-cat1b/release-v2.2.1/make/scripts/20829/flash_postbuild.sh "ARM" "C:/20829_keil/Hello_World/mtb-example-hal-hello-world_Objects" "mtb-example-hal-hello-world" "C:/Infineon/Tools/ModusToolbox/tools_3.3/gcc/bin" "C:/Infineon/Tools/ModusToolbox/tools_3.3/srecord/bin/srec_cat.exe" "0x00002400"

    "C:/Infineon/Tools/ModusToolbox/tools_3.3/modus-shell/bin/bash.exe" --norc --noprofile ../mtb_shared/recipe-make-cat1b/release-v2.2.1/make/scripts/20829/run_toc2_generator.sh "NORMAL_NO_SECURE" "C:/20829_keil/Hello_World/mtb-example-hal-hello-world_Objects" "mtb-example-hal-hello-world" "flash" "bsps/TARGET_APP_CYW920829M2EVK-02" "NONE" "C:/Infineon/Tools/ModusToolbox/tools_3.3/gcc" "" 0x20000 0 "" "0x00002400" "256"

    C:/Infineon/Tools/ModusToolbox/tools_3.3/srecord/bin/srec_cat.exe C:/20829_keil/Hello_World/mtb-example-hal-hello-world_Objects/mtb-example-hal-hello-world.final.bin -Binary -offset 0x60000000 -o C:/20829_keil/Hello_World/mtb-example-hal-hello-world_Objects/mtb-example-hal-hello-world.final.hex -Intel -Output_Block_Size=16

    del "C:\20829_keil\Hello_World\mtb-example-hal-hello-world_Objects\mtb-example-hal-hello-world.bin"

  6. Save the

    postbuild.bat

    file.

  7. Open the

    Project > Options for Target ‘Target 1’

    dialog, select the

    User

    tab, select the

    After build/Rebuild run #1

    check box, and select the

    postbuild.bat

    file:


    ../figures/image21.png

  8. Select the

    Output

    tab and add a ".elf" extension to the file in the

    Name of Executable

    field:


    ../figures/image22.png

  9. Create empty

    project.ini

    and

    project_2.ini

    files in the project root folder.

  10. Select the

    Utilities

    tab, select the

    project.ini

    file in the

    Init File

    field, click the

    Edit

    button, and click

    OK

    :


    ../figures/image23.png

  11. Add the following text to the

    project.ini file

    and click

    Save

    :

    LOAD $L@L.final.hex

    ../figures/image24.png

  12. Reopen the

    Project > Options for Target ‘Target 1’

    dialog and select the

    Debug

    tab. Make sure that the

    Load Application at Startup

    check box is not checked.

  13. Select the

    project_2.ini

    file in the

    Initialization File

    field, click the

    Edit

    button, and click

    OK

    :


    ../figures/image25.png

  14. Add the following text to the

    project_2.ini

    file and click

    Save

    .

    LOAD $L@L.elf NOCODE
    g, main

    ../figures/image26.png

  15. Select

    Project > Build Target

    to build the application and execute post-build commands.

After following these steps, you should be able to run Debug, Erase, and Program for the AIROC™ CYW20829 device.

PSOC™ Control C3 device configuration

For a PSOC™ Control C3 device, you must set the TrustZone

Software Model

option before building an application. Open the Options for Target dialog, select the

Target

tab, and choose the mode depending on your application type "Secure Mode" or "Non-Secure Mode."



If you select Secure Mode, the system will automatically add the required compiler and linker flags.



For non-secure projects, you must manually add the path of the generated import library to the linker flags. Select the

Linker

tab, and enter the object file generated by the secure project as a linker argument in

Misc Controls

.



Additionally, for a device in NORMAL_NO_SECURE LCS, image should be shifted by 0x2000 0000; for a device in Secure LCS, image should be signed with same key used during provisioning to Secure LCS using the ModusToolbox™ Edge Protect Security Suite. This can be configured by adding an additional post-build step to the default build flow.

To configure the application, do the following:

  1. Create a

    postbuild.bat

    file in the root directory of the project.

  2. Paste the command into the

    postbuild.bat file

    and make changes to the file to match the Keil µVision structure (changing paths to .elf and .hex files, etc.). For example:

    For NORMAL_NO_SECURE LCS devices:

    C:\Keil_v5\ARM\ARMCLANG\bin\fromelf --output "mtb-example-empty-app_Objects/tmp.hex" --i32combined "mtb-example-empty-app_Objects/mtb-example-empty-app.elf"
    C:\Infineon\Tools\ModusToolbox\tools_3.3\gcc\bin\arm-none-eabi-objcopy -O ihex "mtb-example-empty-app_Objects/tmp.hex" "mtb-example-empty-app_Objects/mtb-example-empty-app.hex" --change-addresses 0x20000000
    del "mtb-example-empty-app_Objects\tmp.hex"

    For SECURE LCS devices

    1

    :

    C:\Users\<username>\ModusToolbox-Edge-Protect-SecuritySuite-1.0\tools\edgeprotecttools\bin\edgeprotecttools sign-image --image "mtb-exampleempty-app_Objects/mtb-example-empty-app.hex" --output "mtb-example-empty-app_Objects/mtbexample-empty-app.hex" --header-size 0x400 --slot-size 0x20000 --key keys/ oem_rot_priv_key_0.pem --hex-addr 0x32000000 --align 1 --pad --security-counter 0 -erased-val 0 --publickey-format full --pubkey-encoding raw --signature-encoding raw --minerase-size 0x200 --overwrite-only
  3. On the Options for Target dialog, select the

    User

    tab, select the

    After Build/Rebuild Run #1

    check box, and select the

    postbuild.bat

    file:



  4. Select the

    Output

    tab and add a ".elf" extension to the file in the

    Name of Executable

    field.



  5. Create empty

    project.ini

    and

    project2.ini

    files in the project root folder.

  6. Select the

    Utilities

    tab, select the

    project.ini

    file in the

    Init File

    field, click the

    Edit

    button, and click

    OK

    :



  7. Add the following text to the

    project.ini

    file and click

    Save

    :

    LOAD $L@L.hex


  8. Reopen the Options for Target dialog and select the

    Debug

    tab. Make sure that the

    Load Application at Startup

    check box is not checked.

  9. Select the

    project2.ini

    file in the

    Initialization File

    field, click the

    Edit

    button, and click

    OK

    :



  10. Add the following text to the

    project2.ini

    file and click

    Save

    .

    LOAD $L@L.elf NOCODE
    g, main


  11. Select

    Project > Build Target

    to build the application and execute post-build commands.

    After following these steps, you should be able to run Debug, Erase, and Program for the PSOC™ Control C3 device.

1

This is an example, your actual sign-image command depends on your application.

1

This is an example, your actual sign-image command depends on your application.