You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
arch/riscv: Allow overriding ROM region for PMP setup
The Physical Memory Protection (PMP) setup for the ROM region currently
relies on the fixed linker symbols `__rom_region_start` and
`__rom_region_size`.
In environments where the firmware is loaded by a bootloader (example
a two-stage boot, or jumping from a RO-image to a RW-image), the actual
physical address of the executable code might change. This is especially
critical when the PMP must protect the entire persistent ROM area,
regardless of which stage of the firmware is executing.
This commit addresses this by:
1. Introducing `CONFIG_ROM_REGION_START` and `CONFIG_ROM_REGION_SIZE`
Kconfig options, guarded by `RISCV_PMP`. These default to the standard
linker symbols but allow manual override via hexadecimal strings.
2. Adding a compile-time `ADDRESS_RESOLVER` macro in `pmp.c` to parse
the Kconfig string, correctly handling the conversion of either the
default linker symbol or a user-provided hexadecimal address into
a numerical value.
3. Updating `z_riscv_pmp_init()` to use the resolved Kconfig values,
ensuring that the PMP always protects the correct, full ROM area as
defined by the user or the linker.
Signed-off-by: Firas Sammoura <[email protected]>
0 commit comments