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 <haoc@cypress.com>
pull/13677/head
Charley Chu 2020-09-28 11:11:12 -07:00
parent f38aa597c8
commit 57f36264c5
3 changed files with 139 additions and 0 deletions

View File

@ -0,0 +1,83 @@
/***************************************************************************//**
* \file cytfm_flash_info.c
*
* Description:
* Provides Flash characteristics information for target CYTFM_064B0S2_4343W
* Cypress board.
*
********************************************************************************
* \copyright
* Copyright 2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#include "cyhal_flash.h"
#include "region_defs.h"
#include "cytfm_flash_info.h"
#if DEVICE_FLASH
#ifdef __cplusplus
extern "C" {
#endif
/* Flash layout for App on TARGET_CYTFM_064B0S2_4343W
* +--------------------------+
* | |
* | KVSTORE | }+ MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE
* | |
* +--------------------------+
* | |
* | |
* | NS partition for App | }+ NS_PARTITION_SIZE
* | |
* | |
* +--------------------------+ <-+ NS_PARTITION_START
*/
static const cyhal_flash_block_info_t CYTFM_FLASH_BLOCKS[2] =
{
// Main Flash
{
.start_address = NS_PARTITION_START,
.size = NS_PARTITION_SIZE + MBED_CONF_STORAGE_TDB_INTERNAL_INTERNAL_SIZE,
.sector_size = CY_FLASH_SIZEOF_ROW,
.page_size = CY_FLASH_SIZEOF_ROW,
.erase_value = 0x00U,
},
// Working Flash
{
.start_address = CY_EM_EEPROM_BASE,
.size = CY_EM_EEPROM_SIZE,
.sector_size = CY_FLASH_SIZEOF_ROW,
.page_size = CY_FLASH_SIZEOF_ROW,
.erase_value = 0x00U,
},
};
void cytfm_flash_get_info(const cyhal_flash_t *obj, cyhal_flash_info_t *info)
{
CY_UNUSED_PARAMETER(obj);
CY_ASSERT(NULL != obj);
info->block_count =
sizeof(CYTFM_FLASH_BLOCKS) / sizeof(cyhal_flash_block_info_t);
info->blocks = CYTFM_FLASH_BLOCKS;
}
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,47 @@
/***************************************************************************//**
* \file cytfm_flash_info.h
*
* Description:
* Provides Flash characteristics information for target CYTFM_064B0S2_4343W
* Cypress board.
*
********************************************************************************
* \copyright
* Copyright 2020 Cypress Semiconductor Corporation
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
#pragma once
#include "cyhal_flash.h"
#ifdef __cplusplus
extern "C" {
#endif
/** Gets flash characteristics like the start address, size, erase values etc
* for TF-M platform.
* Refer \ref cyhal_flash_info_t for more information.
*
* @param[in] obj The flash object.
* @param[out] info The flash characteristic info.
*
* Refer \ref subsection_flash_use_case_1 for more information.
*/
void cytfm_flash_get_info(const cyhal_flash_t *obj, cyhal_flash_info_t *info);
#ifdef __cplusplus
}
#endif

View File

@ -17,6 +17,10 @@
#include "flash_api.h"
#include "cyhal_flash.h"
#ifdef TARGET_TFM
#include "cytfm_flash_info.h"
#endif
#if DEVICE_FLASH
#ifdef __cplusplus
@ -28,7 +32,12 @@ int32_t flash_init(flash_t *obj)
if (CY_RSLT_SUCCESS != cyhal_flash_init(&(obj->flash))) {
return -1;
}
#ifdef TARGET_TFM
cytfm_flash_get_info(&(obj->flash), &(obj->info));
#else /* TARGET_TFM */
cyhal_flash_get_info(&(obj->flash), &(obj->info));
#endif /* TARGET_TFM */
return 0;
}