Skip to content

Commit b80c961

Browse files
authored
Merge pull request #10034 from evgenibo/flash_protected_region_config
PSA: PSoc 6 configurable secure memory size
2 parents 5252163 + 5d1dae4 commit b80c961

File tree

8 files changed

+57935
-93606
lines changed

8 files changed

+57935
-93606
lines changed

features/storage/kvstore/conf/tdb_internal/mbed_lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"CY8CKIT_062_WIFI_BT_M0_PSA": {
1919
"internal_size": "0x8000",
20-
"internal_base_address": "0x10078000"
20+
"internal_base_address": "0x10038000"
2121
},
2222
"LPC55S69_S": {
2323
"internal_size": "0x10000",

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT_M0_PSA/cyprotection_config.h

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* mbed Microcontroller Library
2-
*
2+
*
33
* \copyright
44
55
* (c) 2018, Cypress Semiconductor Corporation
@@ -25,6 +25,7 @@
2525
#define _CYPROTECTION_CONFIG_H_
2626

2727
#include "cyprotection.h"
28+
#include "mbed_assert.h"
2829

2930
/* Add to M0_PSA target in targets.json:
3031
* - INITIAL_ROT_PROTECTION_AVAILABLE - to disable pc0 related protections
@@ -42,10 +43,46 @@ CY_PROT_PCMASK3 + CY_PROT_PCMASK4)
4243

4344
#define ALL_SUBREGIONS (0x0)
4445

46+
47+
/* protected rom region size */
48+
49+
#if PSA_SECURE_ROM_SIZE == 0x10000
50+
#define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_64KB /* 0x10000 */
51+
#elif PSA_SECURE_ROM_SIZE == 0x20000
52+
#define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_128KB /* 0x20000 */
53+
#elif PSA_SECURE_ROM_SIZE == 0x40000
54+
#define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_256KB /* 0x40000 */
55+
#elif PSA_SECURE_ROM_SIZE == 0x80000
56+
#define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_512KB /* 0x80000 */
57+
#elif PSA_SECURE_ROM_SIZE == 0x100000
58+
#define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_1MB /* 0x100000 */
59+
#else
60+
#error unsupported protected rom region size - not aligned or out of range
61+
#endif
62+
63+
64+
/* protected ram region size */
65+
66+
#if PSA_SECURE_RAM_SIZE == 0x8000
67+
#define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_32KB /* 0x8000 */
68+
#elif PSA_SECURE_RAM_SIZE == 0x10000
69+
#define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_64KB /* 0x10000 */
70+
#elif PSA_SECURE_RAM_SIZE == 0x20000
71+
#define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_128KB /* 0x20000 */
72+
#elif PSA_SECURE_RAM_SIZE == 0x40000
73+
#define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_256KB /* 0x40000 */
74+
#else
75+
#error unsupported protected ram region size - not aligned or out of range
76+
#endif
77+
78+
MBED_STATIC_ASSERT((PSA_SECURE_ROM_START % PSA_SECURE_ROM_SIZE) == 0, "PSA_SECURE_ROM_START is not alligned with PSA_SECURE_ROM_SIZE");
79+
MBED_STATIC_ASSERT((PSA_SECURE_RAM_START % PSA_SECURE_RAM_SIZE) == 0, "PSA_SECURE_RAM_START is not alligned with PSA_SECURE_RAM_SIZE");
80+
81+
4582
const cy_smpu_region_config_t flash_spm_smpu_config[] = {
4683
{ /* FLASH_PC1_SPM */
4784
.address = (uint32_t *)PSA_SECURE_ROM_START, /* 0x10000000 */
48-
.regionSize = CY_PROT_SIZE_512KB, /* 0x80000 */
85+
.regionSize = CY_PROT_ROM_REGION_SIZE,
4986
.subregions = ALL_SUBREGIONS,
5087
.userPermission = CY_PROT_PERM_RWX,
5188
.privPermission = CY_PROT_PERM_RWX,
@@ -62,7 +99,7 @@ const cy_smpu_region_config_t flash_spm_smpu_config[] = {
6299
const cy_smpu_region_config_t sram_spm_smpu_config[] = {
63100
{ /* SRAM_SPM_PRIV - must include SRAM_SPM_PUB area */
64101
.address = (uint32_t *)PSA_SECURE_RAM_START, /* 0x08020000 */
65-
.regionSize = CY_PROT_SIZE_64KB, /* 0x10000 */
102+
.regionSize = CY_PROT_RAM_REGION_SIZE,
66103
.subregions = ALL_SUBREGIONS, /* 0xC0, /*Size 0xC000 ALL_SUBREGIONS,*/
67104
.userPermission = CY_PROT_PERM_DISABLED,
68105
.privPermission = CY_PROT_PERM_RWX,

0 commit comments

Comments
 (0)