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

Runner name deprecation + deprecate 'misc-flasher' to prefer 'misc' #61243

Conversation

mbolivar-ampere
Copy link
Contributor

An alternative to #60894. As pointed out there, the 'misc-flasher' ZephyrBinaryRunner name is inconsistent with the names of these associated files:

  • zephyr/boards/common/misc.board.cmake
  • scripts/west_commands/runners/misc.py

The runner probably should have been named 'misc' all along. I added it in a hurry to get an issue report to go away a long time ago, and I wasn't thinking about how it would evolve. Right now it only "flashes", but it would be trivial to extend this to add miscellaneous debug support as well.

Clean things up so that the flasher's name is "misc".

To avoid breaking out of tree boards, though, preserve backwards compatibility by allowing runners to declare deprecated names as well, and keep the old 'misc-flasher' name around, but deprecated.

@mbolivar-ampere mbolivar-ampere changed the title Runner name deprecation Runner name deprecation + deprecate 'misc-flasher' to prefer 'misc' Aug 7, 2023
@zephyrbot zephyrbot added area: RISCV RISCV Architecture (32-bit & 64-bit) platform: Intel ADSP Intel Audio platforms platform: Microchip MEC Microchip MEC Platform platform: ITE ITE platform: X86 x86 and x86-64 area: West West utility labels Aug 7, 2023
@mbolivar-ampere
Copy link
Contributor Author

Looks like CI is flagging some real issues; I'll update when I've fixed them.

Comment on lines +3 to +4
board_set_flasher_ifnset(misc)
board_finalize_runner_args(misc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

want to to dedup these in the template while you are at it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabiobaltieri sorry, I don't know what you mean

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's load of these in board.cmake, all other runners have a template file for the board_set_flasher_ifnset and board_finalize_runner_args pair, that's what I was trying to get rid of with my PR.

The do_run_common_image() function responsible for calling west flash,
debug, etc. is doing runner-related work before setting up the logging
for the runners module. This means messages aren't formatted properly.
Fix it.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
The 'if' statement was added in commit
8408af6
("scripts: west commands to support --domain"),
because do_run_common_image() was called once per
domain as a result of this commit.

The 'if' is no longer necessary now that this code
has been moved back into do_run_common(), which should
only be called once per 'west <flash|debug|...>' process.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
The dump_runner_option_help() function is breaking an argparse
abstraction in a way that is not working properly. The attempt to
remove the 'REMOVE ME' string mentioned in the function is not
working for the 'misc-flasher' runner, which has additional positional
argument groups that this function did not contemplate.

(The function was implemented before the misc-flasher runner, so probably
this regression has existed since misc-flasher was introduced.)

Fix it by replacing it with an implementation that sticks to
argparse abstractions. With this patch, 'west flash -H -r misc-flasher'
results look like:

  misc-flasher options:
    usage: [--elf-file FILE] [--hex-file FILE] [--bin-file FILE] cmd ...

    positional arguments:
      cmd              command to run; it will be passed the build
                       directory as its first argument
      args             additional arguments to pass after the build
                       directory

    options:
      --elf-file FILE  path to zephyr.elf
      --hex-file FILE  path to zephyr.hex
      --bin-file FILE  path to zephyr.bin

Instead of how they appear now:

  misc-flasher options:
    cmd              command to run; it will be passed the build
                     directory as its first argument
    args             additional arguments to pass after the build
                     directory

  REMOVE ME:
    --elf-file FILE  path to zephyr.elf
    --hex-file FILE  path to zephyr.hex
    --bin-file FILE  path to zephyr.bin

Output for other runners is similar. For instance, (abbreviated) jlink
output looks like this now:

  jlink options:
    usage:  [-i DEV_ID] [--dt-flash {Y,y,N,n,yes,no,YES,NO}] [...]

    options:
      -i DEV_ID, --dev-id DEV_ID
                            Device identifier. Use it to select the
                            J-Link Serial Number of the device
                            connected over USB.
      --dt-flash {Y,y,N,n,yes,no,YES,NO}
                            If 'yes', try to use flash address
                            information from devicetree when flash
                            addresses are unknown (e.g. when flashing
                            a .bin)
      [...]

Including the usage is arguably better anyway.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
The location of the runners.yaml file is a hard-coded implementation
detail. Its path is also still present in the cmake cache, but we
don't look for it there.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
The only caller of dump_all_runner_context() already has
the path to runners.yaml, so pass it down to the function
instead of recomputing it. Additionally, the content of
that file is already loaded, so do not load it again.

This avoids unnecessary work.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
Over time, we may want to deprecate and phase out old runner names.
There is currently no way to do this. Add one by allowing
ZephyrBinaryRunner subclasses to override a new deprecated_names()
classmethod. Subclasses can move their current name into the return
value of this list and return their new names from the name()
classmethod.

Make the framework support this by falling back on deprecated names.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
Make this runner name match the file names used to refer to it
(e.g. misc.board.cmake and misc.py). Use the new name deprecation
framework to avoid compatibility breaks.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
The preferred name is 'misc' and 'misc-flasher' has been deprecated.

The current board files and related documentation still work, but they
generate warnings. Use the new preferred name to avoid the warnings.

Signed-off-by: Martí Bolívar <mbolivar@amperecomputing.com>
@MaureenHelm
Copy link
Member

@fabiobaltieri please revisit

@fabiobaltieri
Copy link
Member

fabiobaltieri commented Sep 21, 2023

hey 6ff9efb#r1294803186 is still relevant, asking if this should have something like c63f621, that's how every other runner is used in the board files

Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Nov 21, 2023
@github-actions github-actions bot closed this Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: RISCV RISCV Architecture (32-bit & 64-bit) area: West West utility platform: Intel ADSP Intel Audio platforms platform: ITE ITE platform: Microchip MEC Microchip MEC Platform platform: X86 x86 and x86-64 Stale
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants