Configure and build the application
Right-click on the
mtb-example-psoc6-hello-world
directory in the µVision Project view, and select
Options for Target '<application-name>' …
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.
Select the
Debug
tab, and select KitProg3 CMSIS-DAP as an active debug adapter:
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.
Select
Project > Build target
.
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:
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.
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
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
Copy the edited command.
In µVision, select
Project > Options for Target 'Target 1'…
to open the Options dialog.
Select the
User
tab and enable the
Run #1
check box under
After Build/Rebuild
. Then, paste the edited command.
Select the
Output
tab and enable the
Create HEX File
check box.
On the same
Output
tab, add an ".elf" extension in the
Name of Executable
field.
Create an empty
project.ini
file in the project root folder.
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.
Type
LOAD $L@L.hex
in the
project.ini
file and save the file.
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:
Create a
postbuild.bat
file in the root directory of the project.
Add
SET PATH=%PATH%;"/usr/bin"
at the start of the file.
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.
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;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"Save the
postbuild.bat
file.
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:
Select the
Output
tab and add a ".elf" extension to the file in the
Name of Executable
field:
Create empty
project.ini
and
project_2.ini
files in the project root folder.
Select the
Utilities
tab, select the
project.ini
file in the
Init File
field, click the
Edit
button, and click
OK
:
Add the following text to the
project.ini file
and click
Save
:
LOAD $L@L.final.hex
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.
Select the
project_2.ini
file in the
Initialization File
field, click the
Edit
button, and click
OK
:
Add the following text to the
project_2.ini
file and click
Save
.
LOAD $L@L.elf NOCODE
g, mainSelect
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:
Create a
postbuild.bat
file in the root directory of the project.
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
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:
Select the
Output
tab and add a ".elf" extension to the file in the
Name of Executable
field.
Create empty
project.ini
and
project2.ini
files in the project root folder.
Select the
Utilities
tab, select the
project.ini
file in the
Init File
field, click the
Edit
button, and click
OK
:
Add the following text to the
project.ini
file and click
Save
:
LOAD $L@L.hex
Reopen the Options for Target dialog and select the
Debug
tab. Make sure that the
Load Application at Startup
check box is not checked.
Select the
project2.ini
file in the
Initialization File
field, click the
Edit
button, and click
OK
:
Add the following text to the
project2.ini
file and click
Save
.
LOAD $L@L.elf NOCODE
g, mainSelect
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.