Page 1 of 1

STM32G431/441 flash bank count incorrect  Topic is solved

Posted: Thu Nov 28, 2024 12:12 pm
by tzarc
The G4's stm32_registry.h defines the number of flash banks on the G431/G441 as 2 -- these are single bank parts.
Would be great to get this fixed on the stable-21.11.x branch as well as trunk.

Re: STM32G431/441 flash bank count incorrect

Posted: Mon Dec 02, 2024 11:31 pm
by alex31
And G491 is also a one bank device (2 in registry also)
A.

Re: STM32G431/441 flash bank count incorrect

Posted: Wed Dec 04, 2024 4:05 pm
by alex31
Hello,

In order to use EFL+MFS on a G491, I had to fix the registry, I post here a G4 registry with bank number fixes for all lines, and I also add missing entries for G471 line.

I also had to fix minor forbidden arithmetic on void pointer, which is not allowed by the standard, and is catched by gcc 14.

Code: Select all

iff --git a/os/hal/ports/STM32/STM32G4xx/hal_efl_lld.c b/os/hal/ports/STM32/STM32G4xx/hal_efl_lld.c
index 82ff9e8a0..4644224d6 100644
--- a/os/hal/ports/STM32/STM32G4xx/hal_efl_lld.c
+++ b/os/hal/ports/STM32/STM32G4xx/hal_efl_lld.c
@@ -116,6 +116,7 @@ static inline bool stm32_flash_dual_bank(EFlashDriver *eflp) {
 #if STM32_FLASH_NUMBER_OF_BANKS > 1
   return ((eflp->flash->OPTR & (FLASH_OPTR_DBANK)) != 0U);
 #endif
+  (void) eflp;
   return false;
 }
 
@@ -241,8 +242,10 @@ flash_error_t efl_lld_read(void *instance, flash_offset_t offset,
   stm32_flash_clear_status(devp);
 
   /* Actual read implementation.*/
-  memcpy((void *)rp, (const void *)efl_lld_get_descriptor(instance)->address
-                                   + offset, n);
+  memcpy((void *)rp,
+        (const void *) ((uint32_t) efl_lld_get_descriptor(instance)->address
+                        + offset),
+        n);
 
   /* Checking for errors after reading.*/
   if ((devp->flash->SR & FLASH_SR_RDERR) != 0U) {


Finally, I had to write a linker script for the G491, which has not the same memory layout than the G474.

Alexandre

Re: STM32G431/441 flash bank count incorrect

Posted: Sun Jan 26, 2025 10:07 am
by Giovanni
Hi,

Change committed thanks, had to change the filename of the .ld file because the suffix matters.

Giovanni