Mistake on this page?
Report an issue in GitHub or email us
flash_data.h
1 /* mbed Microcontroller Library
2  * Copyright (c) 2017 ARM Limited
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #ifndef MBED_FLASH_DATA_H
18 #define MBED_FLASH_DATA_H
19 
20 #include <stdint.h>
21 
22 /** Target flash algorithm structure
23  */
24 typedef struct {
25  const uint32_t init; /**< Init function address */
26  const uint32_t uninit; /**< Uninit function address */
27  const uint32_t erase_sector; /**< Erase sector function address */
28  const uint32_t program_page; /**< Program page function address */
29  const uint32_t static_base; /**< Static base address */
30  uint32_t *algo_blob; /**< Pointer to flash algo binary blob */
31 } flash_algo_t;
32 
33 /** Sector information structure
34  */
35 typedef struct {
36  const uint32_t start; /**< Sector start address */
37  const uint32_t size; /**< Sector size */
39 
40 /** Flash configuration structure
41  */
42 typedef struct {
43  const uint32_t page_size; /**< The minimum program page size that can be written */
44  const uint32_t flash_start; /**< Start address of the flash <0, flash_size) */
45  const uint32_t flash_size; /**< Flash size. The size is accumulative sum of all sector sizes */
46  const sector_info_t *sectors; /**< List of sectors - sector can vary in sizes */
47  const uint32_t sector_info_count; /**< Number of sectors */
49 
50 /** Target flash configuration
51  * For targets not supporting TrustZone, its flash_set_target_config must define target_config.
52  * For targets supporting TrustZone, it has the following requirements:
53  * -# Flash IAP H/W can only configure to secure. It can access both secure/non-secure flash.
54  * -# Flash IAP port is for secure build only. It exports secure functions for non-secure build.
55  * -# In Flash IAP port, flash_set_target_config must define both target_config/target_config_ns for secure/non-secure flash respectively.
56  * -# Non-secure application can access its non-secure flash only through secure flash IAP functions. It cannot access secure flash.
57  */
58 struct flash_s {
59  const flash_target_config_t *target_config; /**< Normal/secure flash configuration structure for targets not supporting/supporting TrustZone */
60 #if defined(__CORTEX_M23) || defined(__CORTEX_M33)
61  const flash_target_config_t *target_config_ns; /**< Non-secure flash configuration structure for targets supporting TrustZone */
62 #endif
63  const flash_algo_t *flash_algo;
64 };
65 
66 /** Flash algo argument structure
67  * Contains all registers that should be preserved
68  */
69 typedef struct {
70  uint32_t r0;
71  uint32_t r1;
72  uint32_t r2;
73  uint32_t r3;
74  uint32_t r9;
75  uint32_t pc;
76 } args_t;
77 
78 typedef int32_t (*flash_algo_jump_t)(args_t *);
79 
80 // prototypes for flash algo CMSIS API
81 
82 typedef int (*CMSIS_Algo_Function_Init)(unsigned long adr, unsigned long clk, unsigned long fnc);
83 typedef int (*CMSIS_Algo_Function_UnInit)(unsigned long fnc);
84 typedef int (*CMSIS_Algo_Function_EraseSector)(unsigned long adr);
85 typedef int (*CMSIS_Algo_Function_EraseChip)(void);
86 typedef int (*CMSIS_Algo_Function_ProgramPage)(unsigned long adr, unsigned long sz, unsigned char *buf);
87 typedef unsigned long (*CMSIS_Algo_Function_Verify)(unsigned long adr, unsigned long sz, unsigned char *buf);
88 
89 #ifdef __cplusplus
90 extern "C" {
91 #endif
92 
93 /* Set target configuration
94  */
95 void flash_set_target_config(flash_t *obj);
96 
97 #ifdef __cplusplus
98 };
99 #endif
100 
101 
102 #endif
Sector information structure.
Definition: flash_data.h:35
const flash_target_config_t * target_config
Normal/secure flash configuration structure for targets not supporting/supporting TrustZone...
Definition: flash_data.h:59
const uint32_t page_size
The minimum program page size that can be written.
Definition: flash_data.h:43
const uint32_t flash_size
Flash size.
Definition: flash_data.h:45
const sector_info_t * sectors
List of sectors - sector can vary in sizes.
Definition: flash_data.h:46
const uint32_t static_base
Static base address.
Definition: flash_data.h:29
const uint32_t uninit
Uninit function address.
Definition: flash_data.h:26
Flash algo argument structure Contains all registers that should be preserved.
Definition: flash_data.h:69
const uint32_t sector_info_count
Number of sectors.
Definition: flash_data.h:47
const uint32_t flash_start
Start address of the flash <0, flash_size)
Definition: flash_data.h:44
Target flash algorithm structure.
Definition: flash_data.h:24
const uint32_t init
Init function address.
Definition: flash_data.h:25
Target flash configuration For targets not supporting TrustZone, its flash_set_target_config must def...
Definition: flash_data.h:58
uint32_t * algo_blob
Pointer to flash algo binary blob.
Definition: flash_data.h:30
const uint32_t program_page
Program page function address.
Definition: flash_data.h:28
Flash configuration structure.
Definition: flash_data.h:42
const uint32_t start
Sector start address.
Definition: flash_data.h:36
const uint32_t size
Sector size.
Definition: flash_data.h:37
const uint32_t erase_sector
Erase sector function address.
Definition: flash_data.h:27
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.