OpenOCD failes to program PSoC6 when CM0+ has restricted access to the internal flash memory

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

cross mob
OnPi_2263161
Level 4
Level 4
First like received Code Expert

Hi All,

our project aims to use SMPU to protect a bootloader IP. Our current security setup is that PC1 can read/execute from the bootloader flash section and other PCs (except PC0) have all permissions disabled [1] for this section. TC bus master is kept in PC0. Whenever PC2 is set to CM0+ OpenOCD ends with an error during internal flash memory erase [2]. Therefore new code cannot be loaded until we perform a full chip erase via PSoC Programmer application.

Does OpenOCD use CortexM0+ to erase the internal flash memory? What steps should we take to be able to program with OpenOCD a chip with such security setting?

[1]

static const cy_stc_smpu_cfg_t BOOTLOADER_FULL_PROTECTION = {

  .address = (uint32_t *)CY_FLASH_BASE,

  .regionSize = CY_PROT_SIZE_128KB,

  .subregions = (uint8_t)((CY_PROT_SUBREGION_DIS6) | (CY_PROT_SUBREGION_DIS7)), /* Protects only the bootloader code (96KB). */

  .userPermission = CY_PROT_PERM_DISABLED,

  .privPermission = CY_PROT_PERM_DISABLED,

  .secure = false,

  .pcMatch = false,

  .pcMask = CY_SI_DEVICE_PC_MASK  /* Only allow PC=0 */

};

[2]

target halted due to debug-request, current mode: Thread

xPSR: 0x81000000 pc: 0x1001e90c msp: 0x0800ffc0

Info : SWD DPIDR 0x6ba02477

Error: Failed to read memory at 0x4025f00c

Warn : FLASHC.GEOMETRY is not accessible, assuming device is PSoC6BLE2

Info : SWD DPIDR 0x6ba02477

Error: Failed to read memory at 0x4025f00c

Warn : FLASHC.GEOMETRY is not accessible, assuming Flash Size is 1024 kB

Error: SROM API execution failed. Status: 0xF0000005

Error: SECTOR @10000000 not erased!

Error: failed erasing sectors 0 to 2047

0 Likes
1 Solution

Please check your OpenOCD configuration file for the following:

(1) If you have used "cmsis-dap.cfg" instead of "kitprog3.cfg"

(2) If you have disabled Test Mode acquire (set ENABLE_ACQUIRE 0)

To solve this, do the following:

  • Remove the -c "set ENABLE_ACQUIRE 0" command if it is present
  • Change -c "source [find interface/cmsis-dap.cfg]" to -c "source [find interface/kitprog3.cfg]"

Let me know if this helps

Regards,

Dheeraj

View solution in original post

5 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Can you please copy the entire OpenOCD log into a file and then attach it here? It will give us more insight into your issue.

Regards,

Dheeraj

0 Likes

Openocd log attached.

0 Likes

Please check your OpenOCD configuration file for the following:

(1) If you have used "cmsis-dap.cfg" instead of "kitprog3.cfg"

(2) If you have disabled Test Mode acquire (set ENABLE_ACQUIRE 0)

To solve this, do the following:

  • Remove the -c "set ENABLE_ACQUIRE 0" command if it is present
  • Change -c "source [find interface/cmsis-dap.cfg]" to -c "source [find interface/kitprog3.cfg]"

Let me know if this helps

Regards,

Dheeraj

Remove -c "set ENABLE_ACQUIRE 0"  helps.

What does ENABLE_ACQUIRE mean and why it is a problem with combination with SMPU?

Thank you

0 Likes

This option disables Test Mode acquire.

The problem is that there is no easy way to stop the CPU right after Reset before it starts to execute the code. To do this Cypress uses something called Test Mode Acquisition.

In this particular case, once execution entered main() - user code protects the Flash and there is no way to reprogram it. SROM API returns corresponding error code (STATUS_NVL_PROTECTED) and refuses to program the Flash. This is normal and expected.

If Test Mode acquisition is disabled - nothing stops the CPU after reset.

Regards,

Dheeraj

0 Likes