is it a right BANK2_OFFSET define in flash_stm32l5x.c? #65712
Unanswered
liweifeng81
asked this question in
Q&A
Replies: 1 comment 3 replies
-
@liweifeng81 Looks you're right. When this code has been implemented we didn't support as much as flash variant as today. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
the below bold code is for avoiding the range is crossing bank. but the define of BANK2_OFFSET is not right.
e.g. I'm using stm32u545, the flash size is 512k, and BANK2_OFFSET should be 256k.
I think it should not use BANK2_OFFSET, but FLASH_SIZE / 2 instead.
#if defined(CONFIG_SOC_SERIES_STM32H5X)
/* at this time stm32h5 mcus have 128KB (stm32h50x) or 2MB (stm32h56x/57x) /
#define STM32_SERIES_MAX_FLASH 2048
#elif defined(CONFIG_SOC_SERIES_STM32L5X)
#define STM32_SERIES_MAX_FLASH 512
#elif defined(CONFIG_SOC_SERIES_STM32U5X)
/ at this time stm32u5 mcus have 1MB (stm32u575) or 2MB (stm32u585) */
#define STM32_SERIES_MAX_FLASH 2048
#endif
#define PAGES_PER_BANK ((FLASH_SIZE / FLASH_PAGE_SIZE) / 2)
#define BANK2_OFFSET (KB(STM32_SERIES_MAX_FLASH) / 2)
bool flash_stm32_valid_range(const struct device dev, off_t offset,
uint32_t len,
bool write)
{
if (stm32_flash_has_2_banks(dev) &&
(CONFIG_FLASH_SIZE < STM32_SERIES_MAX_FLASH)) {
/
* In case of bank1/2 discontinuity, the range should not
* start before bank2 and end beyond bank1 at the same time.
* Locations beyond bank2 are caught by
* flash_stm32_range_exists.
*/
if ((offset < BANK2_OFFSET) &&
(offset + len > FLASH_SIZE / 2)) {
return 0;
}
}
}
Beta Was this translation helpful? Give feedback.
All reactions