1 /**
2   ******************************************************************************
3   * @file    low_level_device.c
4   * @author  MCD Application Team
5   * @brief   This file contains device definition for low_level_device
6   ******************************************************************************
7   * @attention
8   *
9   * <h2><center>&copy; Copyright (c) 2021 STMicroelectronics.
10   * All rights reserved.</center></h2>
11   * <h2><center>&copy; Copyright (c) 2021 Arm Limited.
12   * All rights reserved.</center></h2>
13   *
14   * This software component is licensed under BSD 3-Clause license,
15   * the "License"; You may not use this file except in compliance with the
16   * License. You may obtain a copy of the License at:
17   *                        opensource.org/licenses/BSD-3-Clause
18   *
19   ******************************************************************************
20   */
21 #include "region_defs.h"
22 #include "low_level_flash.h"
23 static struct flash_range write_vect[] =
24 {
25   { FLASH_NV_COUNTERS_AREA_OFFSET, FLASH_NV_COUNTERS_AREA_OFFSET + FLASH_NV_COUNTERS_AREA_SIZE - 1},
26   { FLASH_PS_AREA_OFFSET, FLASH_PS_AREA_OFFSET + FLASH_PS_AREA_SIZE - 1},
27   { FLASH_ITS_AREA_OFFSET, FLASH_ITS_AREA_OFFSET + FLASH_ITS_AREA_SIZE - 1},
28   /* Area for writing confirm flag on in installed image */
29   { S_IMAGE_PRIMARY_PARTITION_OFFSET + FLASH_S_PARTITION_SIZE - 32, S_IMAGE_PRIMARY_PARTITION_OFFSET + FLASH_S_PARTITION_SIZE - 16 - 1},
30   { NS_IMAGE_PRIMARY_PARTITION_OFFSET + FLASH_NS_PARTITION_SIZE - 32, NS_IMAGE_PRIMARY_PARTITION_OFFSET + FLASH_NS_PARTITION_SIZE - 16 - 1},
31   /* Area for writing secondary images */
32   { S_IMAGE_SECONDARY_PARTITION_OFFSET ,  NS_IMAGE_SECONDARY_PARTITION_OFFSET + FLASH_NS_PARTITION_SIZE - 1}
33 };
34 static struct flash_range erase_vect[] =
35 {
36   { FLASH_NV_COUNTERS_AREA_OFFSET, FLASH_NV_COUNTERS_AREA_OFFSET + FLASH_NV_COUNTERS_AREA_SIZE - 1},
37   { FLASH_PS_AREA_OFFSET, FLASH_PS_AREA_OFFSET + FLASH_PS_AREA_SIZE - 1},
38   { FLASH_ITS_AREA_OFFSET, FLASH_ITS_AREA_OFFSET + FLASH_ITS_AREA_SIZE - 1},
39   /* Area for writing secondary images */
40   { S_IMAGE_SECONDARY_PARTITION_OFFSET ,  NS_IMAGE_SECONDARY_PARTITION_OFFSET + FLASH_NS_PARTITION_SIZE - 1}
41 };
42 
43 static struct flash_range secure_vect[] =
44 {
45   { FLASH_NV_COUNTERS_AREA_OFFSET, FLASH_NV_COUNTERS_AREA_OFFSET + FLASH_NV_COUNTERS_AREA_SIZE - 1},
46   { FLASH_PS_AREA_OFFSET, FLASH_PS_AREA_OFFSET + FLASH_PS_AREA_SIZE - 1},
47   { FLASH_ITS_AREA_OFFSET, FLASH_ITS_AREA_OFFSET + FLASH_ITS_AREA_SIZE - 1},
48   /* Area for writing confirm flag on in installed image */
49   { S_IMAGE_PRIMARY_PARTITION_OFFSET + FLASH_S_PARTITION_SIZE - 32, S_IMAGE_PRIMARY_PARTITION_OFFSET + FLASH_S_PARTITION_SIZE -1},
50 };
51 
52 struct low_level_device FLASH0_DEV =
53 {
54   .erase = { .nb = sizeof(erase_vect) / sizeof(struct flash_range), .range = erase_vect},
55   .write = { .nb = sizeof(write_vect) / sizeof(struct flash_range), .range = write_vect},
56   .secure ={ .nb = sizeof(secure_vect) / sizeof(struct flash_range), .range = secure_vect}
57 };
58