Skip to content
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

proposal: dap-server: allow read register value by default #2266

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

eZioPan
Copy link
Contributor

@eZioPan eZioPan commented Mar 7, 2024

@eZioPan eZioPan marked this pull request as ready for review March 7, 2024 08:33
@noppej
Copy link
Contributor

noppej commented Mar 7, 2024

@burrbull Would you be open to advising on this? I originally took the conservative approach (to compensate for my limited experience in this area), because I was concerned about unintended consequences when reading modifies some registers.

What do you recommend?

@burrbull
Copy link
Contributor

burrbull commented Mar 7, 2024

I recommend to use expand_properties on Device after parsing.
After this access == None always is read-write.

@eZioPan
Copy link
Contributor Author

eZioPan commented Mar 7, 2024

@burrbull thanks for reply!

I have try your suggestion, but expand_properties just not work in this situation. Since the Device has been expanded before:

let svd_cache = match svd::parse_with_config(
svd_xml,
&Config::default().expand(true).ignore_enums(true),

And after the expantion at parsing, the .access value of .default_register_properties just be None. Thus rerun expand_properties still get None.

I guess the reason this happend is from svd-rs

https://github.com/rust-embedded/svd/blob/819473991adee9b205cd77d1ed7ae28d89dbe318/svd-rs/src/registerproperties.rs#L33-L38

the default value of access is None, and none of the crates set it to Some(ReadWrite)

@burrbull
Copy link
Contributor

burrbull commented Mar 7, 2024

I have try your suggestion, but expand_properties just not work in this situation. Since the Device has been expanded before:

.expand(true) is about arrays/clusters and derivedFrom.
There is also .expand_properties(true) option.
It does not convert None to Some(ReadWrite) (should it?). It just update missing register properties (size, access, resetValue) from peripheral's or device's default_register_properties. Nothing more smart.
I recommend to enable it anyway.

P.S. Saying about .expand(true). If you want to decrease memory usage you should disable it. Create Index and then "derive" peripherals/registers, expand arrays, etc. manually on request. Although this is not easy task.

@eZioPan
Copy link
Contributor Author

eZioPan commented Mar 7, 2024

Ah, so you mean "use expand_properties to add an extra guarantee, that None can be safely assume to read-write", not "use expand_properties to make None to Some(ReadWrite)"?

@burrbull
Copy link
Contributor

burrbull commented Mar 7, 2024

Ah, so you mean "use expand_properties to add an extra guarantee, that None can be safely assume to read-write"?

Yes. SVD can keep part of information upper on tree.

@burrbull
Copy link
Contributor

burrbull commented Mar 7, 2024

To check if reading register is danger you also should look at each field in register. It also has readAction.
Although I never did this as svd2rust can do nothing with this information except better docs.

@eZioPan
Copy link
Contributor Author

eZioPan commented Mar 7, 2024

P.S. Saying about .expand(true). If you want to decrease memory usage you should disable it. Create Index and then "derive" peripherals/registers, expand arrays, etc. manually on request. Although this is not easy task.

Thank for the hints! I might just keep track on the issue, this suggestion might be a little over my ability. XD

@eZioPan
Copy link
Contributor Author

eZioPan commented Mar 7, 2024

you also should look at each field in register. It also has readAction.

Yeah, and it has already been checked in original code:

let field_has_restricted_read = register_has_restricted_read
|| field.read_action.is_some()
|| field
.access
.map(|a| !a.can_read())
.unwrap_or(register_has_restricted_read);

@noppej noppej self-requested a review March 8, 2024 10:17
@noppej
Copy link
Contributor

noppej commented Mar 8, 2024

P.S. Saying about .expand(true). If you want to decrease memory usage you should disable it. Create Index and then "derive" peripherals/registers, expand arrays, etc. manually on request. Although this is not easy task.

Thank for the hints! I might just keep track on the issue, this suggestion might be a little over my ability. XD

@eZioPan I am a bit slammed this week, but will look into this early next week and if you are keen, I can help you with it.

@eZioPan
Copy link
Contributor Author

eZioPan commented Mar 9, 2024

and if you are keen, I can help you with it.

@noppej Thank you for your kindness!

I have no experience on using svd library before, and it might be a long time for me to learn it, and potentially let you wait a lot. I would ask leaving the task for someone more familiar than me. And thanks again!

@eZioPan eZioPan force-pushed the allow-read-register-by-default branch from fedf286 to 4500dc3 Compare April 6, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants