MCUBoot with custom BSP - build problem

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

cross mob
PZbb
Level 2
Level 2
10 replies posted First solution authored 5 sign-ins

Hi,

I am trying to create a project based on the https://github.com/Infineon/mtb-example-psoc6-security/tree/release-v1.0.0  project. So far I used the CY8CPROTO-062-4343W evalboard and everything was fine. I was able to build a bootloader and application, upload it to the hardware, etc.

The problem arose when I wanted to do the same on a custom BSP. As per  https://www.infineon.com/dgdl/Infineon-ModusToolbox_2.4_User_Guide-UserManual-v01_00-EN.pdf?fileId=8... section 4.3 Creating your own BSP, I created a target using 'make bsp TARGET_GEN = myBSP DEVICE_GEN = CY8C6247FDI-D32' and went through all the steps.

In bootloader  https://github.com/Infineon/mtb-example-psoc6-security/blob/release-v1.0.0/bootloader_cm0p/source/ma... I changed references to "cybsp.h" and changed init_cycfg_all () to cybsp_init (), no problem with that.

There is a problem with the MCUBoot library. The build logs (at the bottom of the post) show that for some reason the file mtb_shared\mcuboot\v1.7.2-cypress\boot\cypress\libs\cy-mbedtls-acceleration\mbedtls_MXCRYPTO\crypto_common.h with the declaration of the type cy_en_crypto_ecc_curve_id_t is not included. The same is true for a few other files.

If I only change TARGET=CY8CPROTO-062-4343W then everything compiles and the bootloader works on the board.

Additional information is the fact that all files related to the bootloader folder itself along with main.c have been compiled, and the problem appears later while MCUBoot is compiling.

What might be missing from my setup?

Best regards,
PZbb


