Skip to content

Commit cbe3e18

Browse files
FRASTMkartben
authored andcommitted
drivers: flash: stm32h7RS flash size is fixed to 64KBytes
Fix the flash size to 64KB for the stm32H7RS series. Restore the get_size API function for that series. This is a specificity of this stm32 mcu (RefMan RM0477). Signed-off-by: Francois Ramu <[email protected]>
1 parent 48a8716 commit cbe3e18

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/flash/flash_stm32h7x.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
5656
#define STM32H7_SERIES_MAX_FLASH_KB KB(2048)
5757
#define BANK2_OFFSET (STM32H7_SERIES_MAX_FLASH_KB / 2)
5858
/* When flash is dual bank and flash size is smaller than Max flash size of
59-
* the serie, there is a discontinuty between bank1 and bank2.
59+
* the series, there is a discontinuty between bank1 and bank2.
6060
*/
6161
#define DISCONTINUOUS_BANKS (REAL_FLASH_SIZE_KB < STM32H7_SERIES_MAX_FLASH_KB)
6262
#define NUMBER_OF_BANKS 2
@@ -840,17 +840,19 @@ static const struct flash_parameters *flash_stm32h7_get_parameters(const struct
840840
return &flash_stm32h7_parameters;
841841
}
842842

843-
#ifndef CONFIG_SOC_SERIES_STM32H7RSX
844843
/* Gives the total logical device size in bytes and return 0. */
845844
static int flash_stm32h7_get_size(const struct device *dev, uint64_t *size)
846845
{
847846
ARG_UNUSED(dev);
848847

848+
#ifdef CONFIG_SOC_SERIES_STM32H7RSX
849+
*size = (uint64_t)0x10000U; /* The series has only 64K of user flash memory */
850+
#else
849851
*size = (uint64_t)LL_GetFlashSize() * 1024U;
852+
#endif /* CONFIG_SOC_SERIES_STM32H7RSX */
850853

851854
return 0;
852855
}
853-
#endif /* !CONFIG_SOC_SERIES_STM32H7RSX */
854856

855857
void flash_stm32_page_layout(const struct device *dev, const struct flash_pages_layout **layout,
856858
size_t *layout_size)
@@ -909,9 +911,7 @@ static DEVICE_API(flash, flash_stm32h7_api) = {
909911
.write = flash_stm32h7_write,
910912
.read = flash_stm32h7_read,
911913
.get_parameters = flash_stm32h7_get_parameters,
912-
#ifndef CONFIG_SOC_SERIES_STM32H7RSX
913914
.get_size = flash_stm32h7_get_size,
914-
#endif
915915
#ifdef CONFIG_FLASH_PAGE_LAYOUT
916916
.page_layout = flash_stm32_page_layout,
917917
#endif

0 commit comments

Comments
 (0)