[riot-notifications] [RIOT-OS/RIOT] cpu/stm32f3: add support for flashpage and flashpage_raw (#11749)

Francisco notifications at github.com
Fri Jun 28 10:54:16 CEST 2019


fjmolinas requested changes on this pull request.

Tested on stm32f302r8, the tests pass and everything seems to work but according to the datasheet HSI also needs to be enabled for erase operations, which is not being done here for F3.

> @@ -174,7 +175,7 @@ void flashpage_write_raw(void *target_addr, const void *data, size_t len)
 
     DEBUG("[flashpage_raw] write: now writing the data\n");
 #if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) || \
-    defined(CPU_FAM_STM32L4)
+    defined(CPU_FAM_STM32L4) || defined(CPU_FAM_STM32F3)

Minot nit-picking, this could be in alphabetical order. 

> @@ -43,6 +43,20 @@ extern "C" {
 #define CPU_FLASH_BASE                  FLASH_BASE
 /** @} */
 
+/**
+ * @name    Flash page configuration
+ * @{
+ */
+#define FLASHPAGE_SIZE      (2048U)
+#define FLASHPAGE_NUMOF     (STM32_FLASHSIZE / FLASHPAGE_SIZE)
+
+/* The minimum block size which can be written is 2B. However, the erase
+ * block is always FLASHPAGE_SIZE.
+ */
+#define FLASHPAGE_RAW_BLOCKSIZE    (2U)
+/* Writing should be always 4 bytes aligned */
+#define FLASHPAGE_RAW_ALIGNMENT    (4U)

Why 4 bytes? The blocksize is 2 bytes, skimming through the datasheet I couldn't find a reference to this being a requirement. 

>      CNTRL_REG &= ~(FLASH_CR_PG);
 #endif
     DEBUG("[flashpage_raw] write: done writing data\n");
 
     /* lock the flash module again */
     _lock();
 
-#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1)
+#if defined(CPU_FAM_STM32F0) || defined(CPU_FAM_STM32F1) || \

This also need to be done for erase operations according to the reference manual p68.

> For program and erase operations on the Flash memory (write/erase), the internal RC
> oscillator (HSI) must be ON.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11749#pullrequestreview-255651670
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190628/a1fdb4b8/attachment.html>


More information about the notifications mailing list