-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
script/dts: Generate Extended Device Tree database #9876
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9876 +/- ##
=======================================
Coverage 53.29% 53.29%
=======================================
Files 215 215
Lines 25843 25843
Branches 5694 5694
=======================================
Hits 13773 13773
Misses 9754 9754
Partials 2316 2316 Continue to review full report at Codecov.
|
3311a99
to
7f61c4c
Compare
372afa8
to
9c02e67
Compare
scripts/dts/edtsdatabase.py
Outdated
# @param none | ||
# @return list of supported device types | ||
def get_device_types(self): | ||
return list(self._edts['device_types']) |
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.
'device_types' -> 'device-types'
self._edts['device-types'][device_type].append(device_id) | ||
self._edts['device-types'][device_type].sort() | ||
|
||
def insert_device_type(self, compatible, device_type): |
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.
Remove - already accomplished by insert.
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.
I've chosen a different device-type dict as the one you proposed.
I've chosen to display: dict(device-type : sorted list(compatible)) instead of a sorted list of device_id.
Aim was to make it easier to access to get device-type information per compatible (for DTS_ #define's generation), as well as device-type list for CI.
So I need to inject (device-type, compatible) couple, which I can't using insert.
scripts/dts/extract/compatible.py
Outdated
if not isinstance(device_types, list): | ||
device_types = [device_types, ] | ||
for j, dev_type in enumerate(device_types): | ||
edts_insert_device_type(comp, dev_type) |
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.
Remove edts_insert_device_type - see above.
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.
After thinking a bit - device type generation should be moved to heuristics.py.
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.
See reasonning behind this choice above
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.
My last answer was response to first comment.
After thinking a bit - device type generation should be moved to heuristics.py.
Yes, I hesitated indeed. Moved
@@ -23,6 +23,9 @@ def edts_insert_device_property(node_address, property_path, property_value): | |||
device_id = edts_device_id(node_address) | |||
edts.insert_device_property(device_id, property_path, property_value) | |||
|
|||
def edts_insert_device_type(compatible, device_type): |
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.
Remove - use edts_insert_device_property with 'device-type/{}'.format(device_type) instead.
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.
I'm already using edts_insert_device_property with 'device-type/{}'.format(device_type)
in heuristics class.
Aim of edts_insert_device_type is not to fill in device-type sub-node property but dedicated device-type dict. This new dict should be used at least for CI and potentially other purposes related to #9406.
4e3fe7a
to
40434cf
Compare
for compatible in compatibles: | ||
for device_id in self._edts['compatibles'].get(compatible, []): | ||
device_ids[device_id] = 1 | ||
return list(device_ids.keys()) |
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 to re-use the code between this function and the previous.
E.g. by having a private function that returns a dict. And then have each of these two call that function and extract either the keys or the values.
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, thanks
7c07936
to
0090121
Compare
Can you update scripts/dts/edtsdatabase.py to do something similar to scripts/dts/devicetree.py w/regards to main, and being able to run it and have it print out the database. |
0090121
to
3fe947d
Compare
Validate generated etds.json against a reference edts file. Script first checks edts structure then content of various elements and finally devices parameters values. This last step is done using a specific method for ref_edts parameter extraction so we can verify behavior of edtsdatabase class extraction function. Signed-off-by: Erwan Gouriou <[email protected]>
3b0c866
to
88155ce
Compare
The Extended Device Tree Specification database collates device tree (dts) information with information taken from the device tree bindings. The EDTS database may be loaded from a json file, stored to a json file or extracted from the DTS files and the bindings yaml files. The database is integrated into cogeno as a module. The commit integrates database development done in zephyrproject-rtos#9876 which was based on zephyrproject-rtos#6762. Major differences/ improvements to zephyrproject-rtos#9876 are: - the database now has an own extraction function that can be used instead of e.g. extract_dts_includes. The extraction function follows the design of the extract_dts_includes script and the additions that were done in zephyrproject-rtos#9876. It is restructured and several globals are now classes and objects. All functionality of extract_dts_includes related to the generation of defines is not part of the database extract function. It's sole purpose is to fill the database directly from the compiled DTS file. - the database got itś own directory 'edtsdb' to structure all files related to the database. - The EDTSDevice class from zephyrproject-rtos#9876 was enhanced to allow devices to access the database they are taken from. Mayor compatibility issues to zephyrproject-rtos#9876. - The consumer, provider API and the internal structure of the database is copied from zephyrproject-rtos#9876. - API should be fully compatible. - Extraction of children was replaced as it broke the concept of the devices struct as a list of devices. The functions device.get_children() and device.get_parent() may be used to acess the parent<->child relation. - The EDTSDevice class is copied from zephyrproject-rtos#9876. - The device API should be compatible except for - the constructor which now needs the EDTS database and - the unique id feature. To ge an unique id the device.get_name() function can be used instead. Signed off from zephyrproject-rtos#9876 added to attribute for the changes done there and copied. Signed-off-by: Erwan Gouriou <[email protected]> Signed-off-by: Kumar Gala <[email protected]> Signed-off-by: Bobby Noelte <[email protected]>
The Extended Device Tree Specification database collates device tree (dts) information with information taken from the device tree bindings. The EDTS database may be loaded from a json file, stored to a json file or extracted from the DTS files and the bindings yaml files. The database is integrated into cogeno as a module. The commit integrates database development done in zephyrproject-rtos#9876 which was based on zephyrproject-rtos#6762. Major differences/ improvements to zephyrproject-rtos#9876 are: - the database now has an own extraction function that can be used instead of e.g. extract_dts_includes. The extraction function follows the design of the extract_dts_includes script and the additions that were done in zephyrproject-rtos#9876. It is restructured and several globals are now classes and objects. All functionality of extract_dts_includes related to the generation of defines is not part of the database extract function. It's sole purpose is to fill the database directly from the compiled DTS file. - the database got itś own directory 'edtsdb' to structure all files related to the database. - The EDTSDevice class from zephyrproject-rtos#9876 was enhanced to allow devices to access the database they are taken from. Mayor compatibility issues to zephyrproject-rtos#9876. - The consumer, provider API and the internal structure of the database is copied from zephyrproject-rtos#9876. - API should be fully compatible. - Extraction of children was replaced as it broke the concept of the devices struct as a list of devices. The functions device.get_children() and device.get_parent() may be used to acess the parent<->child relation. - The EDTSDevice class is copied from zephyrproject-rtos#9876. - The device API should be compatible except for - the constructor which now needs the EDTS database and - the unique id feature. To ge an unique id the device.get_name() function can be used instead. Signed off from zephyrproject-rtos#9876 added to attribute for the changes done there and copied. Signed-off-by: Erwan Gouriou <[email protected]> Signed-off-by: Kumar Gala <[email protected]> Signed-off-by: Bobby Noelte <[email protected]>
The Extended Device Tree Specification database collates device tree (dts) information with information taken from the device tree bindings. The EDTS database may be loaded from a json file, stored to a json file or extracted from the DTS files and the bindings yaml files. The database is integrated into cogeno as a module. The commit integrates database development done in zephyrproject-rtos#9876 which was based on zephyrproject-rtos#6762. Major differences/ improvements to zephyrproject-rtos#9876 are: - the database now has an own extraction function that can be used instead of e.g. extract_dts_includes. The extraction function follows the design of the extract_dts_includes script and the additions that were done in zephyrproject-rtos#9876. It is restructured and several globals are now classes and objects. All functionality of extract_dts_includes related to the generation of defines is not part of the database extract function. It's sole purpose is to fill the database directly from the compiled DTS file. - the database got itś own directory 'edtsdb' to structure all files related to the database. - The EDTSDevice class from zephyrproject-rtos#9876 was enhanced to allow devices to access the database they are taken from. Mayor compatibility issues to zephyrproject-rtos#9876. - The consumer, provider API and the internal structure of the database is copied from zephyrproject-rtos#9876. - API should be fully compatible. - Extraction of children was replaced as it broke the concept of the devices struct as a list of devices. The functions device.get_children() and device.get_parent() may be used to acess the parent<->child relation. - The EDTSDevice class is copied from zephyrproject-rtos#9876. - The device API should be compatible except for - the constructor which now needs the EDTS database and - the unique id feature. To ge an unique id the device.get_name() function can be used instead. Signed off from zephyrproject-rtos#9876 added to attribute for the changes done there and copied. Signed-off-by: Erwan Gouriou <[email protected]> Signed-off-by: Kumar Gala <[email protected]> Signed-off-by: Bobby Noelte <[email protected]>
Closing, as this should be superceded by PR #17660 |
This PR is subset of #6762 (Codegen introduction, proposed by @b0661), focused on edts database generation.
Extended Device Tree database is a json file generated by extract_dts_includes.py script, from board device tree (dts) collated with yaml bindings.
Since it is post processed from dtc, information is displayed in an easily accessible 'dict' format:
Edit 09/11: Added device-type injection