-
Notifications
You must be signed in to change notification settings - Fork 8.2k
linker: aarch32: automatic derivation of region names from devicetree nodes #37279
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
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. |
|
Bindings have been moved to only |
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.
LGTM, just a naming nitpick. For which I apologize in advance...
include/linker/devicetree_regions.h
Outdated
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.
you would probably want to consider removing attr at all (that at least for the GNU linker is optional). The problem is that when the MPU is present the actual attribute of the region (in terms of RWX) is defined by the MPU and by the attributes that we are using to mark the region and not by the linker.
If you think to introduce the mpu-attr we could think of obtaining this attr from the mpu-attr but that is hard.
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.
That can be done in future PR's if needed. This is purely about updating where the names are coming from, I don't want to potentially introduce other problems here.
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.
This PR is large enough as it it
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.
Ok, I'm only concerned that all the future needed changes (mpu-attr, the FOR_EACH_.. macro, this fix on the _REGION_DECLARE, etc...) will require deep changes to the current state of this PR.
I have no objections on this PR if this is considered a first step.
|
@JordanYates can you rebase and trigger the CI again? |
|
Opened #40569 for the failing test |
|
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. |
|
@galak Would you mind reviewing again ? |
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
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 <[email protected]>
Add checks to ensure that `zephyr,linker-region` property values are always globally unique. Signed-off-by: Jordan Yates <[email protected]>
Adds a macro to convert a devicetree node to the name of a linker memory region. Signed-off-by: Jordan Yates <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
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 <[email protected]>
Link variables into derived section names instead of hardcoded names. Signed-off-by: Jordan Yates <[email protected]>
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-regionproperty
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.