[riot-notifications] [RIOT-OS/RIOT] stm32f{2, 4, 7}: Initial flashpage support (#15420)

Francisco notifications at github.com
Mon Nov 16 14:01:17 CET 2020


@fjmolinas commented on this pull request.

Not sure I I'm missing something here but when there are dual banks sectors go in the form (for 512Kb of flash):

```
Sector 0 0x0800 0000 - 0x0800 3FFF 16 Kbytes
Sector 1 0x0800 4000 - 0x0800 7FFF 16 Kbytes
Sector 2 0x0800 8000 - 0x0800 BFFF 16 Kbytes
Sector 3 0x0800 C000 - 0x0800 FFFF 16 Kbyte
Sector 4 0x0801 0000 - 0x0801 FFFF 64 Kbytes
Sector 5 0x0802 0000 - 0x0803 FFFF 128 Kbytes

Sector 12 0x0810 0000 - 0x0810 3FFF 16 Kbytes
Sector 13 0x0810 4000 - 0x0810 7FFF 16 Kbytes
Sector 14 0x0810 8000 - 0x0810 BFFF 16 Kbytes
Sector 15 0x0810 C000 - 0x0810 FFFF 16 Kbytes
Sector 16 0x0811 0000 - 0x0811 FFFF 64 Kbytes
Sector 17 0x0812 0000 - 0x0813 FFFF 128 Kbytes
```

So sectors numbers go from `1-5` and `12-17`, I'm not sure I can see how and where this is accounted for?

>  #else
-#define FLASHPAGE_WRITE_BLOCK_SIZE      (2U)
+#define FLASHPAGE_WRITE_BLOCK_SIZE   (2U)

Nitpick but they could be aligned.

> @@ -135,8 +144,19 @@ static void _erase_page(void *page_addr)
     pn = (uint8_t)page;
 #endif
     CNTRL_REG &= ~FLASH_CR_PNB;
+#if defined(CPU_FAM_STM32F4) || defined(CPU_FAM_STM32F7)
+    if (FLASHPAGE_DUAL_BANK && (pn > (FLASHPAGE_NUMOF/2 - 1))) {
+        pn = pn - (FLASHPAGE_NUMOF/2);

```suggestion
        pn = pn - (FLASHPAGE_NUMOF / 2);
```

> @@ -135,8 +144,19 @@ static void _erase_page(void *page_addr)
     pn = (uint8_t)page;
 #endif
     CNTRL_REG &= ~FLASH_CR_PNB;
+#if defined(CPU_FAM_STM32F4) || defined(CPU_FAM_STM32F7)
+    if (FLASHPAGE_DUAL_BANK && (pn > (FLASHPAGE_NUMOF/2 - 1))) {

```suggestion
    if (FLASHPAGE_DUAL_BANK && (pn > (FLASHPAGE_NUMOF / 2 - 1))) {
```

Not sure if uncrustify cares about this

>      /* unlock the flash module */
     _unlock_flash();
 
+#if defined(CPU_FAM_STM32F2) || defined(CPU_FAM_STM32F4) || \
+    defined(CPU_FAM_STM32F7)
+    CNTRL_REG |= FLASH_CR_PSIZE_1; /* Word size parallelism */

What parallelism is this?

> +    if (page < 4) {
+        return 16 * 1024;
+    }
+    else if (page == 4) {
+        return 64 * 1024;
+    }
+    else {
+        return 128 * 1024;
+    }

In think we have nice macros for this now if you want to use them `KiB(x)`

-- 
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/15420#pullrequestreview-531290187
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20201116/d24136ea/attachment.htm>


More information about the notifications mailing list