-
Notifications
You must be signed in to change notification settings - Fork 7.4k
west: runners: Add new -i/--dev-id device identifier common runner option #37509
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
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.
Not sure if this is the right approach for all runners. Take for instance the CANopen Node ID; Everybody working with CANopen knows what a Node ID is, but would likely not associate --dev-id
with being that from the generic description given. Compare it to e.g. an IP address of a remote debugger - it would not be obvious to pass that in as --dev-id
? Same applies to serial numbers, USB VID:PID, board names, etc.
Blocking this to ensure we have a discussion about this.
It's a matter of taste more than anything else. Personally I prefer having a single command-line option that is reused by all runners albeit with slight different meanings based on the context, but the opposite argument can be made. For me, anything that identifies a device can fall under the |
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.
Thanks for finally crossing off this longstanding TODO.
I defer to @henrikbrixandersen on the canopennode runner.
As for the rest, no objections to adding the option, but there's no need to break compatibility. See comments for details.
The test cases need updates too. |
4e89644
to
3af1ffd
Compare
I am sorry. I still think these changes are making the command line options less obvious for an end-user. There is no way - except for reading the source code - for en end-user to know what Unifying these into one also means that adding more ways of selecting a given instance is even more obscure. Say, a runner that supports selection via either serial number or USB VID:PID. |
We can fix this in both the .rst files and in the command line help.
Do you actually have a such a situation? I can imagine IP vs. USB debugging with a J-Link, but that seems solvable with either some additional smarts in the runner ("is this argument an IP:port? Then it's IP. Is it just a number? Then it's USB.") or another option like Assuming we sort these things out, are you still opposed to the idea completely, or are you saying you have reservations about the current status? |
3af1ffd
to
33d1e85
Compare
I completely agree with @mbolivar-nordic. Documenting this properly and then getting the users to understand that a command-line option might take different formats based on the runner seems simpler for the user to me than having to remember a bunch of different ones. But again, this is purely cosmetic and so subject to individual taste. @henrikbrixandersen an alternative to generalizing it entirely would be to do this only for those that identify a particular debugger instance. So only jlink, nrfjprog and pyocd would use |
I think it's time to document the individual runner backends on the .rst side. On the help string side, I think core.py should set the help text for the dev_id option using a self.dev_id_help attribute which subclasses can override. Then each runner can explain what the individual ID contents are via an override of that attribute. |
Would using
|
Not as I see it. What I questioning here is what the benefit by combining these different configuration options into one and leave the user to parse a help text/source code in order to find out what kind of argument the given runner expects when specifying that option. I am all for combining options for common parameters (e.g. If I do a We could even (I don't believe we have that today?) have bash completion of runner specific arguments, which would make it even more intuitive to use. Type in Just to clarify: The above goes for other runner device selection arguments than the CANopen runner |
dev-review (Aug 12, 2021):
|
This sounds like a very good idea. I will start with that, given that anyway we are keeping the old options I can actually reuse the same text for both on each runner. |
33d1e85
to
09401e5
Compare
I am not sure about this one for this PR, but I am happy to discuss this with you to see if we can make it happen.
This is now done.
I did that for the runners that are controversial. |
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.
LGTM, I've added one comment. I think deprecation notice would be a useful addition.
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.
A few minor nits, otherwise looks good, thank you for updating.
09401e5
to
1e00e68
Compare
50c9354
to
06b776c
Compare
@mbolivar-nordic and @henrikbrixandersen could you please take another look? |
06b776c
to
8d61186
Compare
8449e4a
to
eeccf51
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.
Looking good now; just a couple of things. Thanks again.
action=partial(depr_action, | ||
replacement='-i/--dev-id'), |
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.
It feels like this should be structured as:
- A commit adding DeprecatedAction
- A commit adding the new common option
- Commits updating the existing runners to use the new option and deprecating the old one using DeprecatedAction (as needed; I know not all runners are deprecating their specific options)
But it's not a huge deal so I'm not blocking on this comment.
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 agree with you, but honestly I think it's not worth the rebase effort. I need to pick my fights :)
In an effort to standardize the way that a particular debugger or device instance is identified when there are multiple present, introduce a new -i/--dev-id option common to all runners that allows the user to specify which device to interact with when there are multiple connected. Signed-off-by: Carles Cufi <[email protected]>
Remove the previous jlink-specific --id option and switch to the common -i/--dev-id one. Signed-off-by: Carles Cufi <[email protected]>
Remove the previous nrfjprog-specific --id option and switch to the common -i/--dev-id one. Signed-off-by: Carles Cufi <[email protected]>
Remove the previous canopen-specific --node-id option and switch to the common -i/--dev-id one. Signed-off-by: Carles Cufi <[email protected]>
Remove the previous dfu-util-specific --pid option and switch to the common -i/--dev-id one. Signed-off-by: Carles Cufi <[email protected]>
Remove the previous pyocd-specific --board-id option and switch to the common -i/--dev-id one. Signed-off-by: Carles Cufi <[email protected]>
In order to allow for further options to be deprecated with minimal impact, add a deprecation argparse Action and a callable instantiator that can be used to deprecate options in favor of new ones. Signed-off-by: Carles Cufi <[email protected]>
eeccf51
to
ccd75e7
Compare
In order to avoid different runners implementing device identification each in their own way, introduce a new
-i/--dev-id
command-line switch that allows the user to specify which board/debugger/node is to be targeted by the flash or debug operation.