cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 6 MCU

Contributor II

I want to compile the secure image project in Keil instead of PSoC Creator.  I followed the regular instructions for exporting a Keil project and changed the post compile batch files to sign the images but the resulting image does not run the app.  Are there instructions for making a secure project in Keil?  I only want to compile the user app in Keil.  The secure image can be compiled in PSoC Creator if it is easier to do.

0 Likes
Reply
1 Solution
Moderator
Moderator

If you want to use Flash Write and the Secure Image, you need to add a #define in the user app0 compilation: DCY_FLASH_RWW_DRV_SUPPORT_DISABLED

This is because the syscall handler in the secure image does not support non-blocking writes.

Regards,

Dheeraj

View solution in original post

0 Likes
Reply
5 Replies
Moderator
Moderator

Can you elaborate more on what error you are seeing so that I help debug your issue?

Regards,

Dheeraj

0 Likes
Reply
Contributor II

The CM0/CM4 user app does not run after I program the image with PSoC Programmer.  I removed all the flash/crypto tests and just kept the LED flashing.  To create the image, I merged the CM0 and CM4 user apps, signed it with the private key, then merged it with the secure image elf compiled with PSoC Creator.  I replaced the CM0/CM4 apps with the PSoC Creator compiled apps and it works so I don't think it is a problem with my script changes.  I think it is something wrong with the Keil projects.  I used the scatter files psoc6_user_app0_cm0plus.scat and psoc6_user_app0_cm4.scat and I added the exported symbols from the secure image:

        EXPORT NvicMux2_IRQHandler

NvicMux2_IRQHandler EQU 0x10001371

        EXPORT HardFault_Handler

HardFault_Handler EQU 0x10000595

        EXPORT NvicMux0_IRQHandler

NvicMux0_IRQHandler EQU 0x10000c19

        EXPORT SVC_Handler

SVC_Handler EQU 0x10000591

        EXPORT Cy_SI_GetVersion

Cy_SI_GetVersion EQU 0x10000831

        EXPORT NvicMux31_IRQHandler

NvicMux31_IRQHandler EQU 0x1000097d

        EXPORT Cy_SI_GetSecureKeyAddr

Cy_SI_GetSecureKeyAddr EQU 0x1000080d

        END

What else do I need to do to configure the Keil project?

0 Likes
Reply
Moderator
Moderator

Can you look at the generated elf files (readelf, objdump) to see if your digital signature exists? After programming the user app0, go back to PSoC Creator and attach debugger to the CM0+ secure image and check if it has passed validation. If it hasn't it will be stuck in the error handler. Otherwise you can go back to MDK and debug from there.

Regards,

Dheeraj

0 Likes
Reply
Contributor II

The validation passed.  The CM0 and CM4 user apps both get stuck in this loop in Cy_Flash_SendCmd():

                while (0u != _FLD2VAL(IPC_STRUCT_ACQUIRE_SUCCESS, ipcBase->LOCK_STATUS))

                {

                    /* Polls whether the IPC is released and the Flash operation is performed */

                }

The first test case in the user app causes this function to be called.

sStatus = Cy_Flash_WriteRow(TEST_FLASHROW_ADDR, outPtr);

I am using the same user app code in Keil as in PSoC Creator.  I built the secure image in Creator and merged with the Keil user apps.

0 Likes
Reply
Moderator
Moderator

If you want to use Flash Write and the Secure Image, you need to add a #define in the user app0 compilation: DCY_FLASH_RWW_DRV_SUPPORT_DISABLED

This is because the syscall handler in the secure image does not support non-blocking writes.

Regards,

Dheeraj

View solution in original post

0 Likes
Reply
Top labels