You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/10/08 20:56:22 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #7258: arch: stm32h7: Add support for dual bank flash

pkarashchenko commented on code in PR #7258:
URL: https://github.com/apache/incubator-nuttx/pull/7258#discussion_r990694486


##########
arch/arm/src/stm32h7/stm32_flash.c:
##########
@@ -330,15 +331,24 @@ static inline uint32_t stm32h7_flash_size(
 static inline
 struct stm32h7_flash_priv_s * stm32h7_flash_bank(size_t address)
 {
-  struct stm32h7_flash_priv_s *priv = &stm32h7_flash_bank1_priv;
-  if (address < priv->base || address >=
-      priv->base + stm32h7_flash_size(priv))
+  struct stm32h7_flash_priv_s *priv = NULL;
+ 
+  uint32_t bank_size;
+#ifdef STM32_DUAL_BANK
+  bank_size = stm32h7_flash_size(priv) / 2;
+#else
+  bank_size = stm32h7_flash_size(priv);
+#endif
+
+  if (address >= stm32h7_flash_bank1_priv.base && address <
+      stm32h7_flash_bank1_priv.base + bank_size)
     {
-      return NULL;
+      priv = &stm32h7_flash_bank1_priv;
     }
 
-#if STM32_FLASH_NBLOCKS > 1
-  if (address >= stm32h7_flash_bank2_priv.base)
+#ifdef STM32_DUAL_BANK
+  else if (address >= stm32h7_flash_bank2_priv.base && address <
+      stm32h7_flash_bank2_priv.base + bank_size)

Review Comment:
   ```suggestion
     else if (address >= stm32h7_flash_bank2_priv.base &&
              address < stm32h7_flash_bank2_priv.base + bank_size)
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org