2020-11-24 16:04:37 +01:00
|
|
|
/** internal flash utilities
|
2020-01-01 23:35:32 +01:00
|
|
|
* @file
|
2016-08-14 19:25:38 +02:00
|
|
|
* @author King Kévin <kingkevin@cuvoodoo.info>
|
2020-06-06 14:35:55 +02:00
|
|
|
* @copyright SPDX-License-Identifier: GPL-3.0-or-later
|
2020-01-01 23:35:32 +01:00
|
|
|
* @date 2016-2020
|
2016-08-14 19:25:38 +02:00
|
|
|
* @note peripherals used: none
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2020-11-24 16:04:37 +01:00
|
|
|
/** 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
|
2020-01-02 13:42:02 +01:00
|
|
|
*/
|
2020-11-24 16:04:37 +01:00
|
|
|
#define FLASH_BASE (0x08000000U)
|
2020-01-02 18:26:12 +01:00
|
|
|
|
2020-11-24 16:04:37 +01:00
|
|
|
/** 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
|
2020-01-02 18:26:12 +01:00
|
|
|
*/
|
2020-11-24 16:04:37 +01:00
|
|
|
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)
|
2020-01-02 18:26:12 +01:00
|
|
|
*/
|
2020-11-24 16:04:37 +01:00
|
|
|
const struct flash_internal_section_info_s* flash_internal_section(uint32_t address);
|
|
|
|
|
2020-06-24 11:52:09 +02:00
|
|
|
/** probe the readable size of the internal flash
|
2020-06-14 19:06:54 +02:00
|
|
|
* @return tested size (in bytes)
|
2020-03-08 18:17:37 +01:00
|
|
|
*/
|
2020-06-14 19:06:54 +02:00
|
|
|
uint32_t flash_internal_probe_read_size(void);
|