37#include <libopencm3/stm32/flash.h>
38#include <libopencm3/stm32/crc.h>
39#include <libopencm3/stm32/dbgmcu.h>
57#define FLASH_SIZE_ MMIO16(0x1FFFF7E0)
59#define FLASH_SIZE_ MMIO16(0x1FFF7A22)
62#define FLASH_BEGIN 0x08000000
76 for (i = 0; i < (size & ~3); i += 4) {
84 for (i = 0; i < (size & ~3); i += 4) {
125 switch (
flash->total_size) {
132 flash->page_size = 0x400;
141 flash->page_size = 0x800;
144 default: {
return -1;}
147#elif defined(STM32F4)
158 flash->page_size = 0x400;
167 flash->page_size = 0x800;
175 flash->page_size = 0x20000;
181 switch (
flash->total_size) {
201#elif defined(STM32F4)
221#elif defined(STM32F4)
227 for (i = 0; i <
flash->page_size; i += 4) {
228 if ((*(
uint32_t *)(
flash->addr + i)) != 0xFFFFFFFF) {
return -1; }
248 for (i = 0; i < (size & ~1); i += 2) {
265 (
uint16_t)((chksum >> 16) & 0xFFFF));
269 for (i = 0; i < size; i++) {
282 if ((size >
flash_info.page_size -
FSIZ) || (size == 0)) {
return -2; }
297 if ((size >
flash.page_size -
FSIZ) || (size == 0)) {
return -2; }
307 for (i = 0; i < size; i++) {
int32_t persistent_write(void *ptr, uint32_t size)
int32_t persistent_read(void *ptr, uint32_t size)
int32_t persistent_clear(void)
Persistent settings interface.
static uint32_t pflash_checksum(uint32_t ptr, uint32_t size)
static int32_t pflash_program_bytes(struct FlashInfo *flash, uint32_t src, uint32_t size, uint32_t chksum)
static int32_t flash_detect(struct FlashInfo *flash)
static int32_t pflash_erase(struct FlashInfo *flash)
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.