-
Notifications
You must be signed in to change notification settings - Fork 151
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
implement Debug for readable fields of registers #716
Conversation
I've missed that you targeting esp32. Do I understand right that you don't have other way to debug except this? |
Cortex debug can work easily for newer esp32 family chips (esp32s3, esp32c3, etc) that have builtin usb - for those without builtin usb its only available if the JTAG pins are available. One specific use case here is that many of the peripherals (for me this is RTC_CTRL power management) are not well documented. And since there is a std hal for esp32 that is built on esp-idf one thing I can do is dump peripherals registers on the std hal to help with implementations of the no-std hal by being able to compare what registers are set differently. After manually building this for esp32 I was starting on esp32s3 and realized this would be much better placed in |
What I really want is to be able to dump all registers from the peripheral level as registers (and fields) differ a fair amount between esp32 chip types. (but at least having the registers handled automatically is a huge help. |
If you want to read a range of registers, you should also decide what to do with registers which have read side effects (see |
Don't do |
I'm already skipping registers that have read side effects. Currently not even generating the Debug implementation but maybe I should and just print the register name and no value or something short indicating it was not read. |
How can I fix this? |
ae2d037
to
bf26619
Compare
I've added debug at the RegisterBlock level so one can print all registers belonging to a peripheral with:
Write only registers are printed with a note that they are read only and registers that have read actions are also printed with a message. All readable registers have their fields printed in struct format and if there are no fields then the raw register value is printed. Register clusters "should" also be handled. |
Looks good for me. |
@liebman Could you how some usage example output? |
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 is good as is, just some improvements on naming and suggestion for the future
some examples would be good also to add, and a mention in the documentation wouldn't hurt
src/util.rs
Outdated
@@ -51,6 +51,10 @@ pub struct Config { | |||
pub feature_peripheral: bool, | |||
#[cfg_attr(feature = "serde", serde(default))] | |||
pub max_cluster_size: bool, | |||
#[cfg_attr(feature = "serde", serde(default))] | |||
pub impl_register_debug: bool, |
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'd like it if this field took a enum instead, which would make it possible to use defmt instead in the future.
Ofcourse, this can be added later with a breaking change
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 or add another bool option for impl_defmt allowing both to be specified.
@burrbull Here is a (truncated) sample run on an esp32s3 using
|
@Emilgardis I like the naming suggestions and will try to update examples and documentation. |
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.
awesome! thank you :)
I think we can merge this, I'll leave the final r+ for @burrbull
Might be good to squash some of the commits btw! |
2d02a20
to
be920c0
Compare
squashed |
bors r=emilgardis,burrbull thank you! |
Build succeeded! The publicly hosted instance of bors-ng is deprecated and will go away soon. If you want to self-host your own instance, instructions are here. If you want to switch to GitHub's built-in merge queue, visit their help page. |
Is there a date planned for the next release? |
contributes towards #48
Notes: