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
linker: aarch32: automatic derivation of region names from devicetree nodes #37279
linker: aarch32: automatic derivation of region names from devicetree nodes #37279
Conversation
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.
- Need to move DT_NODE_LINKER_REGION to different header
- Need to update docs for
zephyr,linker-region
I wonder if it would be enough just to add this property to the specific compatibles that are expected to use it, with a nice multi-line description in the YAML. That would show up in the DT bindings index. |
8fdfe92
to
bb79da9
Compare
Bindings have been moved to only |
99fd7ae
to
42a4865
Compare
On the other hand @JordanYates can you review #40422? I think a lot of the issues are already solved in my PoC so it could be worthwhile taking that into account. |
984fd36
to
1e97b19
Compare
@galak Would you mind reviewing again ? |
1e97b19
to
46fd96a
Compare
Done, I don't think it will make much difference though as the linked issue is still open |
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.
Thanks for this.
Please remember to add same support for the CMake based linker script generator.
And then a minor suggestion on naming,
Implementation wise, things looks good.
include/linker/devicetree_regions.h
Outdated
#define LINKER_DT_NODE_REGION_NAME(node_id) \ | ||
DT_PROP_OR(node_id, zephyr_linker_region, DT_NODE_PATH(node_id)) |
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 should have same behavior here, so that region names are picked up from devicetree if defined regardless of how the linker script is generated.
zephyr/cmake/linker_script/arm/linker.cmake
Lines 37 to 50 in 513517f
# TI CCFG Registers | |
zephyr_linker_dts_memory(NAME FLASH_CCFG FLAGS rwx NODELABEL ti_ccfg_partition) | |
# Data & Instruction Tightly Coupled Memory | |
zephyr_linker_dts_memory(NAME ITCM FLAGS rw CHOSEN "zephyr,itcm") | |
zephyr_linker_dts_memory(NAME DTCM FLAGS rw CHOSEN "zephyr,dtcm") | |
zephyr_linker_dts_memory(NAME SRAM1 FLAGS rw NODELABEL sram1) | |
zephyr_linker_dts_memory(NAME SRAM2 FLAGS rw NODELABEL sram2) | |
zephyr_linker_dts_memory(NAME SRAM3 FLAGS rw NODELABEL sram3) | |
zephyr_linker_dts_memory(NAME SRAM4 FLAGS rw NODELABEL sram4) | |
zephyr_linker_dts_memory(NAME SDRAM1 FLAGS rw NODELABEL sdram1) | |
zephyr_linker_dts_memory(NAME SDRAM2 FLAGS rw NODELABEL sdram2) | |
zephyr_linker_dts_memory(NAME BACKUP_SRAM FLAGS rw NODELABEL backup_sram) |
which would be in this function where name from region property used, otherwise fallback on node path.
Line 3109 in 513517f
function(zephyr_linker_dts_memory) |
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.
done
Introduce optional `zephyr,linker-region` property which signifies that the node should result in a linker memory region and what the name of that region should be. Property added to compatibles likely to result in a linker memory region; 'mmio-sram', 'arm,itcm`, `arm,dtcm`, `nxp,imx-itcm`, `nxp,imx-dtcm` and `fixed-partitions`. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add checks to ensure that `zephyr,linker-region` property values are always globally unique. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Adds a macro to convert a devicetree node to the name of a linker memory region. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add a new application for testing non-core devicetree functionality. Add tests for the default and fallback case of `LINKER_DT_NODE_REGION_NAME`. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
As memory region names are now derived purely from devicetree, remove the `name` parameter from `DT_REGION_FROM_NODE_STATUS_OKAY`. Name is `zephyr,linker-region` if it exists, otherwise the node path. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
46fd96a
to
4229506
Compare
Update the linker script generator to automatically derive memory region names from the devicetree node according to the same logic in `devicetree_regions.h`. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
4229506
to
542a867
Compare
Remove the `NAME` function argument from `zephyr_linker_dts_memory` as the name is now automatically derived from the devicetree node. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Add `zephyr,linker-region` properties to all nodes sram1, sram2, sram3, sram4, sdram1, sdram2, backup_sram, ti_ccfg, dtcm and itcm. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
Link variables into derived section names instead of hardcoded names. Signed-off-by: Jordan Yates <jordan.yates@data61.csiro.au>
542a867
to
47646a5
Compare
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.
All changes looks good.
# Common fields for devices resulting in linker memory regions | ||
|
||
properties: | ||
zephyr,memory-region: |
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.
Nothing wrong on this line but with the latest update you are now using memory-region
👍 to that :)
But the commit message still says e06bc25:
dts: bindings: zephyr,linker-region property
Introduce optional
zephyr,linker-region
property
Note: same goes for some other commit messages.
if (NOT DEFINED name) | ||
# Fallback to the node path | ||
set(name ${DTS_MEMORY_PATH}) | ||
endif() |
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.
minor nit, it's possible to do:
if (NOT DEFINED name) | |
# Fallback to the node path | |
set(name ${DTS_MEMORY_PATH}) | |
endif() | |
set_ifndef(name ${DTS_MEMORY_PATH}) |
Line 1619 in 92fbd7d
function(set_ifndef variable value) |
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.
Consider cleanup the commit message before merging to avoid later confusion if later doing a bisect.
Approving as code looks good.
Update the aarch32 linker file to automatically derive the name of memory regions from devicetree nodes instead of providing hardcoded values. This is required for automatic generation of regions based on compatibles, and also allows chosen and alias nodes to be used to control variable placement (as desired in #36152).
This PR is the first step to enable automatically generating regions from devicetree.
This is a rework of #36365 to address feedback.