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

Run Command refactoring #2295

Merged
merged 6 commits into from
Mar 20, 2024
Merged

Run Command refactoring #2295

merged 6 commits into from
Mar 20, 2024

Conversation

t-moe
Copy link
Contributor

@t-moe t-moe commented Mar 15, 2024

This PR refactors the run cmd. It does not add any new or change any existing functionality.

The idea is to have a set of RunModes (NormalRunMode, TestRunMode) that vary slightly in their implementation but share a common RunLoop (which does the rtt polling and stack trace printing etc).

This refactoring will allow me to work on my testing branch, without running into merge conflicts all the time.

This PR also puts headings in the help output.

New `probe-rs run --help` output
Flash and run an ELF program

Usage: probe-rs run [OPTIONS] <PATH>

Arguments:
  <PATH>
          The path to the ELF file to flash and run

Options:
      --always-print-stacktrace
          Always print the stacktrace on ctrl + c

      --no-location
          Suppress filename and line number information from the rtt log

      --log-format <LOG_FORMAT>
          The default format string to use for decoding defmt logs

      --rtt-scan-memory
          Scan the memory to find the RTT control block

  -h, --help
          Print help (see a summary with '-h')

RUN OPTIONS:
      --catch-reset
          Enable reset vector catch if its supported on the target

      --catch-hardfault
          Enable hardfault vector catch if its supported on the target

DOWNLOAD CONFIGURATION:
      --disable-progressbars
          

      --disable-double-buffering
          Use this flag to disable double-buffering when downloading flash data. If download fails during programming with timeout errors, try this option

      --restore-unwritten
          Enable this flag to restore all bytes erased in the sector erase but not overwritten by any page

      --flash-layout <filename>
          Requests the flash builder to output the layout into the given file in SVG format

      --verify
          After flashing, read back all the flashed data to verify it has been written correctly

      --binary-format <BINARY_FORMAT>
          If a format is provided, use it. If a target has a preferred format, we use that. Finally, if neither of the above cases are true, we default to ELF

      --base-address <BASE_ADDRESS>
          The address in memory where the binary will be put at. This is only considered when `bin` is selected as the format

      --skip <SKIP>
          The number of bytes to skip at the start of the binary file. This is only considered when `bin` is selected as the format
          
          [default: 0]

      --idf-bootloader <IDF_BOOTLOADER>
          The idf bootloader path

      --idf-partition-table <IDF_PARTITION_TABLE>
          The idf partition table path

      --chip-erase
          Whether to erase the entire chip before downloading

PROBE CONFIGURATION:
      --chip <CHIP>
          [env: PROBE_RS_CHIP=]

      --chip-description-path <chip description file path>
          [env: PROBE_RS_CHIP_DESCRIPTION_PATH=]

      --protocol <PROTOCOL>
          Protocol used to connect to chip. Possible options: [swd, jtag]
          
          [env: PROBE_RS_PROTOCOL=]

      --probe <PROBE>
          Use this flag to select a specific probe in the list.
          
          Use '--probe VID:PID' or '--probe VID:PID:Serial' if you have more than one probe with the same VID:PID.",
          
          [env: PROBE_RS_PROBE=]

      --speed <SPEED>
          The protocol speed in kHz
          
          [env: PROBE_RS_SPEED=]

      --connect-under-reset
          Use this flag to assert the nreset & ntrst pins during attaching the probe to the chip
          
          [env: PROBE_RS_CONNECT_UNDER_RESET=]

      --dry-run
          [env: PROBE_RS_DRY_RUN=]

      --allow-erase-all
          Use this flag to allow all memory, including security keys and 3rd party firmware, to be erased even when it has read-only protection
          
          [env: PROBE_RS_ALLOW_ERASE_ALL=]

LOG CONFIGURATION:
      --log-file <LOG_FILE>
          Location for log file
          
          If no location is specified, the behaviour depends on `--log-to-folder`.

      --log-to-folder
          Enable logging to the default folder. This option is ignored if `--log-file` is specified

Process finished with exit code 0

Take a look at #2292 to see how this refactoring is the base for the new TestRunMode

@t-moe t-moe requested review from Yatekii and bugadani March 15, 2024 18:56
Copy link
Member

@Yatekii Yatekii left a comment

Choose a reason for hiding this comment

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

Pretty much LGTM :) Thanks a lot!

probe-rs/src/bin/probe-rs/cmd/run/normal_run_mode.rs Outdated Show resolved Hide resolved
probe-rs/src/bin/probe-rs/cmd/run/mod.rs Outdated Show resolved Hide resolved
probe-rs/src/bin/probe-rs/cmd/run/mod.rs Outdated Show resolved Hide resolved
probe-rs/src/bin/probe-rs/cmd/run/mod.rs Show resolved Hide resolved
@t-moe t-moe requested a review from Yatekii March 19, 2024 18:50
@t-moe t-moe force-pushed the run_cmd_refactoring branch from f0d914b to 43c788b Compare March 20, 2024 07:56
@t-moe t-moe requested a review from bugadani March 20, 2024 16:46
Copy link
Member

@MabezDev MabezDev left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@MabezDev MabezDev added this pull request to the merge queue Mar 20, 2024
Merged via the queue into master with commit f1f478e Mar 20, 2024
18 checks passed
@MabezDev MabezDev deleted the run_cmd_refactoring branch March 20, 2024 17:13
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.

4 participants