Compiling ext file swap_move.c
In file included from ../../mtb_shared/mcuboot/v1.7.2-cypress/ext/mbedtls/crypto/include/mbedtls/ecp.h:267,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/ext/mbedtls/crypto/include/mbedtls/pk.h:41,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/ext/mbedtls/crypto/include/mbedtls/oid.h:34,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/bootutil/src/image_ec256.c:40:
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/ecp_alt.h:175:1: error: unknown type name 'cy_en_crypto_ecc_curve_id_t'
175 | cy_en_crypto_ecc_curve_id_t cy_get_dp_idx(mbedtls_ecp_group_id gid);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [libs/core-make/make/core/build.mk:387: /user/project/bootloader_cm0p/build/myBSP/Custom/ext/mtb_shared/mcuboot/v1.7.2-cypress/boot/bootutil/src/image_ec256.o] Error 1
make[1]: *** Waiting for unfinished jobs....
In file included from ../../mtb_shared/mcuboot/v1.7.2-cypress/ext/mbedtls/crypto/include/mbedtls/ecp.h:267,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/crypto_common.h:36,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/sha256_alt.h:38,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/ext/mbedtls/crypto/include/mbedtls/sha256.h:69,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/bootutil/include/bootutil/crypto/sha256.h:29,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/bootutil/src/image_validate.c:36:
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/ecp_alt.h:175:1: error: unknown type name 'cy_en_crypto_ecc_curve_id_t'
175 | cy_en_crypto_ecc_curve_id_t cy_get_dp_idx(mbedtls_ecp_group_id gid);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/sha256_alt.h:38,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/ext/mbedtls/crypto/include/mbedtls/sha256.h:69,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/bootutil/include/bootutil/crypto/sha256.h:29,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/bootutil/src/image_validate.c:36:
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/crypto_common.h:112:43: error: unknown type name 'cy_stc_crypto_sha_state_t'
112 | int cy_hw_sha_start (cy_hw_crypto_t *obj, cy_stc_crypto_sha_state_t *hashState,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/crypto_common.h:113:22: error: unknown type name 'cy_en_crypto_sha_mode_t'
113 | cy_en_crypto_sha_mode_t shaMode, void *shaBuffers);
| ^~~~~~~~~~~~~~~~~~~~~~~
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/crypto_common.h:115:43: error: unknown type name 'cy_stc_crypto_sha_state_t'
115 | int cy_hw_sha_update(cy_hw_crypto_t *obj, cy_stc_crypto_sha_state_t *hashState,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/crypto_common.h:118:43: error: unknown type name 'cy_stc_crypto_sha_state_t'
118 | int cy_hw_sha_finish(cy_hw_crypto_t *obj, cy_stc_crypto_sha_state_t *hashState,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/crypto_common.h:122:22: error: unknown type name 'cy_stc_crypto_sha_state_t'
122 | cy_stc_crypto_sha_state_t *hashStateDst, void *shaBuffersDst);
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/crypto_common.h:124:44: error: unknown type name 'cy_stc_crypto_sha_state_t'
124 | int cy_hw_sha_process(cy_hw_crypto_t *obj, cy_stc_crypto_sha_state_t *hashState,
| ^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../mtb_shared/mcuboot/v1.7.2-cypress/ext/mbedtls/crypto/include/mbedtls/sha256.h:69,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/bootutil/include/bootutil/crypto/sha256.h:29,
from ../../mtb_shared/mcuboot/v1.7.2-cypress/boot/bootutil/src/image_validate.c:36:
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/sha256_alt.h:44:5: error: unknown type name 'cy_stc_crypto_sha_state_t'
44 | cy_stc_crypto_sha_state_t hashState; /* Structure used by CY Crypto Driver */
| ^~~~~~~~~~~~~~~~~~~~~~~~~
../../mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/cy-mbedtls-acceleration/mbedtls_MXCRYPTO/sha256_alt.h:48:5: error: unknown type name 'cy_stc_crypto_v2_sha256_buffers_t'
48 | cy_stc_crypto_v2_sha256_buffers_t shaBuffers; /* Structure used by CY Crypto Driver */
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 Likes
1 Solution
LeoMathews
Moderator
Moderator
Moderator
First question asked 500 replies posted 100 solutions authored

Hi @PZbb 

Please find that for the MPN CY8C6247FDI-D32 there is no crypto feature included as indicated in the provided catalog.

LeoMathews_0-1668668852121.png

Thanks and Regards,
Leo

 

View solution in original post

0 Likes
7 Replies
PZbb
Level 2
Level 2
10 replies posted First solution authored 5 sign-ins

Here is the exact difference of all compile parameters for the first file that crashed

left: original working example for CY8CPROTO-062-4343W
right: my custom BSP for CY8C6247FDI_D32

PZbb_0-1668085617213.png

From this i conclude that MCUBoot somehow depends on flags referencing CY8CPROTO-062-4343W

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

Hi @PZbb 

Can you please confirm whether there were any errors in the terminal after performing the custom BSP creation as per section 4.3 Creating your own BSP?

Thanks and Regards,
Leo

0 Likes
PZbb
Level 2
Level 2
10 replies posted First solution authored 5 sign-ins

Hello @LeoMathews,

I couldn't remember if there were any errors, so I went through the procedure again.
There are errors (logs at the bottom of the post) that I can successfully fix in Device Configurator. PZbb_0-1668401665999.png

After the fix the problem remains the same as in the original post. All files from the source/ folder compile, the problem arises only when the build reaches the MCUBoot files.

$ make bsp TARGET_GEN=myBSP DEVICE_GEN=CY8C6247FDI-D32
Tools Directory: C:/Infineon/Tools/ModusToolbox/tools_2.4
CY8CPROTO-062-4343W.mk: ./libs/TARGET_CY8CPROTO-062-4343W/CY8CPROTO-062-4343W.mk

Creating myBSP TARGET from CY8CPROTO-062-4343W...
Creating backup of old bsp linker scripts and startup files...
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM0P/TOOLCHAIN_ARM/cy8c6xxa_cm0plus.sct
.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM0P/TOOLCHAIN_ARM/startup_psoc6_02_cm0
plus.s.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM0P/TOOLCHAIN_A_Clang/startup_psoc6_02
_cm0plus.S.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM0P/TOOLCHAIN_GCC_ARM/cy8c6xxa_cm0plus
.ld.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM0P/TOOLCHAIN_GCC_ARM/startup_psoc6_02
_cm0plus.S.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM0P/TOOLCHAIN_IAR/cy8c6xxa_cm0plus.icf
.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM0P/TOOLCHAIN_IAR/startup_psoc6_02_cm0
plus.s.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM4/TOOLCHAIN_ARM/cy8c6xxa_cm4_dual.sct
.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM4/TOOLCHAIN_ARM/startup_psoc6_02_cm4.
s.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM4/TOOLCHAIN_A_Clang/cy8c6xxa_cm4_dual
.mk.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM4/TOOLCHAIN_A_Clang/startup_psoc6_02_
cm4.S.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM4/TOOLCHAIN_GCC_ARM/cy8c6xxa_cm4_dual
.ld.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM4/TOOLCHAIN_GCC_ARM/startup_psoc6_02_
cm4.S.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM4/TOOLCHAIN_IAR/cy8c6xxa_cm4_dual.icf
.bak
Creating backup file /cygdrive/c/temp/modus_workspace_test/project_test.bootloader_cm0p/TARGET_myBSP/./COMPONENT_CM4/TOOLCHAIN_IAR/startup_psoc6_02_cm4.
s.bak

Populating cy8c6xx7 linker scripts and psoc6_01 startup files...

Checking if remote manifest is accessible...
Getting manifests from remote server...
Processing super-manifest https://github.com/cypresssemiconductorco/mtb-super-manifest/raw/v2.X/mtb-super-manifest-fv2.xml...
One or more elements/attributes was ignored from manifest https://github.com/Infineon/mtb-mw-manifest/raw/v2.X/mtb-mw-manifest-fv2.xml. Run using the --verb
ose flag for additional details.
Successfully acquired the information.
INFO - Warning: Multiple versions of "core-make" requested. Keeping version "latest-v1.X" and discarding version "release-v1.9.0".
TARGET_myBSP/deps/capsense.mtbx was created.
TARGET_myBSP/deps/core-lib.mtbx was created.
TARGET_myBSP/deps/core-make.mtbx was created.
TARGET_myBSP/deps/mtb-hal-cat1.mtbx was created.
TARGET_myBSP/deps/mtb-pdl-cat1.mtbx was created.
TARGET_myBSP/deps/psoc6cm0p.mtbx was created.
TARGET_myBSP/deps/recipe-make-cat1a.mtbx was created.
Running device-configurator for CY8C6247FDI-D32...
Log file= "C:/Users/piozmu/AppData/Local/Temp/device-configurator-cli/device-configurator-cli-20221114.053036.733-22256.log"
Command line= "C:/Infineon/Tools/ModusToolbox/tools_2.4/device-configurator/device-configurator-cli.exe --library ./libs/mtb-pdl-cat1/devicesupport.xml ../.
./mtb_shared/mcuboot/v1.7.2-cypress/boot/cypress/libs/mtb-pdl-cat1/devicesupport.xml --build ./TARGET_myBSP/COMPONENT_BSP_DESIGN_MODUS/design.modus --set-de
vice=CY8C6247FDI-D32,CYW4343WKUBG"
ERROR: Generating code failed. Code generation errors:
- Errors exist in the project's configuration:
'ioss[0].port[8].pin[5]' does not exist on the device but has an instantiated personality, 'Pin-1.1'.
'ioss[0].port[8].pin[6]' does not exist on the device but has an instantiated personality, 'Pin-1.1'.
'ioss[0].port[8].pin[7]' does not exist on the device but has an instantiated personality, 'Pin-1.1'.
'srss[0].clock[0].pathmux[5]' does not exist on the device but has an instantiated personality, 'PATH_MUX-1.0'.

ERROR: Device-configuration failed for ./TARGET_myBSP/COMPONENT_BSP_DESIGN_MODUS/design.modus

==============================================================================
--ABORTING--
Script : ./libs/recipe-make-cat1a/make/scripts/run_bsp_device_configurator.bash
Bash path : C:/Infineon/Tools/ModusToolbox/tools_2.4/modus-shell/bin/bash
Bash version: 4.4.12(3)-release
Exit code : 1
Call stack : trap_exit main
myBSP TARGET created at ./TARGET_myBSP

Thanks, 
PZbb

0 Likes
PZbb
Level 2
Level 2
10 replies posted First solution authored 5 sign-ins

I got to the source of the problem. By adding #warning in MCUBoot sources I added a simple debug at the preprocessor level to see the order of including files.

According to the build error the problem started from ecp_alt.h

PZbb_5-1668409698903.png

so in the file I added a test to check if the MBEDTLS_ECP_ALT flag is defined

PZbb_2-1668409329435.png

here is the result confirming the flag is defined

PZbb_6-1668409843995.png

in MCUBoot there are two files cy_crypto_core_ecc.h so I added test to each of them respectively

PZbb_3-1668409452954.png

and

PZbb_4-1668409515287.png

but during compilation, none of them are included, and as a result, later the type cy_en_crypto_ecc_curve_id_t is not understood, because it is declared inside cy_crypto_common.h

I hope this will help you to find a solution more easily

0 Likes
PZbb
Level 2
Level 2
10 replies posted First solution authored 5 sign-ins

I managed to get to the files describing both microcontrollers.

For the previous microcontroller CY8C624ABZI_S2D44 there is a declaration of CY_IP_MXCRYPTO and so on.

PZbb_1-1668424058711.png

There are no such declarations for CY8C6247FDI_D32.

PZbb_2-1668424098790.png

When I manually added the flags to the makefile, the problem disappeared and another one appeared due to the lack of CRYPTO periph declaration.

PZbb_4-1668424284773.pngPZbb_3-1668424119479.png

Is this a bug in the PDL or am I using the wrong version?

In the catalog note https://www.infineon.com/dgdl/Infineon-PSoC_6_MCU_CY8C62x6_CY8C62x7-DataSheet-v14_00-EN.pdf?fileId=8... I see information that such a module is available.

Best regards,
PZbb

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

Hi @PZbb 

Please find that for the MPN CY8C6247FDI-D32 there is no crypto feature included as indicated in the provided catalog.

LeoMathews_0-1668668852121.png

Thanks and Regards,
Leo

 

0 Likes

Thank You Leo, that was the reason of the problem 🙂

0 Likes