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
First draft of the config structure for cmsis pack based flashing configuration #86
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.
To not depend on a server, we ship a binary blob with a select set of sanitized configs, which will be placed in the probe.rs config dir at first run.
I would prefer not to do this as it clutters the user's home directory. Instead, we could fall back to the config data in the binary blob if no external config file defines a target.
Then we could provide a command line flag that will print the config file to stdout, so a user can still obtain the config, place it in the external directory, and edit it to override the defaults.
There's a lot of files that are missing the trailing newline. Does rustfmt not add that? I think we should enforce it to be present (it's good practice, many editors add it by default, and GitHub warns about it being missing).
Is it necessary that so many fields are pub
? I'd prefer to provide getters to access them.
Ok, I can relate to this.
Sorry, I didn't run rustfmt yet as I made this as a draft for structure. And the basic idea. I will do this later. Also I don't understand why there needs to be a trailing newline even tho it's not an issue for me. I personally dislike setters when it's just plain configs and the fields don't depend on each other/internal state. It's just boilerplate ... |
Yeah I guess it would be fine as-is... I just dislike adding so much API surface. Maybe using |
+1 to that! |
Hmm what if someone using probe-rs as a lib would like to add a config from codeside? Don't we want to enable that? Also, we might need a separate crate again to contain all the targets. I would love to have it directly in probe-rs but I am not sure if a) this is nice design wise and b) is good to parse the config files properly in build.rs. What do you think? |
You could still have a public parser function that takes YAML data. Other than that, all targets should be in probe-rs and there should never really be the use case of having an external one. If a use case does come up, we can always change this later too. |
Ok, I guess you are right! Then we also don't really need any repositories for now. This will make everything easier. |
fyi, if you mention someone from a commit message, they'll get a notification when that commit is pushed anywhere. This isn't usually what you want. |
Oh, I am very sorry for the notifications. I will leave the @ next time :) I also added tests and indeed the intersects_range() method was broken. Good spot. |
This is gonna be tricky. Because either we need manual parsing (parse the yaml into a HashMap tree structure or the likes) or we need the struct already present, which is not the case as we are doing this (Build.rs) before compilation which means the struct is not yet known. |
Ok so the new configs are mostly fixed now. |
6c87a05
to
e9a7d4f
Compare
76e2237
to
f3921f7
Compare
Co-Authored-By: Dominik Boehi <dominik.boehi@gmail.com>
Co-Authored-By: Dominik Boehi <dominik.boehi@gmail.com>
… cmsis-pack-config
…figuration (#86) * First draft of the config structure for cmsis pack based flashing configuration * Remove repositories module as we don't need it for now * Add range extension function testing * Updated some types * Add config parsing * Fix target selection * Change everything to the new config structure. * Add fixed algorithm. It is slow as hell now (example blinky takes 68s) * Add extracted LPC845 * Clean up flash builder module * Clean up download.rs & add hex flashing * Removal of old types that were moved to the config module * Add LPC55 series * Add STM32F103 targets * Combine all chip configs into one family config. * Clean up code, comment, remove pyocd artifacts * Improve logging * Add some docs * Clean up some real ugly code * Update cargo-flash/README.md * Add the m33 to the get_core() method
Ok, so I made a small draft of how I imagine hwo we could do this.
Please add your ideas and hints, I'll gladly incooperate them.
I suggest a config file structure like this:
The
chip_name.yaml
contains a chip definition which links to an algorithm (by name).It also contains a list of chip variants which all describe their memory layout.
The target can be selected with cargo-flash via
cargo flash --target target_name::variant_name
orcargo flash --target target_name
which will select the first best variant it can find for the target.To update the repositories we provide a command in cargo-flash too. Which will pull in the repository contents via the git URL provided in the
repositories.yaml
.To not depend on a server, we ship a binary blob with a select set of sanitized configs, which will be placed in the probe.rs config dir at first run.
To extract the target descriptions we provide a tool too, which can parse the packs and generate the configs.
Maybe we should also not leave the algorithms separate as it just makes config management harder.
So we would just have the target configs.
The algorithm for target selection I imagine is:
--config
(or similar) which always wins in priority.I hope this covers it pretty well.