/** internal flash utilities * @file * @author King Kévin * @copyright SPDX-License-Identifier: GPL-3.0-or-later * @date 2016-2020 * @note peripherals used: none */ #pragma once /** base address of the flash memory * @note not sure if there is an STM32F4 with another address, or why this is not defined in libopencm3 */ #define FLASH_BASE (0x08000000U) /** information about a flash section */ struct flash_internal_section_info_s { const uint8_t number; /**< section number */ const uint8_t size; /**< section size, in KiB */ const uint32_t start; /**< section start address */ const uint32_t end; /**< section end address */ }; /** verify if the data is in the internal flash area * @param[in] address start address of the data to read * @param[in] size how much data to read or write, in bytes * @return if the data is in the internal flash area */ bool flash_internal_range(uint32_t address, size_t size); /** find out in which section is this address * @param[in] address address to find the section for * @return section in which this address is (NULL if not in flash, section has not been found, or the sections of this device are unknown) */ const struct flash_internal_section_info_s* flash_internal_section(uint32_t address); /** probe the readable size of the internal flash * @return tested size (in bytes) */ uint32_t flash_internal_probe_read_size(void);