Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/libopencm3.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Palsson <karlp@tweak.net.au>2018-07-11 01:21:18 +0300
committerKarl Palsson <karlp@tweak.net.au>2018-07-29 23:31:17 +0300
commitb23dccc7ae9cb4ee7916c35e81e5a999f162adf4 (patch)
tree3ebb2f5a35b6214ccb031cf006825b0a50aa094a
parent9dd901ba279bc9d65fea920186b2dbb7fd17b16d (diff)
stm32: flash: pull up prefetch to _all
Turns out, there's lots of common code for flash. Pull up prefetch on/off to start with, as there's only a single bit name different. Pull up the definitions of common API functions too, starting with flash_set_ws. Even if the implementations are different, things that meant to be the same, should be defined centrally.
-rw-r--r--include/libopencm3/stm32/common/flash_common_all.h48
-rw-r--r--include/libopencm3/stm32/common/flash_common_f01.h5
-rw-r--r--include/libopencm3/stm32/common/flash_common_f234.h1
-rw-r--r--include/libopencm3/stm32/common/flash_common_f24.h2
-rw-r--r--include/libopencm3/stm32/common/flash_common_l01.h5
-rw-r--r--include/libopencm3/stm32/f0/flash.h1
-rw-r--r--include/libopencm3/stm32/f1/flash.h1
-rw-r--r--include/libopencm3/stm32/f2/flash.h1
-rw-r--r--include/libopencm3/stm32/f3/flash.h5
-rw-r--r--include/libopencm3/stm32/f4/flash.h1
-rw-r--r--include/libopencm3/stm32/f7/flash.h4
-rw-r--r--include/libopencm3/stm32/l0/flash.h1
-rw-r--r--include/libopencm3/stm32/l1/flash.h1
-rw-r--r--include/libopencm3/stm32/l4/flash.h5
-rw-r--r--lib/stm32/common/flash_common_all.c37
-rw-r--r--lib/stm32/common/flash_common_f01.c28
-rw-r--r--lib/stm32/common/flash_common_f24.c28
-rw-r--r--lib/stm32/common/flash_common_l01.c28
-rw-r--r--lib/stm32/f0/Makefile3
-rwxr-xr-xlib/stm32/f1/Makefile5
-rw-r--r--lib/stm32/f2/Makefile3
-rw-r--r--lib/stm32/f3/Makefile5
-rw-r--r--lib/stm32/f3/flash.c20
-rw-r--r--lib/stm32/f4/Makefile3
-rw-r--r--lib/stm32/f7/Makefile2
-rw-r--r--lib/stm32/f7/flash.c29
-rw-r--r--lib/stm32/l0/Makefile2
-rw-r--r--lib/stm32/l1/Makefile2
-rw-r--r--lib/stm32/l4/Makefile1
-rw-r--r--lib/stm32/l4/flash.c25
30 files changed, 117 insertions, 185 deletions
diff --git a/include/libopencm3/stm32/common/flash_common_all.h b/include/libopencm3/stm32/common/flash_common_all.h
new file mode 100644
index 00000000..be1c5eeb
--- /dev/null
+++ b/include/libopencm3/stm32/common/flash_common_all.h
@@ -0,0 +1,48 @@
+/** @addtogroup flash_defines
+ *
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#pragma once
+
+#include <libopencm3/cm3/common.h>
+
+BEGIN_DECLS
+
+/**
+ * This buffer is used for instruction fetches and is enabled by default after
+ * reset.
+ *
+ * Note carefully the clock restrictions under which the prefetch buffer may be
+ * enabled or disabled. Changes are normally made while the clock is running in
+ * the power-on low frequency mode before being set to a higher speed mode.
+ *
+ * See the reference manual for details.
+ */
+void flash_prefetch_enable(void);
+
+/**
+ * Note carefully the clock restrictions under which the prefetch buffer may be
+ * set to disabled. See the reference manual for details.
+ */
+void flash_prefetch_disable(void);
+
+
+void flash_set_ws(uint32_t ws);
+
+END_DECLS \ No newline at end of file
diff --git a/include/libopencm3/stm32/common/flash_common_f01.h b/include/libopencm3/stm32/common/flash_common_f01.h
index 6563db02..d52b1feb 100644
--- a/include/libopencm3/stm32/common/flash_common_f01.h
+++ b/include/libopencm3/stm32/common/flash_common_f01.h
@@ -62,6 +62,8 @@
#define FLASH_ACR_PRFTBS (1 << 5)
#define FLASH_ACR_PRFTBE (1 << 4)
+/** Compatibility define */
+#define FLASH_ACR_PRFTEN FLASH_ACR_PRFTBE
/* --- FLASH_SR values ----------------------------------------------------- */
@@ -97,9 +99,6 @@
BEGIN_DECLS
-void flash_set_ws(uint32_t ws);
-void flash_prefetch_enable(void);
-void flash_prefetch_disable(void);
void flash_unlock(void);
void flash_lock(void);
void flash_clear_pgerr_flag(void);
diff --git a/include/libopencm3/stm32/common/flash_common_f234.h b/include/libopencm3/stm32/common/flash_common_f234.h
index 03ea9fc0..9f546f54 100644
--- a/include/libopencm3/stm32/common/flash_common_f234.h
+++ b/include/libopencm3/stm32/common/flash_common_f234.h
@@ -74,7 +74,6 @@
BEGIN_DECLS
-void flash_set_ws(uint32_t ws);
void flash_unlock(void);
void flash_lock(void);
void flash_clear_pgperr_flag(void);
diff --git a/include/libopencm3/stm32/common/flash_common_f24.h b/include/libopencm3/stm32/common/flash_common_f24.h
index 2f9fe26f..4f9c4a88 100644
--- a/include/libopencm3/stm32/common/flash_common_f24.h
+++ b/include/libopencm3/stm32/common/flash_common_f24.h
@@ -124,8 +124,6 @@ void flash_dcache_enable(void);
void flash_dcache_disable(void);
void flash_icache_enable(void);
void flash_icache_disable(void);
-void flash_prefetch_enable(void);
-void flash_prefetch_disable(void);
void flash_dcache_reset(void);
void flash_icache_reset(void);
void flash_erase_all_sectors(uint32_t program_size);
diff --git a/include/libopencm3/stm32/common/flash_common_l01.h b/include/libopencm3/stm32/common/flash_common_l01.h
index 8827873e..385e8475 100644
--- a/include/libopencm3/stm32/common/flash_common_l01.h
+++ b/include/libopencm3/stm32/common/flash_common_l01.h
@@ -29,6 +29,8 @@
#define LIBOPENCM3_FLASH_COMMON_L01_H
/**@{*/
+#include <libopencm3/stm32/common/flash_common_all.h>
+
/* --- FLASH registers ----------------------------------------------------- */
#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00)
@@ -110,9 +112,6 @@
BEGIN_DECLS
-void flash_prefetch_enable(void);
-void flash_prefetch_disable(void);
-void flash_set_ws(uint32_t ws);
void flash_unlock_pecr(void);
void flash_lock_pecr(void);
void flash_unlock_progmem(void);
diff --git a/include/libopencm3/stm32/f0/flash.h b/include/libopencm3/stm32/f0/flash.h
index e27acc6d..24ef2809 100644
--- a/include/libopencm3/stm32/f0/flash.h
+++ b/include/libopencm3/stm32/f0/flash.h
@@ -36,6 +36,7 @@
#define LIBOPENCM3_FLASH_H
/**@{*/
+#include <libopencm3/stm32/common/flash_common_all.h>
#include <libopencm3/stm32/common/flash_common_f01.h>
/* --- FLASH_OPTION values ------------------------------------------------- */
diff --git a/include/libopencm3/stm32/f1/flash.h b/include/libopencm3/stm32/f1/flash.h
index d57f853f..937c83f3 100644
--- a/include/libopencm3/stm32/f1/flash.h
+++ b/include/libopencm3/stm32/f1/flash.h
@@ -43,6 +43,7 @@
/**@{*/
+#include <libopencm3/stm32/common/flash_common_all.h>
#include <libopencm3/stm32/common/flash_common_f01.h>
/* --- FLASH_OPTION bytes ------------------------------------------------- */
diff --git a/include/libopencm3/stm32/f2/flash.h b/include/libopencm3/stm32/f2/flash.h
index 70668028..e5b43080 100644
--- a/include/libopencm3/stm32/f2/flash.h
+++ b/include/libopencm3/stm32/f2/flash.h
@@ -31,6 +31,7 @@
#ifndef LIBOPENCM3_FLASH_H
#define LIBOPENCM3_FLASH_H
+#include <libopencm3/stm32/common/flash_common_all.h>
#include <libopencm3/stm32/common/flash_common_f24.h>
#endif
diff --git a/include/libopencm3/stm32/f3/flash.h b/include/libopencm3/stm32/f3/flash.h
index 2a2a9775..eaaec2d5 100644
--- a/include/libopencm3/stm32/f3/flash.h
+++ b/include/libopencm3/stm32/f3/flash.h
@@ -32,6 +32,7 @@
#define LIBOPENCM3_FLASH_H
/**@{*/
+#include <libopencm3/stm32/common/flash_common_all.h>
#include <libopencm3/stm32/common/flash_common_f234.h>
/* --- FLASH registers ----------------------------------------------------- */
@@ -44,6 +45,8 @@
#define FLASH_ACR_PRFTBS (1 << 5)
#define FLASH_ACR_PRFTBE (1 << 4)
+/** Compatibility alias */
+#define FLASH_ACR_PRFTEN FLASH_ACR_PRFTBE
#define FLASH_ACR_HLFCYA (1 << 3)
/* --- FLASH_SR values ----------------------------------------------------- */
@@ -70,8 +73,6 @@
BEGIN_DECLS
-void flash_prefetch_enable(void);
-void flash_prefetch_disable(void);
END_DECLS
diff --git a/include/libopencm3/stm32/f4/flash.h b/include/libopencm3/stm32/f4/flash.h
index 55f89721..383cbe8c 100644
--- a/include/libopencm3/stm32/f4/flash.h
+++ b/include/libopencm3/stm32/f4/flash.h
@@ -31,6 +31,7 @@
#ifndef LIBOPENCM3_FLASH_H
#define LIBOPENCM3_FLASH_H
+#include <libopencm3/stm32/common/flash_common_all.h>
#include <libopencm3/stm32/common/flash_common_f24.h>
#endif
diff --git a/include/libopencm3/stm32/f7/flash.h b/include/libopencm3/stm32/f7/flash.h
index 0ac2162a..c0827dc7 100644
--- a/include/libopencm3/stm32/f7/flash.h
+++ b/include/libopencm3/stm32/f7/flash.h
@@ -32,6 +32,7 @@
* along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <libopencm3/stm32/common/flash_common_all.h>
/*
* For details see:
* PM0081 Programming manual: STM32F40xxx and STM32F41xxx Flash programming
@@ -151,7 +152,6 @@
BEGIN_DECLS
-void flash_set_ws(uint32_t ws);
void flash_unlock(void);
void flash_lock(void);
void flash_clear_pgperr_flag(void);
@@ -165,8 +165,6 @@ void flash_clear_wrperr_flag(void);
void flash_clear_pgaerr_flag(void);
void flash_art_enable(void);
void flash_art_disable(void);
-void flash_prefetch_enable(void);
-void flash_prefetch_disable(void);
void flash_art_reset(void);
void flash_clear_status_flags(void);
void flash_erase_all_sectors(uint32_t program_size);
diff --git a/include/libopencm3/stm32/l0/flash.h b/include/libopencm3/stm32/l0/flash.h
index 6eaef6e5..ef1d1883 100644
--- a/include/libopencm3/stm32/l0/flash.h
+++ b/include/libopencm3/stm32/l0/flash.h
@@ -31,6 +31,7 @@
#define LIBOPENCM3_FLASH_H
/**@{*/
+#include <libopencm3/stm32/common/flash_common_all.h>
#include <libopencm3/stm32/common/flash_common_l01.h>
/* --- FLASH registers ----------------------------------------------------- */
diff --git a/include/libopencm3/stm32/l1/flash.h b/include/libopencm3/stm32/l1/flash.h
index 10afcd81..a84a55b3 100644
--- a/include/libopencm3/stm32/l1/flash.h
+++ b/include/libopencm3/stm32/l1/flash.h
@@ -44,6 +44,7 @@
#define LIBOPENCM3_FLASH_H
/**@{*/
+#include <libopencm3/stm32/common/flash_common_all.h>
#include <libopencm3/stm32/common/flash_common_l01.h>
/* --- FLASH registers ----------------------------------------------------- */
diff --git a/include/libopencm3/stm32/l4/flash.h b/include/libopencm3/stm32/l4/flash.h
index fb7e5b9d..50c7859f 100644
--- a/include/libopencm3/stm32/l4/flash.h
+++ b/include/libopencm3/stm32/l4/flash.h
@@ -41,6 +41,8 @@
#ifndef LIBOPENCM3_FLASH_H
#define LIBOPENCM3_FLASH_H
+#include <libopencm3/stm32/common/flash_common_all.h>
+
/* --- FLASH registers ----------------------------------------------------- */
#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00)
@@ -222,7 +224,6 @@
BEGIN_DECLS
-void flash_set_ws(uint32_t ws);
void flash_unlock(void);
void flash_lock(void);
void flash_clear_pgperr_flag(void);
@@ -232,8 +233,6 @@ void flash_dcache_enable(void);
void flash_dcache_disable(void);
void flash_icache_enable(void);
void flash_icache_disable(void);
-void flash_prefetch_enable(void);
-void flash_prefetch_disable(void);
void flash_dcache_reset(void);
void flash_icache_reset(void);
void flash_clear_pgserr_flag(void);
diff --git a/lib/stm32/common/flash_common_all.c b/lib/stm32/common/flash_common_all.c
new file mode 100644
index 00000000..71210008
--- /dev/null
+++ b/lib/stm32/common/flash_common_all.c
@@ -0,0 +1,37 @@
+/** @addtogroup flash_file
+ *
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**@{*/
+
+#include <libopencm3/stm32/flash.h>
+
+void flash_prefetch_enable(void)
+{
+ FLASH_ACR |= FLASH_ACR_PRFTEN;
+}
+
+void flash_prefetch_disable(void)
+{
+ FLASH_ACR &= ~FLASH_ACR_PRFTEN;
+}
+
+
+/*@}*/
diff --git a/lib/stm32/common/flash_common_f01.c b/lib/stm32/common/flash_common_f01.c
index 5ea5ad09..98ee1c6c 100644
--- a/lib/stm32/common/flash_common_f01.c
+++ b/lib/stm32/common/flash_common_f01.c
@@ -26,34 +26,6 @@
#include <libopencm3/stm32/flash.h>
/*---------------------------------------------------------------------------*/
-/** @brief Enable the FLASH Prefetch Buffer
-
-This buffer is used for instruction fetches and is enabled by default after
-reset.
-
-Note carefully the clock restrictions under which the prefetch buffer may be
-enabled or disabled. Changes are normally made while the clock is running in
-the power-on low frequency mode before being set to a higher speed mode.
-See the reference manual for details.
-*/
-
-void flash_prefetch_enable(void)
-{
- FLASH_ACR |= FLASH_ACR_PRFTBE;
-}
-
-/*---------------------------------------------------------------------------*/
-/** @brief Disable the FLASH Prefetch Buffer
-
-Note carefully the clock restrictions under which the prefetch buffer may be
-set to disabled. See the reference manual for details.
-*/
-
-void flash_prefetch_disable(void)
-{
- FLASH_ACR &= ~FLASH_ACR_PRFTBE;
-}
-/*---------------------------------------------------------------------------*/
/** @brief Set the Number of Wait States
Used to match the system clock to the FLASH memory access time. See the
diff --git a/lib/stm32/common/flash_common_f24.c b/lib/stm32/common/flash_common_f24.c
index 75373b87..7ec520ce 100644
--- a/lib/stm32/common/flash_common_f24.c
+++ b/lib/stm32/common/flash_common_f24.c
@@ -81,34 +81,6 @@ void flash_icache_disable(void)
FLASH_ACR &= ~FLASH_ACR_ICEN;
}
-/*---------------------------------------------------------------------------*/
-/** @brief Enable the FLASH Prefetch Buffer
-
-This buffer is used for instruction fetches and is enabled by default after
-reset.
-
-Note carefully the clock restrictions under which the prefetch buffer may be
-enabled or disabled. Changes are normally made while the clock is running in
-the power-on low frequency mode before being set to a higher speed mode.
-See the reference manual for details.
-*/
-
-void flash_prefetch_enable(void)
-{
- FLASH_ACR |= FLASH_ACR_PRFTEN;
-}
-
-/*---------------------------------------------------------------------------*/
-/** @brief Disable the FLASH Prefetch Buffer
-
-Note carefully the clock restrictions under which the prefetch buffer may be
-set to disabled. See the reference manual for details.
-*/
-
-void flash_prefetch_disable(void)
-{
- FLASH_ACR &= ~FLASH_ACR_PRFTEN;
-}
/*---------------------------------------------------------------------------*/
/** @brief Reset the Data Cache
diff --git a/lib/stm32/common/flash_common_l01.c b/lib/stm32/common/flash_common_l01.c
index 48b99f14..53a8a19c 100644
--- a/lib/stm32/common/flash_common_l01.c
+++ b/lib/stm32/common/flash_common_l01.c
@@ -30,34 +30,6 @@
#include <libopencm3/stm32/flash.h>
/*---------------------------------------------------------------------------*/
-/** @brief Enable the FLASH Prefetch Buffer
-
-This buffer is used for instruction fetches and is enabled by default after
-reset.
-
-Note carefully the restrictions under which the prefetch buffer may be
-enabled or disabled. Prefetch is only available when 64-bit
-access is enabled.
-*/
-
-void flash_prefetch_enable(void)
-{
- FLASH_ACR |= FLASH_ACR_PRFTEN;
-}
-
-/*---------------------------------------------------------------------------*/
-/** @brief Disable the FLASH Prefetch Buffer
-
-Note carefully the restrictions under which the prefetch buffer may be
-set to disabled. See the reference and programming manuals for details.
-*/
-
-void flash_prefetch_disable(void)
-{
- FLASH_ACR &= ~FLASH_ACR_PRFTEN;
-}
-
-/*---------------------------------------------------------------------------*/
/** @brief Set the Number of Wait States
Used to match the system clock to the FLASH memory access time. See the
diff --git a/lib/stm32/f0/Makefile b/lib/stm32/f0/Makefile
index ab8d58b5..5f45b7fc 100644
--- a/lib/stm32/f0/Makefile
+++ b/lib/stm32/f0/Makefile
@@ -42,11 +42,12 @@ OBJS = can.o flash.o rcc.o dma.o rtc.o comparator.o \
OBJS += gpio_common_all.o gpio_common_f0234.o crc_common_all.o crc_v2.o \
pwr_common_v1.o iwdg_common_all.o rtc_common_l1f024.o \
dma_common_l1f013.o exti_common_all.o \
- flash_common_f01.o dac_common_all.o \
+ dac_common_all.o \
timer_common_all.o timer_common_f0234.o rcc_common_all.o
OBJS += adc_common_v2.o
OBJS += crs_common_all.o
+OBJS += flash_common_all.o flash_common_f01.o
OBJS += usart_common_all.o usart_common_v2.o
OBJS += i2c_common_v2.o
OBJS += spi_common_all.o spi_common_v2.o
diff --git a/lib/stm32/f1/Makefile b/lib/stm32/f1/Makefile
index b3b12cb9..7803a102 100755
--- a/lib/stm32/f1/Makefile
+++ b/lib/stm32/f1/Makefile
@@ -44,8 +44,9 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_l1f013.o \
gpio_common_all.o i2c_common_v1.o iwdg_common_all.o \
pwr_common_v1.o \
timer_common_all.o usart_common_all.o usart_common_f124.o \
- rcc_common_all.o exti_common_all.o \
- flash_common_f01.o
+ rcc_common_all.o exti_common_all.o
+
+OBJS += flash_common_all.o flash_common_f01.o
OBJS += spi_common_all.o spi_common_v1.o
OBJS += usb.o usb_control.o usb_standard.o usb_msc.o
diff --git a/lib/stm32/f2/Makefile b/lib/stm32/f2/Makefile
index 664bf4ed..97700b19 100644
--- a/lib/stm32/f2/Makefile
+++ b/lib/stm32/f2/Makefile
@@ -43,8 +43,9 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
iwdg_common_all.o rtc_common_l1f024.o \
timer_common_all.o timer_common_f0234.o \
timer_common_f24.o usart_common_all.o usart_common_f124.o \
- flash_common_f234.o flash_common_f24.o hash_common_f24.o \
+ hash_common_f24.o \
crypto_common_f24.o exti_common_all.o rcc_common_all.o
+OBJS += flash_common_all.o flash_common_f234.o flash_common_f24.o
OBJS += rng_common_v1.o
OBJS += spi_common_all.o spi_common_v1.o spi_common_v1_frf.o
diff --git a/lib/stm32/f3/Makefile b/lib/stm32/f3/Makefile
index 125b5cbc..9e347628 100644
--- a/lib/stm32/f3/Makefile
+++ b/lib/stm32/f3/Makefile
@@ -42,9 +42,10 @@ OBJS = rcc.o adc.o can.o pwr.o dma.o flash.o desig.o
OBJS += gpio_common_all.o gpio_common_f0234.o \
dac_common_all.o crc_common_all.o crc_v2.o \
iwdg_common_all.o pwr_common_v1.o dma_common_l1f013.o\
- timer_common_all.o timer_common_f0234.o flash_common_f234.o \
- flash.o exti_common_all.o rcc_common_all.o
+ timer_common_all.o timer_common_f0234.o \
+ exti_common_all.o rcc_common_all.o
OBJS += adc_common_v2.o adc_common_v2_multi.o
+OBJS += flash_common_all.o flash_common_f234.o
OBJS += usart_common_v2.o usart_common_all.o
OBJS += i2c_common_v2.o
OBJS += spi_common_all.o spi_common_v2.o
diff --git a/lib/stm32/f3/flash.c b/lib/stm32/f3/flash.c
index 25fa86c8..16fb8aac 100644
--- a/lib/stm32/f3/flash.c
+++ b/lib/stm32/f3/flash.c
@@ -58,25 +58,5 @@ void flash_clear_status_flags(void)
flash_clear_eop_flag();
}
-/**
- * Enable the FLASH Prefetch Buffer
- * This buffer is used for instruction fetches and is enabled by default after
- * reset.
- */
-void flash_prefetch_enable(void)
-{
- FLASH_ACR |= FLASH_ACR_PRFTBE;
-}
-
-/**
- * Disable the FLASH Prefetch Buffer
- * This buffer is used for instruction fetches and is enabled by default after
- * reset.
- */
-void flash_prefetch_disable(void)
-{
- FLASH_ACR &= ~FLASH_ACR_PRFTBE;
-}
-
/**@}*/
diff --git a/lib/stm32/f4/Makefile b/lib/stm32/f4/Makefile
index ab72ccc9..d9f0ad4a 100644
--- a/lib/stm32/f4/Makefile
+++ b/lib/stm32/f4/Makefile
@@ -47,9 +47,10 @@ OBJS += crc_common_all.o dac_common_all.o dma_common_f24.o \
iwdg_common_all.o pwr_common_v1.o rtc_common_l1f024.o \
timer_common_all.o \
timer_common_f0234.o timer_common_f24.o usart_common_all.o \
- usart_common_f124.o flash_common_f234.o flash_common_f24.o \
+ usart_common_f124.o \
hash_common_f24.o crypto_common_f24.o exti_common_all.o \
rcc_common_all.o
+OBJS += flash_common_all.o flash_common_f234.o flash_common_f24.o
OBJS += rng_common_v1.o
OBJS += spi_common_all.o spi_common_v1.o spi_common_v1_frf.o
diff --git a/lib/stm32/f7/Makefile b/lib/stm32/f7/Makefile
index 7e969269..1cb01162 100644
--- a/lib/stm32/f7/Makefile
+++ b/lib/stm32/f7/Makefile
@@ -42,7 +42,7 @@ TGT_CFLAGS += $(STANDARD_FLAGS)
ARFLAGS = rcs
-OBJS = flash.o pwr.o rcc.o
+OBJS = flash_common_all.o flash.o pwr.o rcc.o
OBJS += gpio.o gpio_common_all.o gpio_common_f0234.o
OBJS += rcc_common_all.o
diff --git a/lib/stm32/f7/flash.c b/lib/stm32/f7/flash.c
index e0e47d45..c525f4f0 100644
--- a/lib/stm32/f7/flash.c
+++ b/lib/stm32/f7/flash.c
@@ -218,35 +218,6 @@ void flash_art_enable(void)
}
/*---------------------------------------------------------------------------*/
-/** @brief Enable the FLASH Prefetch Buffer
-
-This buffer is used for instruction fetches and is enabled by default after
-reset.
-
-Note carefully the clock restrictions under which the prefetch buffer may be
-enabled or disabled. Changes are normally made while the clock is running in
-the power-on low frequency mode before being set to a higher speed mode.
-See the reference manual for details.
-*/
-
-void flash_prefetch_enable(void)
-{
- FLASH_ACR |= FLASH_ACR_PRFTEN;
-}
-
-/*---------------------------------------------------------------------------*/
-/** @brief Disable the FLASH Prefetch Buffer
-
-Note carefully the clock restrictions under which the prefetch buffer may be
-set to disabled. See the reference manual for details.
-*/
-
-void flash_prefetch_disable(void)
-{
- FLASH_ACR &= ~FLASH_ACR_PRFTEN;
-}
-
-/*---------------------------------------------------------------------------*/
/** @brief Reset the ART Cache
The ART cache must be disabled for this to have effect.
diff --git a/lib/stm32/l0/Makefile b/lib/stm32/l0/Makefile
index 40455bcc..cd3e27c3 100644
--- a/lib/stm32/l0/Makefile
+++ b/lib/stm32/l0/Makefile
@@ -46,7 +46,7 @@ OBJS += adc_common_v2.o
OBJS += crs_common_all.o
OBJS += dma_common_l1f013.o
OBJS += exti_common_all.o
-OBJS += flash.o flash_common_l01.o
+OBJS += flash.o flash_common_all.o flash_common_l01.o
OBJS += i2c_common_v2.o
OBJS += rng_common_v1.o
OBJS += usart_common_all.o usart_common_v2.o
diff --git a/lib/stm32/l1/Makefile b/lib/stm32/l1/Makefile
index 30eb43c2..ec1ea928 100644
--- a/lib/stm32/l1/Makefile
+++ b/lib/stm32/l1/Makefile
@@ -38,7 +38,7 @@ ARFLAGS = rcs
OBJS = desig.o flash.o rcc.o dma.o lcd.o
OBJS += crc_common_all.o dac_common_all.o
OBJS += dma_common_l1f013.o
-OBJS += flash_common_l01.o
+OBJS += flash_common_all.o flash_common_l01.o
OBJS += gpio_common_all.o gpio_common_f0234.o
OBJS += i2c_common_v1.o iwdg_common_all.o
OBJS += pwr_common_v1.o pwr_common_v2.o rtc_common_l1f024.o
diff --git a/lib/stm32/l4/Makefile b/lib/stm32/l4/Makefile
index 53c49611..da3283bd 100644
--- a/lib/stm32/l4/Makefile
+++ b/lib/stm32/l4/Makefile
@@ -47,6 +47,7 @@ OBJS += exti_common_all.o
OBJS += adc_common_v2.o adc_common_v2_multi.o
OBJS += crc_common_all.o crc_v2.o
OBJS += crs_common_all.o
+OBJS += flash_common_all.o
OBJS += rng_common_v1.o
OBJS += timer_common_all.o
OBJS += i2c_common_v2.o
diff --git a/lib/stm32/l4/flash.c b/lib/stm32/l4/flash.c
index b23b41c0..27d8783a 100644
--- a/lib/stm32/l4/flash.c
+++ b/lib/stm32/l4/flash.c
@@ -42,31 +42,6 @@
#include <libopencm3/stm32/flash.h>
-/** @brief Enable the FLASH Prefetch Buffer
-
-This buffer is used for instruction fetches and is enabled by default after
-reset.
-
-Note carefully the clock restrictions under which the prefetch buffer may be
-enabled or disabled. Changes are normally made while the clock is running in
-the power-on low frequency mode before being set to a higher speed mode.
-See the reference manual for details.
-*/
-void flash_prefetch_enable(void)
-{
- FLASH_ACR |= FLASH_ACR_PRFTEN;
-}
-
-/** @brief Disable the FLASH Prefetch Buffer
-
-Note carefully the clock restrictions under which the prefetch buffer may be
-set to disabled. See the reference manual for details.
-*/
-void flash_prefetch_disable(void)
-{
- FLASH_ACR &= ~FLASH_ACR_PRFTEN;
-}
-
/** @brief Set the Number of Wait States
Used to match the system clock to the FLASH memory access time. See the