2021-06-21 05:15 AM
FLASH_PAGE_NB is wrong == 64 page, must be 128 pages
#define FLASH_PAGE_NB ((FLASH_SIZE == 0x00080000U) ? 256U : 64U)
Work for STM32G491CE == 256 Pages
Solved! Go to Solution.
2021-06-29 09:02 AM
Hello @Robert ,
We have tried to fix your reported issue but we don't have a STM32G491CC sample with 256k flash available on my side.
So, could you please check the following fix from your side :
Update in stm32g4xx_hal_flash.h file line 883 :
#define FLASH_PAGE_NB ((FLASH_SIZE == 0x00080000U) ? 256U : \
((FLASH_SIZE == 0x00040000U) ? 128U : 64U))
instead of
#define FLASH_PAGE_NB ((FLASH_SIZE == 0x00080000U) ? 256U : 64U)
BeST Regards,
Walid
2021-06-21 12:30 PM
Hello @Robert ,
Please make sure to use the latest release of STM32CubeG4 MCU package (v1.4.0) with FLASH_PAGE_NB = 128U
#define FLASH_PAGE_NB 128U
#define FLASH_PAGE_SIZE_128_BITS 0x1000U /* 4 KB */
#else
#define FLASH_SIZE ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0xFFFFU)) ? (0x80UL << 10U) : \
(((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & 0xFFFFUL) << 10U))
#define FLASH_BANK_SIZE (FLASH_SIZE)
#define FLASH_PAGE_NB ((FLASH_SIZE == 0x00080000U) ? 256U : 64U)
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Imen
2021-06-21 10:42 PM
FLASH_OPTR_DBANK not defined for STM32G491, therefore you get for
the type STM32G491CC (256 Kbyte Flash 128 pages) -> FLASH_PAGE_NB = 64 and not 128
...
#else
#define FLASH_PAGE_NB ((FLASH_SIZE == 0x00080000U) ? 256U : 64U)
#if defined (FLASH_OPTR_DBANK)
#define FLASH_SIZE ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0xFFFFU)) ? (0x200UL << 10U) : \
(((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & 0xFFFFUL) << 10U))
#define FLASH_BANK_SIZE (FLASH_SIZE >> 1)
#define FLASH_PAGE_NB 128U
#define FLASH_PAGE_SIZE_128_BITS 0x1000U /* 4 KB */
#else
#define FLASH_SIZE ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0xFFFFU)) ? (0x80UL << 10U) : \
(((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & 0xFFFFUL) << 10U))
#define FLASH_BANK_SIZE (FLASH_SIZE)
#define FLASH_PAGE_NB ((FLASH_SIZE == 0x00080000U) ? 256U : 64U)
#endif
2021-06-29 07:46 AM
Hi @Robert and thanks for pointing out this issue.
I agree with you and I raised this issue internally to our development teams for fix.
Thanks
Imen
2021-06-29 09:02 AM
Hello @Robert ,
We have tried to fix your reported issue but we don't have a STM32G491CC sample with 256k flash available on my side.
So, could you please check the following fix from your side :
Update in stm32g4xx_hal_flash.h file line 883 :
#define FLASH_PAGE_NB ((FLASH_SIZE == 0x00080000U) ? 256U : \
((FLASH_SIZE == 0x00040000U) ? 128U : 64U))
instead of
#define FLASH_PAGE_NB ((FLASH_SIZE == 0x00080000U) ? 256U : 64U)
BeST Regards,
Walid
2021-06-30 04:24 AM
2021-06-30 04:29 AM
Great news! Thanks for your contribution.
Please close this topic by choosing Select as Best. This will help other users find that answer faster.