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
Add i2c dump filtering #60301
Add i2c dump filtering #60301
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.
I'm not fan of this as a devicetree node. Maybe a property under a controller or something.
I am not sure if I would be able to easily iterate over all devices with some property set. It would also require to add the optional property to all possible i2c devices. |
I agree that this is the easiest approach. However, there is constantly a disagreement (not only in Zephyr, but also in Linux kernel) what constitutes a devicetree and what does not. Linux kernel tends to be stricter about not using devicetree for configuration purposes. Unfortunately I cannot find my older comments about the same issue, but this is perfect example of a place where some "devicetree-like-configuration" would make sense. Maybe we should group such use cases into some issue? |
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 like the way this works.
I was under the impression that zephyr compatibles were understood to be zephyr/virtual-ish like devices and configuration.
I don't see how this would easily be done in Kconfig. It wants structured data as configuration and DT is the tool Zephyr has for that.
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.
@semihalf-barnas-michal
I know that this node doesn't represent any physical device, but I think it is the easiest and most readable approach to this functionality.
I agree that this is the easiest approach.
In my opinion, this is really similar to the first acknowledged type of exception scenario listed in Zephyr's docs comparing DeviceTree with KConfig. So it's acceptable to me as devicetree mechanism.
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.
Non-blocking nits from me.
The GPIO hogs driver provides an example for iterating over all devicetree nodes that have the |
05acdf4
2eeb4d0
to
05acdf4
Compare
@semihalf-barnas-michal Perhaps it would be beneficial to document this debug feature in the i2c bus docs somewhere, as an opt in feature to dump messages, or dump messages with filtering abilities using a dts node. At the moment someone would need to read the source code to understand how to use this feature. |
aa71f31
05acdf4
to
aa71f31
Compare
I've extracted some of the debugging documentation to another file and added the documentation about this feature there. If you do not like it, I can revert and just add the documentation to the i2c doc file. |
691a8db
to
cdcc15d
Compare
Great thank you, I think as long as there's some documentation somewhere on it, it will be helpful. If it turns out to be in the wrong place that's easily fixed. |
This commit changes the parameter of i2c_dump_msgs function from string name to pointer to the device structure. It allows for comparison of device pointers and allow to use the printed device name in i2c shell commands. Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commit changes the format of printed messages to align the following strings and make it more readable. Signed-off-by: Michał Barnaś <mb@semihalf.com>
This commit adds option to dump i2c messages of only specified devices. It makes it easier to debug communication of specific i2c device instead of logging all i2c communication. The filter of devices is specifiec in device-tree using the node with "zephyr,i2c-dump-filter" compatible string. Example of device-tree node: i2c-dump-filter { compatible = "zephyr,i2c-dump-filter"; devices = < &display0 >, < &sensor3 >; }; Signed-off-by: Michał Barnaś <mb@semihalf.com>
Fix text that should be linking to the URLs but was missing the link reference and remove the obsolete links. Signed-off-by: Michał Barnaś <mb@semihalf.com>
Move the chapters about Application Debugging and Debugging using Eclipse to another file for easier search and to allow more debugging chapters to be inserted here. Signed-off-by: Michał Barnaś <mb@semihalf.com>
Add the documentation about I2C_DUMP_MESSAGES and about the I2C_DUMP_MESSAGES_FILTER in the develop/debug/index.rst doc file. Signed-off-by: Michał Barnaś <mb@semihalf.com>
cdcc15d
to
d670f1b
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.
Some of the single quoted additions to the docs don't make much sense to me at a quick glance
This PR changes format of the i2c messages dump, to align the messages for easier comparison, and in case of device emulators, it's using the target device name instead of generic "emul".
It also adds a possibility to filter which devices transactions should be dumped. If someone is debugging the i2c communication, the log being flooded with other devices' transactions make it hard to debug. The logged devices
should be specified in the device-tree using the compatible string.
Example of device-tree node:
i2c-dump-filter {
compatible = "zephyr,i2c-dump-filter";
devices = < &display0 >, < &sensor3 >;
};