Closed ali1234 closed 1 week ago
Building picotool manually myself produces a working binary with USB support.
Installing my manually built version does not work as a workaround because pico-sdk does not recognize that it is installed, and builds its own copy anyway:
CMake Warning at /home/al/Source/Pico/pico-sdk/tools/Findpicotool.cmake:28 (message):
No installed picotool with version 2.0.0 found - building from source
It is recommended to build and install picotool separately, or to set
PICOTOOL_FETCH_FROM_GIT_PATH to a common directory for all your SDK
projects
This is then the version that gets used by the custom target.
A workaround that does work is to make the custom target use the absolute path to the working picotool:
add_custom_target (flash /home/al/.local/bin/picotool load -f ${PROJECT_NAME}.uf2 && picotool reboot DEPENDS ${PROJECT_NAME})
Of course this won't work on anyone else's computer...
This is by design - when building picotool as part of the SDK we set PICOTOOL_NO_LIBUSB, for speedier compilation. If you want to build a full version of picotool separately and have the SDK use that, see the picotool readme for details of how to make sure the SDK can find your installed picotool.
Okay, so those instructions are wrong for Linux. The correct way to do it is to configure picotool with:
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
And then make install
(without root).
Now the SDK will find it without having to pass an additional environment variable to every project.
Another workaround (if you don't care which version the SDK uses) is to just use cmake's find_program
:
cmake_minimum_required(VERSION 3.16)
find_program(PICOTOOL picotool)
// ... normal project boilerplate here ...
add_custom_target (flash ${PICOTOOL} load -f ${PROJECT_NAME}.uf2 && ${PICOTOOL} reboot DEPENDS ${PROJECT_NAME})
Because find_program
is run before the SDK stuff, it will find the version in $PATH, before the SDK shadows it with a broken version.
Okay, so those instructions are wrong for Linux
Can you clarify exactly which bit of the instructions you’re referring to?
For me in Debian, Ubuntu, and macOS, the instructions of
mkdir build
cd build
cmake ..
make
sudo make install
work fine. If you want a non-root install then installing to ~/.local
will also work fine, it’s just user preference.
The part where this is the only alternative to doing a root install:
Alternatively you can install in a custom path via:
cmake -DCMAKE_INSTALL_PREFIX=$MY_INSTALL_DIR -DPICOTOOL_FLAT_INSTALL=1 ..
In order for the SDK to find picotool in this custom path, you will need to set the picotool_DIR variable in your project, either by passing to -Dpicotool_DIR=$MY_INSTALL_DIR/picotool to your SDK cmake command, or by adding
set(picotool_DIR $MY_INSTALL_DIR/picotool)
to your CMakeLists.txt file.
The part where this is the only alternative to doing a root install:
You're adding the word "only" there...
That's not an exhaustive list of alternatives, just one alternative that'll work with any platform and any install directory. I'll add a note about ~/.local
being another alternative for some Linux users who don't want to do a root install
I had exactly same issue, for me, it was caused by holding broken packages (libusb), so installing proper version of them solved the problem.
Closing as by design, and the message printed when compiling has been fixed in develop
To reproduce put the following files in a directory next to the pico-sdk:
CMakeLists.txt: (Note the custom target which runs picotool.)
main.cpp:
Run:
mkdir build && cd build && cmake .. && make && make flash
Expected result: The built uf2 is loaded to the connected pico over USB.
Actual result:
This happens because the picotool build could not find libusb, even though I have libusb-1.0-0-dev and pkg-config installed (on Linux):