riscv: linker: Fallback to Kconfig when defining ROM region #68457
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With
CONFIG_XIP=y
, this linker script would derive the ROM region from the chosenzephyr,flash
DT node with "soc-nv-flash" or "jedec,spi-nor" as its compatible. If the node was absent or had a different compatible, then linking would fail with:Fix this by using
CONFIG_FLASH_BASE_ADDRESS
andCONFIG_FLASH_SIZE
for ROM base and size respectively. The existing DT logic is preserved for compatibility with out-of-tree boards, so the flash Kconfigs serve as a mere fallback.In addition, use
CONFIG_FLASH_LOAD_OFFSET
andCONFIG_FLASH_LOAD_SIZE
if defined, to align with some other architectures' linker scripts. For the existing in-tree RISC-V boards, this should not make a difference.The alternative would've been making sure that all boards and SoCs have the relevant Kconfigs set, and only using those in the linker script. The downside is that
CONFIG_FLASH_SIZE
is given in units of 1 KiB, while some existing boards - hifive1_revb, sparkfun_red_v_things_plus - have more granular flash sizes, which would've been rounded down.