-
Notifications
You must be signed in to change notification settings - Fork 8.2k
arch/riscv: support CONFIG_CODE_DATA_RELOCATION #49262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
arch/riscv: support CONFIG_CODE_DATA_RELOCATION #49262
Conversation
carlocaione
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need also to make this test-able by tests/application_development/code_relocation/
|
Hi @tari, thanks for your contribution. Did you test these changes on any of the RISC-V boards? |
Yes, I'm testing on it8xxx2. |
4b4195f to
a99a068
Compare
The test (and I'm not very happy with the way |
Only the elftools SymbolTableSection section type provides an iter_symbols() method, and compilers are free to emit sections that include the substring '.symtab' in their name which causes errors if gen_relocate_app examines only the section name. Instead check whether a section is a symbol table to skip attempting to inspect sections that are not actually symbol tables. Signed-off-by: Peter Marheine <[email protected]>
Most ARM platforms name their ROM region `FLASH`, but this assumption is not portable. Have gen_relocate_app refer to ROMABLE_REGION instead of hard-coding the platform-specific memory region name. Signed-off-by: Peter Marheine <[email protected]>
Support for CODE_DATA_RELOCATION is not inherently limited to ARM, so move the Kconfig definition to top-level so it can be used by other architectures. Since support is opt-in (requiring linker script support), add a helper symbol enabled by architecture config that gates whether CODE_DATA_RELOCATION is available instead of listing all supported systems inline. Signed-off-by: Peter Marheine <[email protected]>
carlocaione
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only blocking comment is the copyright. The other comment can be addressed here or in another PR.
tests/application_development/code_relocation/linker_riscv_qemu_sram2.ld
Outdated
Show resolved
Hide resolved
This implements support for relocating code to chosen memory regions via the `zephyr_code_relocate` CMake function for RISC-V SoCs. ARM-specific assumptions that were made by gen_relocate_app.py need to be corrected, in particular not assuming any particular name for the default RAM section (which is 'SRAM' for most ARM pltaforms) and not assuming 32-bit pointers (so the test works on RV64). Signed-off-by: Peter Marheine <[email protected]>
1f73b44 to
2ef7b3a
Compare
| * @file | ||
| * @brief Linker command/script file | ||
| * | ||
| * Linker script for the Cortex-M platforms. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cortex-M?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hah, oops. I've added a commit to #49438 that fixes this.
This implements support for relocating code to chosen memory regions via
the
zephyr_code_relocateCMake function for RISC-V, where it waspreviously implemented only for ARM.