Skip to content

Make no libusb build clearer #246

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

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Make no libusb build clearer #246

wants to merge 2 commits into from

Conversation

will-v-pi
Copy link
Contributor

Fix info and config help text without libusb, add no USB support messages to command line parsing errors, and add no USB support message to picotool version

$ picotool version
picotool v2.1.2-develop (Linux, GNU-12.2.0, RelWithDebInfo)

This version of picotool was compiled without USB support. Some commands are not available.

Eg, the output from picotool info is now

$ picotool info

ERROR: missing <filename>

SYNOPSIS:
    picotool info [-b] [-m] [-p] [-d] [--debug] [-l] [-a] <filename> [-t <type>]

Use "picotool help info" for more info

This version of picotool was compiled without USB support. Some commands are not available.

or picotool load

$ picotool load

ERROR: Unknown command: load

COMMANDS:
    info        Display information from the target file.
    config      Display or change program configuration settings from the target file.
    encrypt     Encrypt the program.
    seal        Add final metadata to a binary, optionally including a hash and/or signature.
    link        Link multiple binaries into one block loop.
    otp         Commands related to the RP2350 OTP (One-Time-Programmable) Memory
    partition   Commands related to RP2350 Partition Tables
    uf2         Commands related to UF2 creation and status
    version     Display picotool version
    coprodis    Post-process coprocessor instructions in disassembly files.
    help        Show general help or help for a specific command

Use "picotool help <cmd>" for more info

This version of picotool was compiled without USB support. Some commands are not available.

Fixes #245

@will-v-pi will-v-pi added this to the 2.1.2 milestone Jun 20, 2025
@lurch
Copy link
Contributor

lurch commented Jun 20, 2025

Might also be worth modifying the get_doc for the help_command ?

@will-v-pi
Copy link
Contributor Author

Might also be worth modifying the get_doc for the help_command ?

Do you mean this bit?

$ picotool help
PICOTOOL:
    Tool for interacting with RP-series device(s) in BOOTSEL mode, or with an RP-series binary

This already changes when you don't have libusb to

$ picotool help
PICOTOOL:
    Tool for interacting with an RP-series binary

@lurch
Copy link
Contributor

lurch commented Jun 20, 2025

This already changes when you don't have libusb to

$ picotool help
PICOTOOL:
    Tool for interacting with an RP-series binary

Yeah, I was thinking that it might be nice to also display the "This version of picotool was compiled without USB support. Some commands are not available." text when running picotool help? (Following the "better to be explicit than implicit" principle 😉 )

@will-v-pi
Copy link
Contributor Author

This already changes when you don't have libusb to

$ picotool help
PICOTOOL:
    Tool for interacting with an RP-series binary

Yeah, I was thinking that it might be nice to also display the "This version of picotool was compiled without USB support. Some commands are not available." text when running picotool help? (Following the "better to be explicit than implicit" principle 😉 )

Ah, I'd actually been explicit not to do that (the if (!help_mode) line), to avoid contaminating the output of valid commands? With the current change, it only gets printed when you either do something invalid, or with picotool version which seemed like a tidier place to put it

@@ -114,6 +114,10 @@ static const string rp2350_arm_s_family_name = "rp2350-arm-s";
static const string rp2350_arm_ns_family_name = "rp2350-arm-ns";
static const string rp2350_riscv_family_name = "rp2350-riscv";

#if !HAS_LIBUSB
static const string libusb_not_found_message = "\nThis version of picotool was compiled without USB support. Some commands are not available.\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

Super minor nitpick, but IMHO libusb_not_found_message makes it sound like it's looking for libusb at runtime? built_without_libusb_message might be slightly better? 🤷

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.

3 participants