Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
flash_data.h
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2017 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 #ifndef MBED_FLASH_DATA_H 00017 #define MBED_FLASH_DATA_H 00018 00019 #include <stdint.h> 00020 00021 /** Target flash algorithm structure 00022 */ 00023 typedef struct { 00024 const uint32_t init; /**< Init function address */ 00025 const uint32_t uninit; /**< Uninit function address */ 00026 const uint32_t erase_sector; /**< Erase sector function address */ 00027 const uint32_t program_page; /**< Program page function address */ 00028 const uint32_t static_base; /**< Static base address */ 00029 uint32_t *algo_blob; /**< Pointer to flash algo binary blob */ 00030 } flash_algo_t; 00031 00032 /** Sector information structure 00033 */ 00034 typedef struct { 00035 const uint32_t start; /**< Sector start address */ 00036 const uint32_t size; /**< Sector size */ 00037 } sector_info_t; 00038 00039 /** Flash configuration structure 00040 */ 00041 typedef struct { 00042 const uint32_t page_size; /**< The minimum program page size that can be written */ 00043 const uint32_t flash_start; /**< Start address of the flash <0, flash_size) */ 00044 const uint32_t flash_size; /**< Flash size. The size is accumulative sum of all sector sizes */ 00045 const sector_info_t *sectors; /**< List of sectors - sector can vary in sizes */ 00046 const uint32_t sector_info_count; /**< Number of sectors */ 00047 } flash_target_config_t; 00048 00049 /** Target flash configuration 00050 * For targets not supporting TrustZone, its flash_set_target_config must define target_config. 00051 * For targets supporting TrustZone, it has the following requirements: 00052 * -# Flash IAP H/W can only configure to secure. It can access both secure/non-secure flash. 00053 * -# Flash IAP port is for secure build only. It exports secure functions for non-secure build. 00054 * -# In Flash IAP port, flash_set_target_config must define both target_config/target_config_ns for secure/non-secure flash respectively. 00055 * -# Non-secure application can access its non-secure flash only through secure flash IAP functions. It cannot access secure flash. 00056 */ 00057 struct flash_s { 00058 const flash_target_config_t *target_config; /**< Normal/secure flash configuration structure for targets not supporting/supporting TrustZone */ 00059 #if defined(__CORTEX_M23) || defined(__CORTEX_M33) 00060 const flash_target_config_t *target_config_ns; /**< Non-secure flash configuration structure for targets supporting TrustZone */ 00061 #endif 00062 const flash_algo_t *flash_algo; 00063 }; 00064 00065 /** Flash algo argument structure 00066 * Contains all registers that should be preserved 00067 */ 00068 typedef struct { 00069 uint32_t r0; 00070 uint32_t r1; 00071 uint32_t r2; 00072 uint32_t r3; 00073 uint32_t r9; 00074 uint32_t pc; 00075 } args_t; 00076 00077 typedef int32_t (*flash_algo_jump_t)(args_t *); 00078 00079 // prototypes for flash algo CMSIS API 00080 00081 typedef int (*CMSIS_Algo_Function_Init)(unsigned long adr, unsigned long clk, unsigned long fnc); 00082 typedef int (*CMSIS_Algo_Function_UnInit)(unsigned long fnc); 00083 typedef int (*CMSIS_Algo_Function_EraseSector)(unsigned long adr); 00084 typedef int (*CMSIS_Algo_Function_EraseChip)(void); 00085 typedef int (*CMSIS_Algo_Function_ProgramPage)(unsigned long adr, unsigned long sz, unsigned char *buf); 00086 typedef unsigned long (*CMSIS_Algo_Function_Verify)(unsigned long adr, unsigned long sz, unsigned char *buf); 00087 00088 #ifdef __cplusplus 00089 extern "C" { 00090 #endif 00091 00092 /* Set target configuration 00093 */ 00094 void flash_set_target_config(flash_t *obj); 00095 00096 #ifdef __cplusplus 00097 }; 00098 #endif 00099 00100 00101 #endif
Generated on Tue Jul 12 2022 19:04:38 by
1.7.2