Skip to content

Commit 57f3626

Browse files
author
Charley Chu
committed
psoc64: Update flash layout of CYTFM_064B0S2_4343W
Only report the flash region that can be accessed by none-secure CPU Signed-off-by: Charley Chu <[email protected]>
1 parent f38aa59 commit 57f3626

File tree

3 files changed

+139
-0
lines changed

3 files changed

+139
-0
lines changed
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
/***************************************************************************//**
2+
* \file cytfm_flash_info.c
3+
*
4+
* Description:
5+
* Provides Flash characteristics information for target CYTFM_064B0S2_4343W
6+
* Cypress board.
7+
*
8+
********************************************************************************
9+
* \copyright
10+
* Copyright 2020 Cypress Semiconductor Corporation
11+
* SPDX-License-Identifier: Apache-2.0
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*******************************************************************************/
25+
#include "cyhal_flash.h"
26+
#include "region_defs.h"
27+
#include "cytfm_flash_info.h"
28+
29+
#if DEVICE_FLASH
30+
31+
#ifdef __cplusplus
32+
extern "C" {
33+
#endif
34+
35+
/* Flash layout for App on TARGET_CYTFM_064B0S2_4343W
36+
* +--------------------------+
37+
* | |
38+
* | KVSTORE | }+ MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE
39+
* | |
40+
* +--------------------------+
41+
* | |
42+
* | |
43+
* | NS partition for App | }+ NS_PARTITION_SIZE
44+
* | |
45+
* | |
46+
* +--------------------------+ <-+ NS_PARTITION_START
47+
*/
48+
49+
static const cyhal_flash_block_info_t CYTFM_FLASH_BLOCKS[2] =
50+
{
51+
// Main Flash
52+
{
53+
.start_address = NS_PARTITION_START,
54+
.size = NS_PARTITION_SIZE + MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE,
55+
.sector_size = CY_FLASH_SIZEOF_ROW,
56+
.page_size = CY_FLASH_SIZEOF_ROW,
57+
.erase_value = 0x00U,
58+
},
59+
// Working Flash
60+
{
61+
.start_address = CY_EM_EEPROM_BASE,
62+
.size = CY_EM_EEPROM_SIZE,
63+
.sector_size = CY_FLASH_SIZEOF_ROW,
64+
.page_size = CY_FLASH_SIZEOF_ROW,
65+
.erase_value = 0x00U,
66+
},
67+
};
68+
69+
void cytfm_flash_get_info(const cyhal_flash_t *obj, cyhal_flash_info_t *info)
70+
{
71+
CY_UNUSED_PARAMETER(obj);
72+
CY_ASSERT(NULL != obj);
73+
74+
info->block_count =
75+
sizeof(CYTFM_FLASH_BLOCKS) / sizeof(cyhal_flash_block_info_t);
76+
info->blocks = CYTFM_FLASH_BLOCKS;
77+
}
78+
79+
#ifdef __cplusplus
80+
}
81+
#endif
82+
83+
#endif
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/***************************************************************************//**
2+
* \file cytfm_flash_info.h
3+
*
4+
* Description:
5+
* Provides Flash characteristics information for target CYTFM_064B0S2_4343W
6+
* Cypress board.
7+
*
8+
********************************************************************************
9+
* \copyright
10+
* Copyright 2020 Cypress Semiconductor Corporation
11+
* SPDX-License-Identifier: Apache-2.0
12+
*
13+
* Licensed under the Apache License, Version 2.0 (the "License");
14+
* you may not use this file except in compliance with the License.
15+
* You may obtain a copy of the License at
16+
*
17+
* http://www.apache.org/licenses/LICENSE-2.0
18+
*
19+
* Unless required by applicable law or agreed to in writing, software
20+
* distributed under the License is distributed on an "AS IS" BASIS,
21+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22+
* See the License for the specific language governing permissions and
23+
* limitations under the License.
24+
*******************************************************************************/
25+
#pragma once
26+
27+
#include "cyhal_flash.h"
28+
29+
#ifdef __cplusplus
30+
extern "C" {
31+
#endif
32+
33+
/** Gets flash characteristics like the start address, size, erase values etc
34+
* for TF-M platform.
35+
* Refer \ref cyhal_flash_info_t for more information.
36+
*
37+
* @param[in] obj The flash object.
38+
* @param[out] info The flash characteristic info.
39+
*
40+
* Refer \ref subsection_flash_use_case_1 for more information.
41+
*/
42+
void cytfm_flash_get_info(const cyhal_flash_t *obj, cyhal_flash_info_t *info);
43+
44+
#ifdef __cplusplus
45+
}
46+
#endif
47+

targets/TARGET_Cypress/TARGET_PSOC6/cy_flash_api.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
#include "flash_api.h"
1818
#include "cyhal_flash.h"
1919

20+
#ifdef TARGET_TFM
21+
#include "cytfm_flash_info.h"
22+
#endif
23+
2024
#if DEVICE_FLASH
2125

2226
#ifdef __cplusplus
@@ -28,7 +32,12 @@ int32_t flash_init(flash_t *obj)
2832
if (CY_RSLT_SUCCESS != cyhal_flash_init(&(obj->flash))) {
2933
return -1;
3034
}
35+
#ifdef TARGET_TFM
36+
cytfm_flash_get_info(&(obj->flash), &(obj->info));
37+
#else /* TARGET_TFM */
3138
cyhal_flash_get_info(&(obj->flash), &(obj->info));
39+
#endif /* TARGET_TFM */
40+
3241
return 0;
3342
}
3443

0 commit comments

Comments
 (0)