-
Notifications
You must be signed in to change notification settings - Fork 7.8k
twister: add a --flash-command flag #93944
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
base: main
Are you sure you want to change the base?
twister: add a --flash-command flag #93944
Conversation
bf98be6
to
512a5fb
Compare
@@ -840,6 +840,15 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser: | |||
NOTE: west-flash must be enabled to use this option. | |||
""" | |||
) | |||
parser.add_argument( | |||
"--flash-command", | |||
help="""Uses a custom flash command instead of ninja or make to flash |
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.
Did you mean?
help="""Uses a custom flash command instead of ninja or make to flash | |
help="""Uses a custom flash command instead of west to flash |
Context:
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.
Well by default it uses west through ninja or make, so either works, but also who cares , dropped that whole "instead of bit"
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.
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.
yeah I mean the whole situation is just confusing at this point, even that
if (self.options.west_flash is not None) or runner:
felt like a hack around the current situation, in practice what I found happens is that if you run twister with device testing specifying the serial interface it uses ninja flash
by default and west directly if west-flash
is specified, but if one specifies a hardware map then runners are always set and this code kicks in again regardless of the west-flash
flag.
At this point let's just drop the target and have twister use west directly, what difference does it make anyway. I may followup on it if I don't get sidetracked.
512a5fb
to
dbb61aa
Compare
dbb61aa
to
c5f6c60
Compare
we should first look into implementing this at the cmake level instead of making this yet another twister option. Right now, 'ninja flash' is either using something like this, quickly hacked: diff --git a/boards/nxp/frdm_k64f/board.cmake b/boards/nxp/frdm_k64f/board.cmake
index d2fafeb4a00..e732a1e9bbc 100644
--- a/boards/nxp/frdm_k64f/board.cmake
+++ b/boards/nxp/frdm_k64f/board.cmake
@@ -1,5 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
+set(CUSTOM_FLASHER "/tmp/blah.sh")
board_runner_args(jlink "--device=MK64FN1M0xxx12")
board_runner_args(linkserver "--device=MK64FN1M0xxx12:FRDM-K64F")
diff --git a/cmake/flash/CMakeLists.txt b/cmake/flash/CMakeLists.txt
index 985b7536154..5c609428410 100644
--- a/cmake/flash/CMakeLists.txt
+++ b/cmake/flash/CMakeLists.txt
@@ -186,7 +186,27 @@ foreach(target flash debug debugserver attach rtt)
set(RUNNER_VERBOSE)
endif()
- if(WEST)
+ if(CUSTOM_FLASHER)
+ add_custom_target(${target}
+ # This script will print an error message and fail if <target> has added
+ # dependencies. This is done using dedicated CMake script, as
+ # `cmake -E {true|false}` is not available until CMake 3.16.
+ COMMAND ${CMAKE_COMMAND}
+ -DTARGET=${target}
+ -DDEPENDENCIES="$<TARGET_PROPERTY:${target},MANUALLY_ADDED_DEPENDENCIES>"
+ -P ${CMAKE_CURRENT_LIST_DIR}/check_runner_dependencies.cmake
+ COMMAND
+ ${CMAKE_COMMAND} -E env ZEPHYR_BASE=${ZEPHYR_BASE}
+ ${CUSTOM_FLASHER}
+ ${RUNNER_VERBOSE}
+ ${target}
+ WORKING_DIRECTORY
+ ${APPLICATION_BINARY_DIR}
+ COMMENT
+ ${comment}
+ USES_TERMINAL
+ )
+ elseif(WEST)
add_custom_target(${target}
# This script will print an error message and fail if <target> has added
# dependencies. This is done using dedicated CMake script, as
@@ -212,5 +232,5 @@ foreach(target flash debug debugserver attach rtt)
'${CMAKE_MAKE_PROGRAM} ${target}', please create a west workspace.\"
USES_TERMINAL
)
- endif(WEST)
+ endif()
endforeach() with /tmp/blah.sh:
then run
|
so basically whatever you were doing in #92406, making the only way to flash go via west in the build system is not right and we can't push the problem down to the tooling like twister and other test runners. |
Not going to work, turns out I need |
c5f6c60
to
dde9406
Compare
ping |
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.
5f53201
to
1d98a4e
Compare
Oh cool you were waiting for me the whole time, hey GitHub did you forget to send me the notification email for that comment? Again? Yes, yes you did. Thanks GitHub.
Pong indeed. |
|
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.
twister: use csv to split extra argument arguments
I'm sorry to ask this but I think this deserves a separate, preliminary PR for both 1) visibility and 2) CI reasons.
\2) give upstream and downstream CIs at least a 24h opportunity for one "nightly" build to catch any test failure caused by this. This change is for the greater good but it is technically backwards-incompatible. Maybe some tests already had some "creative" quoting solution that is obviously going to be incompatible with this.
\1) Give people an opportunity to notice this change in their flood of GitHub notifications before it gets merged. And make it easily to spot even after merge when scanning what changed (and possibly broke some test of theirs)
Should be really quick
https://github.com/zephyrproject-rtos/zephyr/pull/83839/files#diff-d84ff1b1f7f14c50055618e1e0f6a0986cae639ab168881fc493de64ebd76971
1d98a4e
to
cd068d1
Compare
@marc-hb cool, dropped the last commit, let's merge the others once they are in I'll open a separate PR for the quotes magic stuff. |
So the example with commas does not work yet? In general I think it's better to 1) merge bug fixes first 2) wait at least 24h to make sure there's no serious regression 3) add the new feature relying on the fixes. Considering the older #92406, you started working on this almost 2 months ago. Surely, waiting for 24 more hours is not that big of a deal? |
Yes I'm happy to merge this with the extra flag quotes behaving in the same way as the twister flag, and I'd rather merge this first on the basis of the quote flag fix pr having a decent likelihood of causing a regression and having to be reverted, if we merge it first, then we merge this, then that gets reverted and conflict, whoever does the rollback may (rightfully so) not care enough to figure what's going on and end up reverting both. So yeah, no. This first. Please. |
Respectfully but strongly disagree with the "process" question here.
|
BTW people sometimes get emotional about reverts but I think a small number of infrequent reverts is perfectly fine. "If you never break anything, then you're not trying hard enough" (a former team lead). |
The quote bug is the existing behavior, it's been there from the start, great job finding it but fixing it is not urgent, this one has been well discussed and tested by multiple people. Let's wrap it and then fix the quotes. |
Or I can add it back to the stack of this PR, you tell me. |
The "urgent" problem is not fixing the quoting bug itself; I understand it's been there since forever. The urgent questions are: 1) finding whether anything depends on the current behavior 2) if anything, figuring out what to do about it/them. Can they be updated easily? Or is that too much branching hassle? Other unexpected problem? Knowing where we stand and what the next steps are is IMHO higher priority than adding a brand new feature interacting with that very same, likely changing behavior. But again: in all likelihood this small and isolated quoting fix will just sail through and not break anything. So I don't understand the rush (after 2 months) to get this new feature first. |
Ok how about this, I'll make this work correctly for the new flag, leave the west flag untouched. No regression chances, win win. |
cd068d1
to
44664ad
Compare
Done, quote handled properly, no changes in behavior for any current flag. |
Not my preference but since you |
Sure opened the followup pr in draft already. Honestly I could probably let both run and whatever gets merged first wins and I'll suck up the merge conflict I'm just a bit tired of the long iteration cycles on this, not pointing fingers really, last one was my fault the rest was people on vacation, I just want this off my radar and not have to think about it during ZDS or let this drag to month three. |
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.
1st commit LGTM. I don't know the test harness.
Currently twister requires west to flash a board, either directly using west-flash or indirectly through the cmake flash target. Add an option to specify a custom flash script, this is passed a build-dir and board-id flags so it can be used to implement custom flashing scripts in a system that does not use west. Signed-off-by: Fabio Baltieri <[email protected]>
Add the necessary logic to pass the custom flash_command to the pytest harness. Signed-off-by: Fabio Baltieri <[email protected]>
44664ad
to
bf3fd92
Compare
|
#95298 should fix those test failures |
Currently twister requires west to flash a board, either directly using west-flash or indirectly through the cmake flash target.
Add an option to specify a custom flash script, this is passed a build-dir and board-id flags so it can be used to implement custom flashing scripts in a system that does not use west.