STM32G431/441 flash bank count incorrect

Report here problems in any of ChibiOS components. This forum is NOT for support.
tzarc
Posts: 13
Joined: Thu Feb 20, 2020 7:08 am
Has thanked: 2 times
Been thanked: 6 times

STM32G431/441 flash bank count incorrect

Postby tzarc » Thu Nov 28, 2024 12:12 pm

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.

User avatar
alex31
Posts: 405
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 46 times
Been thanked: 77 times
Contact:

Re: STM32G431/441 flash bank count incorrect

Postby alex31 » Mon Dec 02, 2024 11:31 pm

And G491 is also a one bank device (2 in registry also)
A.

User avatar
alex31
Posts: 405
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 46 times
Been thanked: 77 times
Contact:

Re: STM32G431/441 flash bank count incorrect

Postby alex31 » Wed Dec 04, 2024 4:05 pm

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
Attachments
fix_flash_g4_registry.diff.zip
(1.66 KiB) Downloaded 34 times
g4_linker_script.zip
(1.25 KiB) Downloaded 32 times


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 8 guests