Skip to content

Commit b3f59da

Browse files
author
Evgeni Bolotin
authored
Merge pull request #1 from orenc17/flash_protected_region_config
Finish memory protection and add static assert
2 parents c87d5d4 + 4c9fe7d commit b3f59da

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

targets/TARGET_Cypress/TARGET_PSOC6/TARGET_CY8CKIT_062_WIFI_BT_M0_PSA/cyprotection_config.h

Lines changed: 17 additions & 5 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
@@ -45,32 +46,43 @@ CY_PROT_PCMASK3 + CY_PROT_PCMASK4)
4546

4647
/* protected rom region size */
4748

48-
#if PSA_SECURE_ROM_SIZE == 0x20000
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
4952
#define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_128KB /* 0x20000 */
5053
#elif PSA_SECURE_ROM_SIZE == 0x40000
5154
#define CY_PROT_ROM_REGION_SIZE CY_PROT_SIZE_256KB /* 0x40000 */
5255
#elif PSA_SECURE_ROM_SIZE == 0x80000
5356
#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 */
5459
#else
5560
#error unsupported protected rom region size - not aligned or out of range
5661
#endif
5762

5863

5964
/* protected ram region size */
6065

61-
#if PSA_SECURE_RAM_SIZE == 0x10000
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
6269
#define CY_PROT_RAM_REGION_SIZE CY_PROT_SIZE_64KB /* 0x10000 */
6370
#elif PSA_SECURE_RAM_SIZE == 0x20000
6471
#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 */
6574
#else
6675
#error unsupported protected ram region size - not aligned or out of range
6776
#endif
6877

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+
6981

7082
const cy_smpu_region_config_t flash_spm_smpu_config[] = {
7183
{ /* FLASH_PC1_SPM */
7284
.address = (uint32_t *)PSA_SECURE_ROM_START, /* 0x10000000 */
73-
.regionSize = CY_PROT_ROM_REGION_SIZE,
85+
.regionSize = CY_PROT_ROM_REGION_SIZE,
7486
.subregions = ALL_SUBREGIONS,
7587
.userPermission = CY_PROT_PERM_RWX,
7688
.privPermission = CY_PROT_PERM_RWX,
@@ -87,7 +99,7 @@ const cy_smpu_region_config_t flash_spm_smpu_config[] = {
8799
const cy_smpu_region_config_t sram_spm_smpu_config[] = {
88100
{ /* SRAM_SPM_PRIV - must include SRAM_SPM_PUB area */
89101
.address = (uint32_t *)PSA_SECURE_RAM_START, /* 0x08020000 */
90-
.regionSize = CY_PROT_RAM_REGION_SIZE,
102+
.regionSize = CY_PROT_RAM_REGION_SIZE,
91103
.subregions = ALL_SUBREGIONS, /* 0xC0, /*Size 0xC000 ALL_SUBREGIONS,*/
92104
.userPermission = CY_PROT_PERM_DISABLED,
93105
.privPermission = CY_PROT_PERM_RWX,

0 commit comments

Comments
 (0)