24#ifndef MBED_FLASHIAP_H
25#define MBED_FLASHIAP_H
27#if DEVICE_FLASH || defined(DOXYGEN_ONLY)
30#include "platform/SingletonPtr.h"
31#include "rtos/Mutex.h"
32#include "platform/NonCopyable.h"
36#ifndef FLASHIAP_APP_ROM_END_ADDR
37#if defined(TOOLCHAIN_GCC_ARM)
38extern uint32_t __etext;
39extern uint32_t __data_start__;
40extern uint32_t __data_end__;
41#define FLASHIAP_APP_ROM_END_ADDR (((uint32_t) &__etext) + ((uint32_t) &__data_end__) - ((uint32_t) &__data_start__))
42#elif defined(TOOLCHAIN_ARM)
43extern uint32_t Load$$LR$$LR_IROM1$$Limit[];
44#define FLASHIAP_APP_ROM_END_ADDR ((uint32_t)Load$$LR$$LR_IROM1$$Limit)
45#elif defined(TOOLCHAIN_IAR)
46#pragma section=".rodata"
47#pragma section=".text"
48#pragma section=".init_array"
49#define FLASHIAP_APP_ROM_END_ADDR std::max(std::max((uint32_t) __section_end(".rodata"), (uint32_t) __section_end(".text")), \
50 (uint32_t) __section_end(".init_array"))
70 constexpr FlashIAP() : _flash(), _page_buf(
nullptr)
97 int read(
void *buffer, uint32_t addr, uint32_t size);
108 int program(
const void *buffer, uint32_t addr, uint32_t size);
118 int erase(uint32_t addr, uint32_t size);
159#if !defined(DOXYGEN_ONLY)
168 bool is_aligned_to_sector(uint32_t addr, uint32_t size);
int init()
Initialize a flash IAP device.
uint32_t get_flash_size() const
Get the flash size.
uint32_t get_flash_start() const
Get the flash start address.
uint32_t get_sector_size(uint32_t addr) const
Get the sector size at the defined address.
uint32_t get_page_size() const
Get the program page size.
int deinit()
Deinitialize a flash IAP device.
int read(void *buffer, uint32_t addr, uint32_t size)
Read data from a flash device.
int program(const void *buffer, uint32_t addr, uint32_t size)
Program data to pages.
uint8_t get_erase_value() const
Get the flash erase value.
int erase(uint32_t addr, uint32_t size)
Erase sectors.
Prevents generation of copy constructor and copy assignment operator in derived classes.
Utility class for creating and using a singleton.
Target flash configuration For targets not supporting TrustZone, its flash_set_target_config must def...