Skip to content

Commit

Permalink
[cortex-m] reserved flash multiple of max page size
Browse files Browse the repository at this point in the history
  • Loading branch information
hshose committed Apr 29, 2024
1 parent 1142c5c commit 0e819e9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/modm/platform/core/cortex/module.lb
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def prepare(module, options):
module.add_option(
NumericOption(
name="linkerscript.flash_reserved",
description="Add a reserved section at the end of the flash.",
description="Add a reserved section at the end of the flash. Must be multiple of 4 Kbytes.",
minimum=0,
maximum=hex(flash_size),
default=0))
Expand Down Expand Up @@ -315,6 +315,13 @@ def validate(env):
flash_reserved_option_name = "modm:platform:cortex-m:linkerscript.flash_reserved"
flash_reserved = env[flash_reserved_option_name]
if flash_reserved != 0:
if flash_reserved % 8192 != 0:
raise ValidateException("Invalid reserved flash size in option '{}'. "
"The 'linkerscript.flash_reserved' of {} "
"is not a multiple of 8Kbytes, which could "
" lead to accidential program flash erasure."
.format(flash_reserved_option_name,
flash_reserved))
if flash_reserved + flash_offset > flash_size:
raise ValidateException("Invalid reserved flash size in option '{}'. "
"The 'linkerscript.flash_offset' of {} at the beginning "
Expand Down

0 comments on commit 0e819e9

Please sign in to comment.