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

Add ability to access device using stdio_usb #23

Merged
merged 2 commits into from
Oct 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.12)

project(picotool)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()

if (DEFINED ENV{PICO_SDK_PATH} AND (NOT PICO_SDK_PATH))
set(PICO_SDK_PATH $ENV{PICO_SDK_PATH})
message("Using PICO_SDK_PATH from environment ('${PICO_SDK_PATH}')")
Expand Down Expand Up @@ -32,13 +36,15 @@ else()
add_executable(picotool main.cpp)
set(PICOTOOL_VERSION 1.1.0-develop)
set(SYSTEM_VERSION "${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")
set(COMPILER_INFO "${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}-${CMAKE_BUILD_TYPE}")
set(COMPILER_INFO "${CMAKE_C_COMPILER_ID}-${CMAKE_C_COMPILER_VERSION}, ${CMAKE_BUILD_TYPE}")
target_compile_definitions(picotool PRIVATE
PICOTOOL_VERSION="${PICOTOOL_VERSION}"
SYSTEM_VERSION="${SYSTEM_VERSION}"
COMPILER_INFO="${COMPILER_INFO}"
)
target_include_directories(picotool PRIVATE ${LIBUSB_INCLUDE_DIR})
# todo, this is a bit of an abstraction failure; but don't want to rev the SDK just for this right now
target_include_directories(picotool PRIVATE ${PICO_SDK_PATH}/src/rp2_common/pico_stdio_usb/include)
target_link_libraries(picotool pico_binary_info boot_uf2_headers boot_picoboot_headers pico_platform_headers picoboot_connection_cxx ${LIBUSB_LIBRARIES})
# allow `make install`
install(TARGETS picotool)
Expand Down
52 changes: 21 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,26 @@ PICOTOOL:
Tool for interacting with a RP2040 device in BOOTSEL mode, or with a RP2040 binary
SYNOPSYS:
picotool info [-b] [-p] [-d] [-l] [-a] [--bus <bus>] [--address <addr>]
picotool info [-b] [-p] [-d] [-l] [-a] [--bus <bus>] [--address <addr>] [-f] [-F]
picotool info [-b] [-p] [-d] [-l] [-a] <filename> [-t <type>]
picotool load [-v] [-r] <filename> [-t <type>] [--bus <bus>] [--address <addr>]
picotool save [-p] [--bus <bus>] [--address <addr>] <filename> [-t <type>]
picotool save -a [--bus <bus>] [--address <addr>] <filename> [-t <type>]
picotool save -r <from> <to> [--bus <bus>] [--address <addr>] <filename> [-t <type>]
picotool verify [--bus <bus>] [--address <addr>] <filename> [-t <type>] [-r <from> <to>]
picotool reboot [-a] [-u] [--bus <bus>] [--address <addr>]
picotool load [-v] [-x] <filename> [-t <type>] [-o <offset>] [--bus <bus>] [--address <addr>] [-f] [-F]
picotool save [-p] [--bus <bus>] [--address <addr>] [-f] [-F] <filename> [-t <type>]
picotool save -a [--bus <bus>] [--address <addr>] [-f] [-F] <filename> [-t <type>]
picotool save -r <from> <to> [--bus <bus>] [--address <addr>] [-f] [-F] <filename> [-t <type>]
picotool verify [--bus <bus>] [--address <addr>] [-f] [-F] <filename> [-t <type>] [-r <from> <to>] [-o <offset>]
picotool reboot [-a] [-u] [--bus <bus>] [--address <addr>] [-f] [-F]
picotool version [-s]
picotool help [<cmd>]
COMMANDS:
info Display information from the target device(s) or file.
Without any arguments, this will display basic information for all connected RP2040 devices in
BOOTSEL mode
load Load the program / memory range stored in a file onto the device.
save Save the program / memory stored in flash on the device to a file.
verify Check that the device contents match those in the file.
reboot Reboot the device
help Show general help or help for a specific command
info Display information from the target device(s) or file.
Without any arguments, this will display basic information for all connected RP2040 devices in BOOTSEL mode
load Load the program / memory range stored in a file onto the device.
save Save the program / memory stored in flash on the device to a file.
verify Check that the device contents match those in the file.
reboot Reboot the device
version Display picotool version
help Show general help or help for a specific command
Use "picotool help <cmd>" for more info
```
Expand All @@ -69,15 +70,14 @@ can find (See Binary Info section below). The info command is for reading this i
The information can be either read from one or more connected RP2040 devices in BOOTSEL mode, or from
a file. This file can be an ELF, a UF2 or a BIN file.

```asciidoc
```text
$ picotool help info
INFO:
Display information from the target device(s) or file.
Without any arguments, this will display basic information for all connected RP2040 devices in USB boot
mode
Without any arguments, this will display basic information for all connected RP2040 devices in BOOTSEL mode
SYNOPSYS:
picotool info [-b] [-p] [-d] [-l] [-a] [--bus <bus>] [--address <addr>]
picotool info [-b] [-p] [-d] [-l] [-a] [--bus <bus>] [--address <addr>] [-f] [-F]
picotool info [-b] [-p] [-d] [-l] [-a] <filename> [-t <type>]
OPTIONS:
Expand Down Expand Up @@ -105,7 +105,6 @@ TARGET SELECTION:
-t <type>
Specify file type (uf2 | elf | bin) explicitly, ignoring file extension
```

e.g.

```text
Expand Down Expand Up @@ -247,11 +246,7 @@ Basic information includes
- program features - this is a list built from individual strings in the binary, that can be displayed (e.g. we will have one for UART stdio and one for USB stdio) in the SDK
- build attributes - this is a similar list of strings, for things pertaining to the binary itself (e.g. Debug Build)

Note it is my intention that things like MicroPython would include features for parts of the language/libraries they include.

This might not be as a feature string per se, but could be another aggregating list (features/attributes are well known)
but we can add another piece of binary info to name a list attribute that aggregates strings with a particular tag, so you
could trivially add "MicroPython libraries:" etc to the `picotool` output without changing the tool itself.
The binary information is self-describing/extensible, so programs can include information picotool is not aware of (e.g. MicroPython includes a list of in-built libraries)

### Pins

Expand Down Expand Up @@ -389,11 +384,6 @@ quotes, newlines etc you may have better luck defining via bi_decl in the code.

## Additional binary information/picotool features

### SDK version

Should add this; git revision in general is hard since the user may not have the SDK checked out from git, so we'll have to stick
a version number in a header

### Block devices

MicroPython and CircuitPython, eventually the SDK and others may support one or more storage devices in flash. We already
Expand Down Expand Up @@ -433,7 +423,7 @@ enum {
### USB device descriptors

Seems like tagging these might be nice (we just need to store the pointer to it assuming - as is often the case -
the descriptor is just a linear chunk of memory) ... I assume there is a tool out there to prettyify such a thing if picotool dumps the descriptor
the descriptor is just a linear chunk of memory) ... I assume there is a tool out there to prettify such a thing if picotool dumps the descriptor
in binary.

### Issues
Expand Down
Loading